├── www ├── .hhconfig ├── index.php ├── xhp │ ├── php-lib │ │ ├── init.php │ │ ├── html.php │ │ └── core.php │ ├── tests │ │ ├── logical-op.phpt │ │ ├── whitespace-03.phpt │ │ ├── whitespace-02.phpt │ │ ├── whitespace-07.phpt │ │ ├── attr-blank.phpt │ │ ├── whitespace-04.phpt │ │ ├── whitespace-06.phpt │ │ ├── attr-entity.phpt │ │ ├── whitespace-01.phpt │ │ ├── whitespace-05.phpt │ │ ├── attr-float.phpt │ │ ├── presumptous.phpt │ │ ├── attr-callable.phpt │ │ ├── attr-quotes.phpt │ │ ├── class.phpt │ │ ├── script-fastpath.php │ │ ├── stack-balance-fail.phpt │ │ ├── apos-fastpath.phpt │ │ ├── array-constant.phpt │ │ ├── idx-01.phpt │ │ ├── class-constants.phpt │ │ ├── json_array.phpt │ │ ├── reflection-01.phpt │ │ ├── xhp-function-param.phpt │ │ ├── reflection-02.phpt │ │ ├── trait.phpt │ │ ├── lineno-02.phpt │ │ ├── reflection-07.phpt │ │ ├── attributes.phpt │ │ ├── reflection-06.phpt │ │ ├── syntax-error-lineno.phpt │ │ ├── xhp_preprocess_code.phpt │ │ ├── lineno-01.phpt │ │ ├── reflection-05.phpt │ │ ├── reflection-03.phpt │ │ ├── reflection-04.phpt │ │ ├── yield-03.phpt │ │ ├── anonymous_function.phpt │ │ ├── yield-01.phpt │ │ ├── new_call.phpt │ │ ├── finally.phpt │ │ ├── reflection-08.phpt │ │ ├── yield-02.phpt │ │ ├── array-types.phpt │ │ ├── idx-04.phpt │ │ ├── xhp_comment.phpt │ │ ├── lib.php │ │ ├── idx-03.phpt │ │ ├── heredoc.phpt │ │ └── idx-02.phpt │ ├── Makefile.frag │ ├── config.m4 │ ├── xhp │ │ ├── Makefile │ │ ├── xhp_preprocess.hpp │ │ ├── code_rope.hpp │ │ ├── fastpath.hpp │ │ ├── xhpize.cpp │ │ ├── xhp_preprocess.cpp │ │ ├── code_rope.cpp │ │ ├── xhp.hpp │ │ ├── fastpath.re │ │ └── scanner.l │ ├── INSTALL │ ├── ext.hpp │ ├── LICENSE.ZEND │ ├── LICENSE.PHP │ ├── README.textile │ └── ext.cpp ├── hello │ └── index.php ├── collections │ └── index.php ├── type-checker │ └── index.php ├── attributes │ └── index.php ├── promotion │ └── index.php ├── types │ └── index.php └── hhxhp │ └── index.php ├── .gitignore ├── conf ├── php.ini ├── nginx-fastcgi └── config.hdf ├── Vagrantfile └── README.md /www/.hhconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | -------------------------------------------------------------------------------- /www/index.php: -------------------------------------------------------------------------------- 1 | ; 7 | --EXPECT-- 8 | 1 9 | -------------------------------------------------------------------------------- /www/xhp/tests/whitespace-03.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Whitespace 03 3 | --FILE-- 4 | {'a'} ; 7 | --EXPECT-- 8 | a 9 | -------------------------------------------------------------------------------- /www/xhp/tests/whitespace-02.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Whitespace 02 3 | --FILE-- 4 | {'a'}; 7 | --EXPECT-- 8 | a 9 | -------------------------------------------------------------------------------- /www/xhp/tests/whitespace-07.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Whitespace 07 3 | --FILE-- 4 | a{ 'b' }c ; 7 | --EXPECT-- 8 | abc 9 | -------------------------------------------------------------------------------- /www/xhp/tests/attr-blank.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Blank attribute 3 | --FILE-- 4 | ; 7 | echo "pass"; 8 | --EXPECT-- 9 | pass 10 | -------------------------------------------------------------------------------- /www/xhp/tests/whitespace-04.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Whitespace 04 3 | --FILE-- 4 | {'a'} ; 7 | --EXPECT-- 8 | a 9 | -------------------------------------------------------------------------------- /www/xhp/tests/whitespace-06.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Whitespace 06 3 | --FILE-- 4 | a { 'b' } c ; 7 | --EXPECT-- 8 | a b c 9 | -------------------------------------------------------------------------------- /www/xhp/tests/attr-entity.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Entities in attributes 3 | --FILE-- 4 | c; 7 | echo "pass"; 8 | --EXPECT-- 9 | pass 10 | -------------------------------------------------------------------------------- /www/xhp/tests/whitespace-01.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Whitespace 01 3 | --FILE-- 4 | 7 | 8 | . 9 | ; 10 | --EXPECT-- 11 | . 12 | -------------------------------------------------------------------------------- /www/xhp/tests/whitespace-05.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Whitespace 05 3 | --FILE-- 4 | 8 | foo 9 | ; 10 | --EXPECT-- 11 | foo 12 | -------------------------------------------------------------------------------- /www/xhp/tests/attr-float.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Float attribute parsing 3 | --FILE-- 4 | hi; 7 | echo "pass"; 8 | --EXPECT-- 9 | pass 10 | -------------------------------------------------------------------------------- /www/xhp/tests/attr-callable.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Callable attribute parsing 3 | --FILE-- 4 | c; 8 | --EXPECT-- 9 | c 10 | -------------------------------------------------------------------------------- /www/xhp/tests/class.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | XHP Classes 3 | --FILE-- 4 | bar;'); 7 | echo isset($foo['new_code']); 8 | --EXPECT-- 9 | 1 10 | -------------------------------------------------------------------------------- /www/xhp/tests/stack-balance-fail.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Stack Balance Fail 3 | --FILE-- 4 | ; 7 | function f() {} 8 | echo 'pass'; 9 | --EXPECT-- 10 | pass 11 | -------------------------------------------------------------------------------- /www/xhp/tests/apos-fastpath.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Apostrophe Fastpath 3 | --FILE-- 4 | Her\'s;foo(\'\');'); 7 | echo isset($foo['new_code']); 8 | --EXPECT-- 9 | 1 10 | -------------------------------------------------------------------------------- /www/xhp/tests/array-constant.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Constant in Array 3 | --FILE-- 4 | :foo::bar); 9 | echo $foo['etc']; 10 | --EXPECT-- 11 | pass 12 | -------------------------------------------------------------------------------- /www/xhp/tests/idx-01.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | XHP idx Expression 01 3 | --INI-- 4 | xhp.idx_expr=1 5 | --FILE-- 6 | 'etc', 10 | ); 11 | } 12 | echo foo()['bar']; 13 | --EXPECT-- 14 | etc 15 | -------------------------------------------------------------------------------- /www/xhp/Makefile.frag: -------------------------------------------------------------------------------- 1 | XHP_SHARED_DEPENDENCIES = $(srcdir)/xhp/libxhp.a 2 | XHP_SHARED_LIBADD := ${XHP_SHARED_LIBADD} 3 | $(srcdir)/ext.cpp: $(srcdir)/xhp/libxhp.a 4 | $(srcdir)/xhp/libxhp.a: FORCE 5 | $(MAKE) $(MFLAGS) -C $(srcdir)/xhp libxhp.a 6 | 7 | FORCE: 8 | -------------------------------------------------------------------------------- /www/xhp/tests/class-constants.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | XHP Class Attributes 3 | --FILE-- 4 | 7 | --FILE-- 8 | getDocComment(); 8 | exit; 9 | ; 10 | --EXPECT-- 11 | /** b */ 12 | -------------------------------------------------------------------------------- /www/xhp/tests/xhp-function-param.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | XHP Function Call Param 3 | --FILE-- 4 | )->exist(); 10 | echo 'pass'; 11 | --EXPECT-- 12 | pass 13 | -------------------------------------------------------------------------------- /www/xhp/tests/reflection-02.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Reflection API 02 3 | --FILE-- 4 | getDocComment(); 8 | exit; 9 | ; 10 | --EXPECT-- 11 | /** d */ 12 | -------------------------------------------------------------------------------- /www/xhp/tests/trait.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | PHP5.4 Traits work 3 | --FILE-- 4 | var; 16 | --EXPECT-- 17 | 5 -------------------------------------------------------------------------------- /www/hello/index.php: -------------------------------------------------------------------------------- 1 | 8 | 9 | {$hello}! 10 | 11 | 12 |

