Skip to content

Commit

Permalink
Whip_RequirementsChecker: explicitly declare all properties
Browse files Browse the repository at this point in the history
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, both the `$configuration` property, as well as the `$messageManager` property fall in the "known property" category and should be declared.

Note: while this _could_ be considered a BC-break, I've elected to make these properties `private` (was previously automatically `public` due to these being dynamic properties).

Refs:
* https://wiki.php.net/rfc/deprecate_dynamic_properties
  • Loading branch information
jrfnl committed Dec 23, 2021
1 parent a051918 commit df5ab81
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Whip_RequirementsChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ class Whip_RequirementsChecker {
*/
private $requirements;

/**
* The configuration to check.
*
* @var Whip_Configuration
*/
private $configuration;

/**
* Message Manager.
*
* @var Whip_MessagesManager
*/
private $messageManager;

/**
* The text domain to use for translations.
*
Expand Down

0 comments on commit df5ab81

Please sign in to comment.