php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38782 Object confusion related to arrays
Submitted: 2006-09-11 18:52 UTC Modified: 2006-09-11 19:05 UTC
From: saeven at saeven dot net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.1.6 OS: CentOS/Windows/Slackware
Private report: No CVE-ID: None
 [2006-09-11 18:52 UTC] saeven at saeven dot net
Description:
------------
When specifying a parameter object type in a method signature, if the object was stored in an array prior to being passed, the method signature revokes the object type even though var_dump reports it to be correct!



Reproduce code:
---------------
[file: obj.php]

class Obj1{
  //.. object methods/params herein
}

---------------------------------------
[file: main.php]

function foo( Obj1 $x ){}

$a = array();
$o = new Obj1();
$a[0] = $o;

foo( $a[0] );

Expected result:
----------------
shouldn't see any errors

Actual result:
--------------
Fatal error: Argument 1 passed to foo() must be an object of class Obj1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-11 18:57 UTC] saeven at saeven dot net
Issue corrected.
 [2006-09-11 18:57 UTC] tony2001@php.net
Can't reproduce with both 5.1.6 and 5.2.
 [2006-09-11 19:05 UTC] tony2001@php.net
.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 18 17:00:03 2025 UTC