From: gggeek Date: Sat, 23 May 2015 18:57:34 +0000 (+0100) Subject: Remove usage of one global var in favor of static class var X-Git-Tag: 4.0.0-alpha^2~45 X-Git-Url: http://git.onelab.eu/?p=plcapi.git;a=commitdiff_plain;h=a5da33dc74d339b73996a566fefd59336d44b295 Remove usage of one global var in favor of static class var --- diff --git a/src/Wrapper.php b/src/Wrapper.php index 2c0d1f7..6529950 100644 --- a/src/Wrapper.php +++ b/src/Wrapper.php @@ -18,6 +18,9 @@ namespace PhpXmlRpc; */ class Wrapper { + /// used to hold a reference to object instances whose methods get wrapped by wrap_php_function(), in 'create source' mode + public static $objHolder = array(); + /** * Given a string defining a php type or phpxmlrpc type (loosely defined: strings * accepted come from javadoc blocks), return corresponding phpxmlrpc type. @@ -541,10 +544,10 @@ class Wrapper $innerCode .= "\$np = false;\n"; // since we are building source code for later use, if we are given an object instance, - // we go out of our way and store a pointer to it in a global var... + // we go out of our way and store a pointer to it in a static class var var... if (is_array($callable) && is_object($callable[0])) { - $GLOBALS['xmlrpcWPFObjHolder'][$newFuncName] = &$callable[0]; - $innerCode .= "\$obj =& \$GLOBALS['xmlrpcWPFObjHolder']['$newFuncName'];\n"; + self::$objHolder[$newFuncName] = $callable[0]; + $innerCode .= "\$obj = PhpXmlRpc\\Wrapper::\$objHolder['$newFuncName'];\n"; $realFuncName = '$obj->' . $callable[1]; } else { $realFuncName = $plainFuncName; @@ -777,6 +780,8 @@ class Wrapper * @param array $extraOptions * @param string $mSig * @return callable + * + * @todo should we allow usage of parameter simple_client_copy to mean 'do not clone' in this case? */ protected function buildWrapMethodClosure($client, $methodName, array $extraOptions, $mSig) {