|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #70643 Allow update of class alias
Submitted: 2015-10-05 14:40 UTC Modified: -
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: remyfox at hotmail dot com Assigned:
Status: Open Package: Class/Object related
PHP Version: Next Major Version OS: irrelevant
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-10-05 14:40 UTC] remyfox at hotmail dot com
Since a class alias is assigned during run time, I suppose it would make sense to allow a class alias's update.

Use case:
E.g. in a system where multiple classes of different code versions (temporarily) exist to ensure backward compatibility when importing a number of updates. The versions of the class could all be put in separate temporarily generated uniquely named namespaces. During the execution of the updates, the class alias could be updated once it reaches an update which needs to use a newer version of a class that was also used by previous updates - albeit in an older state.

Might be a good idea to include this in PHP 7. It seems like a small enhancement.

Test script:
class A {}
class B {}

class_alias("A", "X");

class_alias("B", "X");

Expected result:
Class alias X becomes B's alias.

Actual result:
Fatal error: Cannot redeclare class A


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu May 23 15:01:32 2019 UTC