Phan\Language\Element\Clazz::getMethodByNameInContext PHP Method

getMethodByNameInContext() public method

public getMethodByNameInContext ( CodeBase $code_base, string $name, Context $context ) : Method
$code_base Phan\CodeBase
$name string
$context Phan\Language\Context
return Method The method with the given name
    public function getMethodByNameInContext(CodeBase $code_base, string $name, Context $context) : Method
    {
        $method_fqsen = FullyQualifiedMethodName::make($this->getFQSEN(), $name);
        if (!$code_base->hasMethodWithFQSEN($method_fqsen)) {
            if ('__construct' === $name) {
                // Create a default constructor if its requested
                // but doesn't exist yet
                $default_constructor = Method::defaultConstructorForClassInContext($this, $context, $code_base);
                $this->addMethod($code_base, $default_constructor, $this->getParentTypeOption());
                return $default_constructor;
            }
            throw new CodeBaseException($method_fqsen, "Method with name {$name} does not exist for class {$this->getFQSEN()}.");
        }
        return $code_base->getMethodByFQSEN($method_fqsen);
    }