Bug #64007 [Opn]: There is an ability to create instance of Generator by hand
| From: | laruence@php.net | Date: | Thu, 17 Jan 2013 10:07:24 +0000 |
| Subject: | Bug #64007 [Opn]: There is an ability to create instance of Generator by hand | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-176064@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64007&edit=1
ID: 64007
Updated by: laruence@php.net
Reported by: lisachenko dot it at gmail dot com
Summary: There is an ability to create instance of Generator
by hand
Status: Open
Type: Bug
Package: Reflection related
Operating System: Windows 7 x64
PHP Version: 5.5.0alpha2
-Assigned To:
+Assigned To: laruence
Block user comment: N
Private report: N
New Comment:
agree, I will make a patch
Previous Comments:
------------------------------------------------------------------------
[2013-01-16 12:50:56] nikic@php.net
Looks like a bug in Reflection. It should get the constructor through the
get_constructor handler, not from the class property.
------------------------------------------------------------------------
[2013-01-16 12:37:13] lisachenko dot it at gmail dot com
Description:
------------
Generator is an internal class, so there shouldn't be an ability to create it by hand. However,
the Generator class doesn't have a private constructor and instance of it can be created via
ReflectionClass.
Solution: add a private constructor for this class to prevent instantiation (like for Closure
class).
Test script:
---------------
$reflection = new ReflectionClass('Generator');
$generator = $reflection->newInstance();
var_dump($generator);
Expected result:
----------------
Expected ReflectionException that restricts an object instantiation.
Fatal error: Uncaught exception 'ReflectionException' with message 'Access to
non-public constructor of class Generator'
Actual result:
--------------
Generator object created:
object(Generator)#2 (0) { }
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64007&edit=1