Skip to content

Commit 2066357

Browse files
committed
Validators::assertField: first argument has typehint array (BC break)
1 parent 65c28a4 commit 2066357

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/Utils/Validators.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,10 @@ public static function assert($value, string $expected, string $label = 'variabl
9393

9494
/**
9595
* Throws exception if an array field is missing or of unexpected type (separated by pipe).
96-
* @param array
9796
* @return void
9897
*/
99-
public static function assertField($arr, $field, string $expected = NULL, string $label = "item '%' in array")
98+
public static function assertField(array $arr, $field, string $expected = NULL, string $label = "item '%' in array")
10099
{
101-
self::assert($arr, 'array', 'first argument');
102100
if (!array_key_exists($field, $arr)) {
103101
throw new AssertionException('Missing ' . str_replace('%', $field, $label) . '.');
104102

tests/Utils/Validators.assertField().phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ $arr = ['first' => TRUE];
1717

1818
Assert::exception(function () use ($arr) {
1919
Validators::assertField(NULL, 'foo', 'foo');
20-
}, Nette\Utils\AssertionException::class, 'The first argument expects to be array, NULL given.');
20+
}, TypeError::class);
2121

2222
Assert::exception(function () use ($arr) {
2323
Validators::assertField($arr, 'second', 'int');

0 commit comments

Comments
 (0)