Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PHP 8.2: explicitly declare properties (#705)
* Locator: explicitly declare all properties Dynamic (non-explicitly declared) property usage is expected to be deprecated as of PHP 8.2 and will become a fatal error in PHP 9.0. There are a number of ways to mitigate this: * If it's an accidental typo for a declared property: fix the typo. * For known properties: declare them on the class. * For unknown properties: add the magic `__get()`, `__set()` et al methods to the class or let the class extend `stdClass` which has highly optimized versions of these magic methods build in. * For unknown _use of_ dynamic properties, the `#[AllowDynamicProperties]` attribute can be added to the class. The attribute will automatically be inherited by child classes. In this case, the `$dom` property is referenced multiple times throughout this class, so falls in the "known property" category. Refs: * https://wiki.php.net/rfc/deprecate_dynamic_properties * Sanitize: explicitly declare all properties Dynamic (non-explicitly declared) property usage is expected to be deprecated as of PHP 8.2 and will become a fatal error in PHP 9.0. There are a number of ways to mitigate this: * If it's an accidental typo for a declared property: fix the typo. * For known properties: declare them on the class. * For unknown properties: add the magic `__get()`, `__set()` et al methods to the class or let the class extend `stdClass` which has highly optimized versions of these magic methods build in. * For unknown _use of_ dynamic properties, the `#[AllowDynamicProperties]` attribute can be added to the class. The attribute will automatically be inherited by child classes. In this case, the `$registry` property is referenced multiple times throughout this class, so falls in the "known property" category. Refs: * https://wiki.php.net/rfc/deprecate_dynamic_properties * Autoloader: explicitly declare all properties Dynamic (non-explicitly declared) property usage is expected to be deprecated as of PHP 8.2 and will become a fatal error in PHP 9.0. There are a number of ways to mitigate this: * If it's an accidental typo for a declared property: fix the typo. * For known properties: declare them on the class. * For unknown properties: add the magic `__get()`, `__set()` et al methods to the class or let the class extend `stdClass` which has highly optimized versions of these magic methods build in. * For unknown _use of_ dynamic properties, the `#[AllowDynamicProperties]` attribute can be added to the class. The attribute will automatically be inherited by child classes. In this case, the `$path` property is referenced a couple of times throughout this class, so falls in the "known property" category. Refs: * https://wiki.php.net/rfc/deprecate_dynamic_properties * SimplePie_Cache_Redis: fix bug for using undefined property The `$ttl` property is not declared, not set on this cache, nor its parent, which means that it would always be passed as `null`. As the call to the `Redis::expire()` method is within a `if ($this->options['expire'])` condition and a similar call to the `Redis::expire()` method in the `SimplePie_Cache_Redis::save()` method, also uses `$this->options['expire']` for the "ttl" value, changing the passed parameter to `$this->options['expire']` seems the correct fix. Co-authored-by: jrfnl <[email protected]>
- Loading branch information