public function OptionalParametersFilter::filter in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-hydrator/src/Filter/OptionalParametersFilter.php \Zend\Hydrator\Filter\OptionalParametersFilter::filter()
Should return true, if the given filter does not match
Parameters
string $property The name of the property:
Return value
bool
Overrides FilterInterface::filter
File
- vendor/
zendframework/ zend-hydrator/ src/ Filter/ OptionalParametersFilter.php, line 34
Class
- OptionalParametersFilter
- Filter that includes methods which have no parameters or only optional parameters
Namespace
Zend\Hydrator\FilterCode
public function filter($property) {
if (isset(static::$propertiesCache[$property])) {
return static::$propertiesCache[$property];
}
try {
$reflectionMethod = new ReflectionMethod($property);
} catch (ReflectionException $exception) {
throw new InvalidArgumentException(sprintf('Method %s doesn\'t exist', $property));
}
$mandatoryParameters = array_filter($reflectionMethod
->getParameters(), function (ReflectionParameter $parameter) {
return !$parameter
->isOptional();
});
return static::$propertiesCache[$property] = empty($mandatoryParameters);
}