Bug #81683 [Ver->Csd]: Misleading "access type ... must be public" interface method error message
Edit report at https://bugs.php.net/bug.php?id=81683&edit=1
ID: 81683
Updated by: ilutov@php.net
Reported by: requinix@php.net
Summary: Misleading "access type ... must be public"
interface method error message
-Status: Verified
+Status: Closed
Type: Bug
Package: Class/Object related
PHP Version: 8.1.0
Assigned To: ilutov
Block user comment: N
Private report: N
New Comment:
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at
http://www.php.net/downloads.php
Will be fixed in PHP 8.1.2. Thanks for the report!
Previous Comments:
------------------------------------------------------------------------
[2021-12-05 02:49:18] requinix@php.net
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 02:04:48] camporter1 at gmail dot com
Seems like this might have been due to https://github.com/php/php-src/pull/7086 ?
Perhaps the final and abstract keywords should have a separate message for clarity?
------------------------------------------------------------------------
[2021-12-01 09:50:34] requinix@php.net
Description:
------------
https://github.com/php/php-src/blob/PHP-8.1.0/Zend/zend_compile.c#L7036
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.
https://3v4l.org/otUKp
Test script:
---------------
<?php
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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81683&edit=1
Thread (5 messages)