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

_extractTokens() protected method

Extract tokens out of all files to be processed
protected _extractTokens ( ) : void
return void
    protected function _extractTokens()
    {
        $progress = $this->helper('progress');
        $progress->init(['total' => count($this->_files)]);
        $isVerbose = $this->param('verbose');
        foreach ($this->_files as $file) {
            $this->_file = $file;
            if ($isVerbose) {
                $this->out(sprintf('Processing %s...', $file), 1, Shell::VERBOSE);
            }
            $code = file_get_contents($file);
            $allTokens = token_get_all($code);
            $this->_tokens = [];
            foreach ($allTokens as $token) {
                if (!is_array($token) || $token[0] !== T_WHITESPACE && $token[0] !== T_INLINE_HTML) {
                    $this->_tokens[] = $token;
                }
            }
            unset($allTokens);
            $this->_parse('__', ['singular']);
            $this->_parse('__n', ['singular', 'plural']);
            $this->_parse('__d', ['domain', 'singular']);
            $this->_parse('__dn', ['domain', 'singular', 'plural']);
            $this->_parse('__x', ['context', 'singular']);
            $this->_parse('__xn', ['context', 'singular', 'plural']);
            $this->_parse('__dx', ['domain', 'context', 'singular']);
            $this->_parse('__dxn', ['domain', 'context', 'singular', 'plural']);
            if (!$isVerbose) {
                $progress->increment(1);
                $progress->draw();
            }
        }
    }