public function findClosingParenthesisPosition($startPos) {
		// Find the opening parenthesis after current position
		$pos = $this->findNextStringPosition('(', $startPos);
		$parenthesisCount = 1;

		$pos += 1; // Skip the opening parenthesis

		$nbTokens = count($this->tokens);
		while ($parenthesisCount > 0 && $pos < $nbTokens) {
			// Look for the next token
			$token = $this->peekTokenAt($pos);

			// Increment or decrement the parenthesis count
			if ($token->id === T_PARENTHESIS_OPEN) {
				$parenthesisCount += 1;
			} else if ($token->id === T_PARENTHESIS_CLOSE) {
				$parenthesisCount -= 1;
			}

			// Increment the position
			$pos += 1;
		}

		return $pos - 1;
	}
public function findClosingParenthesisPosition($startPos) {
		// Find the opening parenthesis after current position
		$pos = $this->findNextStringPosition('(', $startPos);
		$parenthesisCount = 1;

		$pos += 1; // Skip the opening parenthesis

		$nbTokens = count($this->tokens);
		while ($parenthesisCount > 0 && $pos < $nbTokens) {
			// Look for the next token
			$token = $this->peekTokenAt($pos);

			// Increment or decrement the parenthesis count
			if ($token->id === T_PARENTHESIS_OPEN) {
				$parenthesisCount += 1;
			} else if ($token->id === T_PARENTHESIS_CLOSE) {
				$parenthesisCount -= 1;
			}

			// Increment the position
			$pos += 1;
		}

		return $pos - 1;
	}
public function findClosingParenthesisPosition ( $ startPos ) { // Find the opening parenthesis after current position $ pos = $ this -> findNextStringPosition ( '(' , $ startPos ) ; $ parenthesisCount = 1 ; $ pos += 1 ; // Skip the opening parenthesis $ nbTokens = count ( $ this -> tokens ) ; while ( $ parenthesisCount > 0 && $ pos < $ nbTokens ) { // Look for the next token $ token = $ this -> peekTokenAt ( $ pos ) ; // Increment or decrement the parenthesis count if ( $ token -> id === T_PARENTHESIS_OPEN ) { $ parenthesisCount += 1 ; } else if ( $ token -> id === T_PARENTHESIS_CLOSE ) { $ parenthesisCount -= 1 ; } // Increment the position $ pos += 1 ; } return $ pos - 1 ; }
Find the position of the closing parenthesis corresponding to the current position opening parenthesis.

@param Integer $startPos
@return Integer $closing position
Find the position of the closing parenthesis corresponding to the current position opening parenthesis .