Phan\CodeBase::addMethod PHP Method

addMethod() public method

public addMethod ( Method $method ) : void
$method Phan\Language\Element\Method A method to add to the code base
return void
    public function addMethod(Method $method)
    {
        // Add the method to the map
        $this->getClassMapByFQSEN($method->getFQSEN())->addMethod($method);
        $this->func_and_method_set->attach($method);
        // If we're doing dead code detection and this is a
        // method, map the name to the FQSEN so we can do hail-
        // mary references.
        if (Config::get()->dead_code_detection) {
            if (empty($this->name_method_map[$method->getFQSEN()->getNameWithAlternateId()])) {
                $this->name_method_map[$method->getFQSEN()->getNameWithAlternateId()] = new Set();
            }
            $this->name_method_map[$method->getFQSEN()->getNameWithAlternateId()]->attach($method);
        }
    }

Usage Example

コード例 #1
0
ファイル: Clazz.php プロジェクト: ablyler/phan
 /**
  * @return null
  */
 public function addMethod(CodeBase $code_base, Method $method)
 {
     $method_fqsen = FullyQualifiedMethodName::make($this->getFQSEN(), $method->getName());
     // Don't overwrite overridden methods with
     // parent methods
     if ($code_base->hasMethodWithFQSEN($method_fqsen)) {
         // Note that we're overriding something
         $existing_method = $code_base->getMethodByFQSEN($method_fqsen);
         $existing_method->setIsOverride(true);
         // Don't add the method
         return;
     }
     if ($method->getFQSEN() !== $method_fqsen) {
         $method = clone $method;
         $method->setFQSEN($method_fqsen);
     }
     $code_base->addMethod($method);
 }