Skip to content

Commit e62bb03

Browse files
committed
Fixed bug #64417 (ArrayAccess::&offsetGet() in a trait causes fatal error)
1 parent e25b2d7 commit e62bb03

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2013, PHP 5.4.14
44
- Core
5+
. Fixed bug #64417 (ArrayAccess::&offsetGet() in a trait causes fatal error).
6+
(Dmitry)
57
. Fixed bug #64370 (microtime(true) less than $_SERVER['REQUEST_TIME_FLOAT']).
68
(Anatol)
79

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
@@ -3634,7 +3634,7 @@ static zend_bool zend_traits_method_compatibility_check(zend_function *fn, zend_
36343634
zend_uint other_flags = other_fn->common.scope->ce_flags;
36353635

36363636
return zend_do_perform_implementation_check(fn, other_fn TSRMLS_CC)
3637-
&& zend_do_perform_implementation_check(other_fn, fn TSRMLS_CC)
3637+
&& ((other_fn->common.scope->ce_flags & ZEND_ACC_INTERFACE) || zend_do_perform_implementation_check(other_fn, fn TSRMLS_CC))
36383638
&& ((fn_flags & (ZEND_ACC_FINAL|ZEND_ACC_STATIC)) ==
36393639
(other_flags & (ZEND_ACC_FINAL|ZEND_ACC_STATIC))); /* equal final and static qualifier */
36403640
}

0 commit comments

Comments
 (0)