Req #70643 [Opn->Wfx]: Allow update of class alias
| From: | nikic@php.net | Date: | Wed, 08 Jan 2020 16:01:36 +0000 |
| Subject: | Req #70643 [Opn->Wfx]: Allow update of class alias | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-224784@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70643&edit=1
ID: 70643
Updated by: nikic@php.net
Reported by: remyfox at hotmail dot com
Summary: Allow update of class alias
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Class/Object related
Operating System: irrelevant
PHP Version: Next Major Version
Block user comment: N
Private report: N
New Comment:
We're definitely not going to support this, as it makes inheritance checks unsound.
If you want to use the same library in multiple versions (or more typically, to avoid phar
conflicts) you might want to take a look at https://github.com/humbug/php-scoper.
Previous Comments:
------------------------------------------------------------------------
[2015-10-05 14:40:08] remyfox at hotmail dot com
Description:
------------
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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70643&edit=1