Creates proxy methods from the reflection method handle and meta information.

@param $method
@param $meta
@return string The method code.
335845
private function methodProxy($method, $meta)
    {
        //Find out if the method is a property getter or setter
        $property = $meta->findProperty($method->getName());

        //If it is not, don't need the proxy
        if(!$property)
        {
            return;
        }

        //If the method is a straight up property setter/getter and not for a start/end node, you don't need a method proxy either.
        if($property->isProperty() && !$property->isStart() && !$property->isEnd())
        {
            return;
        }

        $parts = array();
        $arguments = array();

        //Loop through the methods parameters
        foreach ($method->getParameters() as $parameter)
        {
            //Convert to a variable name, and add it to parts array
            $variable = '$' . $parameter->getName();
            $parts[] = $variable;

            $arg = $variable;

            //If the parameter is optional, set it to its default value in the arguments list.
            if($parameter->isOptional())
            {
                $arg .= ' = ' . var_export($parameter->getDefaultValue(), true);
            }

            //If the variable is passed by reference, put in an ampersand
            if($parameter->isPassedByReference())
            {
                $arg = "& $arg";
            }

            //If the variable is a set class, add the class name as the type
            elseif($c = $parameter->getClass())
            {
                $arg = $c->getName() . ' ' . $arg;
            }

            //If the argument is a array, add array identifier
            if($parameter->isArray())
            {
                $arg = "array $arg";
            }

            //Add the argument to argument array
            $arguments[] = $arg;
        }

        //Join the argument variable names together with commas
        $parts = implode(', ', $parts);

        //Join the arguments with commas
        $arguments = implode(', ', $arguments);

        //Get the method name as a string
        $name = var_export($method->getName(), true);

        //Get the property name as a string
        $propertyName = var_export($property->getName(), true);

        return <<<FUNC

    function {$method->getName()}($arguments)
    {
        self::__load($name, $propertyName);
        return parent::{$method->getName()}($parts);
    }

FUNC;
    }
1018607
protected function isGetMethod(\ReflectionMethod $method)
    {
        return 'get' === substr($method->name, 0, 3) && strlen($method->name) > 3 &&
            0 === $method->getNumberOfRequiredParameters();
    }
1031067
private static function getCalledMethod($method)
    {
        if (strpos($method, '::') !== false) {
            $methodChunks = explode('::', $method);
            $method = $methodChunks[1];
        }

        return $method;
    }
1242236
protected function methodToConfiguration(ReflectionMethod $method): ?array
    {
        // Get a field from annotation, or an empty one
        /** @var Field $field */
        $field = $this->getAnnotationReader()->getMethodAnnotation($method, Field::class) ?? new Field();

        if (!$field->type instanceof Type) {
            $this->convertTypeDeclarationsToInstances($method, $field);
            $this->completeField($field, $method);
        }

        return $field->toArray();
    }
954971
public function getReflectionMethod(string $method)
    {
        if (!isset($this->reflectionMethod[$method])) {
            $this->reflectionMethod[$method] = new ReflectionMethod($this, $method);
        }

        return $this->reflectionMethod[$method];
    }
675704
public static MethodHandleProxy proxyMethod(Object target,String methodName,Object ...args)
	{
		MethodHandle mh=findMethodHandle(target, methodName, args);
		if(mh!=null)
		{
			return new MethodHandleProxy(target, mh, args);
		}
		return null;
	}
732563
public function getMethodAnnotations($method)
    {
        $reflector = new ReflectionClass($this->className);
        $doc = $reflector->getMethod($method)->getDocComment();
        $annotations = [];
        foreach ($this->filteringList as $filter) {
            preg_match_all('#@' . $filter . '(.*?)\n#s', $doc, $annotation);
            if (!empty($annotation[1])) {
                $annotations[$filter] = $annotation[1];
            }
        }
        return $annotations;
    }
921525
private function getResourceMetadata(Definition $definition, $method)
    {
        foreach ($definition->getMethodCalls() as $methodCall) {
            if ($methodCall[0] === $method) {
                return $methodCall[1][0];
            }
        }
    }
