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>
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>
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>
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.
We could simply add version 3.0 instead of replacing it, but I would
like to stimulate people to keep their libraries up-to-date.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Inside the "data/" directory, we have files with lists of subdivisions
that need to be updated. We have to update them manually, or we automate
that task with a script and GitHub actions.
The two options are very time consuming and also not ideal. We don't
want to deal with that problem and, thinking that the user of this
library may want to show the data that we validate, we should create a
whole library to make it more usable.
The "sokil/php-isocodes" is a simple library that, even supports
translations. It's frequently updated and has gone to major performance
updates.
I am not fond of the idea of requiring an external library to install
Validation, as I have seen that gone wrong before [1]. Ideally, that
would be an optional dependency for people who would like to use those
rules, but to make that happen, we need to release a MAJOR version.
[1]: d072b4de6a
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
The PSR-7 has two interfaces that allow us to validate them as files.
This commit will allow some rules to validate those interfaces.
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
We already supported PHP 8.0 as our constrains in the "composer.json"
file was ">=7.3", but we were not testing it before.
Because of that, I found a bug on "EndsWith" which is fixed now.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Some amazing features had to be ignored because it conflicts with out
coring standards. I hope to soon fix them so we can use PHPStan to its
fullest potential.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Since there will still be secutiry support until 30 Nov 2020 and there
was something happening in Travis when generating coverage with newer
versions of PHP which I'm not in the mood to debug, I decided to change
the support again, this time to version 7.2.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
I don't know whether the next version will be a MINOR or a MAJOR
version, therefore it makes no sense to keep an alias for "dev-master".
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
I am about to release version 2.0, and it's been way too much time since
I created a MINOR or MAJOR version.
Because I don't know when will be the next time I will release the next
version and it is troublesome to keep support to old PHP versions, I
decided to only give support to the versions PHP is actively supporting.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
There are too many PHP_CodeSniffer configurations in this repository.
I have created "respect/coding-standard" to deal with all the
configuration so in this repository we only need to add "Respect" as our
PHP_CodeSniffer rule.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Package names in Composer should not contain uppercase characters, and
after the version 2.0, it will error.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
- Only create objects that are instantiable.
- Validate if validator is a valid Zend Validator after its creation.
- Parse messages from Zend Validator on "assert()" and "check()."
- Upgrade supported version of Zend Validator: version 2.0 has some PHP
deprecations therefore there is no used to support it.
Co-authored-by: Danilo Correa <danilosilva87@gmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
The tool we used to verify whether the code base has the correct coding
standard was removed [1].
This commit will set up one that works best for us and will also make
sure we have fully compliant to PS1 and PSR2.
[1]: ffec95acda
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
It is not the first time that after a PHP-CS-Fixer upgrade our build
fails. Also, I've seemed a couple of files that have a wrong coding
standard, but PHP-CS-Fixer does not indicate failure for them.
This commit will remove the library as a dependency.
I plan to introduce PHP_CodeSniffer as soon as possible.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit will create Composer scripts for commands that are
frequently used during the development of the library.
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
Require "phpstan/phpstan" for development and add to the Travis CI
configuration file to execute the analysis when Travis executes the
build with the version 7.2 of PHP.
The level of the configuration is very week for now (just "1") and still
quite some changes had to be made in order to make the analysis pass. I
hope it does not take much time to increase the level of the strictness
of the analyses.
I tried to configure that before but because of dependencies with
"symfony/validator" it was not possible.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Instead of creating the Symfony constraints itself "Sf" accepts an
instance of "Symfony\Component\Validator\Constraint".
Creating objects inside a rule, specially from an external library,
makes the rule too complex and also limits the possibilities with the
"Sf" rule since Symfony allows users to create complex validations (even
thought their API is not as simple as ours).
This commit also simplifies the way the messages are passed from Symfony
to the "Sf" when only one constraint has failed; instead of passing
the message of the whole constraint violation list, only the fist
constraint violation message it passed.
The problem that this rule will always have is that when using "Not" to
invert the validation we have a way to get a proper message since
Symfony Validator only return the result of constraints that failed.
That's something the Respect\Validation does in a similar way and to
change it a lot has to be changed.
These changes were checked in "symfony/validator" 4.0 and the version
was added to the "composer.json" file.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
- Add documentation to the class and its methods;
- Move RuleTestCase to Test namespace;
- Use PHP 7 type hinting;
- Rename getRuleMock() to createValidatableMock().
Due to this change it was possible to identify that NotEmptyException,
and NotOptionalException where not working as they should. A fix was
made along with this commit.