for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Nexendrie\Menu;
/**
* ConditionCallback
*
* @author Jakub Konečný
*/
class ConditionCallback extends BaseCondition {
* @param callable $parameter
$parameter
callable|null
This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.
@param
It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.
* @throws \InvalidArgumentException
* @throws \UnexpectedValueException
public function isAllowed($parameter = NULL): bool {
if(!is_callable($parameter)) {
throw new \InvalidArgumentException("Method " . static::class . "::isAllowed expects callback as parameter.");
}
$result = call_user_func($parameter);
if(!is_bool($result)) {
throw new \UnexpectedValueException("The callback for method " . static::class . "::isAllowed has to return boolean, " . gettype($result) . " returned.");
return $result;
?>
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.