Skip to content

Commit 2b8d9d4

Browse files
committed
Add separate static property through trait if parent already declares it
Closes GH-10935
1 parent 2ba3c99 commit 2b8d9d4

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Zend/tests/gh10935.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
GH-1093: Add separate static property through trait if parent already declares it
3+
--FILE--
4+
<?php
5+
trait Foo {
6+
static $test;
7+
}
8+
9+
class A {
10+
use Foo;
11+
}
12+
13+
class B extends A {
14+
use Foo;
15+
}
16+
17+
A::$test = 'A';
18+
B::$test = 'B';
19+
var_dump(A::$test, B::$test);
20+
?>
21+
--EXPECT--
22+
string(1) "A"
23+
string(1) "B"

Zend/zend_inheritance.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2377,7 +2377,9 @@ static void zend_do_traits_property_binding(zend_class_entry *ce, zend_class_ent
23772377
ZSTR_VAL(prop_name),
23782378
ZSTR_VAL(ce->name));
23792379
}
2380-
continue;
2380+
if (!(flags & ZEND_ACC_STATIC)) {
2381+
continue;
2382+
}
23812383
}
23822384
}
23832385

0 commit comments

Comments
 (0)