Skip to content

Commit 11703a0

Browse files
authored
[BUGFIX] Avoid wrongly detected class names (#691)
resolves #686
1 parent 065b1c2 commit 11703a0

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

Documentation-rendertest/PhpInline/Index.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,13 @@ In short:
4040
* :php-short:`\TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper`
4141
* :php-short:`\MyVendor\MyExtension\FooBar`
4242
* :php-short:`\Foo\Bar\Something`
43+
44+
A new PSR-14 event :php:`TYPO3\CMS\Backend\RecordList\Event\BeforeRecordDownloadIsExecutedEvent`
45+
has been introduced to modify the result of a download / export initiated via
46+
the :guilabel:`Web > List` module.
47+
48+
This replaces the
49+
:php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList']['customizeCsvHeader']`
50+
and
51+
:php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList']['customizeCsvRow']`,
52+
hooks, which have been :ref:`deprecated <changelog:deprecation-102337-1715591179>`.

packages/typo3-docs-theme/src/TextRoles/PhpTextRole.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55
use phpDocumentor\Guides\Nodes\Inline\InlineNode;
66
use phpDocumentor\Guides\RestructuredText\Parser\DocumentParserContext;
77
use phpDocumentor\Guides\RestructuredText\TextRoles\TextRole;
8-
use T3Docs\GuidesPhpDomain\PhpDomain\FullyQualifiedNameService;
98
use T3Docs\Typo3DocsTheme\Api\Typo3ApiService;
109
use T3Docs\Typo3DocsTheme\Inventory\Typo3VersionService;
1110
use T3Docs\Typo3DocsTheme\Nodes\Inline\CodeInlineNode;
1211

1312
final class PhpTextRole implements TextRole
1413
{
14+
/**
15+
* @see https://regex101.com/r/LN5Ick/1
16+
*/
17+
final public const CLASS_NAME_PATTERN_REGEX = '/^(\\\\)?[A-Za-z_][A-Za-z0-9_]*(\\\\[A-Za-z_][A-Za-z0-9_]*)*$/';
18+
19+
1520
public function __construct(
16-
private readonly FullyQualifiedNameService $fullyQualifiedNameService,
1721
private readonly Typo3ApiService $typo3ApiService,
1822
private readonly Typo3VersionService $typo3VersionService,
1923
) {}
@@ -34,7 +38,7 @@ public function processNode(DocumentParserContext $documentParserContext, string
3438
{
3539
$fqn = [];
3640
$rawContent = trim($rawContent);
37-
if (str_contains($rawContent, '\\') && $this->fullyQualifiedNameService->isFullyQualifiedName($rawContent, $fqn)) {
41+
if (str_contains($rawContent, '\\') && $this->isClassName($rawContent, $fqn)) {
3842
if (!str_starts_with($rawContent, '\\')) {
3943
$rawContent = '\\' . $rawContent;
4044
}
@@ -134,7 +138,11 @@ private function getClassCodeNode(string $fqn, array $apiInfo, string $role, str
134138
}
135139
$modifiers[] = $apiInfo['type'];
136140
$infoArray = [];
137-
$infoArray[] = '<code>' . implode(' ', $modifiers) . ' ' . $apiInfo['short'] . '</code>: <code>' . $apiInfo['fqn'] . '</code>';
141+
$infoArray[] = '<code>' . implode(' ', $modifiers) . ' ' . $apiInfo['short'] . '</code>';
142+
143+
if ($role === 'php-short') {
144+
$infoArray[] = '<code>' . $apiInfo['fqn'] . '</code>';
145+
}
138146
if ($apiInfo['internal']) {
139147
$infoArray[] = 'internal!';
140148
}
@@ -145,6 +153,7 @@ private function getClassCodeNode(string $fqn, array $apiInfo, string $role, str
145153
$infoArray[] = '<em>' . $apiInfo['summary'] . '</em>';
146154
}
147155
$info = implode('<br>', $infoArray);
156+
$info = str_replace('\\', '&#8203;\\', $info);
148157
return new CodeInlineNode($name, 'PHP ' . $type, $info, $apiInfo);
149158
} elseif(str_starts_with($fqn, '\\TYPO3Fluid')) {
150159
$info = 'This PHP class or interface belongs to Fluid. ';
@@ -177,4 +186,11 @@ private function getClassCodeNode(string $fqn, array $apiInfo, string $role, str
177186
[]
178187
);
179188
}
189+
/**
190+
* @param list<string> $matches
191+
*/
192+
private function isClassName(string $name, array &$matches): bool
193+
{
194+
return (bool)preg_match(self::CLASS_NAME_PATTERN_REGEX, $name, $matches);
195+
}
180196
}

tests/Integration/tests-full/changelog/expected/Changelog/12.0/Breaking-87616-RemovedHookForAlteringPageLinks.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ <h2>Description<a class="headerlink" href="#description" data-bs-toggle="modal"
169169
settings stored in a global array called $GLOBALS['TYPO3_CONF_VARS'].
170170
They are commonly set in config/system/settings.php, config/system/additional.php,
171171
or the ext_localconf.php file of an extension. " data-bs-html="true"><a href="https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/Configuration/Typo3ConfVars/Index.html" target="_blank">$GLOBALS[&#039;TYPO3_CONF_VARS&#039;][&#039;SC_OPTIONS&#039;][&#039;typolinkProcessing&#039;][&#039;typolinkModifyParameterForPageLinks&#039;] <span class="text-secondary"><i class="fa-regular fa-circle-question"></i></span></a></code>
172-
has been removed in favor of a new PSR-14 event <code class="code-inline" translate="no" aria-description="PHP class" aria-details="<code>final class ModifyPageLinkConfigurationEvent</code>: <code>\TYPO3\CMS\Frontend\Event\ModifyPageLinkConfigurationEvent</code><br><em>A generic PSR 14 Event to allow modifying the incoming (and resolved) page when building a &quot;page link&quot;.</em>" data-bs-html="true"><a href="https://api.typo3.org/main/classes/TYPO3-CMS-Frontend-Event-ModifyPageLinkConfigurationEvent.html" target="_blank">\TYPO3\CMS\Frontend\Event\ModifyPageLinkConfigurationEvent <span class="text-secondary"><i class="fa-regular fa-circle-question"></i></span></a></code>.</p>
172+
has been removed in favor of a new PSR-14 event <code class="code-inline" translate="no" aria-description="PHP class" aria-details="<code>final class ModifyPageLinkConfigurationEvent</code><br><em>A generic PSR 14 Event to allow modifying the incoming (and resolved) page when building a &quot;page link&quot;.</em>" data-bs-html="true"><a href="https://api.typo3.org/main/classes/TYPO3-CMS-Frontend-Event-ModifyPageLinkConfigurationEvent.html" target="_blank">\TYPO3\CMS\Frontend\Event\ModifyPageLinkConfigurationEvent <span class="text-secondary"><i class="fa-regular fa-circle-question"></i></span></a></code>.</p>
173173

174174

175175
<p>The event is called after TYPO3 has already prepared some functionality

0 commit comments

Comments
 (0)