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" [2] #108

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 interpretCallable() may be null, which leads to the following deprecation notice as can be seen when running the tests on PHP 8.1:

Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated in path/to/patchwork/src/Utils.php on line 123

By handling null separately and setting $class to an empty string, the previous behaviour is maintained.

Refs: