antecedent / patchwork

Method redefinition (monkey-patching) functionality for PHP.
https://antecedent.github.io/patchwork/
MIT License
444 stars 40 forks source link

PHP 8.1: fix "passing null to non-nullable" [1] #107

Closed jrfnl closed 3 years ago

jrfnl commented 3 years ago

As of PHP 8.1, passing null to not explicitly nullable scalar parameters for PHP native functions is deprecated.

In this case, $class within applyWildcard() may be null, which leads to the following deprecation notice as can be seen when running the tests on PHP 8.1:

Deprecated: class_exists(): Passing null to parameter #1 ($class) of type string is deprecated in path/to/patchwork/src/CallRerouting.php on line 141

By handling null separately in the condition, the previous behaviour is maintained.

Refs: