php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42802 Namespace not supported in typehints
Submitted: 2007-09-30 13:01 UTC Modified: 2007-10-01 10:38 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: kore@php.net Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2007-09-30 (CVS) OS: Linux 2.6.21
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: kore@php.net
New email:
PHP Version: OS:

 

 [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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-30 13:05 UTC] johannes@php.net
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.
 [2007-10-01 08:24 UTC] sebastian@php.net
Looks like a duplicate of http://bugs.php.net/bug.php?id=42798 to me.
 [2007-10-01 10:38 UTC] dmitry@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 07 10:01:34 2025 UTC