Skip to content

Commit 722c1ed

Browse files
author
Emil Masiakowski
committed
Support propertyExists
1 parent ed8c49f commit 722c1ed

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/Type/BeberleiAssert/AssertHelper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,10 @@ private static function getExpressionResolvers(): array
393393
[$key, $array],
394394
),
395395
),
396+
'propertyExists' => static fn (Scope $scope, Arg $object, Arg $property): Expr => new FuncCall(
397+
new Name('property_exists'),
398+
[$object, $property],
399+
),
396400
'notBlank' => static fn (Scope $scope, Arg $value): Expr => new BooleanAnd(
397401
new BooleanAnd(
398402
new NotIdentical(

tests/Type/BeberleiAssert/data/data.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public function doFoo($a, $b, array $c, iterable $d, $e, $f, $g, $h, $i, $j, $k,
4141
Assertion::objectOrClass($j);
4242
\PHPStan\Testing\assertType('object', $j);
4343

44+
Assertion::propertyExists($j, 'foo');
45+
\PHPStan\Testing\assertType('object&hasProperty(foo)', $j);
46+
4447
Assertion::isResource($k);
4548
\PHPStan\Testing\assertType('resource', $k);
4649

0 commit comments

Comments
 (0)