Skip to content

Method visibility issue introduced in version 8.3.8 #14480

Closed
@aurimasrim

Description

@aurimasrim

Description

The following code:

<?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
The code is a simplified piece of code from a popular PHP framework API platform

PHP Version

PHP 8.3.8

Operating System

Ubuntu 22.04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions