2 declare(strict_types = 1);
19 use Symfony\Component\Finder\Finder;
20 use Symfony\Component\Finder\SplFileInfo;
58 if ($this->registry ===
null) {
62 $this->changelogPath = str_replace(
'\\',
'/', $this->changelogPath);
74 if (strcasecmp($path, $this->changelogPath) < 0 || strpos($path, $this->changelogPath) ===
false) {
75 throw new \InvalidArgumentException(
'the given path does not belong to the changelog dir. Aborting', 1537158043);
85 foreach (
$finder->directories() as $directory) {
87 $directories[] = $directory->getBasename();
102 if (strcasecmp($path, $this->changelogPath) < 0 || strpos($path, $this->changelogPath) ===
false) {
103 throw new \InvalidArgumentException(
'the given path does not belong to the changelog dir. Aborting', 1485425530);
109 return $documentationFiles;
121 if (strcasecmp($file, $this->changelogPath) < 0 || strpos($file, $this->changelogPath) ===
false) {
122 throw new \InvalidArgumentException(
'the given file does not belong to the changelog dir. Aborting', 1485425531);
124 $lines = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
127 $entry[
'headline'] = $headline;
128 $entry[
'filepath'] = $file;
129 $entry[
'filename'] = pathinfo($file)[
'filename'];
131 $entry[
'class'] =
'default';
132 foreach ($entry[
'tags'] as $key => $tag) {
133 if (strpos($tag,
'cat:') === 0) {
134 $substr = substr($tag, 4);
135 $entry[
'class'] = strtolower($substr);
136 $entry[
'tags'][$key] = $substr;
139 $entry[
'tagList'] = implode(
',', $entry[
'tags']);
140 $entry[
'content'] = file_get_contents($file);
141 $entry[
'parsedContent'] = $this->
parseContent($entry[
'content']);
142 $entry[
'file_hash'] = md5($entry[
'content']);
143 if ($entry[
'version'] !==
'') {
144 $entry[
'url'][
'documentation'] = sprintf(
145 'https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/%s/%s.html',
152 $entry[
'url'][
'issue'] = sprintf(
'https://forge.typo3.org/issues/%s', $issueId);
155 return [md5($file) => $entry];
166 $isRelevantFile = $fileInfo[
'extension'] ===
'rst' && $fileInfo[
'filename'] !==
'Index';
169 $isRelevantFile =
false;
172 return $isRelevantFile;
200 foreach ($file as $line) {
201 if (strpos($line,
'.. index::') === 0) {
202 $tagString = substr($line, strlen(
'.. index:: '));
203 return GeneralUtility::trimExplode(
',', $tagString,
true);
221 if (strpos($headline,
':') !==
false) {
222 return 'cat:' . substr($headline, 0, strpos($headline,
':'));
237 while (strpos($lines[$index],
'..') === 0 || strpos($lines[$index],
'==') === 0) {
240 return trim($lines[$index]);
250 $absolutePath = str_replace(
'\\',
'/', $docDirectory) .
'/' . $version;
253 return $finder->files()->count() > 0;
264 $documentationFiles = [[]];
265 $absolutePath = str_replace(
'\\',
'/', $docDirectory);
268 foreach (
$finder->files() as $file) {
270 $documentationFiles[] = $this->
getListEntry($file->getPathname());
273 return array_merge(...$documentationFiles);
285 foreach ($documentationFiles as $fileArray) {
286 $tags[] = $fileArray[
'tags'];
289 return array_unique(array_merge(...$tags));
310 $isFileIgnoredByUsersChoice =
false;
312 $ignoredFiles = $this->registry->get(
'upgradeAnalysisIgnoreFilter',
'ignoredDocumentationFiles');
313 if (is_array($ignoredFiles)) {
314 foreach ($ignoredFiles as $filePath) {
315 if ($filePath !==
null && strlen($filePath) > 0) {
316 if (strpos($filePath, $filename) !==
false) {
317 $isFileIgnoredByUsersChoice =
true;
323 return $isFileIgnoredByUsersChoice;
333 $content = htmlspecialchars($rstContent);
334 $content = preg_replace(
'/:issue:`([\d]*)`/',
'<a href="https://forge.typo3.org/issues/\\1" target="_blank" rel="noopener noreferrer">\\1</a>', $content);
335 $content = preg_replace(
'/#([\d]*)/',
'#<a href="https://forge.typo3.org/issues/\\1" target="_blank" rel="noopener noreferrer">\\1</a>', $content);
336 $content = preg_replace(
'/(\n([=]*)\n(.*)\n([=]*)\n)/',
'', $content, 1);
337 $content = preg_replace(
'/.. index::(.*)/',
'', $content);
338 $content = preg_replace(
'/.. include::(.*)/',
'', $content);
339 return trim($content);
349 return GeneralUtility::trimExplode(
'-', $filename)[1] ??
null;
361 ->name(
'/^(Feature|Breaking|Deprecation|Important)\-\d+.+\.rst$/i');