|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-09-09 10:24 UTC] 6562680 at gmail dot com
[2019-09-09 10:26 UTC] nikic@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: nikic
[2019-09-09 10:26 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 17 10:00:01 2025 UTC |
Description: ------------ Maybe i understand interfaces incorrect but i think that we: 1. Create library 2. Create interface inside library 3. Upload library somewhere (composer) 4. Require library to project 5. Create interface in project for library wrapper 6. Will check our own interface inside project - library should match both interfaces and return instance that match both interfaces But sometimes we need to extend library or just change some functions using `extend`. We want to change return type to our own interface and we cant, because return checker wont check interface, just compare strings Test script: --------------- <?php interface iA {}; class A implements iA { public function test() : self // public function test() : A // or maybe direct class // public function test() : iA // or maybe interface { return true; } } interface iB {}; class B extends A implements iB { // public function test() : self // wtf? incorrect // public function test() : B // wtf? incorrect // public function test() : iA // works but requires `use` everywhere public function test() : A // works but requires `use` everywhere { return true; } } var_dump(new B);