Returns the model namespace, class name and table name.
@param string $fileContents Specifies the file contents.
@return array|null Returns an array with keys 'namespace', 'class' and 'table'
Returns null if the parsing fails.
166837
public function extractModelInfoFromSource($fileContents)
    {
        $stream = new PhpSourceStream($fileContents);

        $result = [];

        while ($stream->forward()) {
            $tokenCode = $stream->getCurrentCode();

            if ($tokenCode == T_NAMESPACE) {
                $namespace = $this->extractNamespace($stream);
                if ($namespace === null) {
                    return null;
                }

                $result['namespace'] = $namespace;
            }

            if ($tokenCode == T_CLASS && !isset($result['class'])) {
                $className = $this->extractClassName($stream);
                if ($className === null) {
                    return null;
                }

                $result['class'] = $className;
            }

            if ($tokenCode == T_PUBLIC || $tokenCode == T_PROTECTED) {
                $tableName = $this->extractTableName($stream);
                if ($tableName === false) {
                    continue;
                }

                if ($tableName === null) {
                    return null;
                }

                $result['table'] = $tableName;
            }
        }

        if (!$result) {
            return null;
        }

        return $result;
    }
823163
public function getAllNamespaces()
    {
        $returnValue = array();

        
        
        if(count($this->namespaces) == 0){
        	$db = core_kernel_classes_DbWrapper::singleton();
        	$query = 'SELECT modelid, modeluri FROM models';
			$result = $db->query($query);
			
			while ($row = $result->fetch()){	
				$id 	= $row['modelid'];
				$uri 	= $row['modeluri'];
				$this->namespaces[$id] = $uri;
			}
        }
        
        foreach($this->namespaces as $id => $uri){
        	$returnValue[$uri] = new common_ext_Namespace($id, $uri);
        }

        

        return (array) $returnValue;
    }
755965
public function getContent()
    {
        return strtr($this->getStubContent('model'), [
            '{{namespace}}' => $this->namespace,
            '{{name}}'      => $this->name,
            '{{table}}'     => $this->table,
            '{{relations}}' => $this->relations->getTrait(),
        ]);
    }
805664
protected function extractNamespace($fullQualifiedNamespace) {
        $parts     = explode('\\', $fullQualifiedNamespace);
        $copyParts = $parts;
        $copyParts = array_splice($copyParts, 0, -1);

        return [
            'namespace'                => implode('\\', $copyParts),
            'class'                    => end($parts),
            'full_qualified_namespace' => $fullQualifiedNamespace
        ];
    }
757316
public function getContent(): ?string {
        if (null !== $this->content) return $this->content;
        if (!$this->isFile()) return null;
        $content = \file_get_contents($this->path);
        if (false === $content) return null;
        return $content;
    }
892530
public function getMainContentClasses(array $additionalClasses = null): string
    {
        $classes = ['controller'];
        if (!empty($additionalClasses)) {
            $classes = Hash::merge($classes, $additionalClasses);
        }
        $classes[] = Inflector::underscore($this->_View->request->controller) . '-' . Inflector::underscore($this->_View->request->action);

        return h(implode(' ', $classes));
    }
780895
public function findLinkedFilesInRte($ttContentRow)
    {
        $fileObjects = array();
        // check if there are links to files in the rte text
        /* @var $rteHtmlParser \TYPO3\CMS\Core\Html\RteHtmlParser */
        $rteHtmlParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(RteHtmlParser::class);

        /** @var \TYPO3\CMS\Core\LinkHandling\LinkService $linkService */
        $linkService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\LinkHandling\LinkService::class);
        $blockSplit = $rteHtmlParser->splitIntoBlock('A', $ttContentRow['bodytext'], 1);
        foreach ($blockSplit as $k => $v) {
            list($attributes) = $rteHtmlParser->get_tag_attributes($rteHtmlParser->getFirstTag($v), true);
            if (!empty($attributes['href'])) {
                $hrefInformation = $linkService->resolve($attributes['href']);
                if ($hrefInformation['type'] === \TYPO3\CMS\Core\LinkHandling\LinkService::TYPE_FILE) {
                    $fileObjects[] = $hrefInformation['file'];
                }
            }
        }

        return $fileObjects;
    }
393885
public function getContents(string $fileName)
    {
        if (!file_exists($this->__path . $fileName)) {
            return null;
        }
        $r = include $this->__path . $fileName;
        return $r === false ? null : $r;
    }
320836
public function getContents()
    {
        try {
            $fileObj = new SplFileObject($this->getName(true) , 'r');
        } catch ( RuntimeException $ex ) {
            throw new FileExistException('The provided file is not readable' , $ex);
        }

        return file_get_contents($fileObj->getPathname());
    }
