Laravel-Lang / publisher

Publisher provides functionality for working with application localization
https://laravel-lang.com/packages-publisher.html
MIT License
211 stars 25 forks source link

Constant expression contains invalid operations #302

Closed SI-IC closed 2 years ago

SI-IC commented 2 years ago

Description:

I've install Lang publisher, set the lang and all work great. But thrice a minute in the laravel.log appear the messages: local.ERROR: Constant expression contains invalid operations {"exception":"[object] (Symfony\Component\ErrorHandler\Error\FatalError(code: 0): Constant expression contains invalid operations at .../vendor/laravel-lang/publisher/src/Helpers/Config.php:30) [stacktrace]

0 {main}

"}

Steps To Reproduce:

Just install the publisher and set the lang.

andrey-helldar commented 2 years ago
laravel new test
cd test
composer require laravel-lang/publisher
php artisan lang:add it

No errors, no log file.

Can you show the full stack trace of the error and describe your steps in detail? I was unable to reproduce the issue.

Checked on PHP 8.1.4 and 8.1.10.

SI-IC commented 2 years ago

Hello,

Please try to install telescope. I have removed telescope and errors are gone, and when I install telescope again they appeared again. The fact is that this is the entire stack trace that I presented. There is nothing else in laravel.log but many messages local.ERROR: Constant expression contains invalid operations {"exception":"[object] (Symfony\Component\ErrorHandler\Error\FatalError(code: 0): Constant expression contains invalid operations at .../vendor/laravel-lang/publisher/src/Helpers/Config.php:30) [stacktrace]

0 {main}

"}

SI-IC commented 2 years ago

It seems that the error is related to the comment https://www.php.net/manual/en/language.oop5.decon.php#127493

andrey-helldar commented 2 years ago
composer require --dev laravel-lang/publisher laravel-lang/lang laravel-lang/attributes laravel/telescope
php artisan lang:add it

No errors ¯_(ツ)_/¯

PHP: 8.1.10 Laravel 9.27.0 Lang Publisher: 14.3.1, 14.3.2 Lang: 11.0.19 Lang Attributes: 2.0.6

andrey-helldar commented 2 years ago

Try to run composer update and check again.

We have released publisher version 14.3.2.

SI-IC commented 2 years ago

Great! It helped! Thank you.

andrey-helldar commented 2 years ago

Excellent! The problem was not in the class arguments, but in the typing of the method:

https://github.com/Laravel-Lang/publisher/pull/303/files#diff-ab7eb3e5b3d108c34e341cd98212ef0e109cf65374852949e8a1e1100002e8f1R131

SI-IC commented 2 years ago

Okay, I get it. Thanks again.