Skip to content

Commit ee7d35c

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix phpGH-14480: Method visibility issue introduced in version 8.3.8 (php#14484)
2 parents 9e1a1c1 + 86b93bc commit ee7d35c

File tree

2 files changed

+66
-4
lines changed

2 files changed

+66
-4
lines changed

Zend/tests/gh14480.phpt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
--TEST--
2+
GH-14480: Method visibility issue
3+
--FILE--
4+
<?php
5+
trait PropertyHelperTrait
6+
{
7+
protected function splitPropertyParts(): void
8+
{
9+
echo "OK\n";
10+
}
11+
}
12+
13+
trait OrmPropertyHelperTrait
14+
{
15+
abstract protected function splitPropertyParts(): void;
16+
17+
protected function addJoinsForNestedProperty(): void
18+
{
19+
$this->splitPropertyParts();
20+
}
21+
}
22+
23+
trait SearchFilterTrait
24+
{
25+
use PropertyHelperTrait;
26+
}
27+
28+
abstract class AbstractFilter
29+
{
30+
use OrmPropertyHelperTrait, PropertyHelperTrait;
31+
32+
public function apply(): void
33+
{
34+
$this->filterProperty();
35+
}
36+
37+
abstract protected function filterProperty(): void;
38+
}
39+
40+
class SearchFilter extends AbstractFilter
41+
{
42+
use SearchFilterTrait;
43+
protected function filterProperty(): void
44+
{
45+
$this->addJoinsForNestedProperty();
46+
}
47+
}
48+
49+
class FilterExtension
50+
{
51+
public function applyToCollection(): void
52+
{
53+
(new SearchFilter())->apply();
54+
}
55+
}
56+
57+
(new FilterExtension)->applyToCollection();
58+
?>
59+
--EXPECT--
60+
OK

Zend/zend_inheritance.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,12 +2018,14 @@ static void zend_add_trait_method(zend_class_entry *ce, zend_string *name, zend_
20182018
if (check_inheritance) {
20192019
/* Inherited members are overridden by members inserted by traits.
20202020
* Check whether the trait method fulfills the inheritance requirements. */
2021+
uint32_t flags = ZEND_INHERITANCE_CHECK_PROTO | ZEND_INHERITANCE_CHECK_VISIBILITY;
2022+
if (!(existing_fn->common.scope->ce_flags & ZEND_ACC_TRAIT)) {
2023+
flags |= ZEND_INHERITANCE_SET_CHILD_CHANGED |ZEND_INHERITANCE_SET_CHILD_PROTO |
2024+
ZEND_INHERITANCE_RESET_CHILD_OVERRIDE;
2025+
}
20212026
do_inheritance_check_on_method(
20222027
fn, fixup_trait_scope(fn, ce), existing_fn, fixup_trait_scope(existing_fn, ce),
2023-
ce, NULL,
2024-
ZEND_INHERITANCE_CHECK_PROTO | ZEND_INHERITANCE_CHECK_VISIBILITY |
2025-
ZEND_INHERITANCE_SET_CHILD_CHANGED| ZEND_INHERITANCE_SET_CHILD_PROTO |
2026-
ZEND_INHERITANCE_RESET_CHILD_OVERRIDE);
2028+
ce, NULL, flags);
20272029
}
20282030
}
20292031
/* }}} */

0 commit comments

Comments
 (0)