Req #61465 [Opn]: class_alias cannot create alias for standard class
| From: | laruence@php.net | Date: | Thu, 22 Mar 2012 05:51:40 +0000 |
| Subject: | Req #61465 [Opn]: class_alias cannot create alias for standard class | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-8102@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61465&edit=1
ID: 61465
Updated by: laruence@php.net
Reported by: php at shark dot kom dot cz
Summary: class_alias cannot create alias for standard class
Status: Open
Type: Feature/Change Request
-Package: SPL related
+Package: Documentation problem
Operating System: Debian
PHP Version: 5.3.10
Block user comment: N
Private report: N
New Comment:
This should be doc bug.
Previous Comments:
------------------------------------------------------------------------
[2012-03-21 14:32:17] php at shark dot kom dot cz
Description:
------------
Function class_alias cannot create alias for standard classes.
I'm using standard exceptions inspired by Java API for very long time. My exceptions was used
earlier than exceptions introduced by SPL. I'd like to use SPL's exceptions instead of my
exceptions in case they are defined, but I don't want to edit all codes to change exception
names used. Therefor I'd like to use class_alias to act SPL exceptions as exceptions expected
by applications.
Test script:
---------------
<?php
class_alias('InvalidArgumentException', 'IllegalArgumentException');
// Application
throw new IllegalArgumentException('Arg must be abcd')
Expected result:
----------------
thrown IllegalArgumentException
Actual result:
--------------
PHP Warning: First argument of class_alias() must be a name of user defined class in aliases.php:17
Fatal error: Class 'IllegalArgumentException' not found in aliases.php on line 28
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61465&edit=1