}
if (!$this->stringIsRegex($pattern)) {
- $pattern = '/' . preg_quote($pattern, '/') . '/';
+ $pattern = '/' . \preg_quote($pattern, '/') . '/';
}
if ($insensitive = $input->getOption('insensitive')) {
*/
public function match($string, array &$matches = null)
{
- return $this->filter === false || (preg_match($this->pattern, $string, $matches) xor $this->invert);
+ return $this->filter === false || (\preg_match($this->pattern, $string, $matches) xor $this->invert);
}
/**
*/
private function stringIsRegex($string)
{
- return substr($string, 0, 1) === '/' && substr($string, -1) === '/' && strlen($string) >= 3;
+ return \substr($string, 0, 1) === '/' && \substr($string, -1) === '/' && \strlen($string) >= 3;
}
/**
*/
private function validateRegex($pattern)
{
- set_error_handler(['Psy\Exception\ErrorException', 'throwException']);
+ \set_error_handler(['Psy\Exception\ErrorException', 'throwException']);
try {
- preg_match($pattern, '');
+ \preg_match($pattern, '');
} catch (ErrorException $e) {
- throw new RuntimeException(str_replace('preg_match(): ', 'Invalid regular expression: ', $e->getRawMessage()));
+ \restore_error_handler();
+ throw new RuntimeException(\str_replace('preg_match(): ', 'Invalid regular expression: ', $e->getRawMessage()));
}
- restore_error_handler();
+ \restore_error_handler();
}
}