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             if (str_contains($identifier, "@anonymous\0")) {

                $this->value = $identifier = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) {

                    return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0];

                }, $identifier);

            }
<?php         if (isset($a[Caster::PREFIX_PROTECTED.'message']) && str_contains($a[Caster::PREFIX_PROTECTED.'message'], "@anonymous\0")) {

            $a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) {

                return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0];

            }, $a[Caster::PREFIX_PROTECTED.'message']);

        }
<?php         if (isset($a[$prefix.'returnType'])) {

            $v = $a[$prefix.'returnType'];

            $v = $v instanceof \ReflectionNamedType ? $v->getName() : (string) $v;

            $a[$prefix.'returnType'] = new ClassStub($a[$prefix.'returnType'] instanceof \ReflectionNamedType && $a[$prefix.'returnType']->allowsNull() && 'mixed' !== $v ? '?'.$v : $v, [class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', '']);

        }

        if (isset($a[$prefix.'class'])) {

            $a[$prefix.'class'] = new ClassStub($a[$prefix.'class']);
<?php         if (isset($a[$prefix.'typeHint'])) {

            $v = $a[$prefix.'typeHint'];

            $a[$prefix.'typeHint'] = new ClassStub($v, [class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', '']);

        } else {

            unset($a[$prefix.'allowsNull']);

        }
<?php     public function testCastMemcachedWithDefaultOptions()

    {

        if (!class_exists(\Memcached::class)) {

            $this->markTestSkipped('Memcached not available');

        }
<?php     public function testCastMemcachedWithCustomOptions()

    {

        if (!class_exists(\Memcached::class)) {

            $this->markTestSkipped('Memcached not available');

        }
<?php     public function testComplete(array $input, array $expectedSuggestions)

    {

        if (!class_exists(CommandCompletionTester::class)) {

            $this->markTestSkipped('Test command completion requires symfony/console 5.4+.');

        }
<?php namespace Symfony\Component\VarDumper\Tests\Fixture;



if (!class_exists(\Symfony\Component\VarDumper\Tests\Fixture\DumbFoo::class)) {

    class DumbFoo

    {

        public $foo = 'foo';
<?php     {

        $contextProviders = [];



        if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && (class_exists(Request::class))) {

            $requestStack = new RequestStack();

            $requestStack->push(Request::createFromGlobals());

            $contextProviders['request'] = new RequestContextProvider($requestStack);
<?php             $contextProviders['request'] = new RequestContextProvider($requestStack);

        }



        $fileLinkFormatter = class_exists(FileLinkFormatter::class) ? new FileLinkFormatter(null, $requestStack ?? null) : null;



        return $contextProviders + [

            'cli' => new CliContextProvider(),