You are here

public static function ClassLoader::classExists in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php \Doctrine\Common\ClassLoader::classExists()

Checks whether a class with a given name exists. A class "exists" if it is either already defined in the current request or if there is an autoloader on the SPL autoload stack that is a) responsible for the class in question and b) is able to load a class file in which the class definition resides.

If the class is not already defined, each autoloader in the SPL autoload stack is asked whether it is able to tell if the class exists. If the autoloader is a <tt>ClassLoader</tt>, {@link canLoadClass} is used, otherwise the autoload function of the autoloader is invoked and expected to return a value that evaluates to TRUE if the class (file) exists. As soon as one autoloader reports that the class exists, TRUE is returned.

Note that, depending on what kinds of autoloaders are installed on the SPL autoload stack, the class (file) might already be loaded as a result of checking for its existence. This is not the case with a <tt>ClassLoader</tt>, who separates these responsibilities.

Parameters

string $className The fully-qualified name of the class.:

Return value

boolean TRUE if the class exists as per the definition given above, FALSE otherwise.

3 calls to ClassLoader::classExists()
ClassLoaderTest::testClassExists in vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest.php
ClassLoaderTest::testClassExistsWhenLoaderIsProtected in vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest.php
ClassLoaderTest::testClassExistsWithSilentAutoloader in vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest.php

File

vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php, line 238

Class

ClassLoader
A <tt>ClassLoader</tt> is an autoloader for class files that can be installed on the SPL autoload stack. It is a class loader that either loads only classes of a specific namespace or all namespaces and it is suitable for working…

Namespace

Doctrine\Common

Code

public static function classExists($className) {
  return self::typeExists($className, true);
}