Req #10546 [Asn->Csd]: extract() to work with objects

From: Date: Sat, 06 Aug 2016 00:31:04 +0000
Subject: Req #10546 [Asn->Csd]: extract() to work with objects
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202977@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=10546&edit=1 ID: 10546 Updated by: kalle@php.net Reported by: fabiankessler at usa dot net Summary: extract() to work with objects -Status: Assigned +Status: Closed Type: Feature/Change Request Package: Class/Object related Operating System: * PHP Version: * -Assigned To: andrei +Assigned To: kalle Block user comment: N Private report: N New Comment: I'm gonna close this, such a feature would need a healthy discussion on the mailing list which most likely will end in an RFC. All in all I'm not a huge fan of this, but every idea deserves a chance Previous Comments: ------------------------------------------------------------------------ [2014-08-19 16:11:03] levim@php.net Related To: Bug #26545 ------------------------------------------------------------------------ [2013-09-19 23:03:14] metamarkers at gmail dot com A blind import into an object would be neat for shortcutting certain things, but would undermine __set(). Consider instead: function import ( $object , array $vars ) { foreach ($vars as $k=>$v) { $object->$k = $v; } } ------------------------------------------------------------------------ [2001-04-29 01:06:34] fabiankessler at usa dot net example: class foo { function foo() { $var_array = array('hello'=>'world'); extract($var_array, EXTR_PREFIX_ALL, "this->prefix"); echo $this->prefix_hello; } }; $f = new foo(); :) fab ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=10546&edit=1

« previous php.bugs (#202977) next »