Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14400062
D13113.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D13113.diff
View Options
diff --git a/src/parser/xhpast/api/XHPASTNode.php b/src/parser/xhpast/api/XHPASTNode.php
--- a/src/parser/xhpast/api/XHPASTNode.php
+++ b/src/parser/xhpast/api/XHPASTNode.php
@@ -3,16 +3,10 @@
final class XHPASTNode extends AASTNode {
public function isStaticScalar() {
- switch ($this->getTypeName()) {
- case 'n_NUMERIC_SCALAR':
- return true;
-
- case 'n_STRING_SCALAR':
- return $this->checkIsConstantString(array('n_MAGIC_SCALAR'));
-
- default:
- return false;
- }
+ return in_array($this->getTypeName(), array(
+ 'n_STRING_SCALAR',
+ 'n_NUMERIC_SCALAR',
+ ));
}
public function getDocblockToken() {
@@ -39,12 +33,6 @@
return $this->getChildByIndex(0)->evalStatic();
break;
case 'n_STRING_SCALAR':
- if (!$this->checkIsConstantString()) {
- throw new Exception(
- pht(
- 'Non-constant scalar strings cannot be statically evaluated.'));
- }
-
return (string)$this->getStringLiteralValue();
case 'n_NUMERIC_SCALAR':
$value = $this->getSemanticString();
diff --git a/src/parser/xhpast/api/__tests__/XHPASTTreeTestCase.php b/src/parser/xhpast/api/__tests__/XHPASTTreeTestCase.php
--- a/src/parser/xhpast/api/__tests__/XHPASTTreeTestCase.php
+++ b/src/parser/xhpast/api/__tests__/XHPASTTreeTestCase.php
@@ -55,6 +55,9 @@
$this->assertEval(0, '0');
+ // Static evaluation treats '$' as a literal dollar glyph.
+ $this->assertEval('$asdf', '"$asdf"');
+
$this->assertEval(
'\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z'.
'\1\2\3\4\5\6\7\8\9\0'.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 6:36 PM (19 h, 18 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6921788
Default Alt Text
D13113.diff (1 KB)
Attached To
Mode
D13113: Revert "Don't consider strings with variables to be static"
Attached
Detach File
Event Timeline
Log In to Comment