Phan\Issue::maybeEmitInstance PHP Method

maybeEmitInstance() public static method

public static maybeEmitInstance ( CodeBase $code_base, Context $context, phan\IssueInstance $issue_instance ) : void
$code_base CodeBase The code base within which we're operating
$context Phan\Language\Context The context in which the instance was found
$issue_instance phan\IssueInstance An issue instance to emit
return void
    public static function maybeEmitInstance(CodeBase $code_base, Context $context, IssueInstance $issue_instance)
    {
        // If this issue type has been suppressed in
        // the config, ignore it
        if (!Config::get()->disable_suppression && in_array($issue_instance->getIssue()->getType(), Config::get()->suppress_issue_types ?? [])) {
            return;
        }
        // If a white-list of allowed issue types is defined,
        // only emit issues on the white-list
        if (!Config::get()->disable_suppression && count(Config::get()->whitelist_issue_types) > 0 && !in_array($issue_instance->getIssue()->getType(), Config::get()->whitelist_issue_types ?? [])) {
            return;
        }
        // If this issue type has been suppressed in
        // this scope from a doc block, ignore it.
        if (!Config::get()->disable_suppression && $context->hasSuppressIssue($code_base, $issue_instance->getIssue()->getType())) {
            return;
        }
        self::emitInstance($issue_instance);
    }

Same methods

Issue::maybeEmitInstance ( CodeBase $code_base, Context $context, phan\IssueInstance $issue_instance ) : void

Usage Example

Beispiel #1
0
 /**
  * Check to see if the given Clazz is a duplicate
  *
  * @return null
  */
 public static function analyzePropertyTypes(CodeBase $code_base, Clazz $clazz)
 {
     foreach ($clazz->getPropertyList($code_base) as $property) {
         try {
             $union_type = $property->getUnionType();
         } catch (IssueException $exception) {
             Issue::maybeEmitInstance($code_base, $property->getContext(), $exception->getIssueInstance());
             continue;
         }
         // Look at each type in the parameter's Union Type
         foreach ($union_type->getTypeSet() as $type) {
             // If its a native type or a reference to
             // self, its OK
             if ($type->isNativeType() || $type->isSelfType()) {
                 continue;
             }
             if ($type instanceof TemplateType) {
                 if ($property->isStatic()) {
                     Issue::maybeEmit($code_base, $property->getContext(), Issue::TemplateTypeStaticProperty, $property->getFileRef()->getLineNumberStart(), (string) $property->getFQSEN());
                 }
             } else {
                 // Make sure the class exists
                 $type_fqsen = $type->asFQSEN();
                 if (!$code_base->hasClassWithFQSEN($type_fqsen) && !$type instanceof TemplateType && (!$property->hasDefiningFQSEN() || $property->getDefiningFQSEN() == $property->getFQSEN())) {
                     Issue::maybeEmit($code_base, $property->getContext(), Issue::UndeclaredTypeProperty, $property->getFileRef()->getLineNumberStart(), (string) $property->getFQSEN(), (string) $type_fqsen);
                 }
             }
         }
     }
 }
All Usage Examples Of Phan\Issue::maybeEmitInstance