Update version of PHPStan packages

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 is contained in:
Henrique Moody 2020-07-22 14:02:39 +02:00
parent fc14c6c669
commit 642602fd43
No known key found for this signature in database
GPG key ID: 221E9281655813A6
41 changed files with 109 additions and 65 deletions

View file

@ -23,9 +23,9 @@
"egulias/email-validator": "^2.1", "egulias/email-validator": "^2.1",
"malukenho/docheader": "^0.1", "malukenho/docheader": "^0.1",
"mikey179/vfsstream": "^1.6", "mikey179/vfsstream": "^1.6",
"phpstan/phpstan": "^0.11", "phpstan/phpstan": "^0.12",
"phpstan/phpstan-deprecation-rules": "^0.11.0", "phpstan/phpstan-deprecation-rules": "^0.12",
"phpstan/phpstan-phpunit": "^0.11.0", "phpstan/phpstan-phpunit": "^0.12",
"phpunit/phpunit": "^7.5", "phpunit/phpunit": "^7.5",
"respect/coding-standard": "^2.1", "respect/coding-standard": "^2.1",
"squizlabs/php_codesniffer": "^3.5", "squizlabs/php_codesniffer": "^3.5",

View file

@ -22,6 +22,7 @@ use function count;
use function current; use function current;
use function implode; use function implode;
use function is_array; use function is_array;
use function is_string;
use function spl_object_hash; use function spl_object_hash;
use function sprintf; use function sprintf;
use function str_repeat; use function str_repeat;
@ -39,6 +40,8 @@ use const PHP_EOL;
* @author Henrique Moody <henriquemoody@gmail.com> * @author Henrique Moody <henriquemoody@gmail.com>
* @author Jonathan Stewmon <jstewmon@rmn.com> * @author Jonathan Stewmon <jstewmon@rmn.com>
* @author Wojciech Frącz <fraczwojciech@gmail.com> * @author Wojciech Frącz <fraczwojciech@gmail.com>
*
* @implements IteratorAggregate<ValidationException>
*/ */
class NestedValidationException extends ValidationException implements IteratorAggregate class NestedValidationException extends ValidationException implements IteratorAggregate
{ {
@ -215,11 +218,11 @@ class NestedValidationException extends ValidationException implements IteratorA
} }
/** /**
* @param string[] $templates * @param string[]|string[][] $templates
*/ */
private function renderMessage(ValidationException $exception, array $templates): string private function renderMessage(ValidationException $exception, array $templates): string
{ {
if (isset($templates[$exception->getId()])) { if (isset($templates[$exception->getId()]) && is_string($templates[$exception->getId()])) {
$exception->updateTemplate($templates[$exception->getId()]); $exception->updateTemplate($templates[$exception->getId()]);
} }
@ -227,10 +230,10 @@ class NestedValidationException extends ValidationException implements IteratorA
} }
/** /**
* @param string[] $templates * @param string[]|string[][] $templates
* @param mixed ...$ids * @param mixed ...$ids
* *
* @return string[] * @return string[]|string[][]
*/ */
private function findTemplates(array $templates, ...$ids): array private function findTemplates(array $templates, ...$ids): array
{ {

View file

@ -24,7 +24,7 @@ use UnexpectedValueException;
final class RecursiveExceptionIterator implements RecursiveIterator, Countable final class RecursiveExceptionIterator implements RecursiveIterator, Countable
{ {
/** /**
* @var ArrayIterator|ValidationException[] * @var ArrayIterator<int, ValidationException>
*/ */
private $exceptions; private $exceptions;
@ -67,7 +67,7 @@ final class RecursiveExceptionIterator implements RecursiveIterator, Countable
public function key(): int public function key(): int
{ {
return $this->exceptions->key(); return (int) $this->exceptions->key();
} }
public function next(): void public function next(): void

View file

@ -131,9 +131,11 @@ final class Factory
{ {
foreach ($this->rulesNamespaces as $namespace) { foreach ($this->rulesNamespaces as $namespace) {
try { try {
/** @var class-string<Validatable> $name */
$name = $namespace . '\\' . ucfirst($ruleName);
/** @var Validatable $rule */ /** @var Validatable $rule */
$rule = $this $rule = $this
->createReflectionClass($namespace . '\\' . ucfirst($ruleName), Validatable::class) ->createReflectionClass($name, Validatable::class)
->newInstanceArgs($arguments); ->newInstanceArgs($arguments);
return $rule; return $rule;
@ -160,13 +162,16 @@ final class Factory
$ruleName = $reflection->getShortName(); $ruleName = $reflection->getShortName();
$params = ['input' => $input] + $extraParams + $this->extractPropertiesValues($validatable, $reflection); $params = ['input' => $input] + $extraParams + $this->extractPropertiesValues($validatable, $reflection);
$id = lcfirst($ruleName); $id = lcfirst($ruleName);
if ($validatable->getName()) { if ($validatable->getName() !== null) {
$id = $params['name'] = $validatable->getName(); $id = $params['name'] = $validatable->getName();
} }
foreach ($this->exceptionsNamespaces as $namespace) { foreach ($this->exceptionsNamespaces as $namespace) {
try { try {
/** @var class-string<ValidationException> $exceptionName */
$exceptionName = $namespace . '\\' . $ruleName . 'Exception';
return $this->createValidationException( return $this->createValidationException(
$namespace . '\\' . $ruleName . 'Exception', $exceptionName,
$id, $id,
$input, $input,
$params, $params,
@ -183,6 +188,9 @@ final class Factory
/** /**
* Creates a reflection based on class name. * Creates a reflection based on class name.
* *
* @param class-string $name
* @param class-string $parentName
*
* @throws InvalidClassException * @throws InvalidClassException
* @throws ReflectionException * @throws ReflectionException
*/ */
@ -203,6 +211,8 @@ final class Factory
/** /**
* Creates a Validation exception. * Creates a Validation exception.
* *
* @param class-string<ValidationException> $exceptionName
*
* @param mixed $input * @param mixed $input
* @param mixed[] $params * @param mixed[] $params
* *

View file

@ -34,7 +34,7 @@ final class Subdivisions
throw new ComponentException(sprintf('"%s" is not a supported country code', $countryCode)); throw new ComponentException(sprintf('"%s" is not a supported country code', $countryCode));
} }
$this->data = (array) json_decode(file_get_contents($filename), true); $this->data = (array) json_decode((string) file_get_contents($filename), true);
} }
public function getCountry(): string public function getCountry(): string

View file

@ -67,7 +67,7 @@ abstract class AbstractComposite extends AbstractRule
*/ */
public function addRule(Validatable $rule): self public function addRule(Validatable $rule): self
{ {
if ($this->shouldHaveNameOverwritten($rule)) { if ($this->shouldHaveNameOverwritten($rule) && $this->getName() !== null) {
$rule->setName($this->getName()); $rule->setName($this->getName());
} }

View file

@ -63,7 +63,7 @@ abstract class AbstractRelated extends AbstractRule
$this->rule = $rule; $this->rule = $rule;
$this->mandatory = $mandatory; $this->mandatory = $mandatory;
if ($rule && $rule->getName()) { if ($rule && $rule->getName() !== null) {
$this->setName($rule->getName()); $this->setName($rule->getName());
} elseif (is_scalar($reference)) { } elseif (is_scalar($reference)) {
$this->setName((string) $reference); $this->setName((string) $reference);

View file

@ -52,11 +52,20 @@ final class Callback extends AbstractRule
*/ */
public function validate($input): bool public function validate($input): bool
{ {
$arguments = [$input]; return (bool) call_user_func_array($this->callback, $this->getArguments($input));
if (count($this->arguments) > 0) {
$arguments = array_merge($arguments, $this->arguments);
} }
return (bool) call_user_func_array($this->callback, $arguments); /**
* @param mixed $input
* @return mixed[]
*/
private function getArguments($input): array
{
$arguments = [$input];
if (count($this->arguments) === 0) {
return $arguments;
}
return array_merge($arguments, $this->arguments);
} }
} }

View file

@ -37,7 +37,7 @@ final class Cnh extends AbstractRule
} }
// Canonicalize input // Canonicalize input
$input = preg_replace('{\D}', '', (string) $input); $input = (string) preg_replace('{\D}', '', (string) $input);
// Validate length and invalid numbers // Validate length and invalid numbers
if (mb_strlen($input) != 11 || ((int) $input === 0)) { if (mb_strlen($input) != 11 || ((int) $input === 0)) {

View file

@ -80,7 +80,7 @@ final class Cnpj extends AbstractRule
return array_map( return array_map(
'intval', 'intval',
str_split( str_split(
preg_replace('/\D/', '', $input) (string) preg_replace('/\D/', '', $input)
) )
); );
} }

View file

@ -74,7 +74,7 @@ final class Contains extends AbstractRule
return false; return false;
} }
$encoding = mb_detect_encoding($haystack); $encoding = (string) mb_detect_encoding($haystack);
if ($this->identical) { if ($this->identical) {
return mb_strpos($haystack, $needle, 0, $encoding) !== false; return mb_strpos($haystack, $needle, 0, $encoding) !== false;
} }

View file

@ -92,7 +92,7 @@ final class CreditCard extends AbstractRule
return false; return false;
} }
$input = preg_replace('/[ .-]/', '', (string) $input); $input = (string) preg_replace('/[ .-]/', '', (string) $input);
if (!(new Luhn())->validate($input)) { if (!(new Luhn())->validate($input)) {
return false; return false;
} }

View file

@ -70,7 +70,7 @@ final class EndsWith extends AbstractRule
return end($input) == $this->endValue; return end($input) == $this->endValue;
} }
$encoding = mb_detect_encoding($input); $encoding = (string) mb_detect_encoding($input);
$endPosition = mb_strlen($input, $encoding) - mb_strlen($this->endValue, $encoding); $endPosition = mb_strlen($input, $encoding) - mb_strlen($this->endValue, $encoding);
return mb_strripos($input, $this->endValue, -1, $encoding) === $endPosition; return mb_strripos($input, $this->endValue, -1, $encoding) === $endPosition;
@ -85,7 +85,7 @@ final class EndsWith extends AbstractRule
return end($input) === $this->endValue; return end($input) === $this->endValue;
} }
$encoding = mb_detect_encoding($input); $encoding = (string) mb_detect_encoding($input);
$endPosition = mb_strlen($input, $encoding) - mb_strlen($this->endValue, $encoding); $endPosition = mb_strlen($input, $encoding) - mb_strlen($this->endValue, $encoding);
return mb_strrpos($input, $this->endValue, 0, $encoding) === $endPosition; return mb_strrpos($input, $this->endValue, 0, $encoding) === $endPosition;

View file

@ -55,7 +55,7 @@ final class Factor extends AbstractRule
return false; return false;
} }
$input = (int) abs($input); $input = (int) abs((int) $input);
$dividend = (int) abs($this->dividend); $dividend = (int) abs($this->dividend);
// The dividend divided by the input must be an integer if input is a // The dividend divided by the input must be an integer if input is a

View file

@ -141,7 +141,7 @@ final class Iban extends AbstractRule
private function convertToInteger(string $reArrangedIban): string private function convertToInteger(string $reArrangedIban): string
{ {
return preg_replace_callback( return (string) preg_replace_callback(
'/[A-Z]/', '/[A-Z]/',
static function (array $match): int { static function (array $match): int {
return ord($match[0]) - 55; return ord($match[0]) - 55;

View file

@ -61,6 +61,6 @@ final class Image extends AbstractRule
return false; return false;
} }
return mb_strpos($this->fileInfo->file($input), 'image/') === 0; return mb_strpos((string) $this->fileInfo->file($input), 'image/') === 0;
} }
} }

View file

@ -40,7 +40,7 @@ final class Imei extends AbstractRule
return false; return false;
} }
$numbers = preg_replace('/\D/', '', $input); $numbers = (string) preg_replace('/\D/', '', (string) $input);
if (mb_strlen($numbers) != self::IMEI_SIZE) { if (mb_strlen($numbers) != self::IMEI_SIZE) {
return false; return false;
} }

View file

@ -29,7 +29,7 @@ use function mb_strpos;
final class In extends AbstractRule final class In extends AbstractRule
{ {
/** /**
* @var mixed[]|string * @var mixed[]|mixed
*/ */
private $haystack; private $haystack;
@ -41,7 +41,7 @@ final class In extends AbstractRule
/** /**
* Initializes the rule with the haystack and optionally compareIdentical flag. * Initializes the rule with the haystack and optionally compareIdentical flag.
* *
* @param mixed[]|string $haystack * @param mixed[]|mixed $haystack
*/ */
public function __construct($haystack, bool $compareIdentical = false) public function __construct($haystack, bool $compareIdentical = false)
{ {
@ -76,7 +76,7 @@ final class In extends AbstractRule
$inputString = (string) $input; $inputString = (string) $input;
return mb_stripos($this->haystack, $inputString, 0, mb_detect_encoding($inputString)) !== false; return mb_stripos($this->haystack, $inputString, 0, (string) mb_detect_encoding($inputString)) !== false;
} }
/** /**
@ -94,6 +94,6 @@ final class In extends AbstractRule
$inputString = (string) $input; $inputString = (string) $input;
return mb_strpos($this->haystack, $inputString, 0, mb_detect_encoding($inputString)) !== false; return mb_strpos($this->haystack, $inputString, 0, (string) mb_detect_encoding($inputString)) !== false;
} }
} }

View file

@ -125,11 +125,11 @@ final class Ip extends AbstractRule
if (mb_strpos($input, '-') !== false) { if (mb_strpos($input, '-') !== false) {
[$this->startAddress, $this->endAddress] = explode('-', $input); [$this->startAddress, $this->endAddress] = explode('-', $input);
if (!$this->verifyAddress($this->startAddress)) { if ($this->startAddress !== null && !$this->verifyAddress($this->startAddress)) {
throw new ComponentException('Invalid network range'); throw new ComponentException('Invalid network range');
} }
if (!$this->verifyAddress($this->endAddress)) { if ($this->endAddress !== null && !$this->verifyAddress($this->endAddress)) {
throw new ComponentException('Invalid network range'); throw new ComponentException('Invalid network range');
} }
@ -193,13 +193,15 @@ final class Ip extends AbstractRule
{ {
$input = sprintf('%u', ip2long($input)); $input = sprintf('%u', ip2long($input));
return bccomp($input, sprintf('%u', ip2long($this->startAddress))) >= 0 return $this->startAddress !== null
&& $this->endAddress !== null
&& bccomp($input, sprintf('%u', ip2long($this->startAddress))) >= 0
&& bccomp($input, sprintf('%u', ip2long($this->endAddress))) <= 0; && bccomp($input, sprintf('%u', ip2long($this->endAddress))) <= 0;
} }
private function belongsToSubnet(string $input): bool private function belongsToSubnet(string $input): bool
{ {
if ($this->mask === null) { if ($this->mask === null || $this->startAddress === null) {
return false; return false;
} }

View file

@ -44,6 +44,6 @@ final class Isbn extends AbstractRule
return false; return false;
} }
return preg_match(sprintf('/%s/', implode(self::PIECES)), $input) > 0; return preg_match(sprintf('/%s/', implode(self::PIECES)), (string) $input) > 0;
} }
} }

View file

@ -121,7 +121,7 @@ final class KeyValue extends AbstractRule
try { try {
$rule = Factory::getDefaultInstance()->rule($this->ruleName, [$input[$this->baseKey]]); $rule = Factory::getDefaultInstance()->rule($this->ruleName, [$input[$this->baseKey]]);
$rule->setName($this->comparedKey); $rule->setName((string) $this->comparedKey);
} catch (ComponentException $exception) { } catch (ComponentException $exception) {
throw parent::reportError($input, ['component' => true]); throw parent::reportError($input, ['component' => true]);
} }

View file

@ -89,7 +89,7 @@ final class Length extends AbstractRule
private function extractLength($input): ?int private function extractLength($input): ?int
{ {
if (is_string($input)) { if (is_string($input)) {
return (int) mb_strlen($input, mb_detect_encoding($input)); return (int) mb_strlen($input, (string) mb_detect_encoding($input));
} }
if (is_array($input) || $input instanceof CountableInterface) { if (is_array($input) || $input instanceof CountableInterface) {

View file

@ -36,6 +36,6 @@ final class Lowercase extends AbstractRule
return false; return false;
} }
return $input === mb_strtolower($input, mb_detect_encoding($input)); return $input === mb_strtolower($input, (string) mb_detect_encoding($input));
} }
} }

View file

@ -42,7 +42,7 @@ final class Nip extends AbstractRule
} }
$weights = [6, 5, 7, 2, 3, 4, 5, 6, 7]; $weights = [6, 5, 7, 2, 3, 4, 5, 6, 7];
$digits = array_map('intval', str_split($input)); $digits = array_map('intval', str_split((string) $input));
$targetControlNumber = $digits[9]; $targetControlNumber = $digits[9];
$calculateControlNumber = 0; $calculateControlNumber = 0;

View file

@ -45,7 +45,7 @@ final class Pesel extends AbstractRule
$calculateControlNumber = 0; $calculateControlNumber = 0;
for ($i = 0; $i < 10; ++$i) { for ($i = 0; $i < 10; ++$i) {
$calculateControlNumber += $stringInput[$i] * $weights[$i]; $calculateControlNumber += (int) $stringInput[$i] * $weights[$i];
} }
$calculateControlNumber = (10 - $calculateControlNumber % 10) % 10; $calculateControlNumber = (10 - $calculateControlNumber % 10) % 10;

View file

@ -36,7 +36,7 @@ final class Pis extends AbstractRule
return false; return false;
} }
$digits = preg_replace('/\D/', '', $input); $digits = (string) preg_replace('/\D/', '', (string) $input);
if (mb_strlen($digits) != 11 || preg_match('/^' . $digits[0] . '{11}$/', $digits)) { if (mb_strlen($digits) != 11 || preg_match('/^' . $digits[0] . '{11}$/', $digits)) {
return false; return false;
} }

View file

@ -31,7 +31,7 @@ use function sprintf;
final class Size extends AbstractRule final class Size extends AbstractRule
{ {
/** /**
* @var string|null * @var string|int|null
*/ */
private $minSize; private $minSize;
@ -41,7 +41,7 @@ final class Size extends AbstractRule
private $minValue; private $minValue;
/** /**
* @var string|null * @var string|int|null
*/ */
private $maxSize; private $maxSize;

View file

@ -68,7 +68,7 @@ final class StartsWith extends AbstractRule
return reset($input) == $this->startValue; return reset($input) == $this->startValue;
} }
return mb_stripos($input, $this->startValue, 0, mb_detect_encoding($input)) === 0; return mb_stripos($input, $this->startValue, 0, (string) mb_detect_encoding($input)) === 0;
} }
/** /**
@ -80,6 +80,6 @@ final class StartsWith extends AbstractRule
return reset($input) === $this->startValue; return reset($input) === $this->startValue;
} }
return mb_strpos($input, $this->startValue, 0, mb_detect_encoding($input)) === 0; return mb_strpos($input, $this->startValue, 0, (string) mb_detect_encoding($input)) === 0;
} }
} }

View file

@ -36,6 +36,6 @@ final class Uppercase extends AbstractRule
return false; return false;
} }
return $input === mb_strtoupper($input, mb_detect_encoding($input)); return $input === mb_strtoupper($input, (string) mb_detect_encoding($input));
} }
} }

View file

@ -32,7 +32,7 @@ use function sprintf;
final class VideoUrl extends AbstractRule final class VideoUrl extends AbstractRule
{ {
/** /**
* @var string * @var string|null
*/ */
private $service; private $service;

View file

@ -21,6 +21,7 @@ use Throwable;
use Zend\Validator\ValidatorInterface; use Zend\Validator\ValidatorInterface;
use function array_map; use function array_map;
use function class_exists;
use function current; use function current;
use function is_string; use function is_string;
use function sprintf; use function sprintf;
@ -125,6 +126,10 @@ final class Zend extends AbstractRule
$className = stripos($validator, 'Zend') === false ? 'Zend\\Validator\\' . $validator : '\\' . $validator; $className = stripos($validator, 'Zend') === false ? 'Zend\\Validator\\' . $validator : '\\' . $validator;
try { try {
if (!class_exists($className)) {
throw new ComponentException(sprintf('"%s" is not a valid class name', $className));
}
$reflection = new ReflectionClass($className); $reflection = new ReflectionClass($className);
if (!$reflection->isInstantiable()) { if (!$reflection->isInstantiable()) {
throw new ComponentException(sprintf('"%s" is not instantiable', $className)); throw new ComponentException(sprintf('"%s" is not instantiable', $className));

View file

@ -7,9 +7,20 @@ parameters:
fileExtensions: fileExtensions:
- php - php
- phpt - phpt
checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
ignoreErrors: ignoreErrors:
- '/Call to an undefined static method Respect\\Validation\\Validator::iDoNotExistSoIShouldThrowException/' -
- '/Parameter #2 $locale of function setlocale expects array|string|null, int given./' message: '/Instanceof between mixed and SimpleXMLElement will always evaluate to false\./'
path: library/Rules/ArrayVal.php
-
message: '/Parameter #1 \$error_handler of function set_error_handler expects \(callable\(int, string, string, int, array\): bool\)\|null, Closure\(\): void given\./'
paths:
- library/Rules/Call.php
- tests/unit/Rules/CallTest.php
-
message: '/Call to an undefined static method Respect\\Validation\\Validator::iDoNotExistSoIShouldThrowException/'
path: tests/unit/ValidatorTest.php
level: 7 level: 7
paths: paths:
- library/ - library/

View file

@ -26,7 +26,7 @@ try {
'schema' => 'schema', 'schema' => 'schema',
], ],
]; ];
$object = json_decode(json_encode($array)); $object = json_decode((string) json_encode($array));
v::create() v::create()
->attribute( ->attribute(
'mysql', 'mysql',

View file

@ -64,7 +64,7 @@ abstract class RuleTestCase extends TestCase
*/ */
public function getFixtureDirectory(): string public function getFixtureDirectory(): string
{ {
return realpath(__DIR__ . '/../fixtures'); return (string) realpath(__DIR__ . '/../fixtures');
} }
/** /**

View file

@ -27,8 +27,10 @@ final class ZendValidator implements ValidatorInterface
/** /**
* {@inheritDoc} * {@inheritDoc}
*
* @return string[]
*/ */
public function getMessages() public function getMessages(): array
{ {
return []; return [];
} }

View file

@ -50,6 +50,10 @@ final class CheckExceptionsTest extends TestCase
} }
$className = 'Respect\\Validation\\Rules\\' . $ruleName; $className = 'Respect\\Validation\\Rules\\' . $ruleName;
if (!class_exists($className)) {
continue;
}
$reflectionClass = new ReflectionClass($className); $reflectionClass = new ReflectionClass($className);
if ($reflectionClass->isAbstract() || $reflectionClass->isInterface()) { if ($reflectionClass->isAbstract() || $reflectionClass->isInterface()) {
continue; continue;

View file

@ -28,7 +28,7 @@ use Respect\Validation\Test\TestCase;
final class AlwaysInvalidTest extends TestCase final class AlwaysInvalidTest extends TestCase
{ {
/** /**
* {@inheritDoc} * @return mixed[][]
*/ */
public function providerForInvalidInput(): array public function providerForInvalidInput(): array
{ {

View file

@ -28,7 +28,7 @@ use Respect\Validation\Test\TestCase;
final class AlwaysValidTest extends TestCase final class AlwaysValidTest extends TestCase
{ {
/** /**
* {@inheritDoc} * @return mixed[][]
*/ */
public function providerForValidInput(): array public function providerForValidInput(): array
{ {

View file

@ -40,7 +40,7 @@ final class NoTest extends RuleTestCase
*/ */
protected function setUp(): void protected function setUp(): void
{ {
$this->locale = setlocale(LC_ALL, 0); $this->locale = (string) setlocale(LC_ALL, '0');
} }
/** /**
@ -117,7 +117,7 @@ final class NoTest extends RuleTestCase
{ {
setlocale(LC_ALL, $locale); setlocale(LC_ALL, $locale);
if ($locale !== setlocale(LC_ALL, 0)) { if ($locale !== setlocale(LC_ALL, '0')) {
$this->markTestSkipped(sprintf('Could not set locale information to "%s"', $locale)); $this->markTestSkipped(sprintf('Could not set locale information to "%s"', $locale));
} }
@ -133,7 +133,7 @@ final class NoTest extends RuleTestCase
{ {
setlocale(LC_ALL, $locale); setlocale(LC_ALL, $locale);
if ($locale !== setlocale(LC_ALL, 0)) { if ($locale !== setlocale(LC_ALL, '0')) {
$this->markTestSkipped(sprintf('Could not set locale information to "%s"', $locale)); $this->markTestSkipped(sprintf('Could not set locale information to "%s"', $locale));
} }

View file

@ -44,7 +44,7 @@ final class YesTest extends RuleTestCase
*/ */
protected function setUp(): void protected function setUp(): void
{ {
$this->locale = setlocale(LC_ALL, 0); $this->locale = (string) setlocale(LC_ALL, '0');
} }
/** /**
@ -124,7 +124,7 @@ final class YesTest extends RuleTestCase
{ {
setlocale(LC_ALL, $locale); setlocale(LC_ALL, $locale);
if ($locale !== setlocale(LC_ALL, 0)) { if ($locale !== setlocale(LC_ALL, '0')) {
$this->markTestSkipped(sprintf('Could not set locale information to "%s"', $locale)); $this->markTestSkipped(sprintf('Could not set locale information to "%s"', $locale));
} }
@ -140,7 +140,7 @@ final class YesTest extends RuleTestCase
{ {
setlocale(LC_ALL, $locale); setlocale(LC_ALL, $locale);
if ($locale !== setlocale(LC_ALL, 0)) { if ($locale !== setlocale(LC_ALL, '0')) {
$this->markTestSkipped(sprintf('Could not set locale information to "%s"', $locale)); $this->markTestSkipped(sprintf('Could not set locale information to "%s"', $locale));
} }

View file

@ -92,8 +92,6 @@ final class ZendTest extends RuleTestCase
* @test * @test
* *
* @dataProvider providerForUnbuildableValidator * @dataProvider providerForUnbuildableValidator
*
* @param mixed $validator
*/ */
public function itShouldThrowAnExceptionWhenValidatorCannotBeCreated(string $validator): void public function itShouldThrowAnExceptionWhenValidatorCannotBeCreated(string $validator): void
{ {