Optionally process compiled code by post filter

@param string $code compiled code

@return string
@throws \SmartyException
513967
public function postFilter($code)
    {
        // run post filter if on code
        if (!empty($code) &&
            (isset($this->smarty->autoload_filters[ 'post' ]) || isset($this->smarty->registered_filters[ 'post' ]))
        ) {
            return $this->smarty->ext->_filterHandler->runFilter('post', $code, $this->template);
        } else {
            return $code;
        }
    }
1361206
public function html($code)
    {
        if ($this->sdopx->parsingType == Sdopx::PARSING_SQL) {
            if ($code != '') {
                if (trim($code) == '') {
                    $this->output[] = ' ';
                    return;
                } else {
                    if (preg_match('@^\s+([\w\W]+)\s+$@', $code, $mt)) {
                        $this->output[] = ' ' . trim($mt[1]) . ' ';
                    } else if (preg_match('@^\s+([\w\W]+)$@', $code, $mt)) {
                        $this->output[] = ' ' . trim($mt[1]);
                    } else if (preg_match('@^([\w\W]+)\s+$@', $code, $mt)) {
                        $this->output[] = trim($mt[1]) . ' ';
                    } else {
                        $this->output[] = $code;
                    }
                    return;
                }
            }
            return;
        }
        $this->output[] = $code;
    }
876669
protected function decodeHash( $code )
	{
		$php	= gzinflate( base64_decode( $code ) );
		$php	= substr( $php, strlen( $this->incodePrefix) , -strlen( $this->incodeSuffix ) );
		return 	$php;
	}
859780
public function onExecute($code)
    {
        foreach ($this->loopListeners as $listener) {
            if (($return = $listener->onExecute($this, $code)) !== null) {
                $code = $return;
            }
        }

        return $code;
    }
316479
public function tokenize($code)
    {
        $this->tokens = array();
        $lines        = preg_split('/\r?\n/', $code);
        $number       = 0;

        foreach ($lines as $number => $fragment) {
            $this->processLine($number + 1, $fragment);
            $this->tokens[] = new Token(self::TOKEN_EOL, null, $number + 1);
        }
        $this->tokens[] = new Token(self::TOKEN_EOF, null, $number + 1);

        return new TokenStream($this->tokens);
    }
1328004
public function parseCode($code)
    {
        $segments = (new NamespacedItemResolver)->parseKey($code);

        if (is_null($segments[0])) {
            $segments[0] = '*';
        }

        return $segments;
    }
277654
public function transpile($code)
    {
        try {
            return AfxService::convertAfxToFusion($code);
        } catch (AfxException $afxException) {
            throw new Fusion\Exception(sprintf('Error during AFX-parsing: %s', $afxException->getMessage()));
        }
    }
1301542
public function preOutputNoLineFeed($code)
    {
        $this->lastLine = $code;
        $this->code = str_repeat("\t", $this->level).$code.$this->code;
    }
778851
public function process($code) {
		// Flatten out the code so the tabs and newlines don't get in the way
		$this->code = str_replace(
			array("\n","\r","\t"), 
			array("","",""),
			$code
		);		

		$blockList = array ();
		$blockIndex = array ();

		preg_match_all("/<% (loop|with) (.*?) %>/", $this->code,  $openBlocks, PREG_OFFSET_CAPTURE);
		preg_match_all("/<% end_(loop|with) %>/", $this->code, $closeBlocks, PREG_OFFSET_CAPTURE);
		
		if(!$openBlocks || !$closeBlocks) return;

		$openBlocks = reset($openBlocks);
		$closeBlocks = reset($closeBlocks);
		
		// If there aren't the same about of opening delimiters as close delimiters,
		// this is a malformed template
		if(count($openBlocks) != count($closeBlocks)) {
			throw new ValidationException("Template is malformed. Open loops and closed loops are mismatched");
		}

		$loops = array_merge($openBlocks, $closeBlocks);
		
		// Index all the mactches by their offset, e.g. strpos
		foreach($loops as $match) {
			$blockList[$match[1]] = $match[0];	
		}
		ksort($blockList, SORT_NUMERIC);


		$openBlocks = array();

		// Now that each block has a unique identifier (its offset), create an index
		// that allows lookups of its parent block and where it ends
		foreach($blockList as $pos => $block) {
			if($block != "<% end_loop %>" && $block != "<% end_with %>") {
				$blockIndex[$pos] = array (
					'parent' => empty($openBlocks) ? 0 : end($openBlocks)
				);
				array_push($openBlocks, $pos);	
			}
			else {
				$opener = array_pop($openBlocks);
				$blockIndex[$opener]['end'] = $pos;
			}
		}

		// Lopp through the index to create ReflectionTemplate_Block instances for each.
		foreach($blockIndex as $pos => $data) {
			$block = new ReflectionTemplate_Block($this, $pos, $data['end'], $data['parent']);
			if(!in_array(strtolower($block->getName()), $this->getTemplateAccessors())) {
				$this->blockManifest[$pos] = $block;
				if($data['parent'] > 0) {
					$this->getBlockByID($data['parent'])->addChild($pos);
				}
			}
		}				

		// Generate a top level block, consisting of all the vars and conditions in the top scope.
		// Strips out all the contents of every known block, and what you're left with is the
		// "root" template
		$originalCode = $this->code;
		foreach($this->getBlocks() as $block) {
			$this->code = str_replace($block->getOuterContents(), "", $this->code);
		}
		$top = new ReflectionTemplate_Block($this);
		$this->topBlock = $top;
		$this->code = $originalCode;
	}
