php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #61465 class_alias cannot create alias for standard class
Submitted: 2012-03-21 14:32 UTC Modified: 2013-10-09 06:07 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:0 (0.0%)
From: php at shark dot kom dot cz Assigned: krakjoe (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.10 OS: Debian
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: php at shark dot kom dot cz
New email:
PHP Version: OS:

 

 [2012-03-21 14:32 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-21 14:43 UTC] cataphract@php.net
-Type: Bug +Type: Feature/Change Request
 [2012-03-22 05:51 UTC] laruence@php.net
-Package: SPL related +Package: Documentation problem
 [2012-03-22 05:51 UTC] laruence@php.net
This should be doc bug.
 [2012-03-22 05:52 UTC] laruence@php.net
doc should doc that class_alias can only create a alias for user defined class
 [2012-03-22 08:06 UTC] php at shark dot kom dot cz
OK, that shall be DOC bug. But why it can't alias standard classes? I'd like to alias them.
 [2013-10-09 06:07 UTC] krakjoe@php.net
Automatic comment from SVN on behalf of krakjoe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=331737
Log: #61465 adjust description for clarity
 [2013-10-09 06:07 UTC] krakjoe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 [2013-10-09 06:07 UTC] krakjoe@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 12 05:01:35 2024 UTC