/** * @param MethodMetaInfo $metaInfo * * @return string */ private function getInjectedCode(MethodMetaInfo $metaInfo) { static $namespace = '\\Influence\\RemoteControl::'; if ($metaInfo->getIsStatic() or $metaInfo->isConstructor()) { $hasMethod = $namespace . 'hasStatic(get_called_class(), __FUNCTION__)'; $getMethod = $namespace . 'getStatic(get_called_class())'; } else { $hasMethod = $namespace . 'hasObject($this, __FUNCTION__)'; $getMethod = $namespace . 'getObject($this)'; } $scope = $metaInfo->getIsStatic() ? '__CLASS__' : '$this'; $manifest = uniqid('$manifest_'); $code = <<<EOL if ({$hasMethod}) { {$manifest} = {$getMethod}->get(__FUNCTION__); if ({$manifest}->log(func_get_args())->hasValue()) { return {$manifest}->getValue(func_get_args(), {$scope}); } } EOL; return preg_replace('/\\s+/', '', $code); }