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

[11.x] Using the ?? Operator (Null Coalescing Operator) #51305

Merged

Conversation

saMahmoudzadeh
Copy link
Contributor

@saMahmoudzadeh saMahmoudzadeh commented May 5, 2024

This PR, introduces the use of the Null Coalescing Operator (??) in the some cases. The Null Coalescing Operator is a concise and effective way to handle null values, providing a default value if the variable is null.

Laravel 11 supports PHP 8.2 and higher, and the ?? operator has been available since PHP 7 and above. Therefore, we have no issues in terms of compatibility with the changes. The goal of these changes is to simplify the code and utilize the powerful features of PHP.

example:

// before
if (isset($this->dispatchAfterCommit)) {
    return $this->dispatchAfterCommit;
}

return false;
// after
return $this->dispatchAfterCommit ?? false;

@taylorotwell taylorotwell merged commit dbcad29 into laravel:11.x May 6, 2024
30 checks passed
@saMahmoudzadeh saMahmoudzadeh deleted the refactor/null-coalescing-operator branch May 6, 2024 17:23
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