Skip to content

Commit f43fa59

Browse files
committed
Add various tests for GH-10168
1 parent 915b283 commit f43fa59

25 files changed

+624
-0
lines changed

Zend/tests/gh10168/assign.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
GH-10168: Assign
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
function __destruct() {
8+
$GLOBALS['a'] = null;
9+
}
10+
}
11+
12+
$a = new Test;
13+
var_dump($a = new Test);
14+
15+
?>
16+
--EXPECT--
17+
object(Test)#2 (0) {
18+
}

Zend/tests/gh10168/assign_dim.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
GH-10168: Assign dim
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
function __destruct() {
8+
$GLOBALS['a'] = null;
9+
}
10+
}
11+
12+
$a = [new Test];
13+
var_dump($a[0] = new Test);
14+
15+
?>
16+
--EXPECT--
17+
object(Test)#2 (0) {
18+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
GH-10168: Assign dim ref
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
function __destruct() {
8+
$GLOBALS['a'] = null;
9+
}
10+
}
11+
12+
$a = [new Test];
13+
$tmp = new Test;
14+
var_dump($a[0] = &$tmp);
15+
16+
?>
17+
--EXPECT--
18+
object(Test)#2 (0) {
19+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-10168: Assign dim ref with prop ref
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
static ?Test $test;
8+
9+
function __destruct() {
10+
$GLOBALS['a'] = null;
11+
}
12+
}
13+
14+
$a = [new Test];
15+
Test::$test = &$a[0];
16+
$tmp = new Test;
17+
var_dump($a[0] = &$tmp);
18+
19+
?>
20+
--EXPECT--
21+
object(Test)#2 (0) {
22+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
GH-10168: Assign dim with prop ref
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
static ?Test $test;
8+
9+
function __destruct() {
10+
$GLOBALS['a'] = null;
11+
}
12+
}
13+
14+
$a = [new Test];
15+
Test::$test = &$a[0];
16+
var_dump($a[0] = new Test);
17+
18+
?>
19+
--EXPECT--
20+
object(Test)#2 (0) {
21+
}

Zend/tests/gh10168/assign_prop.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
GH-10168: Assign prop
3+
--XFAIL--
4+
--FILE--
5+
<?php
6+
7+
class Box {
8+
public ?Test $value;
9+
}
10+
11+
class Test {
12+
function __destruct() {
13+
global $box;
14+
$box->value = null;
15+
}
16+
}
17+
18+
function test($box) {
19+
var_dump($box->value = new Test);
20+
}
21+
22+
$box = new Box();
23+
$box->value = new Test;
24+
test($box);
25+
// Second call tests the cache slot path
26+
test($box);
27+
28+
?>
29+
--EXPECT--
30+
object(Test)#3 (0) {
31+
}
32+
object(Test)#3 (0) {
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
GH-10168: Assign prop ref
3+
--XFAIL--
4+
--FILE--
5+
<?php
6+
7+
class Box {
8+
public ?Test $value;
9+
}
10+
11+
class Test {
12+
function __destruct() {
13+
global $box;
14+
$box->value = null;
15+
}
16+
}
17+
18+
function test($box) {
19+
$tmp = new Test;
20+
var_dump($box->value = &$tmp);
21+
}
22+
23+
$box = new Box();
24+
$box->value = new Test;
25+
test($box);
26+
// Second call tests the cache slot path
27+
test($box);
28+
29+
?>
30+
--EXPECT--
31+
NULL
32+
object(Test)#2 (0) {
33+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
GH-10168: Assign prop ref with prop ref
3+
--XFAIL--
4+
--FILE--
5+
<?php
6+
7+
class Box {
8+
public ?Test $value;
9+
}
10+
11+
class Test {
12+
static ?Test $test;
13+
14+
function __destruct() {
15+
global $box;
16+
$box->value = null;
17+
}
18+
}
19+
20+
function test($box) {
21+
$tmp = new Test;
22+
var_dump($box->value = &$tmp);
23+
}
24+
25+
$box = new Box();
26+
$box->value = new Test;
27+
Test::$test = &$box->value;
28+
test($box);
29+
// Second call tests the cache slot path
30+
test($box);
31+
32+
?>
33+
--EXPECT--
34+
object(Test)#3 (0) {
35+
}
36+
NULL
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
GH-10168: Assign prop with prop ref
3+
--XFAIL--
4+
--FILE--
5+
<?php
6+
7+
class Box {
8+
public ?Test $value;
9+
}
10+
11+
class Test {
12+
static ?Test $test;
13+
14+
function __destruct() {
15+
global $box;
16+
$box->value = null;
17+
}
18+
}
19+
20+
function test($box) {
21+
var_dump($box->value = new Test);
22+
}
23+
24+
$box = new Box();
25+
$box->value = new Test;
26+
Test::$test = &$box->value;
27+
test($box);
28+
// Second call tests the cache slot path
29+
test($box);
30+
31+
?>
32+
--EXPECT--
33+
object(Test)#3 (0) {
34+
}
35+
object(Test)#3 (0) {
36+
}

Zend/tests/gh10168/assign_ref.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
GH-10168: Assign ref
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
function __destruct() {
8+
$GLOBALS['a'] = null;
9+
}
10+
}
11+
12+
$a = new Test;
13+
$tmp = new Test;
14+
var_dump($a = &$tmp);
15+
16+
?>
17+
--EXPECT--
18+
NULL
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-10168: Assign ref with prop ref
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
static ?Test $test;
8+
9+
function __destruct() {
10+
$GLOBALS['a'] = null;
11+
}
12+
}
13+
14+
$a = new Test;
15+
$tmp = new Test;
16+
var_dump($a = &$tmp);
17+
18+
?>
19+
--EXPECT--
20+
NULL
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-10168: Assign static prop
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
static ?Test $test;
8+
9+
function __destruct() {
10+
Test::$test = null;
11+
}
12+
}
13+
14+
Test::$test = new Test;
15+
var_dump(Test::$test = new Test);
16+
17+
?>
18+
--EXPECT--
19+
object(Test)#2 (0) {
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-10168: Assign static prop ref
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
static ?Test $test;
8+
9+
function __destruct() {
10+
Test::$test = null;
11+
}
12+
}
13+
14+
Test::$test = new Test;
15+
$tmp = new Test;
16+
var_dump(Test::$test = &$tmp);
17+
18+
?>
19+
--EXPECT--
20+
NULL
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
GH-10168: Assign static prop ref with prop ref
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
static ?Test $test;
8+
static ?Test $test2;
9+
10+
function __destruct() {
11+
Test::$test = null;
12+
}
13+
}
14+
15+
Test::$test = new Test;
16+
Test::$test2 = &Test::$test;
17+
$tmp = new Test;
18+
var_dump(Test::$test = &$tmp);
19+
20+
?>
21+
--EXPECT--
22+
object(Test)#2 (0) {
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-10168: Assign static prop with prop ref
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
static ?Test $test;
8+
static ?Test $test2;
9+
10+
function __destruct() {
11+
Test::$test = null;
12+
}
13+
}
14+
15+
Test::$test = new Test;
16+
Test::$test2 = &Test::$test;
17+
var_dump(Test::$test = new Test);
18+
19+
?>
20+
--EXPECT--
21+
object(Test)#2 (0) {
22+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-10168: Assign static prop
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
static $test;
8+
9+
function __destruct() {
10+
Test::$test = null;
11+
}
12+
}
13+
14+
Test::$test = new Test;
15+
var_dump(Test::$test = new Test);
16+
17+
?>
18+
--EXPECT--
19+
object(Test)#2 (0) {
20+
}

0 commit comments

Comments
 (0)