Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.2 | Various tests: explicitly declare properties #1170

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Mar 15, 2022

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.

This commit addresses a number of issues in the "known property" category within the test suite.

Refs:

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.

This commit addresses a number of issues in the "known property" category within the test suite.

Refs:
* https://wiki.php.net/rfc/deprecate_dynamic_properties
@jrfnl jrfnl force-pushed the feature/php-8.2-tests-explicitly-declare-properties branch from 74cee39 to 358c21a Compare March 15, 2022 07:52
@davedevelopment davedevelopment merged commit 69e0b0f into mockery:master Apr 12, 2022
@jrfnl jrfnl deleted the feature/php-8.2-tests-explicitly-declare-properties branch April 12, 2022 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants