Bug #78517 [NEW]: Unable to connect two libraries where developer wants to return typehint
| From: | 6562680 at gmail dot com | Date: | Mon, 09 Sep 2019 10:23:03 +0000 |
| Subject: | Bug #78517 [NEW]: Unable to connect two libraries where developer wants to return typehint | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-222642@lists.php.net to get a copy of this message | ||
From: 6562680 at gmail dot com
Operating system: Win10
PHP version: 7.2.22
Package: Reflection related
Bug Type: Bug
Bug description:Unable to connect two libraries where developer wants to return typehint
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);
--
Edit bug report at https://bugs.php.net/bug.php?id=78517&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78517&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78517&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78517&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78517&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78517&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78517&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78517&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78517&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78517&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78517&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78517&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78517&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78517&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78517&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78517&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78517&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78517&r=mysqlcfg