250681
public function getCodeFromDocumentation(string $fileContent): array
    {
        $start = strpos($fileContent, Constants::MARKDOWN_PHP_CODE_KEYWORD);
        $code = substr($fileContent, $start);

        $regularExpression = '!' . Constants::MARKDOWN_PHP_CODE_KEYWORD . self::DOCUMENTATION_REGEX . '!';
        if (!preg_match_all($regularExpression, $code, $matches)) {
            return [];
        }

        return array_map(
            function ($line) {
                return trim($line);
            },
            $matches[1]
        );
    }
525085
public function getFileClassNamespace($file)
    {
        $filenameBlock = explode(DIRECTORY_SEPARATOR, $file);
        $filename = explode('.', end($filenameBlock), 2);
        $filename = reset($filename);

        preg_match('/\snamespace\s+(.+?);/s', file_get_contents($file), $match);

        return    is_array($match) && isset($match[1])
                ? $match[1] . '\\' . $filename
                : false;
    }
418543
public static function createFromInline($fileContents)
    {
        // '//# sourceMappingURL=data:application/json;charset:utf-8;base64,
        // '//# sourceMappingURL=data:application/json;base64,'
        $pos = strrpos($fileContents, "\n//# sourceMappingURL=");
        $isCss = false;
        if ($pos === false) {
            $pos = strrpos($fileContents, "\n/*# sourceMappingURL=");
            if ($pos === false) {
                throw new Exception("No sourceMappingURL found");
            }
            $isCss = true;
        }
        $url = substr($fileContents, $pos + 22);
        $url = rtrim($url);
        if ($isCss) {
            if (substr($url, -2) != '*/') {
                throw new Exception("sourceMappingURL isn't wrapped with closing */");
            }
            $url = substr($url, 0, -2); //remove "*/"
            $url = rtrim($url);
        }

        if (substr($url, 0, 29) == 'data:application/json;base64,') {
            $map = substr($url, 29);
        } else if (substr($url, 0, 29 + 14) == 'data:application/json;charset:utf-8;base64,') {
            $map = substr($url, 29 + 14);
        } else if (substr($url, 0, 29 + 14) == 'data:application/json;charset=utf-8;base64,') {
            $map = substr($url, 29 + 14);
        } else {
            throw new Exception("Unsupported sourceMappingURL");
        }
        $map = base64_decode($map);
        $map = json_decode($map);
        $fileContents = substr($fileContents, 0, $pos);
        $ret = new self($map, $fileContents);
        $ret->setMimeType($isCss ? 'text/css' : 'text/javascript');
        return $ret;
    }
1022267
protected function _classesInNamespaces($names, array $namespaces, array &$logs = array())
    {
        if (!is_array($names)) {
            $names = array($names);
        }
        foreach ($names as $_name) {
            foreach ($namespaces as $_namespace) {
                if (CodeHelper::namespaceExists($_namespace)) {
                    $tmp_namespace = rtrim(TextHelper::toCamelCase($_namespace), '\\').'\\';
                    if (substr_count(TextHelper::toCamelCase($_name), $tmp_namespace)>0) {
                        return $_name;
                    }
                } else {
                    $logs[] = $this->_getErrorMessage('Namespace "%s" not found!', $_namespace);
                }
            }
        }
        return false;
    }
346752
private function xmlToObj($fileContents)
  {
    $fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents);
    $fileContents = trim(str_replace('"', "'", $fileContents));
    $simpleXml    = simplexml_load_string($fileContents, null, LIBXML_NOCDATA);

    return $simpleXml;
  }
860698
public function rewriteNamespacedImports (string $fileContent) : string
    {
        $importParser = new CssUrlImportParser();
        return $importParser->replaceValidImports(
            $fileContent,
            function (string $path)
            {
                try
                {
                    $asset = Asset::createFromAssetPath($path);
                    return $this->assetUrl->generateUrl($asset);
                }
                catch (AssetsException $e)
                {
                    // wasn't an asset path
                    return $path;
                }
            }
        );
    }
1257218
public function getClassContentDir()
    {
        if (null === $this->classcontentDir) {
            $this->classcontentDir = [];

            array_unshift($this->classcontentDir, $this->getBBDir().'/ClassContent');
            array_unshift($this->classcontentDir, $this->getBaseRepository().'/ClassContent');

            if ($this->hasContext()) {
                array_unshift($this->classcontentDir, $this->getRepository().'/ClassContent');
            }

            array_map(['BackBee\Utils\File\File', 'resolveFilepath'], $this->classcontentDir);
        }

        return $this->classcontentDir;
    }
546179
private function getFileContents($file) {
    if (file_exists($file) === FALSE) {
      return NULL;
    }

    $contents = file_get_contents($file);
    if ($contents === FALSE) {
      return NULL;
    }

    return $contents;
  }