743210
public function getMethodAnnotations($method)
    {
        if (!$this->hasMethod($method)) {
            $name = $this->_getReflection()->getName();
            throw new Exception\InvalidArgumentException(
                "The class {$name} doesn't have a property called {$method}"
            );
        }

        if (empty($this->_annotations['methods'][$method])) {
            $comment = $this->_getReflection()
                ->getMethod($method)
                ->getDocComment();
            $data = AnnotationParser::getAnnotations($comment);
            $methodAnnotations = new AnnotationsList();
            foreach ($data as $property => $parsedData) {
                $methodAnnotations->append(
                    $this->_createAnnotation($property, $parsedData)
                );
            }
            $this->_annotations['methods'][$method] = $methodAnnotations;
        }
        return $this->_annotations['methods'][$method];
    }
1330675
private function getOnValidate(\ReflectionMethod $method)
    {
        /** @var $valid Valid */
        $valid = $this->reader->getMethodAnnotation($method, Valid::class);
        $class = $method->getDeclaringClass();
        $onMethods = $this->findOnMethods($class, $valid);
        if ($onMethods[0] && $onMethods[0] instanceof \ReflectionMethod) {
            return $onMethods;
        }
        throw new ValidateMethodNotFound($method->getShortName());
    }
732247
public function getMethodAttribute($method)
    {
        if (is_array($method)) {
            return $method;
        } else {
            if (is_string($method)) {
                $method = (integer)$method;
            }
        }

        return VerbsMask::maskToArray($method);
    }
565652
private function getMethodCallbacks(ReflectionMethod $method)
    {
        $annotations = $this->getMethodAnnotations($method);
        $events      = [
            Events::prePersist  => Annotation\PrePersist::class,
            Events::postPersist => Annotation\PostPersist::class,
            Events::preUpdate   => Annotation\PreUpdate::class,
            Events::postUpdate  => Annotation\PostUpdate::class,
            Events::preRemove   => Annotation\PreRemove::class,
            Events::postRemove  => Annotation\PostRemove::class,
            Events::postLoad    => Annotation\PostLoad::class,
            Events::preFlush    => Annotation\PreFlush::class,
        ];

        // Check for callbacks
        $callbacks = [];

        foreach ($events as $eventName => $annotationClassName) {
            if (isset($annotations[$annotationClassName]) || $method->getName() === $eventName) {
                $callbacks[] = $eventName;
            }
        }

        return $callbacks;
    }
806090
protected function callProxy($class, $method, array $args)
    {
        $new = $this->cloneInstance();

        $ref = new \ReflectionMethod($class, $method);
        $params = $ref->getParameters();
        array_shift($params);

        /** @var \ReflectionParameter $param */
        foreach (array_values($params) as $k => $param) {
            if (!array_key_exists($k, $args)) {
                if ($param->getName() === 'encoding' && !isset($args[$k])) {
                    $args[$k] = $this->encoding;
                    continue;
                }

                $args[$k] = $param->getDefaultValue();
            }
        }

        array_unshift($args, $new->string);

        $result = call_user_func_array([$class, $method], $args);

        if (is_string($result)) {
            $new->string = $result;

            return $new;
        }

        return $result;
    }
180041
final public function withMethod($method): self
    {
        $request = clone $this;
        $request->method = $this->filterMethod($method);

        return $request;
    }
971741
private function getMethod(\ReflectionMethod $method)
    {
        $methodStmt = $this->factory->method($method->name);
        $params = $method->getParameters();
        foreach ($params as $param) {
            $methodStmt = $this->getMethodStatement($param, $methodStmt);
        }
        $returnType = $method->getReturnType();
        if ($returnType instanceof \ReflectionType) {
            $this->setReturnType($returnType, $methodStmt);
        }
        $methodInsideStatements = $this->getMethodInsideStatement($method);
        $methodStmt->addStmts($methodInsideStatements);

        return $this->addMethodDocComment($methodStmt, $method);
    }
677761
def method_missing(name, *args, &block)
      return meta[name.to_s] if meta.key?(name.to_s)
      super
    end
1132501
public function withMethod($method)
    {
        if ($this->getMethod() === $method) {
            return $this;
        }

        $newInstance = clone $this;
        $newInstance->setMethod($method);
        return $newInstance;
    }