|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81683 Misleading "access type ... must be public" interface method error message
Submitted: 2021-12-01 09:50 UTC Modified: 2021-12-05 22:51 UTC
From: Assigned: ilutov (profile)
Status: Closed Package: Class/Object related
PHP Version: 8.1.0 OS:
Private report: No CVE-ID: None
 [2021-12-01 09:50 UTC]

When PHP encounters an interface with a method declared non-public, it errors that the "access type for interface method %s must be public" (or "omitted" for <8.1). This is fine. But it also uses that same error message for public methods that include the final or abstract keywords, which is confusing.

Test script:

interface Foo {
    public abstract function bar();


Expected result:
Fatal error: [something about Foo::bar being marked abstract/final] in /in/otUKp on line 4

Actual result:
Fatal error: Access type for interface method Foo::bar() must be public in /in/otUKp on line 4


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-12-05 02:04 UTC] camporter1 at gmail dot com
Seems like this might have been due to ?

Perhaps the final and abstract keywords should have a separate message for clarity?
 [2021-12-05 02:49 UTC]
Even before that PR, the message used the words "access type" when the fault could be in just the final/abstract keywords: you could add or remove a "public" like the message suggests and continue getting the same error.

To fix, the message could be changed like "Interface method %s must be public, not final, and not abstract". Or the if could be split into separate public and final/abstract checks with separate error messages.
 [2021-12-05 19:24 UTC]
-Assigned To: +Assigned To: ilutov
 [2021-12-05 19:24 UTC]
-Status: Assigned +Status: Verified
 [2021-12-05 22:51 UTC]
-Status: Verified +Status: Closed
 [2021-12-05 22:51 UTC]
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at

Will be fixed in PHP 8.1.2. Thanks for the report!
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 20:01:32 2024 UTC