Skip to content

Commit

Permalink
Upgrade "respect/stringifier" to version 2.0.0
Browse files Browse the repository at this point in the history
Signed-off-by: Henrique Moody <[email protected]>
  • Loading branch information
henriquemoody committed Jan 28, 2024
1 parent 12c1457 commit 4c33f08
Show file tree
Hide file tree
Showing 51 changed files with 122 additions and 119 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"require": {
"php": "^8.1 || ^8.2",
"respect/stringifier": "^0.2.0",
"respect/stringifier": "^2.0.0",
"symfony/polyfill-mbstring": "^1.28"
},
"require-dev": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use Respect\Validation\Exceptions\NestedValidationException;
use Respect\Validation\Exceptions\ValidationException;
use Respect\Validation\Validator;

$usernameValidator = Validator::alnum('_')->length(1, 15)->noWhitespace();
$usernameValidator = Validator::alnum('__')->length(1, 15)->noWhitespace();
try {
$usernameValidator->check('really messed up screen#name');
} catch (NestedValidationException $e) {
Expand All @@ -23,4 +23,4 @@ try {
}
?>
--EXPECT--
"really messed up screen#name" must contain only letters (a-z), digits (0-9) and "_"
"really messed up screen#name" must contain only letters (a-z), digits (0-9) and "__"
2 changes: 1 addition & 1 deletion tests/integration/issue-1033.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use Respect\Validation\Validator as v;
exceptionFullMessage(static fn() => v::each(v::equals(1))->assert(['A', 'B', 'B']));
?>
--EXPECT--
- Each item in `{ "A", "B", "B" }` must be valid
- Each item in `["A", "B", "B"]` must be valid
- "A" must equal 1
- "B" must equal 1
- "B" must equal 1
2 changes: 1 addition & 1 deletion tests/integration/issue-1289.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ exceptionFullMessage(static fn() => $validator->assert($input));
?>
--EXPECT--
default must be of type string
- These rules must pass for `{ "default": 2, "description": { }, "children": { "nope" } }`
- These rules must pass for `["default": 2, "description": [], "children": ["nope"]]`
- Only one of these rules must pass for default
- default must be of type string
- default must be of type boolean
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/issue-1348.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ Array
(
[each] => Array
(
[validator.0] => All of the required rules must pass for `{ "manufacturer": "Ford", "model": "not real" }`
[validator.1] => All of the required rules must pass for `{ "manufacturer": "Honda", "model": "not valid" }`
[validator.0] => All of the required rules must pass for `["manufacturer": "Ford", "model": "not real"]`
[validator.1] => All of the required rules must pass for `["manufacturer": "Honda", "model": "not valid"]`
)

)
2 changes: 1 addition & 1 deletion tests/integration/issue-1376.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ try {
}
?>
--EXPECT--
- All of the required rules must pass for `[object] (stdClass: { "author": "foo" })`
- All of the required rules must pass for `stdClass { +$author="foo" }`
- Attribute title must be present
- Attribute description must be present
- All of the required rules must pass for author
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/issue-425.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exceptionFullMessage(static fn() => $validator->assert(['age' => 1]));
exceptionFullMessage(static fn() => $validator->assert(['reference' => 'QSF1234']));
?>
--EXPECT--
- These rules must pass for `{ "age": 1 }`
- These rules must pass for `["age": 1]`
- reference must be present
- These rules must pass for `{ "reference": "QSF1234" }`
- These rules must pass for `["reference": "QSF1234"]`
- age must be present
4 changes: 2 additions & 2 deletions tests/integration/rules/alwaysValid.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ exceptionMessage(static fn() => v::not(v::alwaysValid())->check(true));
exceptionFullMessage(static fn() => v::not(v::alwaysValid())->assert(true));
?>
--EXPECT--
`TRUE` is always invalid
- `TRUE` is always invalid
`true` is always invalid
- `true` is always invalid
6 changes: 3 additions & 3 deletions tests/integration/rules/arrayType.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ exceptionFullMessage(static fn() => v::not(v::arrayType())->assert([1, 2, 3]));
?>
--EXPECT--
"teste" must be of type array
`{ }` must not be of type array
- `[traversable] (ArrayObject: { })` must be of type array
- `{ 1, 2, 3 }` must not be of type array
`[]` must not be of type array
- `ArrayObject { getArrayCopy() => [] }` must be of type array
- `[1, 2, 3]` must not be of type array
6 changes: 3 additions & 3 deletions tests/integration/rules/arrayVal.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ exceptionFullMessage(static fn() => v::not(v::arrayVal())->assert(new ArrayObjec
?>
--EXPECT--
"Bla %123" must be an array value
`{ 42 }` must not be an array value
- `[object] (stdClass: { })` must be an array value
- `[traversable] (ArrayObject: { 2, 3 })` must not be an array value
`[42]` must not be an array value
- `stdClass {}` must be an array value
- `ArrayObject { getArrayCopy() => [2, 3] }` must not be an array value
6 changes: 3 additions & 3 deletions tests/integration/rules/boolType.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ exceptionFullMessage(static fn() => v::not(v::boolType())->assert(false));
?>
--EXPECT--
"teste" must be of type boolean
`TRUE` must not be of type boolean
- `{ }` must be of type boolean
- `FALSE` must not be of type boolean
`true` must not be of type boolean
- `[]` must be of type boolean
- `false` must not be of type boolean
14 changes: 7 additions & 7 deletions tests/integration/rules/call.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ require 'vendor/autoload.php';
use Respect\Validation\Validator as v;

exceptionMessage(static fn() => v::call('trim', v::noWhitespace())->check(' two words '));
exceptionMessage(static fn() => v::not(v::call('trim', v::stringType()))->check(' something '));
exceptionMessage(static fn() => v::call('trim', v::alwaysValid())->check([]));
exceptionMessage(static fn() => v::not(v::call('stripslashes', v::stringType()))->check(' something '));
exceptionMessage(static fn() => v::call('stripslashes', v::alwaysValid())->check([]));
exceptionFullMessage(static fn() => v::call('strval', v::intType())->assert(1234));
exceptionFullMessage(static fn() => v::not(v::call('is_float', v::boolType()))->assert(1.2));
exceptionFullMessage(static fn() => v::call('array_walk', v::alwaysValid())->assert(INF));
exceptionFullMessage(static fn() => v::call('array_shift', v::alwaysValid())->assert(INF));
?>
--EXPECT--
"two words" must not contain whitespace
" something " must not be valid when executed with "trim"
`{ }` must be valid when executed with "trim"
" something " must not be valid when executed with `stripslashes(string $string): string`
`[]` must be valid when executed with `stripslashes(string $string): string`
- "1234" must be of type integer
- 1.2 must not be valid when executed with "is_float"
- `INF` must be valid when executed with "array_walk"
- 1.2 must not be valid when executed with `is_float(?mixed $value): bool`
- `INF` must be valid when executed with `array_shift(array &$array): ?mixed`
8 changes: 4 additions & 4 deletions tests/integration/rules/callableType.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ try {
}
?>
--EXPECT--
`{ }` must be callable
"trim" must not be callable
- `TRUE` must be callable
- `[object] (Closure: { })` must not be callable
`[]` must be callable
`trim(string $string, string $characters = " \n\r\t\u000b\u0000"): string` must not be callable
- `true` must be callable
- `function (): void` must not be callable
4 changes: 2 additions & 2 deletions tests/integration/rules/callback.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exceptionFullMessage(static fn() => v::callback('is_string')->assert(true));
exceptionFullMessage(static fn() => v::not(v::callback('is_string'))->assert('foo'));
?>
--EXPECT--
`{ }` must be valid
`[]` must be valid
"foo" must not be valid
- `TRUE` must be valid
- `true` must be valid
- "foo" must not be valid
8 changes: 4 additions & 4 deletions tests/integration/rules/charset.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exceptionFullMessage(static fn() => v::charset('ASCII')->assert('açaí'));
exceptionFullMessage(static fn() => v::not(v::charset('UTF-8'))->assert('açaí'));
?>
--EXPECT--
"açaí" must be in the `{ "ASCII" }` charset
"açaí" must not be in the `{ "UTF-8" }` charset
- "açaí" must be in the `{ "ASCII" }` charset
- "açaí" must not be in the `{ "UTF-8" }` charset
"açaí" must be in the `["ASCII"]` charset
"açaí" must not be in the `["UTF-8"]` charset
- "açaí" must be in the `["ASCII"]` charset
- "açaí" must not be in the `["UTF-8"]` charset
4 changes: 2 additions & 2 deletions tests/integration/rules/contains.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ exceptionFullMessage(static fn() => v::not(v::contains('foo', true))->assert(['b
--EXPECT--
"bar" must contain the value "foo"
"fool" must not contain the value "foo"
- `{ "bar" }` must contain the value "foo"
- `{ "bar", "foo" }` must not contain the value "foo"
- `["bar"]` must contain the value "foo"
- `["bar", "foo"]` must not contain the value "foo"
8 changes: 4 additions & 4 deletions tests/integration/rules/containsAny.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exceptionFullMessage(static fn() => v::containsAny(['foo', 'bar'])->assert(['baz
exceptionFullMessage(static fn() => v::not(v::containsAny(['foo', 'bar'], true))->assert(['bar', 'foo']));
?>
--EXPECT--
"baz" must contain at least one of the values `{ "foo", "bar" }`
"fool" must not contain any of the values `{ "foo", "bar" }`
- `{ "baz" }` must contain at least one of the values `{ "foo", "bar" }`
- `{ "bar", "foo" }` must not contain any of the values `{ "foo", "bar" }`
"baz" must contain at least one of the values `["foo", "bar"]`
"fool" must not contain any of the values `["foo", "bar"]`
- `["baz"]` must contain at least one of the values `["foo", "bar"]`
- `["bar", "foo"]` must not contain any of the values `["foo", "bar"]`
4 changes: 2 additions & 2 deletions tests/integration/rules/countable.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ exceptionFullMessage(static fn() => v::not(v::countable())->assert(new ArrayObje
?>
--EXPECT--
1.0 must be countable
`{ }` must not be countable
`[]` must not be countable
- "Not countable!" must be countable
- `[traversable] (ArrayObject: { })` must not be countable
- `ArrayObject { getArrayCopy() => [] }` must not be countable
8 changes: 4 additions & 4 deletions tests/integration/rules/each.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exceptionFullMessage(static fn() => v::each(v::dateTime())->assert(null));
exceptionFullMessage(static fn() => v::not(v::each(v::dateTime()))->assert(['2018-10-10']));
?>
--EXPECT--
Each item in `NULL` must be valid
Each item in `{ "2018-10-10" }` must not validate
- Each item in `NULL` must be valid
- Each item in `{ "2018-10-10" }` must not validate
Each item in `null` must be valid
Each item in `["2018-10-10"]` must not validate
- Each item in `null` must be valid
- Each item in `["2018-10-10"]` must not validate
4 changes: 2 additions & 2 deletions tests/integration/rules/endsWith.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ exceptionFullMessage(static fn() => v::not(v::endsWith('foo'))->assert(['bar', '
?>
--EXPECT--
"bar" must end with "foo"
`{ "bar", "foo" }` must not end with "foo"
`["bar", "foo"]` must not end with "foo"
- "" must end with "foo"
- `{ "bar", "foo" }` must not end with "foo"
- `["bar", "foo"]` must not end with "foo"
4 changes: 2 additions & 2 deletions tests/integration/rules/equivalent.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exceptionFullMessage(static fn() => v::equivalent(123)->assert('true'));
exceptionFullMessage(static fn() => v::not(v::equivalent(true))->assert(1));
?>
--EXPECT--
`FALSE` must be equivalent to `TRUE`
`false` must be equivalent to `true`
"someThing" must not be equivalent to "Something"
- "true" must be equivalent to 123
- 1 must not be equivalent to `TRUE`
- 1 must not be equivalent to `true`
2 changes: 1 addition & 1 deletion tests/integration/rules/falseVal.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exceptionFullMessage(static fn() => v::falseVal()->assert(1));
exceptionFullMessage(static fn() => v::not(v::falseVal())->assert(0));
?>
--EXPECT--
`TRUE` must evaluate to `false`
`true` must evaluate to `false`
"false" must not evaluate to `false`
- 1 must evaluate to `false`
- 0 must not evaluate to `false`
2 changes: 1 addition & 1 deletion tests/integration/rules/finite.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ exceptionFullMessage(static fn() => v::not(v::finite())->assert('123456'));
--EXPECT--
"" must be a finite number
10 must not be a finite number
- `{ 12 }` must be a finite number
- `[12]` must be a finite number
- "123456" must not be a finite number
2 changes: 1 addition & 1 deletion tests/integration/rules/floatType.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ exceptionFullMessage(static fn() => v::not(v::floatType())->assert(2.0));
--EXPECT--
"42.33" must be of type float
`INF` must not be of type float
- `TRUE` must be of type float
- `true` must be of type float
- 2.0 must not be of type float
2 changes: 1 addition & 1 deletion tests/integration/rules/image.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ exceptionFullMessage(static fn() => v::not(v::image())->assert('tests/fixtures/v
--EXPECT--
"tests/fixtures/invalid-image.png" must be a valid image
"tests/fixtures/valid-image.png" must not be a valid image
- `[object] (stdClass: { })` must be a valid image
- `stdClass {}` must be a valid image
- "tests/fixtures/valid-image.gif" must not be a valid image
2 changes: 1 addition & 1 deletion tests/integration/rules/imei.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ exceptionFullMessage(static fn() => v::not(v::imei())->assert('356938035643809')
--EXPECT--
"490154203237512" must be a valid IMEI
"350077523237513" must not be a valid IMEI
- `NULL` must be a valid IMEI
- `null` must be a valid IMEI
- "356938035643809" must not be a valid IMEI
6 changes: 3 additions & 3 deletions tests/integration/rules/in.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exceptionFullMessage(static fn() => v::in([2, '1', 3], true)->assert('2'));
exceptionFullMessage(static fn() => v::not(v::in([2, '1', 3], true))->assert('1'));
?>
--EXPECT--
1 must be in `{ 3, 2 }`
1 must be in `[3, 2]`
"foo" must not be in "foobar"
- "2" must be in `{ 2, "1", 3 }`
- "1" must not be in `{ 2, "1", 3 }`
- "2" must be in `[2, "1", 3]`
- "1" must not be in `[2, "1", 3]`
2 changes: 1 addition & 1 deletion tests/integration/rules/infinite.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ exceptionFullMessage(static fn() => v::not(v::infinite())->assert(INF * -1));
--EXPECT--
-9 must be an infinite number
`INF` must not be an infinite number
- `[object] (stdClass: { })` must be an infinite number
- `stdClass {}` must be an infinite number
- `-INF` must not be an infinite number
8 changes: 4 additions & 4 deletions tests/integration/rules/instance.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exceptionFullMessage(static fn() => v::instance(ArrayIterator::class)->assert(ne
exceptionFullMessage(static fn() => v::not(v::instance(stdClass::class))->assert(new stdClass()));
?>
--EXPECT--
"" must be an instance of "DateTime"
`[traversable] (ArrayObject: { })` must not be an instance of "Traversable"
- `[object] (stdClass: { })` must be an instance of "ArrayIterator"
- `[object] (stdClass: { })` must not be an instance of "stdClass"
"" must be an instance of `DateTime`
`ArrayObject { getArrayCopy() => [] }` must not be an instance of `Traversable`
- `stdClass {}` must be an instance of `ArrayIterator`
- `stdClass {}` must not be an instance of `stdClass`
2 changes: 1 addition & 1 deletion tests/integration/rules/intType.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exceptionFullMessage(static fn() => v::intType()->assert(INF));
exceptionFullMessage(static fn() => v::not(v::intType())->assert(1234567890));
?>
--EXPECT--
`[object] (stdClass: { })` must be of type integer
`stdClass {}` must be of type integer
42 must not be of type integer
- `INF` must be of type integer
- 1234567890 must not be of type integer
4 changes: 2 additions & 2 deletions tests/integration/rules/iterableType.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ exceptionFullMessage(static fn() => v::not(v::iterableType())->assert(new stdCla
?>
--EXPECT--
3 must be iterable
`{ 2, 3 }` must not be iterable
`[2, 3]` must not be iterable
- "String" must be iterable
- `[object] (stdClass: { })` must not be iterable
- `stdClass {}` must not be iterable
4 changes: 2 additions & 2 deletions tests/integration/rules/json.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exceptionFullMessage(static fn() => v::json()->assert(new stdClass()));
exceptionFullMessage(static fn() => v::not(v::json())->assert('{}'));
?>
--EXPECT--
`FALSE` must be a valid JSON string
`false` must be a valid JSON string
"{\"foo\": \"bar\", \"number\":1}" must not be a valid JSON string
- `[object] (stdClass: { })` must be a valid JSON string
- `stdClass {}` must be a valid JSON string
- "{}" must not be a valid JSON string
2 changes: 1 addition & 1 deletion tests/integration/rules/languageCode.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exceptionFullMessage(static fn() => v::languageCode()->assert('por'));
exceptionFullMessage(static fn() => v::not(v::languageCode())->assert('en'));
?>
--EXPECT--
`NULL` must be a valid ISO 639 "alpha-2" language code
`null` must be a valid ISO 639 "alpha-2" language code
"pt" must not be a valid ISO 639 "alpha-2" language code
- "por" must be a valid ISO 639 "alpha-2" language code
- "en" must not be a valid ISO 639 "alpha-2" language code
2 changes: 1 addition & 1 deletion tests/integration/rules/notBlank.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ Field must not be blank
1 must be blank
- The value must not be blank
- Field must not be blank
- `{ 1 }` must be blank
- `[1]` must be blank
2 changes: 1 addition & 1 deletion tests/integration/rules/notEmpty.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ Field must not be empty
1 must be empty
- The value must not be empty
- Field must not be empty
- `{ 1 }` must be empty
- `[1]` must be empty
6 changes: 3 additions & 3 deletions tests/integration/rules/nullType.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ exceptionFullMessage(static fn() => v::not(v::nullType())->assert(null));
?>
--EXPECT--
"" must be null
`NULL` must not be null
- `FALSE` must be null
- `NULL` must not be null
`null` must not be null
- `false` must be null
- `null` must not be null
6 changes: 3 additions & 3 deletions tests/integration/rules/objectType.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exceptionFullMessage(static fn() => v::objectType()->assert('test'));
exceptionFullMessage(static fn() => v::not(v::objectType())->assert(new ArrayObject()));
?>
--EXPECT--
`{ }` must be of type object
`[object] (stdClass: { })` must not be of type object
`[]` must be of type object
`stdClass {}` must not be of type object
- "test" must be of type object
- `[traversable] (ArrayObject: { })` must not be of type object
- `ArrayObject { getArrayCopy() => [] }` must not be of type object
2 changes: 1 addition & 1 deletion tests/integration/rules/readable.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ exceptionFullMessage(static fn() => v::not(v::readable())->assert('tests/fixture
--EXPECT--
"tests/fixtures/invalid-image.jpg" must be readable
"tests/fixtures/valid-image.png" must not be readable
- `[object] (stdClass: { })` must be readable
- `stdClass {}` must be readable
- "tests/fixtures/valid-image.png" must not be readable
2 changes: 1 addition & 1 deletion tests/integration/rules/regex.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ exceptionFullMessage(static fn() => v::not(v::regex('/^[a-z]+$/i'))->assert('wPo
--EXPECT--
"w poiur" must validate against "/^w+$/"
"wpoiur" must not validate against "/^[a-z]+$/"
- `[object] (stdClass: { })` must validate against "/^w+$/"
- `stdClass {}` must validate against "/^w+$/"
- "wPoiur" must not validate against "/^[a-z]+$/i"
6 changes: 3 additions & 3 deletions tests/integration/rules/resourceType.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ exceptionFullMessage(static fn() => v::not(v::resourceType())->assert(tmpfile())
?>
--EXPECT--
"test" must be a resource
`[resource] (stream)` must not be a resource
- `{ }` must be a resource
- `[resource] (stream)` must not be a resource
`resource <stream>` must not be a resource
- `[]` must be a resource
- `resource <stream>` must not be a resource
6 changes: 3 additions & 3 deletions tests/integration/rules/scalarVal.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exceptionFullMessage(static fn() => v::scalarVal()->assert(new stdClass()));
exceptionFullMessage(static fn() => v::not(v::scalarVal())->assert(42));
?>
--EXPECT--
`{ }` must be a scalar value
`TRUE` must not be a scalar value
- `[object] (stdClass: { })` must be a scalar value
`[]` must be a scalar value
`true` must not be a scalar value
- `stdClass {}` must be a scalar value
- 42 must not be a scalar value
Loading

0 comments on commit 4c33f08

Please sign in to comment.