[2.15.0] Inserting AllowDynamicProperties attribute breaks final classes
tminich opened this issue · comments
Versions:
- ide-helper Version: 2.15.0
- Laravel Version: 10.44.0
- PHP Version: 8.2.15
Description:
Apparently 2.15.0 introduced adding the AllowDynamicProperties attribute to generated model helper classes. Unfortunately, if the model class is declared final, this attribute is inserted between the final
and class
keywords leading to invalid php.
final #[\AllowDynamicProperties]
class IdeHelperParticipant {}
Steps To Reproduce:
- Declare a model class final
- Generate model helper (with -M -R, not sure if and how far that matters)
I guess we just need to shuffle $keyword
and $allowDynamicAttributes
in
laravel-ide-helper/src/Console/ModelsCommand.php
Line 1086 in c119e89
Do you want to make a PR, including a test using final
(ideally also abstract
, which is also covered in \Barryvdh\LaravelIdeHelper\Console\ModelsCommand::getClassKeyword
Does this fix it for you? #1517
I guess we just need to shuffle
$keyword
and$allowDynamicAttributes
inlaravel-ide-helper/src/Console/ModelsCommand.php
Line 1086 in c119e89
Yeah that fixes it, according to the tests
Looks like it's fixed in 1.5.1, thanks a lot!