hasFunctionWithFQSEN() public method

public hasFunctionWithFQSEN ( FullyQualifiedFunctionName $fqsen ) : boolean
$fqsen Phan\Language\FQSEN\FullyQualifiedFunctionName
return boolean True if an element with the given FQSEN exists
コード例 #1
0
 /**
  * Check to see if the given Clazz is a duplicate
  *
  * @return null
  */
 public static function analyzeDuplicateFunction(CodeBase $code_base, FunctionInterface $method)
 {
     $fqsen = $method->getFQSEN();
     if (!$fqsen->isAlternate()) {
         return;
     }
     $original_fqsen = $fqsen->getCanonicalFQSEN();
     if ($original_fqsen instanceof FullyQualifiedFunctionName) {
         if (!$code_base->hasFunctionWithFQSEN($original_fqsen)) {
             return;
         }
         $original_method = $code_base->getFunctionByFQSEN($original_fqsen);
     } else {
         if (!$code_base->hasMethodWithFQSEN($original_fqsen)) {
             return;
         }
         $original_method = $code_base->getMethodByFQSEN($original_fqsen);
     }
     $method_name = $method->getName();
     if (!$method->hasSuppressIssue(Issue::RedefineFunction)) {
         if ($original_method->isInternal()) {
             Issue::maybeEmit($code_base, $method->getContext(), Issue::RedefineFunctionInternal, $method->getFileRef()->getLineNumberStart(), $method_name, $method->getFileRef()->getFile(), $method->getFileRef()->getLineNumberStart());
         } else {
             Issue::maybeEmit($code_base, $method->getContext(), Issue::RedefineFunction, $method->getFileRef()->getLineNumberStart(), $method_name, $method->getFileRef()->getFile(), $method->getFileRef()->getLineNumberStart(), $original_method->getFileRef()->getFile(), $original_method->getFileRef()->getLineNumberStart());
         }
     }
 }
コード例 #2
0
ファイル: ContextNode.php プロジェクト: ablyler/phan
 /**
  * @return Method
  */
 public function getClosure() : Func
 {
     $closure_fqsen = FullyQualifiedFunctionName::fromClosureInContext($this->context);
     if (!$this->code_base->hasFunctionWithFQSEN($closure_fqsen)) {
         throw new CodeBaseException($closure_fqsen, "Could not find closure {$closure_fqsen}");
     }
     return $this->code_base->getFunctionByFQSEN($closure_fqsen);
 }
コード例 #3
0
ファイル: Func.php プロジェクト: ablyler/phan
 /**
  * @return Func[]|\Generator
  * The set of all alternates to this function
  */
 public function alternateGenerator(CodeBase $code_base) : \Generator
 {
     $alternate_id = 0;
     $fqsen = $this->getFQSEN();
     while ($code_base->hasFunctionWithFQSEN($fqsen)) {
         (yield $code_base->getFunctionByFQSEN($fqsen));
         $fqsen = $fqsen->withAlternateId(++$alternate_id);
     }
 }
コード例 #4
0
ファイル: Context.php プロジェクト: etsy/phan
 /**
  * @param CodeBase $code_base
  * The global code base holding all state
  *
  * @return Element\Func|Element\Method
  * Get the method in this scope or fail real hard
  */
 public function getFunctionLikeInScope(CodeBase $code_base) : FunctionInterface
 {
     assert($this->isInFunctionLikeScope(), "Must be in method scope to get method.");
     $fqsen = $this->getFunctionLikeFQSEN();
     if ($fqsen instanceof FullyQualifiedFunctionName) {
         assert($code_base->hasFunctionWithFQSEN($fqsen), "The function does not exist");
         return $code_base->getFunctionByFQSEN($fqsen);
     }
     if ($fqsen instanceof FullyQualifiedMethodName) {
         assert($code_base->hasMethodWithFQSEN($fqsen), "Method does not exist");
         return $code_base->getMethodByFQSEN($fqsen);
     }
     assert(false, "FQSEN must be for a function or method");
 }