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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mail at adrianlang dot de
New email:
PHP Version: OS:

 

 [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 19 22:01:28 2024 UTC