JamesHeinrich / phpThumb

phpThumb() - The PHP thumbnail generator
Other
315 stars 141 forks source link

Deprecation notice: Creation of dynamic property in phpthumb.class.php #214

Closed plantheo closed 1 year ago

plantheo commented 1 year ago

Hi there. I'm getting a deprecation notice about creation of dynamic properties:

Deprecated: Creation of dynamic property phpthumb::$hash is deprecated in /vendor/james-heinrich/phpthumb/phpthumb.class.php on line 391
phpThumb() v1.7.20-202212091316

Edit: I'm using PHP 8.2

JamesHeinrich commented 1 year ago

Apparently dynamic properties have become deprecated in PHP 8.2: https://php.watch/versions/8.2/dynamic-properties-deprecated

If someone wants to submit a PR with a suggestion of how to sensibly fix this I'd be interested. Possibly prefacing the class phpthumb with #[AllowDynamicProperties] might fix that, according to the above article, but this is the first I've heard of this new deprecation, and I don't have a PHP8.2 system at hand.

plantheo commented 1 year ago

I've tried the #[AllowDynamicProperties] but no success: Warning: The use statement with non-compound name 'AllowDynamicProperties' has no effect...

christianzingg commented 1 year ago

I could sove the problem locally with adding a __set magic method to the class. https://php.watch/versions/8.2/dynamic-properties-deprecated#__get-__set

I will submit a PR.

JamesHeinrich commented 1 year ago

Thank you, your PR is much appreciated.