diff --git a/src/Type/PHPUnit/Assert/AssertTypeSpecifyingExtensionHelper.php b/src/Type/PHPUnit/Assert/AssertTypeSpecifyingExtensionHelper.php index 34d86ca..963b4f5 100644 --- a/src/Type/PHPUnit/Assert/AssertTypeSpecifyingExtensionHelper.php +++ b/src/Type/PHPUnit/Assert/AssertTypeSpecifyingExtensionHelper.php @@ -276,6 +276,9 @@ private static function getExpressionResolvers(): array 'ObjectHasAttribute' => static function (Scope $scope, Arg $property, Arg $object): FuncCall { return new FuncCall(new Name('property_exists'), [$object, $property]); }, + 'ObjectHasProperty' => static function (Scope $scope, Arg $property, Arg $object): FuncCall { + return new FuncCall(new Name('property_exists'), [$object, $property]); + }, 'Contains' => static function (Scope $scope, Arg $needle, Arg $haystack): Expr { return new Expr\BinaryOp\BooleanOr( new Expr\Instanceof_($haystack->value, new Name('Traversable')), diff --git a/tests/Type/PHPUnit/AssertFunctionTypeSpecifyingExtensionTest.php b/tests/Type/PHPUnit/AssertFunctionTypeSpecifyingExtensionTest.php index f2a254d..2d43f8b 100644 --- a/tests/Type/PHPUnit/AssertFunctionTypeSpecifyingExtensionTest.php +++ b/tests/Type/PHPUnit/AssertFunctionTypeSpecifyingExtensionTest.php @@ -11,11 +11,15 @@ class AssertFunctionTypeSpecifyingExtensionTest extends TypeInferenceTestCase /** @return mixed[] */ public function dataFileAsserts(): iterable { - if (!function_exists('PHPUnit\\Framework\\assertInstanceOf')) { - return []; + if (function_exists('PHPUnit\\Framework\\assertInstanceOf')) { + yield from $this->gatherAssertTypes(__DIR__ . '/data/assert-function.php'); } - yield from $this->gatherAssertTypes(__DIR__ . '/data/assert-function.php'); + if (function_exists('PHPUnit\\Framework\\assertObjectHasProperty')) { + yield from $this->gatherAssertTypes(__DIR__ . '/data/assert-function-9.6.11.php'); + } + + return []; } /** diff --git a/tests/Type/PHPUnit/data/assert-function-9.6.11.php b/tests/Type/PHPUnit/data/assert-function-9.6.11.php new file mode 100644 index 0000000..dea6b85 --- /dev/null +++ b/tests/Type/PHPUnit/data/assert-function-9.6.11.php @@ -0,0 +1,17 @@ +