Skip to content

Missing visibility check for private abstract trait methods #14156

Description

@iluuu1994

Description

The following code:

<?php

trait T {
    public abstract function test();
}

class P {
    private function test() {}
}

class C extends P {
    use T;
}

This passes without errors. There's an intentional BC layer that skips visibility checks for abstract trait methods (see Zend/tests/traits/abstract_method_4.phpt). However, this should not include private parent methods, because the trait cannot call those. The whole BC layer is questionable today, so it might be better to remove it entirely.

PHP Version

All supported branches

Operating System

No response

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