Skip to content

Commit

Permalink
chore: update coding-standards to 5.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
brotkrueml committed Feb 12, 2024
1 parent 18e4749 commit abbea81
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 47 deletions.
3 changes: 1 addition & 2 deletions Classes/Event/EnrichCodeSnippetEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@ public function __construct(
public readonly TagAttributesCollector $codeAttributesCollector,
public readonly TagAttributeValuesCollector $codeClassesCollector,
public readonly ServerRequestInterface $request,
) {
}
) {}
}
5 changes: 2 additions & 3 deletions Classes/EventListener/CopyToClipboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ final class CopyToClipboard
{
public function __construct(
private readonly LanguageServiceFactory $languageServiceFactory,
) {
}
) {}

public function __invoke(EnrichCodeSnippetEvent $event): void
{
Expand All @@ -36,7 +35,7 @@ public function __invoke(EnrichCodeSnippetEvent $event): void
$event->scriptsCollector->addPath(Extension::PRISM_BASE_PATH . 'plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js');

$languageService = $this->languageServiceFactory->createFromSiteLanguage(
$event->request->getAttribute('language') ?? $event->request->getAttribute('site')->getDefaultLanguage()
$event->request->getAttribute('language') ?? $event->request->getAttribute('site')->getDefaultLanguage(),
);

$event->preAttributesCollector->setAttribute('prismjs-copy', $languageService->sL('toolbar.copy'));
Expand Down
7 changes: 3 additions & 4 deletions Classes/Preview/ContentPreviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ final class ContentPreviewRenderer extends StandardContentPreviewRenderer

public function __construct(
private readonly FlexFormService $flexFormService,
) {
}
) {}

public function renderPageModulePreviewContent(GridColumnItem $item): string
{
Expand All @@ -36,7 +35,7 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
$content .= '<pre><code style="margin-left:0;">' . $this->renderSnippet($record['bodytext']) . '</code></pre>';
} else {
$content .= $this->buildWarning(
$this->getLanguageService()->sL(Extension::LANGUAGE_PATH_CONTENT_ELEMENT . ':codeSnippet.notDefined')
$this->getLanguageService()->sL(Extension::LANGUAGE_PATH_CONTENT_ELEMENT . ':codeSnippet.notDefined'),
);
}

Expand Down Expand Up @@ -78,7 +77,7 @@ private function renderSnippet(string $input): string

private function treatSpecialChars(string $input): string
{
return \htmlspecialchars(\trim($input), ENT_QUOTES, 'UTF-8', false);
return \htmlspecialchars(\trim($input), \ENT_QUOTES, 'UTF-8', false);
}

private function buildWarning(string $text): string
Expand Down
9 changes: 4 additions & 5 deletions Classes/UserFunctions/CodeSnippetGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public function __construct(
private readonly EventDispatcher $eventDispatcher,
private readonly FlexFormService $flexFormService,
private readonly PageRenderer $pageRenderer,
) {
}
) {}

public function setContentObjectRenderer(ContentObjectRenderer $cObj): void
{
Expand All @@ -52,7 +51,7 @@ public function setContentObjectRenderer(ContentObjectRenderer $cObj): void
public function generate(
string $content,
array $conf,
ServerRequestInterface $request
ServerRequestInterface $request,
): string {
$snippet = $this->cObj->data['bodytext'] ?? '';
if ($snippet === '') {
Expand All @@ -76,7 +75,7 @@ public function generate(
new TagAttributeValuesCollector(),
new TagAttributesCollector(),
new TagAttributeValuesCollector(),
$request
$request,
);
$event->preAttributesCollector->setAttribute('id', self::PRE_ID_PREFIX . $this->cObj->data['uid']);

Expand Down Expand Up @@ -125,7 +124,7 @@ private function addJsFile(string $file, bool $allowConcatenation = true): void
false,
false,
'',
true
true,
);
}
}
2 changes: 1 addition & 1 deletion Configuration/TCA/Overrides/sys_template.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
ExtensionManagementUtility::addStaticFile(
Extension::KEY,
'Configuration/TypoScript/',
'Code Highlight'
'Code Highlight',
);
4 changes: 2 additions & 2 deletions Configuration/TCA/Overrides/tt_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
'special',
],
ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT,
Extension::KEY
Extension::KEY,
);

