Cake\Upgrade\Shell\Task\NamespacesTask::_process PHP Method

_process() protected method

Adds the namespace to a given file.
protected _process ( $path ) : boolean
return boolean
    protected function _process($path)
    {
        $namespace = $this->_getNamespace($path);
        if (!$namespace) {
            return false;
        }
        $original = $contents = $this->Stage->source($path);
        $patterns = [['Namespace to ' . $namespace, '#^(<\\?(?:php)?\\s+(?:\\/\\*.*?\\*\\/\\s{0,1})?)#s', "\\1namespace " . $namespace . ";\n\n"]];
        $contents = $this->_updateContents($contents, $patterns);
        return $this->Stage->change($path, $original, $contents);
    }