private function _checkIndentationLevel($token) {
		$whitespaceString = $token->text;

		// Number of spaces used
		$indentationNumber = $this->_config->getTestProperty('indentation', 'number');
		if (empty($indentationNumber)) {
			$indentationNumber = 4;
		}

		// doesn't work if we are not in a class
		if (!$this->_inClass) {
			return;
		}

		// don't check empty lines, when we are inside a control statement, when the next token is a object opérator, ...
		if ($this->_inControlStatement || $this->_inFuncCall || !isset($this->lineNumber) || $this->tokenizer->checkNextToken(T_NEW_LINE) || $this->tokenizer->checkNextValidToken(T_PARENTHESIS_CLOSE) || $this->tokenizer->checkNextValidToken(T_BOOLEAN_AND) || $this->tokenizer->checkNextValidToken(T_BOOLEAN_OR) || $this->tokenizer->checkNextValidToken(T_OBJECT_OPERATOR)) {
			return;
		}

		$previousToken = $this->tokenizer->peekPrvsToken();

		// only check a line once
		if (!isset($this->indentationLevel['previousLine']) || $this->lineNumber !== $this->indentationLevel['previousLine']) {
			// Nesting level is the number of items in the branching stack
			$nesting = $this->statementStack->count();

			// But we must anticipate if the current line change the level
			if ($this->tokenizer->checkNextValidToken(T_BRACES_CLOSE) || $this->tokenizer->checkNextValidToken(T_SQUARE_BRACKET_CLOSE)) {
				$nesting --;
			}

			$expectedIndentation = $nesting * $indentationNumber;
			$indentation = strlen($whitespaceString);
			if ($previousToken->id !== T_NEW_LINE) {
				$indentation = 0;
			}

			// don't check when the line is a comment
			if ($this->tokenizer->checkNextToken(T_COMMENT)) {
				return;
			}

			// Control switch statement indentation
			if ($this->statementStack->getCurrentStackItem()->type === StatementItem::TYPE_SWITCH) {

				// Don't check brackets in a switch
				if ($this->tokenizer->checkNextValidToken(T_BRACES_OPEN) || $this->tokenizer->checkNextValidToken(T_BRACES_CLOSE)) {
					return;
				}
			} else if ($this->statementStack->getCurrentStackItem()->type === StatementItem::TYPE_CASE || $this->statementStack->getCurrentStackItem()->type === StatementItem::TYPE_DEFAULT) {

				// If the current line contains a new case, we decrease the expected level
				if ($this->tokenizer->checkNextValidToken(T_CASE) || $this->tokenizer->checkNextValidToken(T_DEFAULT) || $this->tokenizer->checkNextValidToken(T_BRACES_CLOSE)) {
					$expectedIndentation -= $indentationNumber;
				}
			}

			if ($expectedIndentation !== $indentation) {
				$msg = $this->_getMessage('INDENTATION_LEVEL', $expectedIndentation, $indentation);
				$this->_writeError('indentationLevel', $msg, $token->line);
			}
		}
		$this->indentationLevel['previousLine'] = $this->lineNumber;
	}
private function _checkIndentationLevel($token) {
		$whitespaceString = $token->text;

		// Number of spaces used
		$indentationNumber = $this->_config->getTestProperty('indentation', 'number');
		if (empty($indentationNumber)) {
			$indentationNumber = 4;
		}

		// doesn't work if we are not in a class
		if (!$this->_inClass) {
			return;
		}

		// don't check empty lines, when we are inside a control statement, when the next token is a object opérator, ...
		if ($this->_inControlStatement || $this->_inFuncCall || !isset($this->lineNumber) || $this->tokenizer->checkNextToken(T_NEW_LINE) || $this->tokenizer->checkNextValidToken(T_PARENTHESIS_CLOSE) || $this->tokenizer->checkNextValidToken(T_BOOLEAN_AND) || $this->tokenizer->checkNextValidToken(T_BOOLEAN_OR) || $this->tokenizer->checkNextValidToken(T_OBJECT_OPERATOR)) {
			return;
		}

		$previousToken = $this->tokenizer->peekPrvsToken();

		// only check a line once
		if (!isset($this->indentationLevel['previousLine']) || $this->lineNumber !== $this->indentationLevel['previousLine']) {
			// Nesting level is the number of items in the branching stack
			$nesting = $this->statementStack->count();

			// But we must anticipate if the current line change the level
			if ($this->tokenizer->checkNextValidToken(T_BRACES_CLOSE) || $this->tokenizer->checkNextValidToken(T_SQUARE_BRACKET_CLOSE)) {
				$nesting --;
			}

			$expectedIndentation = $nesting * $indentationNumber;
			$indentation = strlen($whitespaceString);
			if ($previousToken->id !== T_NEW_LINE) {
				$indentation = 0;
			}

			// don't check when the line is a comment
			if ($this->tokenizer->checkNextToken(T_COMMENT)) {
				return;
			}

			// Control switch statement indentation
			if ($this->statementStack->getCurrentStackItem()->type === StatementItem::TYPE_SWITCH) {

				// Don't check brackets in a switch
				if ($this->tokenizer->checkNextValidToken(T_BRACES_OPEN) || $this->tokenizer->checkNextValidToken(T_BRACES_CLOSE)) {
					return;
				}
			} else if ($this->statementStack->getCurrentStackItem()->type === StatementItem::TYPE_CASE || $this->statementStack->getCurrentStackItem()->type === StatementItem::TYPE_DEFAULT) {

				// If the current line contains a new case, we decrease the expected level
				if ($this->tokenizer->checkNextValidToken(T_CASE) || $this->tokenizer->checkNextValidToken(T_DEFAULT) || $this->tokenizer->checkNextValidToken(T_BRACES_CLOSE)) {
					$expectedIndentation -= $indentationNumber;
				}
			}

			if ($expectedIndentation !== $indentation) {
				$msg = $this->_getMessage('INDENTATION_LEVEL', $expectedIndentation, $indentation);
				$this->_writeError('indentationLevel', $msg, $token->line);
			}
		}
		$this->indentationLevel['previousLine'] = $this->lineNumber;
	}
