public function optimize(array $tokens)
	{
		$this->tokens = $tokens;
		$this->i      = 0;
		$this->cnt    = count($this->tokens);

		$php = '';
		while (++$this->i < $this->cnt)
		{
			if ($this->tokens[$this->i][0] === T_IF)
			{
				$php .= $this->serializeIfBlock($this->parseIfBlock());
			}
			else
			{
				$php .= $this->serializeToken($this->tokens[$this->i]);
			}
		}

		// Free the memory taken up by the tokens
		unset($this->tokens);

		return $php;
	}
public function optimize(array $tokens)
	{
		$this->tokens = $tokens;
		$this->i      = 0;
		$this->cnt    = count($this->tokens);

		$php = '';
		while (++$this->i < $this->cnt)
		{
			if ($this->tokens[$this->i][0] === T_IF)
			{
				$php .= $this->serializeIfBlock($this->parseIfBlock());
			}
			else
			{
				$php .= $this->serializeToken($this->tokens[$this->i]);
			}
		}

		// Free the memory taken up by the tokens
		unset($this->tokens);

		return $php;
	}
public function optimize ( array $ tokens ) { $ this -> tokens = $ tokens ; $ this -> i = 0 ; $ this -> cnt = count ( $ this -> tokens ) ; $ php = '' ; while ( ++ $ this -> i < $ this -> cnt ) { if ( $ this -> tokens [ $ this -> i ] [ 0 ] === T_IF ) { $ php .= $ this -> serializeIfBlock ( $ this -> parseIfBlock ( ) ) ; } else { $ php .= $ this -> serializeToken ( $ this -> tokens [ $ this -> i ] ) ; } } // Free the memory taken up by the tokens unset ( $ this -> tokens ) ; return $ php ; }
Optimize the code used to output content

This method will go through the array of tokens, identify if/elseif/else blocks that contain
identical code at the beginning or the end and move the common code outside of the block

@param  array $tokens Array of tokens from token_get_all()
@return string        Optimized code
Optimize the code used to output content