class_exists

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Checks if the class has been defined
<?php class_exists(string $class, bool $autoload = true): bool
<?php             return $this->exceptionFor($suiteClassName, $suiteClassFile);

        }



        if (! class_exists($suiteClassName, false)) {

            return $this->exceptionFor($suiteClassName, $suiteClassFile);

        }
<?php     {

        return Targeted::make(

            $this,

            fn (ObjectDescription $object): bool => class_exists($object->name) && ! enum_exists($object->name),

            'to be class',

            FileLineFinder::where(fn (string $line): bool => true),

        );
<?php     {

        return Targeted::make(

            $this->original,

            fn (ObjectDescription $object): bool => ! class_exists($object->name),

            'not to be class',

            FileLineFinder::where(fn (string $line): bool => true),

        );
<?php         $classFQN = 'P\\'.$relativePath;



        if (class_exists($classFQN)) {

            return;

        }
<?php                 return $this;

            }



            if (! class_exists($exception)) {

                if ($e instanceof Error && "Class \"$exception\" not found" === $e->getMessage()) {

                    Assert::assertTrue(true);
<?php         Assert::assertTrue(true);



        if (! $exception instanceof Throwable && ! class_exists($exception)) {

            throw new ExpectationFailedException("Exception with message \"$exception\" not thrown.");

        }
<?php     {

        if (is_int($exception)) {

            $exceptionCode = $exception;

        } elseif (class_exists($exception)) {

            $this->testCaseMethod

                ->proxies

                ->add(Backtrace::file(), Backtrace::line(), 'expectException', [$exception]);
<?php     public function covers(string ...$classesOrFunctions): self

    {

        foreach ($classesOrFunctions as $classOrFunction) {

            $isClass = class_exists($classOrFunction) || trait_exists($classOrFunction);

            $isMethod = function_exists($classOrFunction);



            if (! $isClass && ! $isMethod) {
<?php     private static function whenUsingLaravel(array $arguments, Closure $closure): array

    {

        $isLaravelApplication = InstalledVersions::isInstalled('laravel/framework', false);

        $isLaravelPackage = class_exists(\Orchestra\Testbench\TestCase::class);



        if ($isLaravelApplication && ! $isLaravelPackage) {

            return $closure($arguments);
<?php         $afterEach = $this->state[$filename] ?? NullClosure::create();



        return ChainableClosure::bound(function (): void {

            if (class_exists(Mockery::class)) {

                if ($container = Mockery::getContainer()) {


                    $this->addToAssertionCount($container->mockery_getExpectationCount());
<?php     public function use(array $classOrTraits, array $groups, array $paths, array $hooks): void

    {

        foreach ($classOrTraits as $classOrTrait) {

            if (class_exists($classOrTrait)) {

                continue;

            }

            if (trait_exists($classOrTrait)) {
<?php             if ((! is_dir($path) && $testCase->filename === $path) || (is_dir($path) && $startsWith($testCase->filename, $path))) {

                foreach ($classOrTraits as $class) {


                    if (class_exists($class)) {

                        if ($testCase->class !== TestCase::class) {

                            throw new TestCaseAlreadyInUse($testCase->class, $class, $testCase->filename);

                        }
<?php                 $message = str_replace(self::UNDEFINED_METHOD, 'Call to undefined method ', $message);



                if (class_exists((string) $class) && (is_countable(class_parents($class)) ? count(class_parents($class)) : 0) > 0 && array_values(class_parents($class))[0] === TestCase::class) { // @phpstan-ignore-line

                    $message .= '. Did you forget to use the [uses()] function? Read more at: https://pestphp.com/docs/configuring-tests';

                }
<?php use Pest\Support\Coverage;

use Symfony\Component\Console\Output\ConsoleOutput;



it('has plugin')->assertTrue(class_exists(CoveragePlugin::class));



it('adds coverage if --coverage exist', function () {

    $plugin = new CoveragePlugin(new ConsoleOutput());
<?php });



it('exists')

    ->assertTrue(class_exists(Container::class));



it('gets an instance', function () {

    $this->container->add(Container::class, $this->container);