Bug #66944 [Opn->Nab]: can't instance protected construct
| From: | requinix@php.net | Date: | Sun, 23 Mar 2014 12:57:00 +0000 |
| Subject: | Bug #66944 [Opn->Nab]: can't instance protected construct | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-184861@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66944&edit=1
ID: 66944
Updated by: requinix@php.net
Reported by: ian dot email at qq dot com
Summary: can't instance protected construct
-Status: Open
+Status: Not a bug
Type: Bug
Package: Reflection related
Operating System: windows
PHP Version: 5.4.26
Block user comment: N
Private report: N
New Comment:
It doesn't matter what you do with $method - the class's constructor is protected you so
can't instantiate it that way. However you can do a newInstanceWithoutConstructor() and then
call $method on the instance it returns.
Previous Comments:
------------------------------------------------------------------------
[2014-03-23 12:48:41] ian dot email at qq dot com
Description:
------------
class A{ protected function __construct(){} }
why can't set private/protected construct
$method=$class->getmethod('__construct');
$method->setAccessible(true);
$fuc=$class->newInstance(true);
Test script:
---------------
class A{ protected function __construct(){} }
why can't set private/protected construct
$method=$class->getmethod('__construct');
$method->setAccessible(true);
$fuc=$class->newInstance(true);
Expected result:
----------------
class A{ protected function __construct(){} }
why can't set private/protected construct
$method=$class->getmethod('__construct');
$method->setAccessible(true);
$fuc=$class->newInstance(true);
Actual result:
--------------
class A{ protected function __construct(){} }
why can't set private/protected construct
$method=$class->getmethod('__construct');
$method->setAccessible(true);
$fuc=$class->newInstance(true);
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66944&edit=1