Bug #67128 [Opn->Nab]: class_alias is broken with abstract classes
| From: | nikic@php.net | Date: | Sat, 16 Apr 2016 13:47:11 +0000 |
| Subject: | Bug #67128 [Opn->Nab]: class_alias is broken with abstract classes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-200593@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67128&edit=1
ID: 67128
Updated by: nikic@php.net
Reported by: mail at adrianlang dot de
Summary: class_alias is broken with abstract classes
-Status: Open
+Status: Not a bug
Type: Bug
Package: Class/Object related
PHP Version: 5.5.11
Block user comment: N
Private report: N
New Comment:
The issue here is that the classes are early-bound, so the alias does not exist at the point in time
when the method signatures are verified. You can fix this by defining the classes in a different
file or forcing late binding.
Previous Comments:
------------------------------------------------------------------------
[2014-04-24 13:50:01] mail at adrianlang dot de
Description:
------------
While verifying the signature of a class against the signature of an abstract class it extends,
apparently class aliases are not correctly taken into account. This works if the class implements an
interface or extends a non-abstract class.
See also https://github.com/facebook/hhvm/issues/2527.
Test script:
---------------
class A {}
class_alias( 'A', 'B' );
abstract class UserOfA {
abstract public function someMethod( B $a );
}
class ActualUserOfA extends UserOfA {
public function someMethod( A $a ) {
}
}
Actual result:
--------------
PHP Fatal error: Declaration of ActualUserOfA::someMethod() must be compatible with
UserOfA::someMethod(B $a)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67128&edit=1