Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix static variable access from XHP classes

Summary:
Currently you can't access static variables in an XHP class. "echo :x::$foo" is
a syntax error.

Reviewed By: epriestley

Test Plan:
  marcel@dev050 ~/xhp $ cat test.php
  <?php
  class :fb:thing {
    public static $TEST = 1;
  }

  echo :fb:thing::$TEST."\n";
  (:fb:thing::$TEST = 2);
  echo :fb:thing::$TEST."\n";

  marcel@dev050 ~/xhp $ php test.php
  1
  2

Revert: OK
  • Loading branch information...
commit 9b4bd8d82b539514a8989d5b84dcc5c2bb7dd892 1 parent 9d49b01
@laverdet laverdet authored
Showing with 6 additions and 2 deletions.
  1. +1 −1  ext.hpp
  2. +4 −0 xhp/parser.y
  3. +1 −1  xhp/scanner.l
View
2  ext.hpp
@@ -4,7 +4,7 @@
#endif
#include "php.h"
-#define PHP_XHP_VERSION "1.3.5"
+#define PHP_XHP_VERSION "1.3.6"
#define PHP_XHP_EXTNAME "xhp"
extern zend_module_entry xhp_module_entry;
View
4 xhp/parser.y
@@ -1856,6 +1856,8 @@ xhp_children_decl_tag:
// Make XHP classes usable anywhere you see a real class
class_name:
T_XHP_COLON xhp_label_immediate {
+ pop_state();
+ push_state(PHP);
yyextra->used = true;
$$ = "xhp_" + $2;
}
@@ -1863,6 +1865,8 @@ class_name:
fully_qualified_class_name:
T_XHP_COLON xhp_label_immediate {
+ pop_state();
+ push_state(PHP);
yyextra->used = true;
$$ = "xhp_" + $2;
}
View
2  xhp/scanner.l
@@ -349,7 +349,7 @@ NEWLINE ("\r\n"|"\n"|"\r")
switch (yyextra->last_token) {
case ',': case '=': case '|': case '^': case '&': case '<': case '>':
case '+': case '-': case '%': case '!': case '~': case '[': case '(':
- case '{':
+ case '{': case '.':
case T_LOGICAL_OR: case T_LOGICAL_XOR: case T_LOGICAL_AND:
case T_PLUS_EQUAL: case T_MINUS_EQUAL: case T_MUL_EQUAL:
case T_DIV_EQUAL: case T_CONCAT_EQUAL: case T_MOD_EQUAL:
Please sign in to comment.
Something went wrong with that request. Please try again.