php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67128 class_alias is broken with abstract classes
Submitted: 2014-04-24 13:50 UTC Modified: 2016-04-16 13:47 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: mail at adrianlang dot de Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.5.11 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
28 + 13 = ?
Subscribe to this entry?

 
 [2014-04-24 13:50 UTC] 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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-16 13:47 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2016-04-16 13:47 UTC] nikic@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 23:01:29 2024 UTC