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>
This commit will add a couple of rules that we already use but also
introduce new ones and make sure all the code is in accordance with the
new coding standards.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
The "NestedValidationException" has exceptions that are its children.
However, we call them "related". This commit updates the term over the
library.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
In the iterator in the "NestedValidationException" the only information
that is necessary is the depth of the message, for that reason all the
other information can (and should) be removed.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
These two branches are very different, therefore merging is becoming
very hard.
I decided to not put these changes together with 5750952 because it
seems easy to track these changes with a specific commit.
While working on this merge I realized that would make more sense to
create "AbstractComparison" to handle the rules that compare values.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
When a template is set for a chain of rules, does not really matter
which messages the chain can have, the only message to be used should be
the one based on the defined template.
This commit set the same template of a parent rule to its children's
exception. Our first thought was to set the template to its children
however that would mean that if another rule would be added to the chain
we would have to set it as well. Doing that to the children's exception
make sure we only do that once.
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
Use the same condition to not include child exception into the iterator
to also not show the message of the main exception when using
"getFullMessage()".
The method created to validate that condition should probably be in the
"ValidationException" itself, but this commit is meant to be a bug fix,
which will be released in a PATH version, and creating this public
method would imply that a MINOR version should be released.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This method change the behavior of "getMessages()" by changin the keys
of its return to the "id" of the specific exception that was triggered.
It also allows users to overwrite the templates by passing an array to
it.
This is being requested by many users for a long time. It took that long
because I was thinking too much about how to improve the old method
called "findMesssage()" that I didn't realize that it could be done in a
easier way with the "getMessages()".
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
`NestedValidationException` should include all `AbstractRelated` rule
exceptions.
`AbstractRelated` rule failures always indicate an interesting nested
context, which should not be omitted from the final result.
`NonOmissibleExceptionInterface` is a marker interface for
exceptions thrown by instances of `AbstractRelated`, which
facilitates identification of those rules' exceptions with
`instanceof`.
If calling the method `getExceptionForPath()` when the exception was
nested but had no child it was returning null. This commit ensures that
it always return a valid exception.
Then using the `findMessages()` method, tries to use the method
`getRelatedByName()` before using the `findRelated()` method.
This change was made because since on `KeyNested` rule you may have
names with '.' we'll never get the proper exception using
`findRelated()`.