private function _checkIndentationLevel ( $ token ) { $ whitespaceString = $ token -> text ; // Number of spaces used $ indentationNumber = $ this -> _config -> getTestProperty ( 'indentation' , 'number' ) ; if ( empty ( $ indentationNumber ) ) { $ indentationNumber = 4 ; } // doesn't work if we are not in a class if ( ! $ this -> _inClass ) { return ; } // don't check empty lines, when we are inside a control statement, when the next token is a object opérator, ... if ( $ this -> _inControlStatement || $ this -> _inFuncCall || ! isset ( $ this -> lineNumber ) || $ this -> tokenizer -> checkNextToken ( T_NEW_LINE ) || $ this -> tokenizer -> checkNextValidToken ( T_PARENTHESIS_CLOSE ) || $ this -> tokenizer -> checkNextValidToken ( T_BOOLEAN_AND ) || $ this -> tokenizer -> checkNextValidToken ( T_BOOLEAN_OR ) || $ this -> tokenizer -> checkNextValidToken ( T_OBJECT_OPERATOR ) ) { return ; } $ previousToken = $ this -> tokenizer -> peekPrvsToken ( ) ; // only check a line once if ( ! isset ( $ this -> indentationLevel [ 'previousLine' ] ) || $ this -> lineNumber !== $ this -> indentationLevel [ 'previousLine' ] ) { // Nesting level is the number of items in the branching stack $ nesting = $ this -> statementStack -> count ( ) ; // But we must anticipate if the current line change the level if ( $ this -> tokenizer -> checkNextValidToken ( T_BRACES_CLOSE ) || $ this -> tokenizer -> checkNextValidToken ( T_SQUARE_BRACKET_CLOSE ) ) { $ nesting -- ; } $ expectedIndentation = $ nesting * $ indentationNumber ; $ indentation = strlen ( $ whitespaceString ) ; if ( $ previousToken -> id !== T_NEW_LINE ) { $ indentation = 0 ; } // don't check when the line is a comment if ( $ this -> tokenizer -> checkNextToken ( T_COMMENT ) ) { return ; } // Control switch statement indentation if ( $ this -> statementStack -> getCurrentStackItem ( ) -> type === StatementItem :: TYPE_SWITCH ) { // Don't check brackets in a switch if ( $ this -> tokenizer -> checkNextValidToken ( T_BRACES_OPEN ) || $ this -> tokenizer -> checkNextValidToken ( T_BRACES_CLOSE ) ) { return ; } } else if ( $ this -> statementStack -> getCurrentStackItem ( ) -> type === StatementItem :: TYPE_CASE || $ this -> statementStack -> getCurrentStackItem ( ) -> type === StatementItem :: TYPE_DEFAULT ) { // If the current line contains a new case, we decrease the expected level if ( $ this -> tokenizer -> checkNextValidToken ( T_CASE ) || $ this -> tokenizer -> checkNextValidToken ( T_DEFAULT ) || $ this -> tokenizer -> checkNextValidToken ( T_BRACES_CLOSE ) ) { $ expectedIndentation -= $ indentationNumber ; } } if ( $ expectedIndentation !== $ indentation ) { $ msg = $ this -> _getMessage ( 'INDENTATION_LEVEL' , $ expectedIndentation , $ indentation ) ; $ this -> _writeError ( 'indentationLevel' , $ msg , $ token -> line ) ; } } $ this -> indentationLevel [ 'previousLine' ] = $ this -> lineNumber ; }
Check the indentation level.

Launched when T_WHITESPACE is met at the beginning of a line.

@param TokenInfo $token
the token to check
Check the indentation level .