Closed karinarastsinskagia closed 7 months ago
This seems to just be an issue in general with using mixins in this way now. I initially thought this was a bug too and created an issue in phpstan/phpstan#8939 but after some discussion it makes sense. PHPStan is assuming that because the IdeHelper class has no __get
/__set
the properties attached to it are dynamic and since it has no #[\AllowDynamicProperties]
by default it is ignoring those entirely on the main class.
ide-helper could theoretically get around this by adding a fake get/set or AllowDynamicProperties to its generated class but I feel like both of those are just workarounds for the fact that I don't think mixins were made to do something like this.
Wouldn't it be technically more correct if the classes generated in the helper file would actually extend \Illuminate\Database\Eloquent\Model
?
There the __get
is implemented.
Wouldn't it be technically more correct if the classes generated in the helper file would actually
extend \Illuminate\Database\Eloquent\Model
?There the
__get
is implemented.
Well, it works, however I don't if, technically it's more correct
@barryvdh
Do you have any news on this?
Thank you
Versions:
Description:
After the update to PHP 8.2 all @Property annotations which include in
_ide_helper_models.php
are not recognized and anAccess to an undefined property
is thrown. More specifically, I have the following model and the respective_ide_helper_models.php
All works fine with PHP Version 8.1. Although, using PHP 8.2 I get the mentioned error message (
Access to an undefined property App\Models\Article::$title
).About the issue, I have tried 3 different approaches. Please find them below
@mixin IdeHelperArticle
.#[\AllowDynamicProperties]
before model class Result : Not work Comment : I found out that PHP 8.2 needs to have#[\AllowDynamicProperties]
above the class to work however this approach does not solve the issue#[\AllowDynamicProperties]
insideide_helper_models.php
Result : works Comment : I don't know why and how to enforce this feature at generation time ofide_helper_models.php
fileIs there any setting that I have to enable in order to make
ide_helper_models.php
be compatible with PHP 8.2 or is there any other solution in order to keep the functionality as it is in PHP 8.1? Does anyone know why my Model class doesn't work in the same way after the update to PHP 8.2?