Skip to content

Conversation

Egorskov
Copy link

@Egorskov Egorskov commented Dec 8, 2024

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
} 

@rrigby
Copy link

rrigby commented Feb 9, 2025

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

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.

2 participants