The documentation states that we should use Validator::keySet() in
combination with Validator::key() but the return type of key() does not
match the expected parameter type of keyset().
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
PHP 8.0 is no longer supported. Some of our dependencies now do not work
on PHP 8.0 anymore.
This commit will also run tests on PHP 8.3.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
I want to get the build green. Currently, PHPStan is complaining about a
couple of issues that are not so critical. It's especially concerning
that strict_types must be the very first statement on PHPT files, but
that's fine since PHPUnit parses its content.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
For now, I'm ignoring many rules because they'll make the changes that
would bring backward compatibility breaks, and I'm aiming to release a
minor version next.
However, upgrading "respect/coding-standard" is necessary because
version 4.0 no longer works.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
It's essential to test our abstract classes because users might use
them. However, creating mocks when writing those tests make the code too
complicated.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
From PHPUnit 10, all data providers need to be static. This commit will
make migrating from version 9 to 10 a bit easier.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
We can use the AlwaysValid and AlwaysInvalid rules in the tests instead
of mocking them. Those changes will help us later because we mainly use
the `createValidatableMock()` in the data providers and, as from
PHPUnit 10, all data providers need to be static.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
With that, the tests will be more straightforward, and we won't need to
use the test class in the data providers. That will help us later
because, on PHPUnit 10, all data providers need to be static.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
With that, the tests will be more straightforward, and we won't need to
use the test class in the data providers. That will help us later
because, on PHPUnit 10, all data providers need to be static.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
When we write tests requiring those interfaces, we create mocks. Those
new stubs will make those tests easier to read and allow us to reduce
the number of mocks we write with PHPUnit, making the code in the tests
a bit less complex.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
We had a method that returned the full path of the fixture directory,
and we frequently would concatenate that path with a file we needed. I
changed it to include the file's path inside the fixture directory. That
way, we avoid repeating the same patter over and over.
I made the method static because we use it in data providers, which need
to be static.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
The integration tests use the same pattern to test exception messages.
With my changes, we won't validate which exception we throw in those
tests, but matching the message is enough. I created three functions to
replace most of those tests.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Most exception messages in Validation use "must" and "must not" in their
templates, but a few rules don't.
I fixed most of them, but AlwaysValid and AlwaysInvalid remain because I
wonder if they will be better if I update them.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
- For this particular updater, a list of exceptions to the rules
downloaded by geonames is included in POSTAL_CODES_EXTRA, for
cases in which we seem to do better than geonames itself based
on previous user reports.
- Added an option to also validate formatting of the postal codes.
- Combined multiple PR bots into a single one.
Previously, we were loading country info from a JSON file. This
changes it to use PHP files instead. It also caches these resources
across calls avoiding these files to be loaded more than once
per process.
Doing regex on phone numbers is not a great idea. This is a breaking
change, but a good one. Phone validation is now much stricter, and
allows choosing the country.
The use case for negating a keyset is very confusing, and can
lead to validators that don't do what they expect.
This commit introduces NonNegatable rules, which will throw
a Component exception if you try to wrap them in `Not`.
This change was necessary to ensure proper message reporting
when extra keys exist on the keyset.
This fixes#1349
We currently use a GitHub action to automate updating this file.
That action has the ability to ignore making the PR if the file
didn't changed.
Having the version number, which changed a line, was causing
several useless PR.
Users can still check if Tld.php changed by seeing the git log,
and a manual note should be issued by the maintainer on the
CHANGELOG.md file when a release containing such changes is
made.
The `filter_var` function is more of a sanitizer, but we as
a validation library do not care for that use case.
We should treat its sanitizings as a signal for checking if
the type after sanitization matches the option provided.
This fixes#1387