Cake\Shell\Task\ExtractTask::_parse PHP Method

_parse() protected method

Parse tokens
protected _parse ( string $functionName, array $map ) : void
$functionName string Function name that indicates translatable string (e.g: '__')
$map array Array containing what variables it will find (e.g: domain, singular, plural)
return void
    protected function _parse($functionName, $map)
    {
        $count = 0;
        $tokenCount = count($this->_tokens);
        while ($tokenCount - $count > 1) {
            $countToken = $this->_tokens[$count];
            $firstParenthesis = $this->_tokens[$count + 1];
            if (!is_array($countToken)) {
                $count++;
                continue;
            }
            list($type, $string, $line) = $countToken;
            if ($type == T_STRING && $string === $functionName && $firstParenthesis === '(') {
                $position = $count;
                $depth = 0;
                while (!$depth) {
                    if ($this->_tokens[$position] === '(') {
                        $depth++;
                    } elseif ($this->_tokens[$position] === ')') {
                        $depth--;
                    }
                    $position++;
                }
                $mapCount = count($map);
                $strings = $this->_getStrings($position, $mapCount);
                if ($mapCount === count($strings)) {
                    extract(array_combine($map, $strings));
                    $domain = isset($domain) ? $domain : 'default';
                    $details = ['file' => $this->_file, 'line' => $line];
                    if (isset($plural)) {
                        $details['msgid_plural'] = $plural;
                    }
                    if (isset($context)) {
                        $details['msgctxt'] = $context;
                    }
                    $this->_addTranslation($domain, $singular, $details);
                } elseif (strpos($this->_file, CAKE_CORE_INCLUDE_PATH) === false) {
                    $this->_markerError($this->_file, $line, $functionName, $count);
                }
            }
            $count++;
        }
    }