src/Translation/LanguageParser.php
/**
	 * Parses the variable and stores it. Variables can consist of booleans, strings, numbers, or nil/null.
	 *
	 * @param string $line
	 * @param int $lineNumber
	 */
Parses the variable and stores it. Variables can consist of booleans, strings, numbers, or nil/null.
@param string $line
@param int $lineNumber
Parses the variable and stores it . Variables can consist of booleans strings numbers or nil / null . @param string $line @param int $lineNumber
protected function parseVariable($line, $lineNumber) {
		preg_match('/\\s*(["\'](?:[^\'"\\\\]|\\\\.)*["\'])\\s+(["\'](?:[^\'"\\\\]|\\\\.)*["\']|true|false|null|nil|[-]{0,1}\\d*[.]{0,1}\\d*[^.])\\s*/', $line, $components);
		if (count($components) !== 3) {
			throw new LanguageException(sprintf('Parse error: Incorrect variable declaration on line %d.', $lineNumber));
		}
		$variableName = $this->parseQuotedString($components[1]);
		$variableValue = $this->parseMixedValue($components[2]);
		if (isset($this->variables[$variableName])) {
			throw new LanguageException(sprintf('Parse error: Variable "%s" already declared on line %d.', $variableName, $lineNumber));
		}
		$this->variables[strtolower($variableName)] = $variableValue;
	}
protected function parseVariable ( $ line , $ lineNumber ) { preg_match ( '/\\s*(["\'](?:[^\'"\\\\]|\\\\.)*["\'])\\s+(["\'](?:[^\'"\\\\]|\\\\.)*["\']|true|false|null|nil|[-]{0,1}\\d*[.]{0,1}\\d*[^.])\\s*/' , $ line , $ components ) ; if ( count ( $ components ) !== 3 ) { throw new LanguageException ( sprintf ( 'Parse error: Incorrect variable declaration on line %d.' , $ lineNumber ) ) ; } $ variableName = $ this -> parseQuotedString ( $ components [ 1 ] ) ; $ variableValue = $ this -> parseMixedValue ( $ components [ 2 ] ) ; if ( isset ( $ this -> variables [ $ variableName ] ) ) { throw new LanguageException ( sprintf ( 'Parse error: Variable "%s" already declared on line %d.' , $ variableName , $ lineNumber ) ) ; } $ this -> variables [ strtolower ( $ variableName ) ] = $ variableValue ; }
Parses the variable and stores it.
Parses the variable and stores it .
// Find the components of the variable // Make sure it is a correct declaration // Extract the components // Check for duplicates // Store the variable