Currently, we convert the properties of a rule into parameters and pass
them to the exceptions. That complicates things for a few reasons:
1. The exception knows too much: there's a lot of information in an
object, and the exception would only need a few parameters to work
correctly.
2. Any variable change becomes a backward compatibility break: if we
change the name of the variable type in a rule, even if it's a
private one, we may need to change the template, which is a backward
compatibility break.
3. The factory is bloated because of introspection tricks: it reads the
properties from the class, even from the parent, and then passes it
to the exception.
Of course, that means we introduce another method to `Validatable`, but
in most cases, extending `AbstractRule` is enough to create a new rule.
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>
This commit will fix an issue but ignore two of them because it will
require some refactoring that won't be possible in a PATCH version.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
One of the reasons for this change is to spare some space on the
Validator class, leaving only real code there. However, the biggest
reason is that IDEs can auto-complete rules after Validator creates the
first rule.
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>
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>