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
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: 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 11:01:32 2025 UTC