Skip to content

Commit

Permalink
Merge pull request #247 from stefandoorn/ecs
Browse files Browse the repository at this point in the history
ECS improvements
  • Loading branch information
stefandoorn authored Mar 23, 2023
2 parents 9919006 + c4ee06a commit 2e2a094
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 25 deletions.
4 changes: 4 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer;
use PhpCsFixer\Fixer\ControlStructure\TrailingCommaInMultilineFixer;
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;

Expand All @@ -16,4 +17,7 @@
$services->set(
NativeFunctionInvocationFixer::class
)->call('configure', [['include' => ['@all'], 'scope' => 'all', 'strict' => \true]]);
$services->set(
TrailingCommaInMultilineFixer::class
)->call('configure', [['elements' => ['arrays']]]);
};
2 changes: 1 addition & 1 deletion spec/Builder/SitemapBuilderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function it_builds_sitemap(
UrlProviderInterface $productUrlProvider,
SitemapInterface $sitemap,
UrlInterface $bookUrl,
ChannelInterface $channel,
ChannelInterface $channel
): void {
$sitemapFactory->createNew()->willReturn($sitemap);
$this->addProvider($productUrlProvider);
Expand Down
4 changes: 2 additions & 2 deletions spec/Model/SitemapSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function it_adds_url(UrlInterface $sitemapUrl): void
function it_removes_url(
UrlInterface $sitemapUrl,
UrlInterface $productUrl,
UrlInterface $staticUrl,
UrlInterface $staticUrl
): void {
$this->addUrl($sitemapUrl);
$this->addUrl($staticUrl);
Expand All @@ -61,7 +61,7 @@ function it_has_last_modification_date(\DateTime $now): void

function it_throws_sitemap_url_not_found_exception_if_cannot_find_url_to_remove(
UrlInterface $productUrl,
UrlInterface $staticUrl,
UrlInterface $staticUrl
): void {
$this->addUrl($productUrl);

Expand Down
6 changes: 3 additions & 3 deletions spec/Provider/ProductUrlProviderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function let(
UrlFactoryInterface $urlFactory,
AlternativeUrlFactoryInterface $alternativeUrlFactory,
LocaleContextInterface $localeContext,
ProductImagesToSitemapImagesCollectionGeneratorInterface $productToImageSitemapArrayGenerator,
ProductImagesToSitemapImagesCollectionGeneratorInterface $productToImageSitemapArrayGenerator
): void {
$this->beConstructedWith($repository, $router, $urlFactory, $alternativeUrlFactory, $localeContext, $productToImageSitemapArrayGenerator);
}
Expand Down Expand Up @@ -67,7 +67,7 @@ function it_generates_urls_for_the_unique_channel_locale(
QueryBuilder $queryBuilder,
AbstractQuery $query,
ChannelInterface $channel,
ProductImagesToSitemapImagesCollectionGeneratorInterface $productToImageSitemapArrayGenerator,
ProductImagesToSitemapImagesCollectionGeneratorInterface $productToImageSitemapArrayGenerator
): void {
$now = new \DateTime();

Expand Down Expand Up @@ -157,7 +157,7 @@ function it_generates_urls_for_all_channel_locales(
QueryBuilder $queryBuilder,
AbstractQuery $query,
ChannelInterface $channel,
ProductImagesToSitemapImagesCollectionGeneratorInterface $productToImageSitemapArrayGenerator,
ProductImagesToSitemapImagesCollectionGeneratorInterface $productToImageSitemapArrayGenerator
): void {
$now = new \DateTime();

Expand Down
6 changes: 3 additions & 3 deletions src/Command/GenerateSitemapCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(
SitemapIndexBuilderInterface $sitemapIndexBuilder,
Writer $writer,
ChannelRepositoryInterface $channelRepository,
RouterInterface $router,
RouterInterface $router
) {
$this->sitemapRenderer = $sitemapRenderer;
$this->sitemapIndexRenderer = $sitemapIndexRenderer;
Expand Down Expand Up @@ -81,7 +81,7 @@ private function executeChannel(ChannelInterface $channel, OutputInterface $outp

$this->writer->write(
$path,
$xml,
$xml
);

$output->writeln(\sprintf('Finished generating sitemap "%s" for channel "%s" at path "%s"', $provider->getName(), $channel->getCode(), $path));
Expand All @@ -95,7 +95,7 @@ private function executeChannel(ChannelInterface $channel, OutputInterface $outp

$this->writer->write(
$path,
$xml,
$xml
);

$output->writeln(\sprintf('Finished generating sitemap index for channel "%s" at path "%s"', $channel->getCode(), $path));
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/SitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class SitemapController extends AbstractController

public function __construct(
ChannelContextInterface $channelContext,
Reader $reader,
Reader $reader
) {
$this->channelContext = $channelContext;

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/SitemapIndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class SitemapIndexController extends AbstractController

public function __construct(
ChannelContextInterface $channelContext,
Reader $reader,
Reader $reader
) {
$this->channelContext = $channelContext;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class ProductImagesToSitemapImagesCollectionGenerator implements ProductIm
public function __construct(
ImageFactoryInterface $sitemapImageUrlFactory,
CacheManager $imagineCacheManager,
?string $imagePreset = null,
?string $imagePreset = null
) {
$this->sitemapImageUrlFactory = $sitemapImageUrlFactory;
$this->imagineCacheManager = $imagineCacheManager;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function setPriority(float $priority): void
if (0 > $priority || 1 < $priority) {
throw new \InvalidArgumentException(\sprintf(
'The value %s is not supported by the option priority, it must be a number between 0.0 and 1.0.',
$priority,
$priority
));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Provider/IndexUrlProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class IndexUrlProvider implements IndexUrlProviderInterface

public function __construct(
RouterInterface $router,
IndexUrlFactoryInterface $sitemapIndexUrlFactory,
IndexUrlFactoryInterface $sitemapIndexUrlFactory
) {
$this->router = $router;
$this->sitemapIndexUrlFactory = $sitemapIndexUrlFactory;
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/ProductUrlProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(
UrlFactoryInterface $urlFactory,
AlternativeUrlFactoryInterface $urlAlternativeFactory,
LocaleContextInterface $localeContext,
ProductImagesToSitemapImagesCollectionGeneratorInterface $productToImageSitemapArrayGenerator,
ProductImagesToSitemapImagesCollectionGeneratorInterface $productToImageSitemapArrayGenerator
) {
$this->productRepository = $productRepository;
$this->router = $router;
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/StaticUrlProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(
RouterInterface $router,
UrlFactoryInterface $sitemapUrlFactory,
AlternativeUrlFactoryInterface $urlAlternativeFactory,
array $routes,
array $routes
) {
$this->router = $router;
$this->sitemapUrlFactory = $sitemapUrlFactory;
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/TaxonUrlProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(
UrlFactoryInterface $sitemapUrlFactory,
AlternativeUrlFactoryInterface $urlAlternativeFactory,
LocaleContextInterface $localeContext,
bool $excludeTaxonRoot = true,
bool $excludeTaxonRoot = true
) {
$this->taxonRepository = $taxonRepository;
$this->router = $router;
Expand Down
4 changes: 2 additions & 2 deletions src/Routing/SitemapLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public function load($resource, $type = null)
[],
'',
[],
['GET'],
),
['GET']
)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function it_has_providers_enabled_by_default_with_parameter(
array $config,
bool $products,
bool $taxons,
bool $static,
bool $static
) {
$this->load($config);

Expand Down
10 changes: 5 additions & 5 deletions tests/DependencyInjection/Compiler/SitemapProviderPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ public function it_adds_method_call_to_sitemap_builder_if_providers_exist()
'addProvider',
[
new Reference('sylius.sitemap_provider.product'),
],
]
);

$this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
'sylius.sitemap_index_builder',
'addIndexProvider',
[
new Reference('sylius.sitemap_index_provider.index'),
],
]
);
}

Expand All @@ -70,12 +70,12 @@ public function it_does_not_add_method_call_if_there_is_no_url_providers()

$this->assertContainerBuilderDoesNotHaveServiceDefinitionWithMethodCall(
'sylius.sitemap_builder',
'addProvider',
'addProvider'
);

$this->assertContainerBuilderDoesNotHaveServiceDefinitionWithMethodCall(
'sylius.sitemap_index_builder',
'addProvider',
'addProvider'
);
}

Expand All @@ -94,7 +94,7 @@ private function assertContainerBuilderDoesNotHaveServiceDefinitionWithMethodCal

self::assertThat(
$definition,
new \PHPUnit\Framework\Constraint\LogicalNot(new DefinitionHasMethodCallConstraint($method)),
new \PHPUnit\Framework\Constraint\LogicalNot(new DefinitionHasMethodCallConstraint($method))
);
}
}

0 comments on commit 2e2a094

Please sign in to comment.