Skip to content

Commit ef8c8ea

Browse files
committed
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: Fixed bug #64417 (ArrayAccess::&offsetGet() in a trait causes fatal error) Conflicts: NEWS Zend/zend_compile.c
2 parents f621f0b + e62bb03 commit ef8c8ea

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

Zend/tests/bug64417.phpt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
Bug #64417 (BC break: ArrayAccess::&offsetGet() in a trait causes fatal error)
3+
--FILE--
4+
<?php
5+
trait aa {
6+
private $container = array();
7+
public function offsetSet($offset, $value) {
8+
if (is_null($offset)) {
9+
$this->container[] = $value;
10+
} else {
11+
$this->container[$offset] = $value;
12+
}
13+
}
14+
public function offsetExists($offset) {
15+
return isset($this->container[$offset]);
16+
}
17+
public function offsetUnset($offset) {
18+
unset($this->container[$offset]);
19+
}
20+
public function &offsetGet($offset) {
21+
$result = null;
22+
if (isset($this->container[$offset])) {
23+
$result = &$this->container[$offset];
24+
}
25+
return $result;
26+
}
27+
}
28+
29+
class obj implements ArrayAccess {
30+
use aa;
31+
}
32+
33+
$o = new obj;
34+
$o['x'] = 1;
35+
++$o['x'];
36+
echo $o['x'], "\n";
37+
--EXPECT--
38+
2
39+

Zend/zend_compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3831,7 +3831,7 @@ static zend_bool zend_traits_method_compatibility_check(zend_function *fn, zend_
38313831
zend_uint other_flags = other_fn->common.scope->ce_flags;
38323832

38333833
return zend_do_perform_implementation_check(fn, other_fn TSRMLS_CC)
3834-
&& zend_do_perform_implementation_check(other_fn, fn TSRMLS_CC)
3834+
&& ((other_fn->common.scope->ce_flags & ZEND_ACC_INTERFACE) || zend_do_perform_implementation_check(other_fn, fn TSRMLS_CC))
38353835
&& ((fn_flags & (ZEND_ACC_FINAL|ZEND_ACC_STATIC)) ==
38363836
(other_flags & (ZEND_ACC_FINAL|ZEND_ACC_STATIC))); /* equal final and static qualifier */
38373837
}

0 commit comments

Comments
 (0)