Req #61465 [Opn]: class_alias cannot create alias for standard class
| From: | php at shark dot kom dot cz | Date: | Thu, 22 Mar 2012 08:06:43 +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-8104@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
User updated by: php at shark dot kom dot cz
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: Documentation problem
Operating System: Debian
PHP Version: 5.3.10
Block user comment: N
Private report: N
New Comment:
OK, that shall be DOC bug. But why it can't alias standard classes? I'd like to alias
them.
Previous Comments:
------------------------------------------------------------------------
[2012-03-22 05:52:27] laruence@php.net
doc should doc that class_alias can only create a alias for user defined class
------------------------------------------------------------------------
[2012-03-22 05:51:40] laruence@php.net
This should be doc bug.
------------------------------------------------------------------------
[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