Req #60615 [NEW]: Please extend the classmap option

From: Date: Wed, 28 Dec 2011 11:54:40 +0000
Subject: Req #60615 [NEW]: Please extend the classmap option
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-166115@lists.php.net to get a copy of this message
From: Operating system: all PHP version: Irrelevant Package: SOAP related Bug Type: Feature/Change Request Bug description:Please extend the classmap option Description: ------------ Dear Devs, currently we can map SOAP requests and responses to userland classes, using the classmap entry from SoapClient::__construct()'s options argument. Sometimes those userland classes will have dependencies to be injected, before the SoapClient can fill them with their payload. Since SoapClient only accepts class names and not objects to be cloned or at least callbacks to act as a factory, bootstrapping these data objects is impossible. Could you please change the current behavior in that regard? In the interest of backwards compatibility, I suggest simply following the callback approach. If a callback is used, instead of a classname, PHP should use that callback as a factory for new classes. Test script: --------------- Example to explain the idea: <?php class MySoapClient extends SoapClient { public function __construct($wsdl,$dbAdapter) { $options = array(); // hard coded class name $options['classmap']['RequestType'] = 'RequestType'; // anonymous function as factory $options['classmap']['ResponseType1'] = function() use($dbAdapter){ $object=new MyResponseMapping(); $object->injectDBAdapter($dbAdapter); return $object; }; // factory method of a given class $options['classmap']['ResponseType2'] = array($this,'factoryMethod'); parent::__construct($wsdl,$options); } /** a factory method for a certain kind of data access objects * @param void * @return Object */ public function factoryMethod() { $object=new MyResponseMapping(); $object->injectSourceObject($this); return $object; } } $wsdl = 'URL 2 a WDSL'; class RequestType { public $payload; } $request = new RequestType; $request->payload = 'payload'; $soapclient = new MySoapClient($wsdl,$dbAdapter); $result = $soapclient->doSomething($request); var_dump($result); Expected result: ---------------- The var_dump() should reflect that objects of the MyResponseMapping types were used and their dependencies should have been fulfilled using the factories from my example. Actual result: -------------- PHP silently (why?) ignores my mappings and uses stdClass objects instead. -- Edit bug report at https://bugs.php.net/bug.php?id=60615&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60615&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60615&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60615&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60615&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60615&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60615&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60615&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60615&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60615&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60615&r=support Expected behavior: https://bugs.php.net/fix.php?id=60615&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60615&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60615&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60615&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60615&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=60615&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60615&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60615&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60615&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60615&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60615&r=mysqlcfg

« previous php.bugs (#166115) next »