for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Yiisoft\Validator\Tests\Helper;
use Closure;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Yiisoft\Validator\EmptyCondition\NeverEmpty;
use Yiisoft\Validator\EmptyCondition\WhenEmpty;
use Yiisoft\Validator\Helper\SkipOnEmptyNormalizer;
final class SkipOnEmptyNormalizerTest extends TestCase
{
public function normalizeData(): array
return [
[null, NeverEmpty::class],
[false, NeverEmpty::class],
[true, WhenEmpty::class],
[static fn (mixed $value, bool $isAttributeMissing): bool => true, Closure::class],
$value
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
[static fn (/** @scrutinizer ignore-unused */ mixed $value, bool $isAttributeMissing): bool => true, Closure::class],
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
$isAttributeMissing
[static fn (mixed $value, /** @scrutinizer ignore-unused */ bool $isAttributeMissing): bool => true, Closure::class],
];
}
/**
* @dataProvider normalizeData
*/
public function testNormalize(mixed $skipOnEmpty, string $expectedClassName): void
$this->assertInstanceOf($expectedClassName, SkipOnEmptyNormalizer::normalize($skipOnEmpty));
public function testWrongType(): void
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('$skipOnEmpty must be a null, a boolean or a callable');
SkipOnEmptyNormalizer::normalize(1);
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.