$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$contentType] = 'pi_flexform';
ExtensionManagementUtility::addPiFlexFormValue(
'*',
'FILE:EXT:' . Extension::KEY . '/Configuration/FlexForms/Options.xml',
$contentType
$contentType,
);

$GLOBALS['TCA']['tt_content']['types'][$contentType] = [
Expand Down
4 changes: 2 additions & 2 deletions Tests/Traits/CreateEnrichCodeSnippetEventTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ trait CreateEnrichCodeSnippetEventTrait
private function createEnrichCodeSnippetEvent(
SiteConfiguration $siteConfiguration,
Options $options,
ServerRequestInterface $request
ServerRequestInterface $request,
): EnrichCodeSnippetEvent {
return new EnrichCodeSnippetEvent(
$siteConfiguration,
Expand All @@ -35,7 +35,7 @@ private function createEnrichCodeSnippetEvent(
new TagAttributeValuesCollector(),
new TagAttributesCollector(),
new TagAttributeValuesCollector(),
$request
$request,
);
}
}
4 changes: 2 additions & 2 deletions Tests/Unit/EventListener/CommandLineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function commandLineIsDeactivated(): void
$event = $this->createEnrichCodeSnippetEvent(
new SiteConfiguration([]),
new Options([]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new CommandLine();
Expand All @@ -56,7 +56,7 @@ public function commandLineIsActivated(array $options, array $siteConfiguration,
$event = $this->createEnrichCodeSnippetEvent(
new SiteConfiguration($siteConfiguration),
new Options($options),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new CommandLine();
Expand Down
6 changes: 3 additions & 3 deletions Tests/Unit/EventListener/CopyToClipboardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function setUp(): void
$languageServiceStub = $this->createStub(LanguageService::class);
$languageServiceStub
->method('sL')
->willReturnCallback(static fn ($input): string => $input);
->willReturnCallback(static fn($input): string => $input);

$this->languageServiceFactoryStub = $this->createStub(LanguageServiceFactory::class);
$this->languageServiceFactoryStub
Expand All @@ -56,7 +56,7 @@ public function copyToClipboardIsDeactivated(): void
$event = $this->createEnrichCodeSnippetEvent(
new SiteConfiguration([]),
new Options([]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new CopyToClipboard($this->languageServiceFactoryStub);
Expand Down Expand Up @@ -85,7 +85,7 @@ public function copyToClipboardIsActivated(): void
'codehighlightToolbarCopyToClipboard' => true,
]),
new Options([]),
$requestStub
$requestStub,
);

$subject = new CopyToClipboard($this->languageServiceFactoryStub);
Expand Down
14 changes: 7 additions & 7 deletions Tests/Unit/EventListener/HighlightLinesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function highlightLinesIsSetAndUseUrlHashIsDeactivated(): void
$event = $this->createEnrichCodeSnippetEvent(
new SiteConfiguration([]),
new Options([]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new HighlightLines();
Expand All @@ -57,7 +57,7 @@ public function highlightLinesIsSet(): void
new Options([
'highlightLines' => '3-5',
]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new HighlightLines();
Expand All @@ -84,7 +84,7 @@ public function highlightLinesIsSetAndStartWithLineNumberIsGreater1(): void
'highlightLines' => '3-5',
'startWithLineNumber' => '2',
]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new HighlightLines();
Expand All @@ -109,7 +109,7 @@ public function highlightLinesIsSetAndStartWithLineNumberIs1(): void
'highlightLines' => '3-5',
'startWithLineNumber' => '1',
]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new HighlightLines();
Expand All @@ -134,7 +134,7 @@ public function highlightLinesIsNotSetAndStartWithLineNumberIsGreater0(): void
'highlightLines' => '',
'startWithLineNumber' => '2',
]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new HighlightLines();
Expand All @@ -158,7 +158,7 @@ public function useUrlHashIsActivated(): void
'codehighlightUseUrlHash' => true,
]),
new Options([]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new HighlightLines();
Expand Down Expand Up @@ -186,7 +186,7 @@ public function useUrlHashIsActivatedAndStartWithLineNumberIsGreater1(): void
new Options([
'startWithLineNumber' => 2,
]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new HighlightLines();
Expand Down
10 changes: 5 additions & 5 deletions Tests/Unit/EventListener/InlineColourTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function inlineColourIsDeactivated(): void
$event = $this->createEnrichCodeSnippetEvent(
new SiteConfiguration([]),
new Options([]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new InlineColour();
Expand All @@ -58,7 +58,7 @@ public function inlineColourIsActivatedAndLanguageIsCss(): void
'inlineColour' => '1',
'programmingLanguage' => 'css',
]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new InlineColour();
Expand Down Expand Up @@ -87,7 +87,7 @@ public function inlineColourIsActivatedAndLanguageIsHtml(): void
'inlineColour' => '1',
'programmingLanguage' => 'html',
]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new InlineColour();
Expand All @@ -112,7 +112,7 @@ public function inlineColourIsActivatedAndLanguageIsPhp(): void
'inlineColour' => '1',
'programmingLanguage' => 'php',
]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new InlineColour();
Expand All @@ -137,7 +137,7 @@ public function inlineColourIsDeactivatedAndLanguageIsCss(): void
'inlineColour' => '0',
'programmingLanguage' => 'css',
]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new InlineColour();
Expand Down
6 changes: 3 additions & 3 deletions Tests/Unit/EventListener/LanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function languageIsNotSet(): void
$event = $this->createEnrichCodeSnippetEvent(
new SiteConfiguration([]),
new Options([]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new Language();
Expand All @@ -57,7 +57,7 @@ public function languageIsSet(): void
new Options([
'programmingLanguage' => 'php',
]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new Language();
Expand All @@ -79,7 +79,7 @@ public function hasSpecialLanguageIsEnabled(): void
$event = $this->createEnrichCodeSnippetEvent(
new SiteConfiguration([]),
new Options([]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);
$event->hasSpecialLanguage = true;

Expand Down
10 changes: 5 additions & 5 deletions Tests/Unit/EventListener/LineNumbersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function optionShowLineNumbersIsDeactivated(): void
$event = $this->createEnrichCodeSnippetEvent(
new SiteConfiguration([]),
new Options([]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new LineNumbers();
Expand All @@ -57,7 +57,7 @@ public function optionShowLineNumberIsActivated(): void
new Options([
'showLineNumbers' => '1',
]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new LineNumbers();
Expand All @@ -84,7 +84,7 @@ public function optionShowLineNumberIsActivatedAndStartWithLineNumberGreater1():
'showLineNumbers' => '1',
'startWithLineNumber' => '2',
]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new LineNumbers();
Expand All @@ -109,7 +109,7 @@ public function optionShowLineNumberIsActivatedAndStartWithLineNumberIs1(): void
'showLineNumbers' => '1',
'startWithLineNumber' => '1',
]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new LineNumbers();
Expand All @@ -134,7 +134,7 @@ public function optionShowLineNumberIsActivatedAndStartWithLineNumberIsGreater1(
'showLineNumbers' => '0',
'startWithLineNumber' => '2',
]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new LineNumbers();
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/EventListener/TreeviewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function optionTreeviewIsDeactivated(): void
$event = $this->createEnrichCodeSnippetEvent(
new SiteConfiguration([]),
new Options([]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new Treeview();
Expand All @@ -54,7 +54,7 @@ public function optionTreeviewIsActivated(): void
new Options([
'treeview' => '1',
]),
$this->createStub(ServerRequestInterface::class)
$this->createStub(ServerRequestInterface::class),
);

$subject = new Treeview();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"typo3/cms-frontend": "^12.4"
},
"require-dev": {
"brotkrueml/coding-standards": "~3.0.0",
"brotkrueml/coding-standards": "~5.1.0",
"ergebnis/composer-normalize": "~2.42.0",
"php-coveralls/php-coveralls": "^2.7",
"phpstan/phpstan": "1.10.57",
Expand Down

0 comments on commit abbea81

Please sign in to comment.