Phan\CodeBase::getClassByFQSEN PHP Method

getClassByFQSEN() public method

public getClassByFQSEN ( FullyQualifiedClassName $fqsen ) : Clazz
$fqsen Phan\Language\FQSEN\FullyQualifiedClassName The FQSEN of a class to get
return Phan\Language\Element\Clazz A class with the given FQSEN
    public function getClassByFQSEN(FullyQualifiedClassName $fqsen) : Clazz
    {
        $clazz = $this->fqsen_class_map[$fqsen];
        // This is an optimization that saves us a few minutes
        // on very large code bases.
        //
        // Instead of 'hydrating' all classes (expanding their
        // types and importing parent methods, properties, etc.)
        // all in one go, we just do it on the fly as they're
        // requested. When running as multiple processes this
        // lets us avoid a significant amount of hydration per
        // process.
        if ($this->should_hydrate_requested_elements) {
            $clazz->hydrate($this);
        }
        return $clazz;
    }

Usage Example

Example #1
0
 public function testMethodInCodeBase()
 {
     $context = $this->contextForCode("\n                namespace A;\n                Class B {\n                    public function c() {\n                        return 42;\n                    }\n                }\n            ");
     $class_fqsen = FullyQualifiedClassName::fromFullyQualifiedString('\\A\\b');
     self::assertTrue($this->code_base->hasClassWithFQSEN($class_fqsen), "Class with FQSEN {$class_fqsen} not found");
     $clazz = $this->code_base->getClassByFQSEN($class_fqsen);
     self::assertTrue($clazz->hasMethodWithName($this->code_base, 'c'), "Method with FQSEN not found");
 }
All Usage Examples Of Phan\CodeBase::getClassByFQSEN