Check whether a class/interface exists

@param  string          $fq_class_name
@param  CodeLocation $code_location

@return bool
327708
public function classOrInterfaceExists($fq_class_name, CodeLocation $code_location = null)
    {
        return $this->classlikes->classOrInterfaceExists($fq_class_name, $code_location);
    }
222687
private function checkMethod($method_id, PhpParser\Node $stmt, Codebase $codebase)
    {
        $class = explode('::', $method_id)[0];

        if (ClassLikeAnalyzer::checkFullyQualifiedClassLikeName(
            $this,
            $class,
            new CodeLocation($this, $stmt),
            [],
            true
        ) === false
        ) {
            return false;
        }

        $this_context = new Context();
        $this_context->self = $class;
        $this_context->vars_in_scope['$this'] = new Type\Union([new Type\Atomic\TNamedObject($class)]);

        $constructor_id = $class . '::__construct';

        $this->project_analyzer->getMethodMutations(
            $constructor_id,
            $this_context,
            $this->getRootFilePath(),
            $this->getRootFileName()
        );

        $this_context->vars_in_scope['$this'] = new Type\Union([new Type\Atomic\TNamedObject($class)]);

        // check the actual method
        $this->project_analyzer->getMethodMutations(
            $method_id,
            $this_context,
            $this->getRootFilePath(),
            $this->getRootFileName()
        );

        $view_context = new Context();
        $view_context->self = self::VIEW_CLASS;

        // add all $this-> vars to scope
        foreach ($this_context->vars_possibly_in_scope as $var => $_) {
            $view_context->vars_in_scope[str_replace('$this->', '$', $var)] = Type::getMixed();
        }

        foreach ($this_context->vars_in_scope as $var => $type) {
            $view_context->vars_in_scope[str_replace('$this->', '$', $var)] = $type;
        }

        return $view_context;
    }
705191
private static void hasValidatingMcfInterface(PrintStream out, PrintStream error, String classname,
         URLClassLoader cl)
   {
      try
      {
         out.print("  Validating: ");
         Class<?> clazz = Class.forName(classname, true, cl);

         if (hasInterface(clazz, "javax.resource.spi.ValidatingManagedConnectionFactory"))
         {
            out.println("Yes");
         }
         else
         {
            out.println("No");
         }
      }
      catch (Throwable t)
      {
         // Nothing we can do
         t.printStackTrace(error);
         out.println("Unknown");
      }
   }
1106639
private boolean isConstrainedByInterface(FQMethod fqMethod) {

        try {
            JavaClass fqCls = Repository.lookupClass(fqMethod.getClassName());
            if (fqCls.isInterface()) {
                return true;
            }

            for (JavaClass inf : fqCls.getAllInterfaces()) {
                for (Method infMethod : inf.getMethods()) {
                    if (infMethod.getName().equals(fqMethod.getMethodName())) {
                        String infMethodSig = infMethod.getSignature();
                        String fqMethodSig = fqMethod.getSignature();
                        if (infMethodSig.equals(fqMethodSig)) {
                            return true;
                        }

                        List<String> infTypes = SignatureUtils.getParameterSignatures(infMethodSig);
                        List<String> fqTypes = SignatureUtils.getParameterSignatures(fqMethodSig);

                        if (infTypes.size() == fqTypes.size()) {
                            boolean matches = true;
                            for (int i = 0; i < infTypes.size(); i++) {
                                String infParmType = infTypes.get(i);
                                String fqParmType = fqTypes.get(i);
                                if (infParmType.equals(fqParmType)) {
                                    if ((infParmType.charAt(0) != 'L') || (fqParmType.charAt(0) != 'L')) {
                                        matches = false;
                                        break;
                                    }

                                    JavaClass infParmClass = Repository.lookupClass(SignatureUtils.stripSignature(infParmType));
                                    JavaClass fqParmClass = Repository.lookupClass(SignatureUtils.stripSignature(fqParmType));
                                    if (!fqParmClass.instanceOf(infParmClass)) {
                                        matches = false;
                                        break;
                                    }
                                }
                            }

                            if (matches) {
                                return true;
                            }
                        }
                    }
                }
            }

            return false;
        } catch (ClassNotFoundException cnfe) {
            bugReporter.reportMissingClass(cnfe);
            return true;
        }
    }
962349
function isEntity(string $classFQCN) : bool
    {
        if ( ! class_exists($classFQCN)) {

            throw new ClassNotFoundException(sprintf('Given class FQCN "%s" does not exist.', $classFQCN));
        }

        if ( ! is_object($classFQCN)) {

            throw new EntityNotFoundException(sprintf('Given class "%s" is not a Doctrine Entity.', $classFQCN));
        }

        return ! $this->getObjectManager()
                      ->getMetadataFactory()
                      ->isTransient(ClassUtils::getClass($classFQCN));
    }
938929
def exists(self, model_class, ID):
        ''''''

        assert hasattr(model_class, '_fields'), 'Not a valid model class'
        res = self.get(model_class, id=ID, fetchOne=True)
        if res:
            return True
        return False
387451
public static function ExistsClassSession ($name = null, $class_path = null) {
		return Session::Exists(static::_GetSeesionClassLayerPath($name, $class_path ?: static::class));
	}
