|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-09-30 13:01 UTC] kore@php.net
Description:
------------
Namespaces are not supported in type hints. Type hints with namespace result in an "Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM".
Reproduce code:
---------------
<?php
namespace foo;
class bar {}
class blubb
{
public function __construct( bar $bar ) {}
}
new blubb( new bar() );
Expected result:
----------------
No error.
Actual result:
--------------
Catchable fatal error: Argument 1 passed to foo::blubb::__construct( ) must be an instance of bar, instance of foo::bar given, called in ns_test.php on line 17 and defined in ns_test.php on line 11
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 06 17:00:01 2025 UTC |
I think the reporter is right and bar inside the declaration should resolve to foo::bar. And function(foo::bar $param) {} should be allowed, too. Dmitry please take a look, thanks.