Skip to content

Fix false RedundantCondition for instanceof on a class-string variable#11869

Open
eyupcanakman wants to merge 1 commit into
vimeo:6.xfrom
eyupcanakman:fix/instanceof-classstring-redundant-11076
Open

Fix false RedundantCondition for instanceof on a class-string variable#11869
eyupcanakman wants to merge 1 commit into
vimeo:6.xfrom
eyupcanakman:fix/instanceof-classstring-redundant-11076

Conversation

@eyupcanakman

Copy link
Copy Markdown
Contributor

Fix #11076

$x instanceof $class where $class is a class-string<I> for an interface I was reported as RedundantCondition when $x was already I. The variable can name any class implementing I, so the check can be false (an ArrayIterator is not a DirectoryIterator, though both are Traversable). Interface class-strings now resolve through is_a instead of a fixed type, like is_a($x, $class) already does.

`$x instanceof $class` where `$class` is a `class-string<I>` for an interface `I` was reported as RedundantCondition when `$x` was already `I`. The variable can name any class implementing `I`, so the check can be false at runtime. Interface class-strings now resolve through is_a instead of a fixed type, like is_a($x, $class).

Fixes vimeo#11076
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.

Incorrect RedundantCondition with class-string<Foo> and instanceof

1 participant