Skip to content

Commit b4df461

Browse files
author
Emil Masiakowski
committed
Support methodExists
1 parent 722c1ed commit b4df461

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
@@ -397,6 +397,10 @@ private static function getExpressionResolvers(): array
397397
new Name('property_exists'),
398398
[$object, $property],
399399
),
400+
'methodExists' => static fn (Scope $scope, Arg $object, Arg $property): Expr => new FuncCall(
401+
new Name('method_exists'),
402+
[$object, $property],
403+
),
400404
'notBlank' => static fn (Scope $scope, Arg $value): Expr => new BooleanAnd(
401405
new BooleanAnd(
402406
new NotIdentical(

tests/Type/BeberleiAssert/data/data.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public function doFoo($a, $b, array $c, iterable $d, $e, $f, $g, $h, $i, $j, $k,
4444
Assertion::propertyExists($j, 'foo');
4545
\PHPStan\Testing\assertType('object&hasProperty(foo)', $j);
4646

47+
Assertion::methodExists($j, 'doBar');
48+
\PHPStan\Testing\assertType('object&hasMethod(doBar)&hasProperty(foo)', $j);
49+
4750
Assertion::isResource($k);
4851
\PHPStan\Testing\assertType('resource', $k);
4952

0 commit comments

Comments
 (0)