Skip to content

Commit daf1176

Browse files
acasademontondrejmirtes
authored andcommitted
Add support for integerish assertions
1 parent a2940e5 commit daf1176

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/Type/BeberleiAssert/AssertHelper.php

+6
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,12 @@ private static function getExpressionResolvers(): array
366366
[$value]
367367
);
368368
},
369+
'integerish' => function (Scope $scope, Arg $value): \PhpParser\Node\Expr {
370+
return new \PhpParser\Node\Expr\FuncCall(
371+
new \PhpParser\Node\Name('is_numeric'),
372+
[$value]
373+
);
374+
},
369375
];
370376
}
371377

tests/Type/BeberleiAssert/AssertTypeSpecifyingExtensionTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ public function testExtension(): void
252252
'Variable $a is: array<stdClass>',
253253
167,
254254
],
255+
[
256+
'Variable $a is: float|int|(string&numeric)',
257+
173,
258+
],
255259
]);
256260
}
257261

tests/Type/BeberleiAssert/data/data.php

+5
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ public function doBaz(array $a): void
167167
$a;
168168
}
169169

170+
public function doFooBar($a): void
171+
{
172+
Assertion::integerish($a);
173+
$a;
174+
}
170175
}
171176

172177
class Bar

0 commit comments

Comments
 (0)