is_subclass_of

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Checks if the object has this class as one of its parents or implements it
<?php is_subclass_of(mixed $object_or_class, string $class, bool $allow_string = true): bool
<?php         }



        foreach ($this->policies as $expected => $policy) {

            if (is_subclass_of($class, $expected)) {

                return $this->resolvePolicy($policy);

            }

        }
<?php     public function mapInto($class)

    {

        if (is_subclass_of($class, BackedEnum::class)) {

            return $this->map(fn ($value, $key) => $class::from($value));

        }
<?php     protected function parseCommand($command, $parameters)

    {

        if (is_subclass_of($command, SymfonyCommand::class)) {

            $callingClass = true;



            $command = $this->laravel->make($command)->getName();
<?php     public function resolve($command)

    {

        if (is_subclass_of($command, SymfonyCommand::class) && ($commandName = $command::getDefaultName())) {

            foreach (explode('|', $commandName) as $name) {

                $this->commandMap[$name] = $command;

            }
<?php         $this->fireBeforeCallbackArray($abstract, $parameters, $this->globalBeforeResolvingCallbacks);



        foreach ($this->beforeResolvingCallbacks as $type => $callbacks) {

            if ($type === $abstract || is_subclass_of($abstract, $type)) {

                $this->fireBeforeCallbackArray($abstract, $parameters, $callbacks);

            }

        }
<?php                 $enumClass = $this->arguments[0];



                return new ArrayObject((new Collection($data))->map(function ($value) use ($enumClass) {

                    return is_subclass_of($enumClass, BackedEnum::class)

                        ? $enumClass::from($value)

                        : constant($enumClass.'::'.$value);

                })->toArray());
<?php                 $enumClass = $this->arguments[0];



                return (new Collection($data))->map(function ($value) use ($enumClass) {

                    return is_subclass_of($enumClass, BackedEnum::class)

                        ? $enumClass::from($value)

                        : constant($enumClass.'::'.$value);

                });
<?php     protected function getEnumCaseFromValue($enumClass, $value)

    {

        return is_subclass_of($enumClass, BackedEnum::class)

                ? $enumClass::from($value)

                : constant($enumClass.'::'.$value);

    }
<?php             $arguments = explode(',', $segments[1]);

        }



        if (is_subclass_of($castType, Castable::class)) {

            $castType = $castType::castUsing($arguments);

        }
<?php             return static::$globalScopes[static::class][spl_object_hash($scope)] = $scope;

        } elseif ($scope instanceof Scope) {

            return static::$globalScopes[static::class][get_class($scope)] = $scope;

        } elseif (is_string($scope) && class_exists($scope) && is_subclass_of($scope, Scope::class)) {

            return static::$globalScopes[static::class][$scope] = new $scope;

        }
<?php         $class ??= static::class;



        foreach (static::$ignoreTimestampsOn as $ignoredClass) {

            if ($class === $ignoredClass || is_subclass_of($class, $ignoredClass)) {

                return true;

            }

        }
<?php         }



        foreach (static::$ignoreOnTouch as $ignoredClass) {

            if ($class === $ignoredClass || is_subclass_of($class, $ignoredClass)) {

                return true;

            }

        }
<?php         foreach (Finder::create()->in($paths)->files() as $file) {

            $command = $this->commandClassFromFile($file, $namespace);



            if (is_subclass_of($command, Command::class) &&

                ! (new ReflectionClass($command))->isAbstract()) {

                Artisan::starting(function ($artisan) use ($command) {

                    $artisan->resolve($command);
<?php     protected function newModelFor($table)

    {

        return is_subclass_of($table, Model::class) ? (new $table) : null;

    }
<?php             return $table;

        }



        if (is_subclass_of($table, Model::class)) {

            $model = new $table;



            if (str_contains($model->getTable(), '.')) {