protected function processControlStructure()
	{
		// Save the index so we can rewind back to it in case of failure
		$savedIndex = $this->i;

		// Count this control structure in this context's statements unless it's an elseif/else
		// in which case it's already been counted as part of the if
		if (!in_array($this->tokens[$this->i][0], [T_ELSE, T_ELSEIF], true))
		{
			++$this->context['statements'];
		}

		// If the control structure is anything but an "else", skip its condition to reach the first
		// brace or statement
		if ($this->tokens[$this->i][0] !== T_ELSE)
		{
			$this->skipCondition();
		}

		$this->skipWhitespace();

		// Abort if this control structure does not use braces
		if ($this->tokens[$this->i] !== '{')
		{
			// Rewind all the way to the original token
			$this->i = $savedIndex;

			return;
		}

		++$this->braces;

		// Replacement for the first brace
		$replacement = [T_WHITESPACE, ''];

		// Add a space after "else" if the brace is removed and it's not followed by whitespace or a
		// variable
		if ($this->tokens[$savedIndex][0]  === T_ELSE
		 && $this->tokens[$this->i + 1][0] !== T_VARIABLE
		 && $this->tokens[$this->i + 1][0] !== T_WHITESPACE)
		{
			$replacement = [T_WHITESPACE, ' '];
		}

		// Record the token of the control structure (T_IF, T_WHILE, etc...) in the current context
		$this->context['lastBlock'] = $this->tokens[$savedIndex][0];

		// Create a new context
		$this->context = [
			'braces'      => $this->braces,
			'index'       => $this->i,
			'lastBlock'   => null,
			'parent'      => $this->context,
			'replacement' => $replacement,
			'savedIndex'  => $savedIndex,
			'statements'  => 0
		];
	}
protected function processControlStructure()
	{
		// Save the index so we can rewind back to it in case of failure
		$savedIndex = $this->i;

		// Count this control structure in this context's statements unless it's an elseif/else
		// in which case it's already been counted as part of the if
		if (!in_array($this->tokens[$this->i][0], [T_ELSE, T_ELSEIF], true))
		{
			++$this->context['statements'];
		}

		// If the control structure is anything but an "else", skip its condition to reach the first
		// brace or statement
		if ($this->tokens[$this->i][0] !== T_ELSE)
		{
			$this->skipCondition();
		}

		$this->skipWhitespace();

		// Abort if this control structure does not use braces
		if ($this->tokens[$this->i] !== '{')
		{
			// Rewind all the way to the original token
			$this->i = $savedIndex;

			return;
		}

		++$this->braces;

		// Replacement for the first brace
		$replacement = [T_WHITESPACE, ''];

		// Add a space after "else" if the brace is removed and it's not followed by whitespace or a
		// variable
		if ($this->tokens[$savedIndex][0]  === T_ELSE
		 && $this->tokens[$this->i + 1][0] !== T_VARIABLE
		 && $this->tokens[$this->i + 1][0] !== T_WHITESPACE)
		{
			$replacement = [T_WHITESPACE, ' '];
		}

		// Record the token of the control structure (T_IF, T_WHILE, etc...) in the current context
		$this->context['lastBlock'] = $this->tokens[$savedIndex][0];

		// Create a new context
		$this->context = [
			'braces'      => $this->braces,
			'index'       => $this->i,
			'lastBlock'   => null,
			'parent'      => $this->context,
			'replacement' => $replacement,
			'savedIndex'  => $savedIndex,
			'statements'  => 0
		];
	}
protected function processControlStructure ( ) { // Save the index so we can rewind back to it in case of failure $ savedIndex = $ this -> i ; // Count this control structure in this context's statements unless it's an elseif/else // in which case it's already been counted as part of the if if ( ! in_array ( $ this -> tokens [ $ this -> i ] [ 0 ] , [ T_ELSE , T_ELSEIF ] , true ) ) { ++ $ this -> context [ 'statements' ] ; } // If the control structure is anything but an "else", skip its condition to reach the first // brace or statement if ( $ this -> tokens [ $ this -> i ] [ 0 ] !== T_ELSE ) { $ this -> skipCondition ( ) ; } $ this -> skipWhitespace ( ) ; // Abort if this control structure does not use braces if ( $ this -> tokens [ $ this -> i ] !== '{' ) { // Rewind all the way to the original token $ this -> i = $ savedIndex ; return ; } ++ $ this -> braces ; // Replacement for the first brace $ replacement = [ T_WHITESPACE , '' ] ; // Add a space after "else" if the brace is removed and it's not followed by whitespace or a // variable if ( $ this -> tokens [ $ savedIndex ] [ 0 ] === T_ELSE && $ this -> tokens [ $ this -> i + 1 ] [ 0 ] !== T_VARIABLE && $ this -> tokens [ $ this -> i + 1 ] [ 0 ] !== T_WHITESPACE ) { $ replacement = [ T_WHITESPACE , ' ' ] ; } // Record the token of the control structure (T_IF, T_WHILE, etc...) in the current context $ this -> context [ 'lastBlock' ] = $ this -> tokens [ $ savedIndex ] [ 0 ] ; // Create a new context $ this -> context = [ 'braces' => $ this -> braces , 'index' => $ this -> i , 'lastBlock' => null , 'parent' => $ this -> context , 'replacement' => $ replacement , 'savedIndex' => $ savedIndex , 'statements' => 0 ] ; }
Process the control structure starting at current index

@return void
Process the control structure starting at current index