File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #72598 (Reference is lost after array_slice())
3
+ --FILE--
4
+ <?php
5
+ function ref (&$ ref ) {
6
+ var_dump ($ ref );
7
+ }
8
+
9
+ new class {
10
+ function __construct () {
11
+ $ args = [&$ this ];
12
+ for ($ i = 0 ; $ i < 2 ; $ i ++) {
13
+ $ a = array_slice ($ args , 0 , 1 );
14
+ call_user_func_array ('ref ' , $ a );
15
+ }
16
+ }
17
+ };
18
+ ?>
19
+ --EXPECTF--
20
+ Warning: Parameter 1 to ref() expected to be a reference, value given in %sbug72598.php on line 11
21
+ object(class@anonymous)#1 (0) {
22
+ }
23
+
24
+ Warning: Parameter 1 to ref() expected to be a reference, value given in %sbug72598.php on line 11
25
+ object(class@anonymous)#1 (0) {
26
+ }
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #72598.2 (Reference is lost after array_slice())
3
+ --FILE--
4
+ <?php
5
+ function ref (&$ ref ) {
6
+ var_dump ($ ref );
7
+ $ ref = 1 ;
8
+ }
9
+
10
+ new class {
11
+ function __construct () {
12
+ $ b = 0 ;
13
+ $ args = [&$ b ];
14
+ unset($ b );
15
+ for ($ i = 0 ; $ i < 2 ; $ i ++) {
16
+ $ a = array_slice ($ args , 0 , 1 );
17
+ call_user_func_array ('ref ' , $ a );
18
+ }
19
+ }
20
+ };
21
+ ?>
22
+ --EXPECTF--
23
+ Warning: Parameter 1 to ref() expected to be a reference, value given in %sbug72598_2.php on line 14
24
+ int(0)
25
+
26
+ Warning: Parameter 1 to ref() expected to be a reference, value given in %sbug72598_2.php on line 14
27
+ int(0)
You can’t perform that action at this time.
0 commit comments