final private function get_argument_count($callback, $accepted_args = 1)
    {
        try {
            if (\is_string($callback) && \is_callable([$this, $callback])) {
                $reflector = new ReflectionMethod($this, $callback);
                return $reflector->getNumberOfParameters();
            }

            if (\is_object($callback) && $callback instanceof Closure) {
                $reflector = new ReflectionFunction($callback);
                return $reflector->getNumberOfParameters();
            }
        } catch (ReflectionException $exception) {
            \error_log($exception->getMessage());
        }

        return $accepted_args ? $accepted_args : 1;
    }
final private function get_argument_count($callback, $accepted_args = 1)
    {
        try {
            if (\is_string($callback) && \is_callable([$this, $callback])) {
                $reflector = new ReflectionMethod($this, $callback);
                return $reflector->getNumberOfParameters();
            }

            if (\is_object($callback) && $callback instanceof Closure) {
                $reflector = new ReflectionFunction($callback);
                return $reflector->getNumberOfParameters();
            }
        } catch (ReflectionException $exception) {
            \error_log($exception->getMessage());
        }

        return $accepted_args ? $accepted_args : 1;
    }
final private function get_argument_count ( $ callback , $ accepted_args = 1 ) { try { if ( \ is_string ( $ callback ) && \ is_callable ( [ $ this , $ callback ] ) ) { $ reflector = new ReflectionMethod ( $ this , $ callback ) ; return $ reflector -> getNumberOfParameters ( ) ; } if ( \ is_object ( $ callback ) && $ callback instanceof Closure ) { $ reflector = new ReflectionFunction ( $ callback ) ; return $ reflector -> getNumberOfParameters ( ) ; } } catch ( ReflectionException $ exception ) { \ error_log ( $ exception -> getMessage ( ) ) ; } return $ accepted_args ? $ accepted_args : 1 ; }
Use reflection to count the amount of arguments a hook callback expects.

@since 1.0.0

@param  callable|string $callback      Closure or function name.
@param  integer         $accepted_args The amount of arguments passed into the hook.
@return integer
Use reflection to count the amount of arguments a hook callback expects .