Skip to content

Commit 93f3902

Browse files
jiripudildg
authored andcommitted
fix Assert::type() failure error when expected $type is object (#425)
1 parent 9645bc9 commit 93f3902

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/Framework/Assert.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ public static function type($type, $value, string $description = null): void
273273

274274
} elseif (!$value instanceof $type) {
275275
$actual = is_object($value) ? get_class($value) : gettype($value);
276+
$type = is_object($type) ? get_class($type) : $type;
276277
self::fail(self::describe("$actual should be instance of $type", $description));
277278
}
278279
}

tests/Framework/Assert.type.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ $cases = [
2828
['list', []],
2929
['list', [1]],
3030
['list', [4 => 1], '[4 => 1] should be list'],
31+
[new stdClass, 'string', 'string should be instance of stdClass'],
3132
];
3233

3334
foreach ($cases as $case) {

0 commit comments

Comments
 (0)