php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #55490 Allow instantiating objects without invoking the constructor
Submitted: 2011-08-23 12:31 UTC Modified: 2011-08-26 07:41 UTC
Votes:8
Avg. Score:3.6 ± 1.7
Reproduced:6 of 6 (100.0%)
Same Version:3 (50.0%)
Same OS:3 (50.0%)
From: sebastian@php.net Assigned: sebastian (profile)
Status: Closed Package: Reflection related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
 [2011-08-23 12:31 UTC] sebastian@php.net
Description:
------------
Libraries such as Doctrine 2 and PHPUnit_MockObject (ab)use the unserialize() function (unserialize(sprintf('O:%d:"%s":0:{}', strlen($name), $name))) to instantiate an object of a class without invoking the constructor.

It would be nice if the Reflection API provided a clean API for this use case that does not depend on implementation details of PHP's serializer.


Patches

ReflectionClass_newInstanceWithoutConstructor (last revision 2011-08-25 13:26 UTC by sebastian@php.net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-25 09:24 UTC] sebastian@php.net
The following patch has been added/updated:

Patch Name: ReflectionClass_newInstanceWithoutConstructor
Revision:   1314264277
URL:        https://bugs.php.net/patch-display.php?bug=55490&patch=ReflectionClass_newInstanceWithoutConstructor&revision=1314264277
 [2011-08-25 09:27 UTC] sebastian@php.net
The following patch has been added/updated:

Patch Name: ReflectionClass_newInstanceWithoutConstructor
Revision:   1314264428
URL:        https://bugs.php.net/patch-display.php?bug=55490&patch=ReflectionClass_newInstanceWithoutConstructor&revision=1314264428
 [2011-08-25 09:39 UTC] sebastian@php.net
The following patch has been added/updated:

Patch Name: ReflectionClass_newInstanceWithoutConstructor
Revision:   1314265167
URL:        https://bugs.php.net/patch-display.php?bug=55490&patch=ReflectionClass_newInstanceWithoutConstructor&revision=1314265167
 [2011-08-25 13:26 UTC] sebastian@php.net
The following patch has been added/updated:

Patch Name: ReflectionClass_newInstanceWithoutConstructor
Revision:   1314278793
URL:        https://bugs.php.net/patch-display.php?bug=55490&patch=ReflectionClass_newInstanceWithoutConstructor&revision=1314278793
 [2011-08-26 07:40 UTC] sebastian@php.net
Automatic comment from SVN on behalf of sebastian
Revision: http://svn.php.net/viewvc/?view=revision&revision=315538
Log: Close #55490.
 [2011-08-26 07:41 UTC] sebastian@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: sebastian
 [2011-08-26 07:41 UTC] sebastian@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/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC