php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51374 initialized empty arrays in SPLFileObject subclasses fails
Submitted: 2010-03-24 01:32 UTC Modified: 2010-04-27 08:01 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: johnny at localmomentum dot net Assigned: colder (profile)
Status: Closed Package: SPL related
PHP Version: 5.3.2 OS:
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: johnny at localmomentum dot net
New email:
PHP Version: OS:

 

 [2010-03-24 01:32 UTC] johnny at localmomentum dot net
Description:
------------
when subclassing SplFileObject and opening it via SplFileInfo->openFile() initialized array properties of the subclass of SplFileInfo are changing to null, while strings are fine.

Test script:
---------------
<?php
class Foo extends SplFileObject
{
        public $bar = 'baz';
        public $bam = array();
	function __construct($file)
	{
		// do stuff
		parent::__construct($file);	
	}
}
$fileInfo = new SplFileInfo('php://temp');
$fileInfo->setFileClass('Foo');
$file = $fileInfo->openFile('r');

print var_dump($file->bar); // is baz
print var_dump($file->bam); // is null or UNKNOWN:0
?>

Expected result:
----------------
I expected var_dump($file->bam) to print an empty array

Actual result:
--------------
null or UNKNOWN:0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-27 07:58 UTC] colder@php.net
Automatic comment from SVN on behalf of colder
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=298638
Log: Fix #51374 (Wrongly initialized object properties)
 [2010-04-27 08:01 UTC] colder@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: colder
 [2010-04-27 08:01 UTC] colder@php.net
This bug has been fixed in SVN.

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.

It was caused by constant arrays not being transformed to real arrays during class 
instantiation.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC