public static function checkMethodArguments($arguments = [], $method, $objectOrName = null, $returnType = self::ARG_CHECK_RETURN_DATA)
    {
        if ($method instanceof \ReflectionMethod) {
            $reflection = $method;
        } elseif ($objectOrName !== null) {
            $reflection = static::getMethodReflection($objectOrName, $method);
        } else {
            return null;
        }
        if ($reflection->getNumberOfRequiredParameters() === 0) {
            return $returnType === static::ARG_CHECK_RETURN_DATA ? [] : true;
        }
        $methodParams = $reflection->getParameters();
        $data = [];
        foreach ($methodParams as $param) {
            if (!$param->isOptional() && empty($arguments)) {
                $data[$param->name] = static::ARG_REQUIRED_MISSING;
            } elseif(!empty($arguments) && ($type = $param->getType()) !== null) {
                $arg = reset($arguments);
                $typeName = $type->getName();
                $stdTypes = ['bool', 'int', 'string', 'array', 'object', 'float', 'callable'];
                if (!in_array($typeName, $stdTypes) && !$arg instanceof $typeName) {
                    $data[$param->name] = static::ARG_TYPE_MISMATCH;
                }
            }
            array_shift($arguments);
        }
        return $returnType === static::ARG_CHECK_RETURN_DATA ? $data : empty($data);
    }
public static function checkMethodArguments($arguments = [], $method, $objectOrName = null, $returnType = self::ARG_CHECK_RETURN_DATA)
    {
        if ($method instanceof \ReflectionMethod) {
            $reflection = $method;
        } elseif ($objectOrName !== null) {
            $reflection = static::getMethodReflection($objectOrName, $method);
        } else {
            return null;
        }
        if ($reflection->getNumberOfRequiredParameters() === 0) {
            return $returnType === static::ARG_CHECK_RETURN_DATA ? [] : true;
        }
        $methodParams = $reflection->getParameters();
        $data = [];
        foreach ($methodParams as $param) {
            if (!$param->isOptional() && empty($arguments)) {
                $data[$param->name] = static::ARG_REQUIRED_MISSING;
            } elseif(!empty($arguments) && ($type = $param->getType()) !== null) {
                $arg = reset($arguments);
                $typeName = $type->getName();
                $stdTypes = ['bool', 'int', 'string', 'array', 'object', 'float', 'callable'];
                if (!in_array($typeName, $stdTypes) && !$arg instanceof $typeName) {
                    $data[$param->name] = static::ARG_TYPE_MISMATCH;
                }
            }
            array_shift($arguments);
        }
        return $returnType === static::ARG_CHECK_RETURN_DATA ? $data : empty($data);
    }
public static function checkMethodArguments ( $ arguments = [ ] , $ method , $ objectOrName = null , $ returnType = self :: ARG_CHECK_RETURN_DATA ) { if ( $ method instanceof \ ReflectionMethod ) { $ reflection = $ method ; } elseif ( $ objectOrName !== null ) { $ reflection = static :: getMethodReflection ( $ objectOrName , $ method ) ; } else { return null ; } if ( $ reflection -> getNumberOfRequiredParameters ( ) === 0 ) { return $ returnType === static :: ARG_CHECK_RETURN_DATA ? [ ] : true ; } $ methodParams = $ reflection -> getParameters ( ) ; $ data = [ ] ; foreach ( $ methodParams as $ param ) { if ( ! $ param -> isOptional ( ) && empty ( $ arguments ) ) { $ data [ $ param -> name ] = static :: ARG_REQUIRED_MISSING ; } elseif ( ! empty ( $ arguments ) && ( $ type = $ param -> getType ( ) ) !== null ) { $ arg = reset ( $ arguments ) ; $ typeName = $ type -> getName ( ) ; $ stdTypes = [ 'bool' , 'int' , 'string' , 'array' , 'object' , 'float' , 'callable' ] ; if ( ! in_array ( $ typeName , $ stdTypes ) && ! $ arg instanceof $ typeName ) { $ data [ $ param -> name ] = static :: ARG_TYPE_MISMATCH ; } } array_shift ( $ arguments ) ; } return $ returnType === static :: ARG_CHECK_RETURN_DATA ? $ data : empty ( $ data ) ; }
Check class method arguments for consistency
@param array  $arguments
@param string|\ReflectionMethod $method
@param null   $objectOrName
@param string $returnType
@return array|bool|null
Check class method arguments for consistency