php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54532 class_alias and type hint
Submitted: 2011-04-14 14:52 UTC Modified: 2011-04-19 21:48 UTC
From: david at grudl dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3.6 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: david at grudl dot com
New email:
PHP Version: OS:

 

 [2011-04-14 14:52 UTC] david at grudl dot com
Description:
------------
class_alias() is not taken into account by type hints.

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

class A
{
	function foo(A $param) {
	}

}

class_alias('A', 'AliasA');

eval(' 
	class B extends A
	{
		function foo(AliasA $param) {
		}

	}
');

Expected result:
----------------
no error

Actual result:
--------------
Strict Standards: Declaration of B::foo() should be compatible with that of A::foo() 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-14 15:25 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2011-04-14 15:25 UTC] felipe@php.net
This is an error in parsing-time, the alias in this point was not created yet... So we cannot use the alias name in the type hint.
 [2011-04-14 17:13 UTC] david at grudl dot com
No, alias was created, I have used eval(). Or put second class in extra file and 
use include, result is the same.
 [2011-04-19 21:48 UTC] david at grudl dot com
Please, re-open this bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC