pestphp/pest · error · InvalidArgumentException
No class, trait or method named [%s] has been found.
Error message
No class, trait or method named [%s] has been found.
What it means
Error "No class, trait or method named [%s] has been found." thrown in pestphp/pest.
Source
Thrown at src/PendingCalls/TestCall.php:507
return $this;
}
/**
* @param array<int, string>|string $classesOrFunctions
*/
public function covers(array|string ...$classesOrFunctions): self
{
/** @var array<int, string> $classesOrFunctions */
$classesOrFunctions = array_reduce($classesOrFunctions, fn ($carry, $item): array => is_array($item) ? array_merge($carry, $item) : array_merge($carry, [$item]), []); // @pest-ignore-type
foreach ($classesOrFunctions as $classOrFunction) {
$isClass = class_exists($classOrFunction) || interface_exists($classOrFunction) || enum_exists($classOrFunction);
$isTrait = trait_exists($classOrFunction);
$isFunction = function_exists($classOrFunction);
if (! $isClass && ! $isTrait && ! $isFunction) {
throw new InvalidArgumentException(sprintf('No class, trait or method named [%s] has been found.', $classOrFunction));
}
if ($isClass) {
$this->coversClass($classOrFunction);
} elseif ($isTrait) {
$this->coversTrait($classOrFunction);
} else {
$this->coversFunction($classOrFunction);
}
}
return $this;
}
public function coversClass(string ...$classes): self
{
foreach ($classes as $class) {
$this->testCaseFactoryAttributes[] = new Attribute(View on GitHub (pinned to 1af74a215c)
When it happens
Trigger: Thrown at src/PendingCalls/TestCall.php:507 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pestphp/pest@1af74a215c (2026-08-21).
Data as JSON: /api/errors/0099aa64336679bf.
Report an issue: GitHub.