-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support goto, labels, add some missing flags to generated ast node
fix bug analyzing namespaces with properties. Emulate edge cases of php-ast for property visibility flags. Emulate the way php-ast parses a `list($x,) =` expression. Fix RETURNS_REF flag for global functions Copy test files from php-src which revealed new bugs
- Loading branch information
1 parent
e7dab48
commit e722c78
Showing
9 changed files
with
181 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
class test | ||
{ | ||
protected $_id; | ||
static $instances; | ||
|
||
public function __construct($id) { | ||
$this->_id = $id; | ||
self::$instances[$this->_id] = $this; | ||
} | ||
|
||
function __destruct() { | ||
unset(self::$instances[$this->_id]); | ||
} | ||
} | ||
$test = new test(2); | ||
$test = new test(1); | ||
$test = new test(2); | ||
$test = new test(3); | ||
echo "ok\n"; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
namespace foobar; | ||
|
||
class foo { | ||
public function bar(self $a) { } | ||
} | ||
|
||
$foo = new foo; | ||
$foo->bar($foo); // Ok! | ||
$foo->bar(new \stdclass); // Error, ok! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
function crash() { | ||
sin(...[0]); | ||
throw new \Exception(); | ||
yield; | ||
} | ||
|
||
iterator_to_array(crash()); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
function test() {} | ||
$iterator = new LimitIterator( | ||
new InfiniteIterator(new ArrayIterator([42])), | ||
0, 17000 | ||
); | ||
test(...$iterator); | ||
|
||
?> | ||
===DONE=== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
error_reporting(E_ALL); | ||
|
||
$a = array(); | ||
|
||
function &a() { | ||
return $GLOBALS['a']; | ||
} | ||
|
||
var_dump($h =& a()); | ||
$h[] = 1; | ||
var_dump(a()[0]); | ||
|
||
$h[] = array($h); | ||
var_dump(a()[1][0][0]); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
$array = [['a', 'b'], 'c', 'd']; | ||
|
||
foreach($array as $key => list()) { | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
namespace TestNamespace | ||
{ | ||
class TestClass | ||
{ | ||
public static function staticMethod() | ||
{ | ||
echo "Static method called!\n"; | ||
} | ||
|
||
public static function staticMethodWithArgs($arg1, $arg2, $arg3) | ||
{ | ||
printf("Static method called with args: %s, %s, %s\n", $arg1, $arg2, $arg3); | ||
} | ||
} | ||
} | ||
|
||
namespace CallNamespace | ||
{ | ||
// Test basic call using Class::method syntax. | ||
$callback = 'TestNamespace\TestClass::staticMethod'; | ||
$callback(); | ||
|
||
// Case should not matter. | ||
$callback = 'testnamespace\testclass::staticmethod'; | ||
$callback(); | ||
|
||
$args = ['arg1', 'arg2', 'arg3']; | ||
$callback = 'TestNamespace\TestClass::staticMethodWithArgs'; | ||
|
||
// Test call with args. | ||
$callback($args[0], $args[1], $args[2]); | ||
|
||
// Test call with splat operator. | ||
$callback(...$args); | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
goto a; | ||
e: return; | ||
try { | ||
a: print 1; | ||
goto b; | ||
try { | ||
b: print 2; | ||
goto c; | ||
} | ||
catch(Exception $e) { | ||
c: print 3; | ||
goto d; | ||
} | ||
} | ||
catch(Exception $e) { | ||
d: print 4; | ||
goto e; | ||
} | ||
?> |