mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
Fix PhutilTypeSpec's regex handling for PHP 8
Summary: In previous versions, passing the wrong type to preg_match would give a warning that could be suppressed by @ and caught by set_error_handler, but as of PHP 8 this raises a TypeError and so remains uncaught. Thus check up-front whether the provided value is a string. This fixes linting arc itself when run with PHP 8, as includes and excludes use "optional regex | list<regex>", so would previously try to pass an array to preg_match for the first alternative and die. Test Plan: Ran arc lint Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin Maniphest Tasks: T13588 Differential Revision: https://secure.phabricator.com/D21499
This commit is contained in:
parent
446dcf1ccd
commit
0adef03fdf
1 changed files with 4 additions and 0 deletions
|
@ -75,6 +75,10 @@ final class PhutilTypeSpec extends Phobject {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'regex':
|
case 'regex':
|
||||||
|
if (!is_string($value)) {
|
||||||
|
throw new PhutilTypeCheckException($this, $value, $name);
|
||||||
|
}
|
||||||
|
|
||||||
$trap = new PhutilErrorTrap();
|
$trap = new PhutilErrorTrap();
|
||||||
$ok = @preg_match($value, '');
|
$ok = @preg_match($value, '');
|
||||||
$err = $trap->getErrorsAsString();
|
$err = $trap->getErrorsAsString();
|
||||||
|
|
Loading…
Reference in a new issue