getMessage(), self::UNDEFINED_METHOD)) { $message = str_replace(self::UNDEFINED_METHOD, 'Call to undefined method ', $message); Reflection::setPropertyValue($throwable, 'message', $message); } throw $throwable; } } /** * Removes any item from the stack trace referencing Pest so as not to * crowd the error log for the end user. */ public static function removePestReferences(Throwable $t): void { if (!property_exists($t, 'serializableTrace')) { return; } $property = new ReflectionProperty($t, 'serializableTrace'); $property->setAccessible(true); /** @var array> $trace */ $trace = $property->getValue($t); $cleanedTrace = []; foreach ($trace as $item) { if (key_exists('file', $item) && mb_strpos($item['file'], 'vendor/pestphp/pest/') > 0) { continue; } $cleanedTrace[] = $item; } $property->setValue($t, $cleanedTrace); } }