Skip to content

Commit

Permalink
fix Assert::type() failure error when expected $type is object (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiripudil authored Dec 3, 2020
1 parent 652853e commit 4b408f5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Framework/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ public static function type($type, $value, string $description = null): void

} elseif (!$value instanceof $type) {
$actual = is_object($value) ? get_class($value) : gettype($value);
$type = is_object($type) ? get_class($type) : $type;
self::fail(self::describe("$actual should be instance of $type", $description));
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/Framework/Assert.type.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ $cases = [
['list', []],
['list', [1]],
['list', [4 => 1], '[4 => 1] should be list'],
[new stdClass, 'string', 'string should be instance of stdClass'],
];

foreach ($cases as $case) {
Expand Down

0 comments on commit 4b408f5

Please sign in to comment.