mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Merge branch 'PHP-8.3'
* PHP-8.3: Fix incorrect inheritance of private trait methods (#14163)
This commit is contained in:
commit
c5982c961d
38
Zend/tests/gh14009_005.phpt
Normal file
38
Zend/tests/gh14009_005.phpt
Normal file
@ -0,0 +1,38 @@
|
||||
--TEST--
|
||||
GH-14009: Traits inherit prototype
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
trait T {
|
||||
private function test($s) {
|
||||
echo $s . " -> ". __CLASS__ . "::" . __METHOD__ . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
class A {
|
||||
use T;
|
||||
public function foo() {
|
||||
$this->test(__METHOD__);
|
||||
}
|
||||
public function bar() {
|
||||
$this->test(__METHOD__);
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
use T;
|
||||
public function foo() {
|
||||
$this->test(__METHOD__);
|
||||
}
|
||||
}
|
||||
|
||||
(new A)->foo();
|
||||
(new A)->bar();
|
||||
(new B)->foo();
|
||||
(new B)->bar();
|
||||
?>
|
||||
--EXPECT--
|
||||
A::foo -> A::T::test
|
||||
A::bar -> A::T::test
|
||||
B::foo -> B::T::test
|
||||
A::bar -> A::T::test
|
@ -2024,7 +2024,8 @@ static void zend_add_trait_method(zend_class_entry *ce, zend_string *name, zend_
|
||||
do_inheritance_check_on_method(
|
||||
fn, fixup_trait_scope(fn, ce), existing_fn, fixup_trait_scope(existing_fn, ce),
|
||||
ce, NULL,
|
||||
ZEND_INHERITANCE_CHECK_PROTO | ZEND_INHERITANCE_CHECK_VISIBILITY | ZEND_INHERITANCE_SET_CHILD_PROTO |
|
||||
ZEND_INHERITANCE_CHECK_PROTO | ZEND_INHERITANCE_CHECK_VISIBILITY |
|
||||
ZEND_INHERITANCE_SET_CHILD_CHANGED| ZEND_INHERITANCE_SET_CHILD_PROTO |
|
||||
ZEND_INHERITANCE_RESET_CHILD_OVERRIDE);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user