1037474
public function postManage($code = null)
    {
        if ($code === null) {
            throw new NotFoundHttpException();
        }

        $subscriber = Subscriber::where('verify_code', '=', $code)->first();

        if (!$subscriber) {
            throw new BadRequestHttpException();
        }

        try {
            execute(new UpdateSubscriberSubscriptionCommand($subscriber, Binput::get('subscriptions')));
        } catch (ValidationException $e) {
            return cachet_redirect('subscribe.manage', $subscriber->verify_code)
                ->withInput(Binput::all())
                ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))
                ->withErrors($e->getMessageBag());
        }

        return cachet_redirect('subscribe.manage', $subscriber->verify_code)
            ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.updated-subscribe')));
    }
660497
protected function filterStatusCode($code)
    {
        $code = filter_var($code, FILTER_VALIDATE_INT, ['options' => [
            'min_range' => self::MINIMUM,
            'max_range' => self::MAXIMUM,
        ]]);
        if (!$code) {
            throw new InvalidArgumentException(
                'The submitted code must be a positive integer between '.self::MINIMUM.' and '.self::MAXIMUM
            );
        }

        return $code;
    }
133776
protected function check_syntax($code){

        $errors = array();

        ob_start();

        $check = function_exists('eval') ? eval('?>'.'<?php if(0): ?>'.$code.'<?php endif; ?><?php ') : true;

        if ($check === false) {
            $output = ob_get_clean();
            $output = strip_tags($output);

            if (preg_match_all("/on line (\d+)/m", $output, $matches)) {

                foreach($matches[1] as $m){
                    $errors[] = "Parse error on line: ".$m;
                }

            } else {
                $errors[] = 'syntax error';
            }

        } else {
            ob_end_clean();
        }

        return count($errors) ? $errors:false;
    }
87811
public function process($code, $path = null)
    {
        if (!$code) {
            return '';
        }
        $nodes = Parser::parse($code, ['path' => $path]);
        foreach ($this->_patchers as $patcher) {
            $patcher->process($nodes, $path);
        }
        return Parser::unparse($nodes);
    }
1292702
public static function getPhrase(int $code):string
    {
        if (isset(self::$response[$code])) {
            return (self::$response[$code]);
        } else {
            throw new Server500(new \ArrayObject(array("explain" => "Http code does not exist",
                "solution" => "Please check your http code")));
        }
    }
469818
static function postCompile(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
    {
        $compiler->prefixCompiledCode .= "<?php \$_smarty_tpl->ext->_inheritance->init(\$_smarty_tpl, " .
            var_export($initChildSequence, true) . ");\n?>\n";
    }
584387
private function optimizeScriptCode($code)
	{
		if (YII_DEBUG)
			return $code;
		require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'JSMin.php';
		$minified = JSMin::minify($code);

		return ($minified === false ? $code : $minified);
	}
77158
protected function detect_plugin_component_from_versionphp($code) {

        $result = preg_match_all('#^\s*\$plugin\->component\s*=\s*([\'"])(.+?_.+?)\1\s*;#m', $code, $matches);

        // Return if and only if the single match was detected.
        if ($result === 1 and !empty($matches[2][0])) {
            return $matches[2][0];
        }

        return false;
    }