[php-src] Issue #14480: Method visibility issue introduced in version 8.3.8
| From: | aurimasrim | Date: | Wed, 05 Jun 2024 11:29:50 +0000 |
| Subject: | [php-src] Issue #14480: Method visibility issue introduced in version 8.3.8 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247037@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/14480
Author: aurimasrim
### Description
**The following code:**
```php
<?php
trait PropertyHelperTrait
{
protected function splitPropertyParts(): void
{
}
}
trait OrmPropertyHelperTrait
{
abstract protected function splitPropertyParts(): void;
protected function addJoinsForNestedProperty(): void
{
$this->splitPropertyParts();
}
}
trait SearchFilterTrait
{
use PropertyHelperTrait;
}
abstract class AbstractFilter
{
use OrmPropertyHelperTrait, PropertyHelperTrait;
public function apply(): void
{
$this->filterProperty();
}
abstract protected function filterProperty(): void;
}
class SearchFilter extends AbstractFilter
{
use SearchFilterTrait;
protected function filterProperty(): void
{
$this->addJoinsForNestedProperty();
}
}
class FilterExtension
{
public function applyToCollection(): void
{
(new SearchFilter())->apply();
}
}
(new FilterExtension)->applyToCollection();
```
**Resulted in this output:**
```
Fatal error: Uncaught Error: Call to protected method SearchFilter::splitPropertyParts() from scope
AbstractFilter in /in/ZsLJ0:16
Stack trace:
#0 /in/ZsLJ0(42): AbstractFilter->addJoinsForNestedProperty()
#1 /in/ZsLJ0(31): SearchFilter->filterProperty()
#2 /in/ZsLJ0(50): AbstractFilter->apply()
#3 /in/ZsLJ0(54): FilterExtension->applyToCollection()
#4 {main}
thrown in /in/ZsLJ0 on line 16
```
**But I expected this output instead:**
It should produce no errors
**More info:**
Our CI started to fail today without changes from our side. It uses the latest PHP patch version
which now is 8.3.8.
This code succeeds in PHP 8.3.7
It can be reproduced [here](https://3v4l.org/ZsLJ0#v838)
The code is a simplified piece of code from a popular PHP framework [API
platform](https://github.com/api-platform/core)
### PHP Version
PHP 8.3.8
### Operating System
Ubuntu 22.04