php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51310 Using namespaces breaks generic object type hinting
Submitted: 2010-03-17 00:45 UTC Modified: 2010-03-19 01:02 UTC
From: ddebernardy at yahoo dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.2 OS: MacOS X
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: ddebernardy at yahoo dot com
New email:
PHP Version: OS:

 

 [2010-03-17 00:45 UTC] ddebernardy at yahoo dot com
Description:
------------
Specifying object as the type hint seems to be broken when using namespaces.

Test script:
---------------
namespace A;

class X {}

function foo(object $bar) {}

foo(new X);
foo(new \stdClass);

Expected result:
----------------
foo(new X); // works
foo(new \stdClass); // works

Actual result:
--------------
foo(new X); // fails
foo(new \stdClass); // fails

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-19 01:02 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2010-03-19 01:02 UTC] felipe@php.net
The 'object' word doesn't have an special meaning on PHP type hinting.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 08:01:30 2025 UTC