mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-10 00:42:40 +01:00
(stable) Accommodate PHP 7.4 changes to certain "preg_match_all()" calls
Summary: Ref T13518. The result format of this call changed in PHP 7.4, which causes us to emit "-1" matches because "-1" survives `array_filter()`. Filter results in a way that should survive both result formats. Test Plan: Ran `arc unit --everything` under PHP 7.4. Maniphest Tasks: T13518 Differential Revision: https://secure.phabricator.com/D21173
This commit is contained in:
parent
c87880142b
commit
5efbe22c2a
1 changed files with 20 additions and 1 deletions
|
@ -163,7 +163,26 @@ final class XHPASTNode extends AASTNode {
|
|||
$re = '/\\\\.|(\$|\{\$|\${)([a-z_\x7F-\xFF][a-z0-9_\x7F-\xFF]*)/i';
|
||||
$matches = null;
|
||||
preg_match_all($re, $value, $matches, PREG_OFFSET_CAPTURE);
|
||||
return ipull(array_filter($matches[2]), 0, 1);
|
||||
|
||||
// NOTE: The result format for this construction changed in PHP 7.4.
|
||||
// See T13518.
|
||||
|
||||
$names = $matches[2];
|
||||
foreach ($names as $name_idx => $name_match) {
|
||||
if ($name_match === '') {
|
||||
unset($names[$name_idx]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($name_match[1] === -1) {
|
||||
unset($names[$name_idx]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$names = ipull($names, 0, 1);
|
||||
|
||||
return $names;
|
||||
}
|
||||
|
||||
public function getStringLiteralValue() {
|
||||
|
|
Loading…
Reference in a new issue