@param object $object
@param string $method

@return \ReflectionMethod
769401
private function getReflectionMethod($object, $method)
    {
        if (isset($this->methods[$key = $this->getCacheKey($object, $method)])) {
            return $this->methods[$key];
        }

        $reflection = new \ReflectionMethod($object, $method);
        $reflection->setAccessible(true);

        return $this->methods[$key] = $reflection;
    }
1352187
public static function fromReflection($class, $method = '__construct')
  {
    // $serviceDefinition = new static($class);
    $serviceDefinitionParameters = array();

    /* @var $reflection \ReflectionClass */
    $reflection = new \ReflectionClass($class);
    if (!$reflection->isInstantiable())
    {
      throw new \InvalidArgumentException("Class $class is not instantiable");
    }

    try {
      $constructor = $reflection->getMethod($method);

      if ($method != '__construct' && !$constructor->isStatic())
      {
        throw new \InvalidArgumentException("$class::$method is not static");
      }

      foreach ($constructor->getParameters() as $param)
      {
        /* @var $param \ReflectionParameter */

        $parameterDefinition = new ArrayParameterDefinition($param->getName());
        if ($param->isDefaultValueAvailable())
        {
          $parameterDefinition->setDefaultValue($param->getDefaultValue());
        }

        $serviceDefinitionParameters[$param->getName()] = $parameterDefinition;
      }
    }
    catch (\ReflectionException $e)
    {
      if ($method !== '__construct') // not ok
      {
        throw $e;
      }
      // ok
      $serviceDefinitionParameters = array();
    }

    return new static($class, $serviceDefinitionParameters, $method);
  }
26307
protected function invokeMethod($object, $method, array $arguments = array())
    {
        return $this->getReflectionMethod($object, $method)->invokeArgs($object, $arguments);
    }
736897
public static function callProtectedMethod($object, $method, ...$args)
    {
        $refObject = new \ReflectionObject($object);
        $refProp   = $refObject->getMethod($method);
        $refProp->setAccessible(true);

        return $refProp->invokeArgs($object, $args);
    }
224520
private function generateProxyMethod(\ReflectionMethod $method): string
    {
        if ($method->isConstructor()) {
            throw new \RuntimeException(sprintf(
                'Can not generate proxy method for constructor in class "%s".',
                $method->getDeclaringClass()->getName()
            ));
        }

        if ($method->isStatic()) {
            throw new \RuntimeException(sprintf(
                'Can not generate proxy method for static method "%s" in class "%s".',
                $method->getName(),
                $method->getDeclaringClass()->getName()
            ));
        }

        if ($method->isPrivate()) {
            throw new \RuntimeException(sprintf(
                'Can not generate proxy for private method "%s" in class "%s".',
                $method->getName(),
                $method->getDeclaringClass()->getName()
            ));
        }

        $proxyMethodParameters = [];
        $methodParameters = [];

        foreach ($method->getParameters() as $methodParameter) {
            $methodParameters[] = '$'.$methodParameter->getName();

            if ($methodParameter->getClass()) {
                $proxyMethodParameter = sprintf(
                    '\\%s %s',
                    $methodParameter->getClass()->getName(),
                    '$'.$methodParameter->getName()
                );
            } else if ($methodParameter->getType()) {
                $proxyMethodParameter = \sprintf(
                    '%s%s $%s',
                    $methodParameter->getType()->allowsNull() ? '?' : '',
                    $methodParameter->getType()->getName(),
                    $methodParameter->getName()
                );
            } else {
                $proxyMethodParameter = '$'.$methodParameter->getName();
            }

            if ($methodParameter->isOptional()) {
                $proxyMethodParameter .= ' = '.\var_export($methodParameter->getDefaultValue(), true);
            }

            $proxyMethodParameters[] = $proxyMethodParameter;
        }

        if ($method->isPublic()) {
            $availability = 'public';
        } else if ($method->isProtected()) {
            $availability = 'protected';
        } else {
            throw new \RuntimeException(sprintf(
                'Not support availability for method "%s" in class "%s".',
                $method->getName(),
                $method->getDeclaringClass()->getName()
            ));
        }

        $docComment = "/**\n * {@inheritdoc}\n */";
        $returnTypeHint = '';
        $returnResult = "\n\n    return \$result;";

        if ($method->getReturnType()) {
            $returnTypeHint = sprintf(
                ': %s%s%s',
                \class_exists($method->getReturnType()->getName()) ? '\\' : '',
                $method->getReturnType()->allowsNull() ? '?' : '',
                $method->getReturnType()->getName()
            );
        }

        if ($method->getReturnType() && 'void' === $method->getReturnType()->getName()) {
            $returnResult = '';
        }

        $templateVariables = [
            'docComment'            => $docComment,
            'availability'          => $availability,
            'name'                  => $method->getName(),
            'proxyMethodParameters' => \implode(', ', $proxyMethodParameters),
            'parameters'            => \implode(', ', $methodParameters),
            'beginArguments'        => null,
            'rollbackArguments'     => null,
            'commitArguments'       => null,
            'return_type_hint'      => $returnTypeHint,
            'return_result'         => $returnResult,
        ];

        $methodTemplate = $this->getTemplateForProxyMethod();
        $methodCode = $this->replaceVariables($methodTemplate, $templateVariables);
        $methodCode = $this->appendTabulationCharacter($methodCode, 1);

        return $methodCode;
    }
