Skip to content

Commit 899a1ed

Browse files
committed
Merge branch 'ast'
Conflicts: Zend/zend_compile.c
2 parents af59e92 + 6db293d commit 899a1ed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+10456
-8197
lines changed

Zend/tests/024.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var_dump($a++);
1111
var_dump(++$b);
1212
var_dump($a->$b);
1313
var_dump($a->$b);
14-
var_dump($a->$b->$c[1]);
14+
var_dump($a->$b->{$c[1]});
1515

1616
?>
1717
--EXPECTF--

Zend/tests/bug27669.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Bug #27669 (PHP 5 didn't support all possibilities for calling static methods dy
1010
}
1111
}
1212
$y[0] = 'hello';
13-
A::$y[0]();
13+
A::{$y[0]}();
1414
?>
1515
===DONE===
1616
--EXPECTF--

Zend/tests/bug30080.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ class foo {
1010

1111
new foo(array(new stdClass));
1212
?>
13-
--EXPECT--
13+
--EXPECTF--
1414
array(1) {
1515
[0]=>
16-
object(stdClass)#2 (0) {
16+
object(stdClass)#%d (0) {
1717
}
1818
}

Zend/tests/bug39304.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ echo "I am alive";
99
--EXPECTF--
1010
Notice: Uninitialized string offset: 0 in %sbug39304.php on line %d
1111

12-
Notice: Uninitialized string offset: 1 in %sbug39304.php on line %d
13-
1412
Notice: Uninitialized string offset: 0 in %sbug39304.php on line %d
13+
14+
Notice: Uninitialized string offset: 1 in %sbug39304.php on line %d
1515
I am alive
1616

Zend/tests/bug39304_2_4.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Bug #39304 (Segmentation fault with list unpacking of string offset)
1111
--EXPECTF--
1212
Notice: Uninitialized string offset: 0 in %sbug39304_2_4.php on line %d
1313

14-
Notice: Uninitialized string offset: 1 in %sbug39304_2_4.php on line %d
15-
1614
Notice: Uninitialized string offset: 0 in %sbug39304_2_4.php on line %d
15+
16+
Notice: Uninitialized string offset: 1 in %sbug39304_2_4.php on line %d
1717
string(0) ""
1818
string(0) ""

Zend/tests/bug43450.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ class Foo
1818

1919
$num_repeats = 100000;
2020

21-
$start = (memory_get_usage() / 1024) + 16;
21+
$start = memory_get_usage() / 1024;
2222
for ($i=1;$i<$num_repeats;$i++)
2323
{
2424
$foo = new Foo();
2525
md5($foo);
2626
}
27-
$end = memory_get_peak_usage() / 1024;
27+
$end = memory_get_usage() / 1024;
2828

