-
-
Notifications
You must be signed in to change notification settings - Fork 324
PHP 8.1 enum cannot be compiled #825
Description
Hello,
I am using PHP-DI in my projects for quite some time and I am currently facing an issue with PHP enums. I am using monolog library for logging in my apps. Recently I have decided to update Monolog from version 2.6.0 to 3.2.0. Enum Monolog\Level was introduced in Monolog version > 3, which is now prefered way of how to set what messages should be logged. In one of my apps I am using container compiling. After Monolog upgrade my app stop working with error
Fatal error: Uncaught DI\Definition\Exception\InvalidDefinition: Entry "Monolog\Handler\HandlerInterface" cannot be
compiled: An object was found but objects cannot be compiled
Full definition:
Object (
class = Monolog\Handler\StreamHandler
lazy = false
__construct(
$stream = get(app.log.options.target)
$level = Monolog\Level::Info
$bubble = (default value) true
$filePermission = (default value) NULL
$useLocking = (default value) false
)
setFormatter(
$formatter = get(Monolog\Formatter\JsonFormatter)
)
) in /var/www/vendor/php-di/php-di/src/Definition/Exception/InvalidDefinition.php:19
I was debugging the issue and end up in Compiler class, where it failed when Monolog\Level should be processed.
I can get rid of this issue by passing value of enum in my definitions (e.g. use Monolog\Level::Info->value). Is there something, I am missing or this is general issue for all enums? When compiling is off, everything works with enum just fine.