Skip to content

A trait method with weaker visibility than the parent method it overrides is accepted (php: Access level to C::f() must be public) #421

Closed

Description

@blacktrs

Summary

A trait method with weaker visibility than the parent method it overrides is accepted (php: Access level to C::f() must be public).

Repro

<?php
class P { public function f(): int { return 1; } }
trait T { private function f(): int { return 2; } }
class C extends P { use T; }
echo "accepted\n";

Expected (php)

Actual (manticore 35461ba2, Darwin arm64)

accepted

Tracking

Known-bug repro: tests/aot/repro/wrong/trait_method_weaker_visibility_than_parent_accepted.php — bash tests/aot/xfail.sh -k trait_method_weaker_visibility_than_parent_accepted reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Activity

  1. added
    bug
    wrong-answer
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions