functional-php icon indicating copy to clipboard operation
functional-php copied to clipboard

changes for PHP 8.4

Open Egorskov opened this issue 1 year ago • 1 comments

Deprecated: Functional\some(): Implicitly marking parameter $callback as nullable is deprecated, the explicit nullable type must be used instead in /Users/egorgorskov/php-project-48/vendor/lstrojny/functional-php/src/Functional/Some.php on line 25 The deprecation warning we are encountering, “Implicitly marking parameter $callback as nullable is deprecated,” is a result of changes introduced in PHP 8.4, which explicitly requires developers to declare nullable types instead of relying on implicit nullability. This change affects any function or method that previously allowed a parameter to default to null without explicitly defining it as nullable. Solution:

function example(?callable $callback = null) {
    // function
} 
or for PHP 8.@
function example(callable|null $callback = null) {
    // function
} 

Egorskov avatar Dec 08 '24 13:12 Egorskov

Would it be worth taking this opportunity to use the Closure class instead of callable?

rrigby avatar Feb 09 '25 01:02 rrigby