|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-04-02 08:14 UTC] vituko at gmail dot com
Description: ------------ 1 - call_user_func_array ($ref_f, $taboa) ; Here, the visibility is computed from the context where this function is called. 2 - $obx -> newInstanceArgs ($taboa) ; ReflectionException : Access to non-public constructor of class ... Constructor must be public anyway. So ... eval is not so bad. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 14:00:01 2025 UTC |
As of PHP 5.4 you can use ReflectionClass::newInstanceWithoutConstructor() and manually invoke the constructor. $rc = new ReflectionClass("foo"); $obj = $rc->newInstanceWithoutConstructor(); $ctor = $rc->getConstructor(); if ($ctor) { // constructors are optional! $ctor->setAccessible(true); $ctor->invoke($obj); } A couple more function calls seems a small price to pay for the ability to do something the class itself specifically tried to prohibit you from doing.