Skip to content
Permalink
Browse files

Fix #1458 by making instanceof static same as === static

  • Loading branch information...
muglug committed Jun 20, 2019
1 parent 4823e35 commit d845cdf0c5588b6dd1451ab78c307bdc86366e79
@@ -63,6 +63,10 @@ public static function scrapeAssertions(
$var_type = $conditional->expr->inferredType ?? null;
foreach ($instanceof_types as $instanceof_type) {
if ($instanceof_type[0] === '=') {
$instanceof_type = substr($instanceof_type, 1);
}
if ($codebase
&& $var_type
&& $inside_negation
@@ -1873,6 +1877,10 @@ protected static function getInstanceOfTypes(
} elseif ($this_class_name
&& (in_array(strtolower($stmt->class->parts[0]), ['self', 'static'], true))
) {
if ($stmt->class->parts[0] === 'static') {
return ['=' . $this_class_name];
}
return [$this_class_name];
}
} elseif (isset($stmt->class->inferredType)) {
@@ -1355,6 +1355,14 @@ function baz(A $a) : void {
$a->foo();
}',
],
'instanceofStatic' => [
'<?php
class A {
public function foo(self $value): void {
if ($value instanceof static) {}
}
}',
],
];
}

0 comments on commit d845cdf

Please sign in to comment.
You can’t perform that action at this time.