php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43332 self and parent as type hint in namespace
Submitted: 2007-11-19 11:40 UTC Modified: 2007-12-03 14:16 UTC
From: felipensp at gmail dot com Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3CVS-2007-11-19 (snap) OS:
Private report: No CVE-ID: None
 [2007-11-19 11:40 UTC] felipensp at gmail dot com
Description:
------------
self and parent as type hint in namespace must be prefixed with '::', but not is possible to use them as class name. So, i'm guessing that shouldn't be necessary the prefix.

Reproduce code:
---------------
<?php
namespace foobar;

class foo {
  // no namespace
  //public function baz(self $a) { }
  // with namespace
  public function baz(::self $a) { }
}

$foo = new foo;
$foo->baz($foo); // Ok!
//$foo->baz(new stdclass); // Error, ok!

Expected result:
----------------
Don't be necessary prefix in self/parent.

Actual result:
--------------
They must be prefixed.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-24 12:32 UTC] jani@php.net
Another namespace issue.
 [2007-12-03 14:16 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: Sat Jul 19 01:00:03 2025 UTC