Apply "SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking"

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2019-02-09 12:51:31 +01:00
parent 44f4d65a3d
commit e89b32270b
No known key found for this signature in database
GPG key ID: 221E9281655813A6
2 changed files with 10 additions and 2 deletions

View file

@ -13,7 +13,9 @@ declare(strict_types=1);
namespace Respect\Validation\Rules;
use function call_user_func;
use function array_merge;
use function call_user_func_array;
use function count;
/**
* Validates the input using the return of a given callable.
@ -50,6 +52,11 @@ final class Callback extends AbstractRule
*/
public function validate($input): bool
{
return (bool) call_user_func($this->callback, $input, ...$this->arguments);
$arguments = [$input];
if (count($this->arguments) > 0) {
$arguments = array_merge($arguments, $this->arguments);
}
return (bool) call_user_func_array($this->callback, $arguments);
}
}

View file

@ -66,6 +66,7 @@
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash" />
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace" />
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias" />
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking" />
<rule ref="SlevomatCodingStandard.PHP.TypeCast" />
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses" />
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon" />