Skip to content

Commit 242d9f7

Browse files
committed
improved exception messages
1 parent 61f58a6 commit 242d9f7

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

src/Utils/ObjectMixin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static function call($_this, string $name, array $args)
4545
$handler(...$args);
4646
}
4747
} elseif ($_this->$name !== null) {
48-
throw new Nette\UnexpectedValueException("Property $class::$$name must be array or null, " . gettype($_this->$name) . ' given.');
48+
throw new Nette\UnexpectedValueException("Property $class::$$name must be iterable or null, " . gettype($_this->$name) . ' given.');
4949
}
5050

5151
} elseif ($isProp && $_this->$name instanceof \Closure) { // closure in property

src/Utils/SmartObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __call(string $name, array $args)
3535
$handler(...$args);
3636
}
3737
} elseif ($this->$name !== null) {
38-
throw new UnexpectedValueException("Property $class::$$name must be array or null, " . gettype($this->$name) . ' given.');
38+
throw new UnexpectedValueException("Property $class::$$name must be iterable or null, " . gettype($this->$name) . ' given.');
3939
}
4040

4141
} else {

tests/Utils/Object.closureProperty.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ test(function () {
4444
$obj = new TestClass(123);
4545
$obj->onPublic = function () {}; // accidentally forgotten []
4646
$obj->onPublic(1, 2);
47-
}, Nette\UnexpectedValueException::class, 'Property TestClass::$onPublic must be array or null, object given.');
47+
}, Nette\UnexpectedValueException::class, 'Property TestClass::$onPublic must be iterable or null, object given.');
4848

4949

5050
Assert::exception(function () {

tests/Utils/Object.events.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ Assert::exception(function () use ($obj) {
7979
Assert::exception(function () use ($obj) {
8080
$obj->onPublic = 'string';
8181
$obj->onPublic();
82-
}, Nette\UnexpectedValueException::class, 'Property TestClass::$onPublic must be array or null, string given.');
82+
}, Nette\UnexpectedValueException::class, 'Property TestClass::$onPublic must be iterable or null, string given.');

tests/Utils/SmartObject.events.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ Assert::exception(function () use ($obj) {
8080
Assert::exception(function () use ($obj) {
8181
$obj->onPublic = 'string';
8282
$obj->onPublic();
83-
}, Nette\UnexpectedValueException::class, 'Property TestClass::$onPublic must be array or null, string given.');
83+
}, Nette\UnexpectedValueException::class, 'Property TestClass::$onPublic must be iterable or null, string given.');

0 commit comments

Comments
 (0)