Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
Fix static variable access from XHP classes
Browse files Browse the repository at this point in the history
Summary:
Currently you can't access static variables in an XHP class. "echo ❌:$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
Marcel Laverdet committed Nov 24, 2009
1 parent 9d49b01 commit 9b4bd8d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ext.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#endif #endif
#include "php.h" #include "php.h"


#define PHP_XHP_VERSION "1.3.5" #define PHP_XHP_VERSION "1.3.6"
#define PHP_XHP_EXTNAME "xhp" #define PHP_XHP_EXTNAME "xhp"


extern zend_module_entry xhp_module_entry; extern zend_module_entry xhp_module_entry;
Expand Down
4 changes: 4 additions & 0 deletions xhp/parser.y
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1856,13 +1856,17 @@ xhp_children_decl_tag:
// Make XHP classes usable anywhere you see a real class // Make XHP classes usable anywhere you see a real class
class_name: class_name:
T_XHP_COLON xhp_label_immediate { T_XHP_COLON xhp_label_immediate {
pop_state();
push_state(PHP);
yyextra->used = true; yyextra->used = true;
$$ = "xhp_" + $2; $$ = "xhp_" + $2;
} }
; ;


fully_qualified_class_name: fully_qualified_class_name:
T_XHP_COLON xhp_label_immediate { T_XHP_COLON xhp_label_immediate {
pop_state();
push_state(PHP);
yyextra->used = true; yyextra->used = true;
$$ = "xhp_" + $2; $$ = "xhp_" + $2;
} }
Expand Down
2 changes: 1 addition & 1 deletion xhp/scanner.l
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ NEWLINE ("\r\n"|"\n"|"\r")
switch (yyextra->last_token) { switch (yyextra->last_token) {
case ',': case '=': case '|': case '^': case '&': case '<': case '>': case ',': case '=': case '|': case '^': case '&': case '<': case '>':
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_LOGICAL_OR: case T_LOGICAL_XOR: case T_LOGICAL_AND:
case T_PLUS_EQUAL: case T_MINUS_EQUAL: case T_MUL_EQUAL: case T_PLUS_EQUAL: case T_MINUS_EQUAL: case T_MUL_EQUAL:
case T_DIV_EQUAL: case T_CONCAT_EQUAL: case T_MOD_EQUAL: case T_DIV_EQUAL: case T_CONCAT_EQUAL: case T_MOD_EQUAL:
Expand Down

0 comments on commit 9b4bd8d

Please sign in to comment.