Closed chregu closed 2 years ago
Perhaps an alternative solution is to mark the Image
class or abstract ImageAutodoc
class with the #[AllowDynamicProperties]
attribute? This should be fully backwards-compatible with earlier PHP versions according to the RFC mentioned above.
Ooop, sorry Kleis, I missed your comment. Shall I revert?
I wasn't sure whether PHPStan supports that attribute and if that would fix it, so perhaps a revert is not necessary.
That's the other alternative, but then that maybe will break with PHP 9 again (Don't think that's totally decided yet). The abstract functions for set and get seem to be the future proof way.
PHP 8.2 deprecates access to dynamic properties, if not explicitly allowed through set/get or an annotation. Therefor PHPStan fails for some reason in
\Jcupitt\Vips\ImageAutodoc
, even though it is defined in theImage
class, see for example here https://github.com/rokka-io/imagine-vips/actions/runs/3236307918/jobs/5301940309Adding set and get to ImageAutodoc prevents this "fail".
More details about this here https://wiki.php.net/rfc/deprecate_dynamic_properties
(PHP 8.2 is not released yet and "normal" code runs normally, just PHPStan fails currently).
This should also prevent a fatal error, if that is really removed in PHP 9.0 (set/get won't be removed, just implicit dynamic properties)