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

[TypeCoverage] Add EmptyOnNullableObjectToInstanceOfRector #3230

Merged
merged 2 commits into from
Dec 20, 2022

Conversation

TomasVotruba
Copy link
Member

No description provided.

@TomasVotruba TomasVotruba force-pushed the tv-instance-empty branch 7 times, most recently from dd67999 to 756025a Compare December 20, 2022 21:26
@TomasVotruba TomasVotruba merged commit c80cd6f into main Dec 20, 2022
@TomasVotruba TomasVotruba deleted the tv-instance-empty branch December 20, 2022 21:33
@someniatko
Copy link

Hi, I find this one a bit weird, however some may find it appropriate. Is there a rule to change empty($nullableObj) to $nullableObj === null instead?

@TomasVotruba
Copy link
Member Author

Hi, that would not make sense, as comparison is weak.

@someniatko
Copy link

someniatko commented Dec 27, 2022

I might be missing something obvious here:

?AnotherObject type has exactly two atomic possibilities: either AnotherObject, or null, there cannot be a third variant. Passing an instanceof check guarantees it is AnotherObject, and negating it guarantees it is null, thus ! $x instanceof AnotherObject is equivalent to $x === null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants