Skip to content

Monolog version 2.4.0 incompatible with PHP versions <8 #1651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
michdingpayc opened this issue Apr 7, 2022 · 5 comments
Closed

Monolog version 2.4.0 incompatible with PHP versions <8 #1651

michdingpayc opened this issue Apr 7, 2022 · 5 comments
Labels
Milestone

Comments

@michdingpayc
Copy link

The file src/Monolog/Attribute/AsMonologProcessor.php in monolog version 2.4.0 uses constructor property promotion (lines 31-33) which was introduced in PHP version 8.0.

When used in PHP 7.4, one sees the following:
PHP Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting variable (T_VARIABLE) in [...]/vendor/monolog/monolog/src/Monolog/Attribute/AsMonologProcessor.php on line 31.

The issue here is the fact that the composer.json file and therefore the monolog/monlog packagist page lists the PHP version requirement as ">=7.2".

@Seldaek
Copy link
Owner

Seldaek commented Apr 7, 2022

Attributes are a php8 feature so you cannot use this class on 7.4 anyway and I'm not sure what you are doing?

@wp-seopress
Copy link

Same issue here, VS Code returns an error.

Solution?

public function __construct(?string $channel = null, ?string $handler = null, ?string $method = null) {

@michdingpayc
Copy link
Author

Attributes are a php8 feature so you cannot use this class on 7.4 anyway and I'm not sure what you are doing?

Thank you for the quick response.

The attribute class isn't used in the PHP 7.4 project I'm referencing, but the monolog vendor directory is preloaded into opcache. This is done for performance purposes but with monolog version 2.4.0 that is also where this issue arises.

The file can be explicitly excluded from preloading, but I would like to hear your thoughts first.

@Seldaek
Copy link
Owner

Seldaek commented Apr 8, 2022

Fixed in 508df12 - please upgrade to 2.5.0

@Seldaek Seldaek closed this as completed Apr 8, 2022
@Seldaek Seldaek added this to the 2.x milestone Apr 8, 2022
@michdingpayc
Copy link
Author

Thank you kindly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants