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>
The data in this commit has been gathered, scrapped, organized and
treated based on the Emoji Unicode V11 specification [1].
[1]: https://unicode.org/Public/emoji/11.0/emoji-test.txt
Co-authored-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>
The "--EXPECTF--" is supposed to be used when the output of "--FILE--"
is random. In many cases, we are using "--EXPECTF--" section while we
could use "--EXPECT--" instead.
This commit will replace the usages of "--EXPECTF--" by "--EXPECT--"
when the output does "--FILE--" is not random.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Because some classes extend the "Regex" class this commit will also
change the implementation of those classes to use "Regex" by composition
instead of extending the class.
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
While making sure that Validation uses PHP strict types [1] the compared
value in the "Contains" rule was cast to string. That is problematic
when someone wants to enforce the operation to compare if the input has
a value identical to the expected value.
This commit will fix that by not casting the expected value but also
make sure that string comparison will not be used when it's not a
string.
[1]: ef975629f3
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit will do many different things, but they are all improvements
to the "Ip" rules:
* Remove passing variables by reference: the "Ip" class uses that a lot
to define the start address, end address, and the mask used to
validate a network range;
* Remove double-typed argument from the constructor: the class "Ip"
class has only one argument that can be either a string with the range
of the IP or an integer with options for the "filter_var()" function.
This commit will split it into two different arguments, each of them
used for one of this functionalities;
* Update documentation to show how to validate IPv6.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Because traits are behaviors that are added to a class, it makes sense
to name them with the behavior that they add the classes that use them.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
The documentation about custom rules does not specify that creating an
exception for the rule is necessary. This commit will add that to the
documentation with an example to make it explicit.
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
Due to the current status of the development of the library, it seems
like we will be supporting version 1.1 for a long time. Even when we
release version 2.0 we will still give support for version 1.1 for a
while.
This commit will make sure that version 1.1 is fully supported for PHP
7.2 and 7.3. Also, it will remove the support for HHVM since it will not
keep the compatibility with PHP anymore [1].
In order to make that happen, this commit will create a TestCase from
Validation so we can use the same API to create mocks in both PHPUnit
versions 4.0 and 5.0.
During the development of this commit, I noticed that PHPUnit 4.0 had
issues to mock "SplFileInfo" and for that reason, this commit will also
replace those mocks by "SplFileInfo" instances.
[1]: https://hhvm.com/blog/2018/09/12/end-of-php-support-future-of-hack.html
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
All the PHP files have the "@author" annotation to make clear which
people have contributed to that specific file, however, there is no such
thing in the PHPT files.
This commit will add the "CREDITS" section to the PHPT files. The list
of authors is created from the output of the `git blame` command.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit will make sure that every class, interface, or trait will
have the "@author" annotation in it.
In order to create a list of authors, I used the "git blame" command,
which means that if someone changed or even created the file but does
not have any remaining line will not be shown in the list; it's a
trade-off worth but it is worth it. The other way to do it would be
carefully checking each file.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Some classes and one trait had some mismatch values for their "@author"
annotation and this commit will fix the mismatch putting the correct
authors.
I used the "git blame" command to find out which people changed the file
and created a list based on that information.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
The argument "parameters" which is meant to give the wrapped rule's
exception some extra information does not always need to be defined, for
example when the exception does not need any parameter.
The current version of "AbstractEnvelope" required that argument and the
rules that are extending this class are passing an empty array.
This commit will make the "parameters" argument optional. As an extra,
it will make sure the tests from the children of "AbstractEnvelope" are
also covering their parent.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Removes the errant space in the CA PostalCode regex.
This space was introduced by 5a067fa.
It also adds unit tests for the CA PostalCode to validate
the fix.
Reviewed-by: Emmerson Siqueira <emmersonsiqueira@gmail.com>
Because "friendsofphp/php-cs-fixer" does not support PHP 7.3 this commit
will also add "--ignore-platform-reqs" argument to Composer when it is
being executed.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Since the library doesn't need to give support to version 5.4 or less of
PHP using variadics in the constructor of "AbstractFilterRule" seems
better than doing the whole validation.
This commit will also apply the contribution guidelines to
"AbstractFilterRule" and use a better naming for it.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit will allow validation of UUIDs with versions 1, 3, 4 and 5.
Version 2 was not implemented since its adoption is not that broad and
we couldn't find many details about it.
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
Currently the license identifier (BSD Style) does not comform to the
SPDX list of valid identifiers https://spdx.org/licenses/. Having a
valid identifier helps automated license checking tools verify your
package.
I took the liberty of setting the license to BSD-3-Clause. If you want
to allow multiple licenses, you could use a SPDX expression e.g.
(BSD-2-Clause OR BSD-3-Clause).
As it seems, the TLDs "goodhands", "jlc", "panerai", "statoil",
"telecity", and "vista" were removed from the list.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
There shouldn't be possible to consider a non-string value as a valid
email anyways, but the real problem is that the "RFCValidation" from
"egulias/email-validator" casts the input as a string which makes PHP
trigger an error.
Co-authored-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>
The "Yes" rule extends "Regex" rule. The only reasons why that is useful
is because "Yes" uses regular expressions to validate the inputs.
However, the "Yes" rule is way more complex simply validating a regular
expressing and having "Regex" as its parent is also a little bit
misleading.
This commit will:
* Remove unnecessary inheritance from "Yes" rule;
* Improve the documentation of the "Yes" rule;
* Enhance the unit tests of the "Yes" rule.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
The "AbstractRegexRule" seems like an unnecessary overhead on top of the
"AbstractFilterRule". In fact, the "Phone" and "Uuid" rule should not
even be children of "AbstractFilterRule".
This commit will remove the "AbstractRegexRule" and replace it with
"AbstractFilterRule" on the rules that are depending on it. As for the
rules that don't depend on it it will replace by "AbstractRule" like
most of the other rules.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>