808171
public static function runGetter(&$object, string $key)
    {
        $methodName = static::getMethodName($key, 'get');
        if (method_exists($object, $methodName)) {
            return $object->$methodName();
        }
        return null;
    }
1077497
public static function exportObjectMethods($object) {
        $methods = [];
        foreach (get_class_methods($object) as $method) {
            if ($method[0] === '_') {
                continue;
            }
            $methods[$method] = [$object, $method];
        }
        return $methods;
    }
558759
public function setMethod($method) {
        $this->method = (true === in_array($method, [self::HTTP_METHOD_GET, self::HTTP_METHOD_POST]) ? $method : self::HTTP_METHOD_POST);
        return $this;
    }
925261
public static function dump($object, $method = null)
    {
        return App::getServiceDumper()->dump($object, static::getClassName(), $method);
    }
652182
public function method($method)
    {
        if (!$this->isString($method) && !$this->isStringObject($method)) {
            throw new EventManagerException(EventManagerException::MSG_INVALID_ARG, [
                    '$method',
                    'string|StringObject'
                ]
            );
        }
        $this->method = StdObjectWrapper::toString($method);

        return $this;
    }
907007
private function getValue($object, \ReflectionProperty $property)
    {
        $value = null;

        if ($property->isPublic()) {
            $value = $property->getValue($object);
        } else {
            // Try to use accessor if property is not public
            $accessorName = $this->formatter->getPhpAccessor($property->getName(), false);
            $reflectedObject = new \ReflectionObject($object);
            $reflectedMethod = $reflectedObject->getMethod($accessorName);

            if (null !== $reflectedMethod) {
                $value = $reflectedMethod->invoke($object);
            }
        }

        return $value;
    }
1169877
protected static function getReflection($object)
    {
        $reflectionClass = get_class($object);

        if (!isset(self::$reflections[$reflectionClass])) {
            self::$reflections[$reflectionClass]
                = new \ReflectionClass($object);
        }

        return self::$reflections[$reflectionClass];
    }
669847
private function processDeserializeTypeMethod(Type\Method $method, $object, $value): self
    {
        $object->{$method->setter()}($value);

        return $this;
    }
388685
protected function _getMethods($object)
    {
        if (is_string($object)) {
            $className = $object;
        } else {
            $className = get_class($object);
        }
        $methods = get_class_methods($className);

        if (self::$_config['sort']['methods']) {
            sort($methods);
        }
        return $methods;
    }
1142914
public function setObject($object, $method  = null)
    {
        if (! is_object($object)) {
            throw new Exception('not object');
        }
        $ref = new \ReflectionObject($object);
        $file = $ref->getFileName();
        $this->setPath($file);

        return $this;
    }
176406
protected function createCallback(string $method): \Closure
    {
        return \Closure::bind(static function (...$args) use ($method) {
            return self::$method(...$args);
        }, null, $this->type);
    }
715185
public function injectIntoMethod( $object, $methodName = "injectDependencies" ){
        $ref = new \ReflectionClass($object);
        try{
            $refMethod = $ref->getMethod( $methodName );
        }catch( ReflectionException  $e ){
            return null;
        }
        
        $toInject = [];
        foreach ($refMethod->getParameters() as $p) {
            $className = $p->getClass()->name;
            if( $className === "Pimple\\Container" ){
                $toInject[] = $this->container;
            }else{
                $toInject[] = $this->container[ $className ];
            }
        }
        return $refMethod->invoke( $object, ... $toInject );
    }