mirror of
https://github.com/pestphp/pest.git
synced 2026-03-08 08:47:22 +01:00
feat: warnings support
This commit is contained in:
@ -39,20 +39,17 @@ final class HigherOrderTapProxy
|
||||
*/
|
||||
public function __get(string $property)
|
||||
{
|
||||
try {
|
||||
return $this->target->{$property}; // @phpstan-ignore-line
|
||||
} catch (Throwable $throwable) { // @phpstan-ignore-line
|
||||
Reflection::setPropertyValue($throwable, 'file', Backtrace::file());
|
||||
Reflection::setPropertyValue($throwable, 'line', Backtrace::line());
|
||||
|
||||
if (Str::startsWith($message = $throwable->getMessage(), self::UNDEFINED_PROPERTY)) {
|
||||
/** @var ReflectionClass $reflection */
|
||||
$reflection = (new ReflectionClass($this->target))->getParentClass();
|
||||
Reflection::setPropertyValue($throwable, 'message', sprintf('Undefined property %s::$%s', $reflection->getName(), $property));
|
||||
}
|
||||
|
||||
throw $throwable;
|
||||
if (property_exists($this->target, $property)) {
|
||||
return $this->target->{$property};
|
||||
}
|
||||
|
||||
$className = (new ReflectionClass($this->target))->getName();
|
||||
|
||||
if (str_starts_with($className, "P\\")) {
|
||||
$className = substr($className, 2);
|
||||
}
|
||||
|
||||
trigger_error(sprintf('Undefined property %s::$%s', $className, $property), E_USER_WARNING);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user