php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63592 class alias are not used/resolved by type hinting
Submitted: 2012-11-23 21:36 UTC Modified: 2012-11-23 21:49 UTC
From: frederic dot hardy at mageekbox dot net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.4.9 OS: macos X mountain lion
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: frederic dot hardy at mageekbox dot net
New email:
PHP Version: OS:

 

 [2012-11-23 21:36 UTC] frederic dot hardy at mageekbox dot net
Description:
------------
Imagine that you have a A class.
Imagine that you have an alias B on this A class.
Imagine that you have a function/method which require a B as argument.
So, currently, it's not possible to pass a A instance as argument to this 
function/method.

Test script:
---------------
<?php

class A {}
class_alias('A', 'B');
function foo(B $b) {}
foo(new A());

Expected result:
----------------
Nothing.

Actual result:
--------------
PHP Catchable fatal error:  Argument 1 passed to foo() must be an instance of B, 
instance of A given, called in /path/to/test/file.php on line 6 and defined in 
/path/to/test/file.php on line 5


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-23 21:49 UTC] felipe@php.net
-Status: Open +Status: Not a bug
 [2012-11-23 21:49 UTC] felipe@php.net
19:48 @ mageekguy >> you can close my bug report, seems that i made a mistake in 
                     my script
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu May 08 07:01:27 2025 UTC