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 $name = $type->getName();
if (is_subclass_of($name, \BackedEnum::class)) {
return $name;
}
}
<?php $isRenderless = $this->component->getAttributes()
->filter(fn ($i) => is_subclass_of($i, BaseRenderless::class))
->filter(fn ($i) => $i->getName() === $method)
->filter(fn ($i) => $i->getLevel() === AttributeLevel::METHOD)
->count() > 0;
<?php $typeName = $type->getName();
if (! is_subclass_of($typeName, Form::class)) continue;
$form = new $typeName(
$this->component,
<?php public function shouldIsolate()
{
return $this->component->getAttributes()
->filter(fn ($i) => is_subclass_of($i, BaseIsolate::class))
->count() > 0;
}
}
<?php $attributes = $params['attributes'] ?? [];
unset($params['attributes']);
if (is_subclass_of($view, \Illuminate\View\Component::class)) {
$layout = app()->makeWith($view, $params);
$view = $layout->resolveView()->name();
} else {
<?php $class = str($uses)->before('@')->toString();
$method = str($uses)->after('@')->toString();
if (is_subclass_of($class, \Livewire\Component::class) && $method === '__invoke') {
return $class;
}
}
<?php {
$subTarget = $this->getSubTarget();
return $subTarget && is_subclass_of($subTarget, Form::class);
}
public function urlName()
<?php $to = $this->storeGet('redirect');
$usingNavigate = $this->storeGet('redirectUsingNavigate');
if (is_subclass_of($to, Component::class)) {
$to = url()->action($to);
}
<?php {
public function assertRedirect($uri = null)
{
if (is_subclass_of($uri, Component::class)) {
$uri = url()->action($uri);
}
<?php $traces = debug_backtrace(options: DEBUG_BACKTRACE_IGNORE_ARGS, limit: 10);
foreach ($traces as $trace) {
if (is_subclass_of($trace['class'], TestCase::class)) {
return [$trace['class'], $trace['function']];
}
}
<?php {
\Illuminate\Testing\TestResponse::macro('assertSeeLivewire', function ($component) {
if (is_subclass_of($component, Component::class)) {
$component = app(ComponentRegistry::class)->getName($component);
}
$escapedComponentName = trim(htmlspecialchars(json_encode(['name' => $component])), '{}');
<?php \Illuminate\Testing\TestResponse::macro('assertDontSeeLivewire', function ($component) {
if (is_subclass_of($component, Component::class)) {
$component = app(ComponentRegistry::class)->getName($component);
}
$escapedComponentName = trim(htmlspecialchars(json_encode(['name' => $component])), '{}');
<?php if (class_exists(\Illuminate\Testing\TestView::class)) {
\Illuminate\Testing\TestView::macro('assertSeeLivewire', function ($component) {
if (is_subclass_of($component, Component::class)) {
$component = app(ComponentRegistry::class)->getName($component);
}
$escapedComponentName = trim(htmlspecialchars(json_encode(['name' => $component])), '{}');
<?php });
\Illuminate\Testing\TestView::macro('assertDontSeeLivewire', function ($component) {
if (is_subclass_of($component, Component::class)) {
$component = app(ComponentRegistry::class)->getName($component);
}
$escapedComponentName = trim(htmlspecialchars(json_encode(['name' => $component])), '{}');
<?php $class = $this->generateClassFromName($name);
if (class_exists($class) && is_subclass_of($class, Component::class)) {
return true;
}