From 6746ff9067a69d8c382a9607d6aa2f789ecea745 Mon Sep 17 00:00:00 2001 From: SonataCI Date: Wed, 13 Nov 2024 10:50:58 +0000 Subject: [PATCH 1/2] DevKit updates --- rector.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rector.php b/rector.php index b6dac16f..74463238 100644 --- a/rector.php +++ b/rector.php @@ -19,6 +19,7 @@ use Rector\Config\RectorConfig; use Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector; +use Rector\PHPUnit\CodeQuality\Rector\Class_\NarrowUnusedSetUpDefinedPropertyRector; use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector; use Rector\PHPUnit\Set\PHPUnitSetList; use Rector\Set\ValueObject\LevelSetList; @@ -40,5 +41,6 @@ $rectorConfig->skip([ ExceptionHandlerTypehintRector::class, PreferPHPUnitThisCallRector::class, + NarrowUnusedSetUpDefinedPropertyRector::class, ]); }; From 0e21f7ce55f3c1b09bf22b90178ce4b3ef0cd8c1 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Wed, 13 Nov 2024 15:29:02 +0100 Subject: [PATCH 2/2] Fix --- composer.json | 1 + .../BaseBreadcrumbMenuBlockService.php | 2 +- src/Command/SitemapGeneratorCommand.php | 14 +++++++------- src/Twig/Extension/SeoExtension.php | 18 +++++++++--------- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index ec44628e..365b1b87 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,7 @@ "knplabs/knp-menu": "^3.0", "knplabs/knp-menu-bundle": "^3.0", "phpstan/extension-installer": "^1.0", + "phpstan/phpdoc-parser": "^1.0", "phpstan/phpstan": "^1.0", "phpstan/phpstan-phpunit": "^1.0", "phpstan/phpstan-strict-rules": "^1.0", diff --git a/src/Block/Breadcrumb/BaseBreadcrumbMenuBlockService.php b/src/Block/Breadcrumb/BaseBreadcrumbMenuBlockService.php index e528a2f1..72aeb8b3 100644 --- a/src/Block/Breadcrumb/BaseBreadcrumbMenuBlockService.php +++ b/src/Block/Breadcrumb/BaseBreadcrumbMenuBlockService.php @@ -31,7 +31,7 @@ abstract class BaseBreadcrumbMenuBlockService extends AbstractMenuBlockService i { public function __construct( Environment $twig, - private FactoryInterface $factory + private FactoryInterface $factory, ) { parent::__construct($twig); } diff --git a/src/Command/SitemapGeneratorCommand.php b/src/Command/SitemapGeneratorCommand.php index 31d919e3..43b452d2 100644 --- a/src/Command/SitemapGeneratorCommand.php +++ b/src/Command/SitemapGeneratorCommand.php @@ -39,7 +39,7 @@ final class SitemapGeneratorCommand extends Command public function __construct( private RouterInterface $router, private SourceManager $sitemapManager, - private Filesystem $filesystem + private Filesystem $filesystem, ) { parent::__construct(); } @@ -86,7 +86,7 @@ public function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Generating sitemap - this can take a while'); $this->generateSitemap($tempDir, $scheme, $host, $appendPath); - $output->writeln(sprintf('Moving temporary file to %s ...', $permanentDir)); + $output->writeln(\sprintf('Moving temporary file to %s ...', $permanentDir)); $this->moveTemporaryFile($tempDir, $permanentDir); $output->writeln('Cleanup ...'); @@ -111,7 +111,7 @@ private function createTempDir(OutputInterface $output): ?string { $tempDir = sys_get_temp_dir().'/sonata_sitemap_'.md5(__DIR__); - $output->writeln(sprintf('Creating temporary directory: %s', $tempDir)); + $output->writeln(\sprintf('Creating temporary directory: %s', $tempDir)); if ($this->filesystem->exists($tempDir)) { return null; @@ -148,7 +148,7 @@ private function generateSitemap(string $dir, string $scheme, string $host, stri // generate global sitemap index SitemapWriter::generateSitemapIndex( $dir, - sprintf('%s://%s%s', $scheme, $host, $appendPath), + \sprintf('%s://%s%s', $scheme, $host, $appendPath), 'sitemap*.xml', 'sitemap.xml' ); @@ -161,7 +161,7 @@ private function moveTemporaryFile(string $tempDir, string $permanentDir): void $pathname = $file->getRealPath(); if (false === $pathname) { - throw new \LogicException(sprintf('File %s does not exist', (string) $file)); + throw new \LogicException(\sprintf('File %s does not exist', (string) $file)); } $this->filesystem->remove($pathname); @@ -172,10 +172,10 @@ private function moveTemporaryFile(string $tempDir, string $permanentDir): void $pathname = $file->getRealPath(); if (false === $pathname) { - throw new \LogicException(sprintf('File %s does not exist', (string) $file)); + throw new \LogicException(\sprintf('File %s does not exist', (string) $file)); } - $this->filesystem->rename($pathname, sprintf('%s/%s', $permanentDir, $file->getFilename())); + $this->filesystem->rename($pathname, \sprintf('%s/%s', $permanentDir, $file->getFilename())); } } } diff --git a/src/Twig/Extension/SeoExtension.php b/src/Twig/Extension/SeoExtension.php index 3092ee3b..05ce0c4b 100644 --- a/src/Twig/Extension/SeoExtension.php +++ b/src/Twig/Extension/SeoExtension.php @@ -22,7 +22,7 @@ final class SeoExtension extends AbstractExtension { public function __construct( private SeoPageInterface $page, - private string $encoding + private string $encoding, ) { } @@ -51,7 +51,7 @@ public function getName(): string public function getTitle(): string { - return sprintf('%s', strip_tags($this->page->getTitle())); + return \sprintf('%s', strip_tags($this->page->getTitle())); } public function getTitleText(): string @@ -67,14 +67,14 @@ public function getMetadatas(): string [$content, $extras] = $meta; if ('' !== $content) { - $html .= sprintf( + $html .= \sprintf( "\n", $type, $this->normalize($name), $this->normalize((string) $content) ); } else { - $html .= sprintf( + $html .= \sprintf( "\n", $type, $this->normalize($name) @@ -90,7 +90,7 @@ public function getHtmlAttributes(): string { $attributes = ''; foreach ($this->page->getHtmlAttributes() as $name => $value) { - $attributes .= sprintf('%s="%s" ', $name, $value); + $attributes .= \sprintf('%s="%s" ', $name, $value); } return rtrim($attributes); @@ -100,7 +100,7 @@ public function getHeadAttributes(): string { $attributes = ''; foreach ($this->page->getHeadAttributes() as $name => $value) { - $attributes .= sprintf('%s="%s" ', $name, $value); + $attributes .= \sprintf('%s="%s" ', $name, $value); } return rtrim($attributes); @@ -109,7 +109,7 @@ public function getHeadAttributes(): string public function getLinkCanonical(): string { if ('' !== $this->page->getLinkCanonical()) { - return sprintf("\n", $this->page->getLinkCanonical()); + return \sprintf("\n", $this->page->getLinkCanonical()); } return ''; @@ -119,7 +119,7 @@ public function getLangAlternates(): string { $html = ''; foreach ($this->page->getLangAlternates() as $href => $hrefLang) { - $html .= sprintf("\n", $href, $hrefLang); + $html .= \sprintf("\n", $href, $hrefLang); } return $html; @@ -129,7 +129,7 @@ public function getOembedLinks(): string { $html = ''; foreach ($this->page->getOEmbedLinks() as $title => $link) { - $html .= sprintf("\n", $link, $title); + $html .= \sprintf("\n", $link, $title); } return $html;