Bug #79731 [NEW]: Public abstract method on trait fulfilled by private method

From: Date: Wed, 24 Jun 2020 19:47:27 +0000
Subject: Bug #79731 [NEW]: Public abstract method on trait fulfilled by private method
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227637@lists.php.net to get a copy of this message
From: donatj at gmail dot com Operating system: All PHP version: master-Git-2020-06-24 (Git) Package: Scripting Engine problem Bug Type: Bug Bug description:Public abstract method on trait fulfilled by private method Description: ------------ A public abstract method declaration on a trait is fulfilled by a private method on a 'use'-ing class. This seems like an incorrect behaviour. You can see on https://3v4l.org/a65oD that the problem exists even in git-master It is inconsistent with abstract classes or interfaces. Test script: --------------- <?php trait ATrait { abstract public function foo( string $url ) : int; } class AClass { use ATrait; private function foo( string $url ) : int { return 10; } } Expected result: ---------------- Behave either like interfaces: "Fatal error: Access type for interface method ATrait::foo() must be omitted in - on line 4" Similar to interfaces OR like an abstract class: "Fatal error: Access level to ATrait::foo() must be public (as in class ParentClass) in - on line 8" Actual result: -------------- No error -- Edit bug report at https://bugs.php.net/bug.php?id=79731&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79731&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79731&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79731&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79731&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79731&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79731&r=support Expected behavior: https://bugs.php.net/fix.php?id=79731&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79731&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79731&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79731&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79731&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79731&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79731&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79731&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79731&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79731&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79731&r=mysqlcfg

« previous php.bugs (#227637) next »