feat: reworks evalution of Test Case

This commit is contained in:
Nuno Maduro
2021-11-14 19:58:25 +00:00
parent cd34f0ba81
commit 4b213d63bd
26 changed files with 603 additions and 620 deletions

View File

@ -54,8 +54,7 @@ final class HigherOrderMessage
try {
return is_array($this->arguments)
? Reflection::call($target, $this->name, $this->arguments)
: $target->{$this->name};
/* @phpstan-ignore-line */
: $target->{$this->name}; /* @phpstan-ignore-line */
} catch (Throwable $throwable) {
Reflection::setPropertyValue($throwable, 'file', $this->filename);
Reflection::setPropertyValue($throwable, 'line', $this->line);

View File

@ -48,4 +48,14 @@ final class Str
return substr($target, -$length) === $search;
}
/**
* Makes the given string evaluable by an `eval`.
*/
public static function evaluable(string $code): string
{
$code = str_replace(' ', '_', $code);
return (string) preg_replace('/[^A-Z_a-z0-9\\\\]/', '', $code);
}
}