Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

## 2.1.4

### Fixed

- Use custom message for more internal calls

## 2.1.3

### Fixed
Expand Down
10 changes: 5 additions & 5 deletions src/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ public static function isIterable(mixed $value, string $message = ''): iterable
*/
public static function isInstanceOf(mixed $value, mixed $class, string $message = ''): object
{
static::object($value);
static::object($value, $message);
static::string($class, 'Expected class as a string. Got: %s');

if (!($value instanceof $class)) {
Expand All @@ -510,7 +510,7 @@ public static function isInstanceOf(mixed $value, mixed $class, string $message
*/
public static function notInstanceOf(mixed $value, mixed $class, string $message = ''): object
{
static::object($value);
static::object($value, $message);
static::string($class, 'Expected class as a string. Got: %s');

if ($value instanceof $class) {
Expand All @@ -537,7 +537,7 @@ public static function notInstanceOf(mixed $value, mixed $class, string $message
*/
public static function isInstanceOfAny(mixed $value, mixed $classes, string $message = ''): object
{
static::object($value);
static::object($value, $message);
static::isIterable($classes);

foreach ($classes as $class) {
Expand Down Expand Up @@ -596,7 +596,7 @@ public static function isAOf(mixed $value, mixed $class, string $message = ''):
*/
public static function isNotA(mixed $value, mixed $class, string $message = ''): object|string
{
static::objectish($value);
static::objectish($value, $message);
static::string($class, 'Expected class as a string. Got: %s');

if (\is_a($value, $class, \is_string($value))) {
Expand All @@ -621,7 +621,7 @@ public static function isNotA(mixed $value, mixed $class, string $message = ''):
*/
public static function isAnyOf(mixed $value, mixed $classes, string $message = ''): object|string
{
static::objectish($value);
static::objectish($value, $message);
static::isIterable($classes);

foreach ($classes as $class) {
Expand Down
25 changes: 25 additions & 0 deletions tests/AssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,31 @@ public static function getMethodsThatUseOtherMethods(): array
'args' => [111, 'test', 'Value must be an array without key test. Got: %s'],
'exceptionMessage' => 'Value must be an array without key test. Got: integer',
],
[
'method' => 'isInstanceOf',
'args' => [111, 'stdClass', 'Value must be an instance of stdClass. Got: %s'],
'exceptionMessage' => 'Value must be an instance of stdClass. Got: integer',
],
[
'method' => 'notInstanceOf',
'args' => [111, 'stdClass', 'Value must be an instance of stdClass. Got: %s'],
'exceptionMessage' => 'Value must be an instance of stdClass. Got: integer',
],
[
'method' => 'isInstanceOfAny',
'args' => [111, 'stdClass', 'Value must be an instance of stdClass. Got: %s'],
'exceptionMessage' => 'Value must be an instance of stdClass. Got: integer',
],
[
'method' => 'isNotA',
'args' => [111, 'stdClass', 'Value must be an instance of stdClass. Got: %s'],
'exceptionMessage' => 'Value must be an instance of stdClass. Got: integer',
],
[
'method' => 'isAnyOf',
'args' => [111, 'stdClass', 'Value must be an instance of stdClass. Got: %s'],
'exceptionMessage' => 'Value must be an instance of stdClass. Got: integer',
],
];
}
}
Expand Down