for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Valdi package.
*
* (c) Philip Lehmann-Böhm <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Valdi\Validator;
/**
* Base validator for PHPs filter_var function.
abstract class AbstractFilter implements ValidatorInterface
{
* Gets the filter to use within the validation.
* See http://php.net/manual/de/filter.filters.validate.php .
* @return string - the filter to use
abstract protected function getFilter();
* Gets the flags to use within the validation.
* @return string|null - the flags to use
protected function getFlags()
return null;
}
* {@inheritdoc}
public function isValid($value, array $parameters)
return in_array($value, ['', null], true) ||
filter_var($value, $this->getFilter(), $this->getFlags()) !== false;
$this->getFlags()
null
array|integer
$options
filter_var()
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
filter_var($value, $this->getFilter(), /** @scrutinizer ignore-type */ $this->getFlags()) !== false;