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] Utilize null-safe operator instead of conditional check #51328

Merged
merged 2 commits into from
May 8, 2024

Conversation

saMahmoudzadeh
Copy link
Contributor

This PR implements the usage of the null-safe operator (?->) instead of conditional checking.

Thanks!

@saMahmoudzadeh saMahmoudzadeh changed the title [11.x] Utilize ?-> (null safe) operator instead of conditional check [11.x] Utilize null-safe operator instead of conditional check May 7, 2024
@taylorotwell taylorotwell merged commit 192ec66 into laravel:11.x May 8, 2024
28 checks passed
@saMahmoudzadeh saMahmoudzadeh deleted the refactor/null-safe branch May 9, 2024 07:09
if ($this->output) {
$this->output->writeln('');
}
$this->output?->writeln('');
Copy link

@marius-mcp marius-mcp May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safest way is

if (isset($this->output) && $this->output instanceof \Symfony\Component\Console\Output\OutputInterface) {

Because the property is not typed hinted and it could be of another type and because it could be accessed before initialization.
This is valid also for the other changes.

PS.
I forgot to hit submit review before merge...

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.

3 participants