Ejemplo n.º 1
0
 protected static function checkPassedByReference($function)
 {
     $ref_func = new ReflectionFunction($function);
     foreach ($ref_func->getParameters() as $param) {
         if ($param->isPassedByReference()) {
             // Add tmp blacklist
             Cache::appendTmpFunctionBlacklist($function);
             // Remove cache file
             $backtrace = debug_backtrace();
             $info = Backtrace::getInfo('FunctionPatcher', $backtrace);
             $orig_file = $info['file'];
             $cache = Cache::removeSrcCacheFile($orig_file);
             $pr_msg = '';
             if (self::isInternalFunction($function)) {
                 $pr_msg = "<red>Please send Pull Request to add function '{$function}' to default config.</red>\n";
             }
             $tmp_blacklist_file = Cache::getTmpFunctionBlacklistFile();
             $msg = "\n" . "<red>Can't patch on function '{$function}'.</red>\n" . "It has param(s) passed by reference.\n" . "Added it temporary blacklist file '{$tmp_blacklist_file}'.\n" . "And removed cache file '{$cache}'.\n" . "{$pr_msg}" . "\n<red>Please run phpunit again.</red>";
             self::outputMessage($msg);
             throw new LogicException($msg);
         }
     }
 }