638171
public function getMethodReturnTypeLocation(
        $method_id,
        CodeLocation &$defined_location = null
    ) {
        $method_id = $this->getDeclaringMethodId($method_id);

        if ($method_id === null) {
            return null;
        }

        $storage = $this->getStorage($method_id);

        if (!$storage->return_type_location) {
            $overridden_method_ids = $this->getOverriddenMethodIds($method_id);

            foreach ($overridden_method_ids as $overridden_method_id) {
                $overridden_storage = $this->getStorage($overridden_method_id);

                if ($overridden_storage->return_type_location) {
                    $defined_location = $overridden_storage->return_type_location;
                    break;
                }
            }
        }

        return $storage->return_type_location;
    }
977672
private function isImplementing($fqcn, $fqin)
    {
        $interfaces = class_implements($fqcn, true);
        return isset($interfaces[$fqin]);
    }
723672
private function classExists( $fqcn )
	{
		if ( isset( $this->classExists[$fqcn] ) )
			return $this->classExists[$fqcn];

		// first check if the class already exists, maybe loaded through another AnnotationReader
		if ( class_exists( $fqcn ) )
			return $this->classExists[$fqcn] = true;

		return false;
	}
1116759
public function findReferencesToClassLike($fq_class_name)
    {
        $fq_class_name_lc = strtolower($fq_class_name);
        $locations = $this->file_reference_provider->getClassLocations($fq_class_name_lc);

        if (isset($this->use_referencing_locations[$fq_class_name_lc])) {
            $locations = array_merge($locations, $this->use_referencing_locations[$fq_class_name_lc]);
        }

        return $locations;
    }
888481
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "EXS_EXCEPTION_SOFTENING_RETURN_FALSE", justification = "No other simple way to determine whether class exists")
    private boolean checkConfusedName(String methodOrVariableName, String signature) {
        try {
            String name = methodOrVariableName.toLowerCase(Locale.ENGLISH);
            if ((name.endsWith("map") || (name.endsWith("set") && !name.endsWith("toset")) || name.endsWith("list") || name.endsWith("queue"))
                    && signature.startsWith("Ljava/util/")) {
                String clsName = SignatureUtils.stripSignature(signature);
                JavaClass cls = Repository.lookupClass(clsName);
                if ((cls.implementationOf(mapInterface) && !name.endsWith("map")) || (cls.implementationOf(setInterface) && !name.endsWith("set"))
                        || ((cls.implementationOf(listInterface) || cls.implementationOf(queueInterface)) && !name.endsWith("list")
                                && !name.endsWith("queue"))) {
                    return true;
                }
            }
        } catch (ClassNotFoundException cnfe) {
            bugReporter.reportMissingClass(cnfe);
        }

        return false;
    }
826147
public static function checkMethodSignatureMustOmitReturnType(
        MethodStorage $method_storage,
        CodeLocation $code_location
    ) {
        if ($method_storage->signature_return_type === null) {
            return null;
        }

        $cased_method_name = $method_storage->cased_name;
        $methodsOfInterest = ['__clone', '__construct', '__destruct'];
        if (in_array($cased_method_name, $methodsOfInterest)) {
            if (IssueBuffer::accepts(
                new MethodSignatureMustOmitReturnType(
                    'Method ' . $cased_method_name . ' must not declare a return type',
                    $code_location
                )
            )) {
                return false;
            }
        }

        return null;
    }
16122
final boolean checkFunctionEquivalenceHelper(
      FunctionType that, EquivalenceMethod eqMethod, EqCache eqCache) {
    if (this == that) {
      return true;
    }
    if (kind != that.kind) {
      return false;
    }
    switch (kind) {
      case CONSTRUCTOR:
        return false; // constructors use identity semantics, which we already checked for above.
      case INTERFACE:
        return getReferenceName().equals(that.getReferenceName());
      case ORDINARY:
        return typeOfThis.checkEquivalenceHelper(that.typeOfThis, eqMethod, eqCache)
            && call.checkArrowEquivalenceHelper(that.call, eqMethod, eqCache);
      default:
        throw new AssertionError();
    }
  }
52510
public static function isClassMethodCall($class_name, $method_name) {
    return function ($node) use ($class_name, $method_name) {
      if ($node instanceof ClassMethodCallNode) {
        $call_class_name_node = $node->getClassName();
        $call_class_name = $call_class_name_node instanceof NameNode ? $call_class_name_node->getAbsolutePath() : $call_class_name_node->getText();
        $class_matches = $call_class_name === $class_name;
        $method_matches = $node->getMethodName()->getText() === $method_name;
        return $class_matches && $method_matches;
      }
      return FALSE;
    };
  }
1034478
public static Class<?> checkClassExist(String className) {
		Class<?> result = classExistCache.get(className);
		if (result != null) {
			if (ClassOrMethodNotExist.class.equals(result))
				return null;
			else
				return result;
		}
		try {
			result = Class.forName(className);
			if (result != null)
				classExistCache.put(className, result);
			else
				classExistCache.put(className, ClassOrMethodNotExist.class);
			return result;
		} catch (Exception e) {
			DialectException.eatException(e);
			classExistCache.put(className, ClassOrMethodNotExist.class);
			return null;
		}
	}
10876
public static URL codeLocationFromClass(Class<?> codeLocationClass) {
        String pathOfClass = codeLocationClass.getName().replace(".", "/") + ".class";
        URL classResource = codeLocationClass.getClassLoader().getResource(pathOfClass);
        String codeLocationPath = removeEnd(getPathFromURL(classResource), pathOfClass);
        if(codeLocationPath.endsWith(".jar!/")) {
            codeLocationPath=removeEnd(codeLocationPath,"!/");
        }
        return codeLocationFromPath(codeLocationPath);
    }