Changeset View
Changeset View
Standalone View
Standalone View
src/parser/xhpast/api/XHPASTNode.php
Show First 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | switch ($this->getTypeName()) { | ||||
default: | default: | ||||
throw new Exception(pht('Unexpected type %s.', $this->getTypeName())); | throw new Exception(pht('Unexpected type %s.', $this->getTypeName())); | ||||
} | } | ||||
// We extract just the variable names and ignore properties and array keys. | // We extract just the variable names and ignore properties and array keys. | ||||
$re = '/\\\\.|(\$|\{\$|\${)([a-z_\x7F-\xFF][a-z0-9_\x7F-\xFF]*)/i'; | $re = '/\\\\.|(\$|\{\$|\${)([a-z_\x7F-\xFF][a-z0-9_\x7F-\xFF]*)/i'; | ||||
$matches = null; | $matches = null; | ||||
preg_match_all($re, $value, $matches, PREG_OFFSET_CAPTURE); | 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() { | public function getStringLiteralValue() { | ||||
if ($this->getTypeName() != 'n_STRING_SCALAR') { | if ($this->getTypeName() != 'n_STRING_SCALAR') { | ||||
return null; | return null; | ||||
} | } | ||||
$value = $this->getSemanticString(); | $value = $this->getSemanticString(); | ||||
▲ Show 20 Lines • Show All 127 Lines • Show Last 20 Lines |