{$hello}

13 | 14 | ; 15 | -------------------------------------------------------------------------------- /www/xhp/tests/lineno-02.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Line Numbers 02 3 | --FILE-- 4 | » 7 | ; 8 | } 9 | 10 | function bar() { 11 | } 12 | 13 | $r = new ReflectionFunction('bar'); 14 | echo $r->getStartLine(); 15 | --EXPECT-- 16 | 7 17 | -------------------------------------------------------------------------------- /www/xhp/tests/reflection-07.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Reflection API 07 3 | --FILE-- 4 | getDocComment(); 11 | exit; 12 |
; 13 | --EXPECT-- 14 | -------------------------------------------------------------------------------- /www/xhp/tests/attributes.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | XHP attributes Declaration 3 | --FILE-- 4 | getDocComment(); 10 | exit; 11 | ; 12 | --EXPECT-- 13 | /** c */ 14 | -------------------------------------------------------------------------------- /www/xhp/tests/syntax-error-lineno.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Syntax Error Line Number 3 | --FILE-- 4 | ; 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | function foo() {}'); 17 | echo $foo['error_line']; 18 | --EXPECT-- 19 | 2 20 | -------------------------------------------------------------------------------- /www/xhp/tests/xhp_preprocess_code.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | xhp_preprocess_code 3 | --FILE-- 4 | getStartLine(); 13 | --EXPECT-- 14 | 6 15 | -------------------------------------------------------------------------------- /www/xhp/tests/reflection-05.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Reflection API 05 3 | --FILE-- 4 | getDocComment(); 10 | exit; 11 | ; 12 | --EXPECT-- 13 | /** d */ 14 | -------------------------------------------------------------------------------- /www/xhp/tests/reflection-03.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Reflection API 03 3 | --FILE-- 4 | getDocComment(); 10 | exit; 11 | ; 12 | --EXPECT-- 13 | /** c */ 14 | -------------------------------------------------------------------------------- /www/xhp/tests/reflection-04.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Reflection API 04 3 | --FILE-- 4 | getDocComment(); 10 | exit; 11 | ; 12 | --EXPECT-- 13 | /** d */ 14 | -------------------------------------------------------------------------------- /www/xhp/tests/yield-03.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | PHP5.5 Yield keyword 03 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | send(1); 15 | --EXPECT-- 16 | 1 -------------------------------------------------------------------------------- /www/xhp/tests/anonymous_function.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Anonymous Functions 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 7 | --FILE-- 8 | call() 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | call(); 16 | --EXPECT-- 17 | pass 18 | -------------------------------------------------------------------------------- /www/xhp/tests/finally.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | PHP5.5 Finally keyword 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getDocComment(); 9 | if ($comment == '/** e */') { 10 | $comment = '/** d */'; 11 | } 12 | echo $comment; 13 | exit; 14 | ; 15 | --EXPECT-- 16 | /** d */ 17 | -------------------------------------------------------------------------------- /www/xhp/tests/yield-02.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | PHP5.5 Yield keyword 02 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | $b; 13 | } 14 | foreach (yieldTest() as $c => $d) { 15 | echo $c; 16 | echo $d; 17 | } 18 | --EXPECT-- 19 | 12 -------------------------------------------------------------------------------- /www/xhp/tests/array-types.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Types in Array 3 | --FILE-- 4 | a, 9 | array b, 10 | array c, 11 | array d, 12 | array e, 13 | array f, 14 | array int> g, 15 | array string> h; 16 | } 17 | $x = ; 18 | echo 'pass'; 19 | --EXPECT-- 20 | pass 21 | -------------------------------------------------------------------------------- /www/xhp/config.m4: -------------------------------------------------------------------------------- 1 | PHP_ARG_ENABLE(xhp, xhp, 2 | [ --enable-xhp Enable XHP]) 3 | 4 | PHP_REQUIRE_CXX() 5 | if test "$PHP_XHP" = "yes"; then 6 | # XHP_SHARED_DEPENDENCIES="libxhp.a" 7 | PHP_ADD_LIBRARY(stdc++,, XHP_SHARED_LIBADD) 8 | PHP_SUBST(XHP_SHARED_LIBADD) 9 | PHP_NEW_EXTENSION(xhp, ext.cpp, $ext_shared) 10 | PHP_ADD_LIBRARY_WITH_PATH(xhp, $ext_srcdir/xhp/, XHP_SHARED_LIBADD) 11 | PHP_ADD_MAKEFILE_FRAGMENT 12 | fi 13 | -------------------------------------------------------------------------------- /www/xhp/tests/idx-04.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | XHP idx Expression 04 3 | --FILE-- 4 | ; 7 | echo 8 | 9 | 10 | ; 11 | echo 12 | 13 | a 14 | 18 | b 19 | 20 | cd 21 | 22 | ; 23 | echo ; 24 | --EXPECT-- 25 | a b cd 26 | -------------------------------------------------------------------------------- /www/xhp/tests/lib.php: -------------------------------------------------------------------------------- 1 | attrs = $attrs; 7 | $this->children = $children; 8 | } 9 | 10 | public function __toString() { 11 | $head = 'attrs as $key => $val) { 13 | $head .= ' '.htmlspecialchars($key).'="'.htmlspecialchars($val, ENT_QUOTES).'"'; 14 | } 15 | return $head.'>'.implode('', $this->children).''; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /www/xhp/tests/idx-03.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | XHP idx Expression 03 3 | --FILE-- 4 | 7 | EOF; 8 | 9 | // 5.2 doesn't support nowdoc so we can't put this in the test or else it will 10 | // fail. Instead we use xhp_preprocess_code to make sure nowdoc and binary 11 | // nowdocs can parse. 12 | $d = '$'; 13 | $code = << 17 | BAR; 18 | {$d}foo = b<<<'BAR' 19 | ?> 20 | BAR; 21 | if (0) ; 22 | EOF; 23 | 24 | $preprocess = xhp_preprocess_code($code); 25 | if (empty($preprocess['new_code'])) { 26 | echo "No nowdocs!"; 27 | } 28 | echo "pass"; 29 | --EXPECT-- 30 | pass 31 | -------------------------------------------------------------------------------- /www/xhp/tests/idx-02.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | XHP idx Expression 02 3 | --FILE-- 4 | add("a"); 7 | $v->reverse(); 8 | $v = $v->map(($_) ==> strtoupper($_))->filter(($_) ==> strcmp($_, "D") < 0); 9 | 10 | $items =