src/HooksTrait.php
private static function checkCallable(
        $classInstance,
        callable $callable,
        $method = null
    ) {
        // if there are args and debug mode is on
        if ($method && self::$checkCallableParameters) {

            $originalMethodReflection = new \ReflectionMethod($classInstance, $method);

            if ($originalMethodReflection->getNumberOfParameters() === 0) {
                return;
            }

            $originalMethodReflectionParameters = $originalMethodReflection->getParameters();

            if (is_array($callable)) {
                $callableReflection = new \ReflectionMethod($callable[0], $callable[1]);
                $callableReflectionParameters = $callableReflection->getParameters();
            } elseif ($callable instanceof \Closure) {
                $callableReflection = new \ReflectionFunction($callable);
                $callableReflectionParameters = $callableReflection->getParameters();
            }

            $originalParameters = self::getReflectionParameters($originalMethodReflectionParameters);

            $callableParameters = self::getReflectionParameters($callableReflectionParameters);

            $parameterOffset = 0;

            // remove default parameters
            if ($method && $callableParameters && $callable instanceof \Closure === false) {
                $callableParameters = array_slice($callableParameters, 1);

                $parameterOffset = 1;
            }

            /**
             * [
             *      0 => [
             *          'original' => 'resourceLocation'
             *          'callable' => 'uri'
             *          'dirty' => true
             *      ],
             *
             *      1 => [
             *          'original' => 'message'
             *          'callable' => null
             *          'missing' => true
             */

            $parameterMeta = array_map(
                function ($originalParameter, $callableParameter) {
                    return ['original' => $originalParameter, 'callable' => $callableParameter];
                },
                $originalParameters,
                $callableParameters
            );

            $parameterDiff = array_filter(
                $parameterMeta,
                function ($item) {
                    return $item['original'] !== $item['callable'];
                }
            ); // remove matching fields, preserves keys

            if ($parameterDiff) {
                self::findParameterIssues(
                    $method,
                    $callableParameters,
                    $parameterDiff,
                    $parameterOffset
                );
            }
        }
    }
private static function checkCallable(
        $classInstance,
        callable $callable,
        $method = null
    ) {
        // if there are args and debug mode is on
        if ($method && self::$checkCallableParameters) {

            $originalMethodReflection = new \ReflectionMethod($classInstance, $method);

            if ($originalMethodReflection->getNumberOfParameters() === 0) {
                return;
            }

            $originalMethodReflectionParameters = $originalMethodReflection->getParameters();

            if (is_array($callable)) {
                $callableReflection = new \ReflectionMethod($callable[0], $callable[1]);
                $callableReflectionParameters = $callableReflection->getParameters();
            } elseif ($callable instanceof \Closure) {
                $callableReflection = new \ReflectionFunction($callable);
                $callableReflectionParameters = $callableReflection->getParameters();
            }

            $originalParameters = self::getReflectionParameters($originalMethodReflectionParameters);

            $callableParameters = self::getReflectionParameters($callableReflectionParameters);

            $parameterOffset = 0;

            // remove default parameters
            if ($method && $callableParameters && $callable instanceof \Closure === false) {
                $callableParameters = array_slice($callableParameters, 1);

                $parameterOffset = 1;
            }

            /**
             * [
             *      0 => [
             *          'original' => 'resourceLocation'
             *          'callable' => 'uri'
             *          'dirty' => true
             *      ],
             *
             *      1 => [
             *          'original' => 'message'
             *          'callable' => null
             *          'missing' => true
             */

            $parameterMeta = array_map(
                function ($originalParameter, $callableParameter) {
                    return ['original' => $originalParameter, 'callable' => $callableParameter];
                },
                $originalParameters,
                $callableParameters
            );

            $parameterDiff = array_filter(
                $parameterMeta,
                function ($item) {
                    return $item['original'] !== $item['callable'];
                }
            ); // remove matching fields, preserves keys

            if ($parameterDiff) {
                self::findParameterIssues(
                    $method,
                    $callableParameters,
                    $parameterDiff,
                    $parameterOffset
                );
            }
        }
    }
private static function checkCallable ( $ classInstance , callable $ callable , $ method = null ) { // if there are args and debug mode is on if ( $ method && self :: $ checkCallableParameters ) { $ originalMethodReflection = new \ ReflectionMethod ( $ classInstance , $ method ) ; if ( $ originalMethodReflection -> getNumberOfParameters ( ) === 0 ) { return ; } $ originalMethodReflectionParameters = $ originalMethodReflection -> getParameters ( ) ; if ( is_array ( $ callable ) ) { $ callableReflection = new \ ReflectionMethod ( $ callable [ 0 ] , $ callable [ 1 ] ) ; $ callableReflectionParameters = $ callableReflection -> getParameters ( ) ; } elseif ( $ callable instanceof \ Closure ) { $ callableReflection = new \ ReflectionFunction ( $ callable ) ; $ callableReflectionParameters = $ callableReflection -> getParameters ( ) ; } $ originalParameters = self :: getReflectionParameters ( $ originalMethodReflectionParameters ) ; $ callableParameters = self :: getReflectionParameters ( $ callableReflectionParameters ) ; $ parameterOffset = 0 ; // remove default parameters if ( $ method && $ callableParameters && $ callable instanceof \ Closure === false ) { $ callableParameters = array_slice ( $ callableParameters , 1 ) ; $ parameterOffset = 1 ; } /**
             * [
             *      0 => [
             *          'original' => 'resourceLocation'
             *          'callable' => 'uri'
             *          'dirty' => true
             *      ],
             *
             *      1 => [
             *          'original' => 'message'
             *          'callable' => null
             *          'missing' => true
             */ $ parameterMeta = array_map ( function ( $ originalParameter , $ callableParameter ) { return [ 'original' => $ originalParameter , 'callable' => $ callableParameter ] ; } , $ originalParameters , $ callableParameters ) ; $ parameterDiff = array_filter ( $ parameterMeta , function ( $ item ) { return $ item [ 'original' ] !== $ item [ 'callable' ] ; } ) ; // remove matching fields, preserves keys if ( $ parameterDiff ) { self :: findParameterIssues ( $ method , $ callableParameters , $ parameterDiff , $ parameterOffset ) ; } } }
Currently checks for mismatching parameters

@param object|string   $classInstance
@param callable        $callable
@param string          $method        [optional]
Currently checks for mismatching parameters