Skip to content

Commit 70c22d4

Browse files
lcobucciondrejmirtes
authored andcommitted
Add resolvers for assertions added in PHPUnit 7.5
As documented in PHPUnit's change log the methods `assertInternalType()` and `assertNotInternalType()` have been deprecated and new methods were added as alternatives. More info: https://github.com/sebastianbergmann/phpunit/blob/7.5.0/ChangeLog-7.5.md
1 parent 83a0f25 commit 70c22d4

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/Type/PHPUnit/Assert/AssertTypeSpecifyingExtensionHelper.php

+37
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ private static function trimName(string $name): string
5151
return substr($name, 3);
5252
}
5353

54+
if (strpos($name, 'IsNot') === 0) {
55+
return 'Is' . substr($name, 5);
56+
}
57+
5458
return $name;
5559
}
5660

@@ -148,6 +152,39 @@ private static function getExpressionResolvers(): array
148152
new \PhpParser\Node\Expr\ConstFetch(new Name('null'))
149153
);
150154
},
155+
'IsArray' => function (Scope $scope, Arg $actual) {
156+
return new \PhpParser\Node\Expr\FuncCall(new Name('is_array'), [$actual]);
157+
},
158+
'IsBool' => function (Scope $scope, Arg $actual) {
159+
return new \PhpParser\Node\Expr\FuncCall(new Name('is_bool'), [$actual]);
160+
},
161+
'IsCallable' => function (Scope $scope, Arg $actual) {
162+
return new \PhpParser\Node\Expr\FuncCall(new Name('is_callable'), [$actual]);
163+
},
164+
'IsFloat' => function (Scope $scope, Arg $actual) {
165+
return new \PhpParser\Node\Expr\FuncCall(new Name('is_float'), [$actual]);
166+
},
167+
'IsInt' => function (Scope $scope, Arg $actual) {
168+
return new \PhpParser\Node\Expr\FuncCall(new Name('is_int'), [$actual]);
169+
},
170+
'IsIterable' => function (Scope $scope, Arg $actual) {
171+
return new \PhpParser\Node\Expr\FuncCall(new Name('is_iterable'), [$actual]);
172+
},
173+
'IsNumeric' => function (Scope $scope, Arg $actual) {
174+
return new \PhpParser\Node\Expr\FuncCall(new Name('is_numeric'), [$actual]);
175+
},
176+
'IsObject' => function (Scope $scope, Arg $actual) {
177+
return new \PhpParser\Node\Expr\FuncCall(new Name('is_object'), [$actual]);
178+
},
179+
'IsResource' => function (Scope $scope, Arg $actual) {
180+
return new \PhpParser\Node\Expr\FuncCall(new Name('is_resource'), [$actual]);
181+
},
182+
'IsString' => function (Scope $scope, Arg $actual) {
183+
return new \PhpParser\Node\Expr\FuncCall(new Name('is_string'), [$actual]);
184+
},
185+
'IsScalar' => function (Scope $scope, Arg $actual) {
186+
return new \PhpParser\Node\Expr\FuncCall(new Name('is_scalar'), [$actual]);
187+
},
151188
'InternalType' => function (Scope $scope, Arg $type, Arg $value) {
152189
$typeType = $scope->getType($type->value);
153190
if (!$typeType instanceof ConstantStringType) {

0 commit comments

Comments
 (0)