29-
if ($start < $end) {
29+
if ($start + 16 < $end) {
3030
echo 'FAIL';
3131
} else {
3232
echo 'PASS';

Zend/tests/bug44414.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ class C extends A implements B {
1212
}
1313
?>
1414
--EXPECTF--
15-
Fatal error: Class C contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (A::foo, B::bar) in %sbug44414.php on line 9
15+
Fatal error: Class C contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (A::foo, B::bar) in %sbug44414.php on line 8

Zend/tests/bug55007.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Bug #55007 (compiler fail after previous fail)
44
<?php
55

66
function __autoload($classname) {
7-
if ('CompileErrorClass'==$classname) eval('class CompileErrorClass { function foo() { $a[] } }');
7+
if ('CompileErrorClass'==$classname) eval('class CompileErrorClass { function foo() { $a[]; } }');
88
if ('MyErrorHandler'==$classname) eval('class MyErrorHandler { function __construct() { print "My error handler runs.\n"; } }');
99
}
1010

Zend/tests/bug60099.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ namespace foo {
77

88
?>
99
--EXPECTF--
10-
Fatal error: __HALT_COMPILER() can only be used from the outermost scope in %s on line %d
10+
Parse error: syntax error, unexpected end of file in %s on line %d

Zend/tests/declare_001.phpt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ zend.multibyte=1
1313

1414
declare(encoding = 1);
1515
declare(encoding = 112313123213131232100);
16-
declare(encoding = NULL);
1716
declare(encoding = 'utf-8');
1817
declare(encoding = M_PI);
1918

@@ -25,6 +24,4 @@ Warning: Unsupported encoding [1] in %sdeclare_001.php on line %d
2524

2625
Warning: Unsupported encoding [1.1231312321313E+20] in %sdeclare_001.php on line %d
2726

28-
Warning: Unsupported encoding [] in %sdeclare_001.php on line %d
29-
30-
Fatal error: Cannot use constants as encoding in %sdeclare_001.php on line %d
27+
Fatal error: Encoding must be a literal in %s on line %d

Zend/tests/declare_003.phpt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ zend.multibyte=1
88

99
declare(encoding = 1);
1010
declare(encoding = 11111111111111);
11-
declare(encoding = NULL);
1211
declare(encoding = M_PI);
1312

1413
print 'DONE';
@@ -19,6 +18,4 @@ Warning: Unsupported encoding [1] in %sdeclare_003.php on line %d
1918

2019
Warning: Unsupported encoding [11111111111111] in %sdeclare_003.php on line %d
2120

22-
Warning: Unsupported encoding [] in %sdeclare_003.php on line %d
23-
24-
Fatal error: Cannot use constants as encoding in %sdeclare_003.php on line %d
21+
Fatal error: Encoding must be a literal in %s on line %d

Zend/tests/errmsg_014.phpt

Lines changed: 0 additions & 17 deletions
This file was deleted.

Zend/tests/foreach_list_002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ foreach (array(array(1,2), array(3,4)) as list($a, )) {
99

1010
$array = [['a', 'b'], 'c', 'd'];
1111

12-
foreach($array as list(list(), $a)) {
12+
foreach($array as list(, $a)) {
1313
var_dump($a);
1414
}
1515

Zend/tests/isset_003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var_dump(isset($a[0]->a));
1414

1515
var_dump(isset($c[0][1][2]->a->b->c->d));
1616

17-
var_dump(isset(${$a}->{$b->$c[$d]}));
17+
var_dump(isset(${$a}->{$b->{$c[$d]}}));
1818

1919
var_dump(isset($GLOBALS));
2020

Zend/tests/isset_003_2_4.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var_dump(isset($a[0]->a));
1616

1717
var_dump(isset($c[0][1][2]->a->b->c->d));
1818

19-
var_dump(isset(${$a}->{$b->$c[$d]}));
19+
var_dump(isset(${$a}->{$b->{$c[$d]}}));
2020

2121
var_dump(isset($GLOBALS));
2222

Zend/tests/isset_func_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Error message for isset(func())
55
isset(abc());
66
?>
77
--EXPECTF--
8-
Fatal error: Cannot use isset() on the result of a function call (you can use "null !== func()" instead) in %s on line %d
8+
Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in %s on line %d

Zend/tests/list_005.phpt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@ Testing list() with several variables
33
--FILE--
44
<?php
55

6-
$a = "foo";
6+
$str = "foo";
77

8-
list($a, $b, $c) = $a;
8+
list($a, $b, $c) = $str;
99

1010
var_dump($a, $b, $c);
1111

1212
print "----\n";
1313

14-
$a = 1;
14+
$int = 1;
1515

16-
list($a, $b, $c) = $a;
16+
list($a, $b, $c) = $int;
1717

1818
var_dump($a, $b, $c);
1919

2020
print "----\n";
2121

22-
$a = new stdClass;
22+
$obj = new stdClass;
2323

24-
list($a, $b, $c) = $a;
24+
list($a, $b, $c) = $obj;
2525

2626
var_dump($a, $b, $c);
2727

2828
print "----\n";
2929

30-
$a = array(1, 2, 3);
30+
$arr = array(1, 2, 3);
3131

32-
list($a, $b, $c) = $a;
32+
list($a, $b, $c) = $arr;
3333

3434
var_dump($a, $b, $c);
3535

Zend/tests/list_006.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ list($a, list($b, list(list($d)))) = array();
77

88
?>
99
--EXPECTF--
10-
Notice: Undefined offset: 1 in %s on line %d
10+
Notice: Undefined offset: 0 in %s on line %d
1111

1212
Notice: Undefined offset: 1 in %s on line %d
13-
14-
Notice: Undefined offset: 0 in %s on line %d

Zend/tests/use_const/no_global_fallback.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ var_dump(baz);
1010

1111
?>
1212
--EXPECTF--
13-
Notice: Use of undefined constant baz - assumed 'baz' in %s on line %d
14-
string(3) "baz"
13+
Fatal error: Undefined constant 'foo\bar\baz' in %s on line %d
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Global keyword only accepts simple variables
3+
--FILE--
4+
<?php
5+
6+
global $$foo->bar;
7+
8+
?>
9+
--EXPECTF--
10+
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ',' or ';' in %s on line %d
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
--TEST--
2+
Indirect function calls
3+
--FILE--
4+
<?php
5+
6+
function id($x = 'id') { return $x; }
7+
8+
var_dump(0);
9+
10+
id('var_dump')(1);
11+
id('id')('var_dump')(2);
12+
id('id')('id')('var_dump')(3);
13+
id()()('var_dump')(4);
14+
15+
id(['udef', 'id'])[1]()('var_dump')(5);
16+
(id((object) ['a' => 'id', 'b' => 'udef'])->a)()()()()('var_dump')(6);
17+
18+
$id = function($x) { return $x; };
19+
20+
$id($id)('var_dump')(7);
21+
22+
(function($x) { return $x; })('id')('var_dump')(8);
23+
24+
($f = function($x = null) use (&$f) {
25+
return $x ?: $f;
26+
})()()()('var_dump')(9);
27+
28+
class Test {
29+
public static function id($x = [__CLASS__, 'id']) { return $x; }
30+
}
31+
32+
$obj = new Test;
33+
[$obj, 'id']()('id')($id)('var_dump')(10);
34+
['Test', 'id']()()('var_dump')(11);
35+
'id'()('id')('var_dump')(12);
36+
('i' . 'd')()('var_dump')(13);
37+
38+
?>
39+
--EXPECT--
40+
int(0)
41+
int(1)
42+
int(2)
43+
int(3)
44+
int(4)
45+
int(5)
46+
int(6)
47+
int(7)
48+
int(8)
49+
int(9)
50+
int(10)
51+
int(11)
52+
int(12)
53+
int(13)

Zend/tests/varSyntax/issetOnTemp.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
isset() can be used on dereferences of temporary expressions
3+
--FILE--
4+
<?php
5+
6+
var_dump(isset([0, 1][0]));
7+
var_dump(isset(([0, 1] + [])[0]));
8+
var_dump(isset([[0, 1]][0][0]));
9+
var_dump(isset(([[0, 1]] + [])[0][0]));
10+
var_dump(isset(((object) ['a' => 'b'])->a));
11+
var_dump(isset(['a' => 'b']->a));
12+
var_dump(isset("str"->a));
13+
var_dump(isset((['a' => 'b'] + [])->a));
14+
var_dump(isset((['a' => 'b'] + [])->a->b));
15+
16+
?>
17+
--EXPECT--
18+
bool(true)
19+
bool(true)
20+
bool(true)
21+
bool(true)
22+
bool(true)
23+
bool(false)
24+
bool(false)
25+
bool(false)
26+
bool(false)

Zend/tests/varSyntax/newVariable.phpt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
Variable as class name for new expression
3+
--FILE--
4+
<?php
5+
6+
$className = 'stdClass';
7+
$array = ['className' => 'stdClass'];
8+
$obj = (object) ['className' => 'stdClass'];
9+
10+
class Test {
11+
public static $className = 'stdClass';
12+
}
13+
$test = 'Test';
14+
$weird = [0 => (object) ['foo' => 'Test']];
15+
16+
var_dump(new $className);
17+
var_dump(new $array['className']);
18+
var_dump(new $array{'className'});
19+
var_dump(new $obj->className);
20+
var_dump(new Test::$className);
21+
var_dump(new $test::$className);
22+
var_dump(new $weird[0]->foo::$className);
23+
24+
?>
25+
--EXPECTF--
26+
object(stdClass)#%d (0) {
27+
}
28+
object(stdClass)#%d (0) {
29+
}
30+
object(stdClass)#%d (0) {
31+
}
32+
object(stdClass)#%d (0) {
33+
}
34+
object(stdClass)#%d (0) {
35+
}
36+
object(stdClass)#%d (0) {
37+
}
38+
object(stdClass)#%d (0) {
39+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Dereferencing expression parentheses
3+
--FILE--
4+
<?php
5+
6+
$array = [&$array, 1];
7+
var_dump(($array)[1]);
8+
var_dump((($array[0][0])[0])[1]);
9+
10+
var_dump(((object) ['a' => 0, 'b' => 1])->b);
11+
12+
$obj = (object) ['a' => 0, 'b' => ['var_dump', 1]];
13+
(clone $obj)->b[0](1);
14+
15+
?>
16+
--EXPECT--
17+
int(1)
18+
int(1)
19+
int(1)
20+
int(1)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Cannot take property of a string
3+
--FILE--
4+
<?php
5+
6+
"foo"->bar;
7+
8+
?>
9+
--EXPECTF--
10+
Notice: Trying to get property of non-object in %s on line %d

0 commit comments

Comments
 (0)