Skip to content

Commit

Permalink
Merge pull request #479 from BitBagCommerce/OP-164-match-sylius-code
Browse files Browse the repository at this point in the history
OP-164: Code quality upgrade
  • Loading branch information
senghe authored Nov 12, 2023
2 parents 8e91fbf + 7c8a1e8 commit 34d1b7b
Show file tree
Hide file tree
Showing 197 changed files with 4,218 additions and 1,384 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ jobs:
name: Run PHPSpec
run: vendor/bin/phpspec run --ansi -f progress --no-interaction

-
name: Run PHPUnit
run: vendor/bin/phpunit --colors=always

-
name: Run Behat
run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"require-dev": {
"behat/behat": "^3.7",
"behat/mink-selenium2-driver": "^1.4",
"bitbag/coding-standard": "^1.0",
"bitbag/coding-standard": "^2.0",
"dmore/behat-chrome-extension": "^1.3",
"dmore/chrome-mink-driver": "^2.7",
"friends-of-behat/mink": "^1.8",
Expand All @@ -33,10 +33,10 @@
"lchrusciel/api-test-case": "^4.1 || ^5.0",
"phpspec/phpspec": "^7.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "0.12.99",
"phpstan/phpstan-doctrine": "0.12.33",
"phpstan/phpstan-strict-rules": "^0.12.0",
"phpstan/phpstan-webmozart-assert": "0.12.12",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-doctrine": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-webmozart-assert": "^1.0",
"phpunit/phpunit": "^9.5",
"sylius-labs/coding-standard": "^4.0",
"symfony/browser-kit": "^5.4 || ^6.0",
Expand Down
2 changes: 0 additions & 2 deletions easy-coding-standard.yml

This file was deleted.

8 changes: 4 additions & 4 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Option;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import('vendor/bitbag/coding-standard/ecs.php');
return static function (ECSConfig $config): void {
$config->import('vendor/bitbag/coding-standard/ecs.php');

$parameters = $containerConfigurator->parameters();
$parameters = $config->parameters();
$parameters->set(Option::PATHS, [
__DIR__ . '/src',
__DIR__ . '/tests',
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
includes:
- vendor/bitbag/coding-standard/phpstan.neon
parameters:
level: 8
reportUnmatchedIgnoredErrors: false
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
Expand Down
13 changes: 7 additions & 6 deletions spec/Assigner/ChannelsAssignerSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\BitBag\SyliusCmsPlugin\Assigner;

use BitBag\SyliusCmsPlugin\Assigner\ChannelsAssigner;
Expand All @@ -11,28 +13,27 @@

final class ChannelsAssignerSpec extends ObjectBehavior
{
function let(ChannelRepositoryInterface $channelRepository): void
public function let(ChannelRepositoryInterface $channelRepository): void
{
$this->beConstructedWith($channelRepository);
}

function it_is_initializable(): void
public function it_is_initializable(): void
{
$this->shouldHaveType(ChannelsAssigner::class);
}

function it_implements_channels_assigner_interface(): void
public function it_implements_channels_assigner_interface(): void
{
$this->shouldHaveType(ChannelsAssignerInterface::class);
}

function it_assigns_channels(
public function it_assigns_channels(
ChannelRepositoryInterface $channelRepository,
ChannelInterface $webChannel,
ChannelInterface $posChannel,
ChannelsAwareInterface $channelsAware
): void
{
): void {
$channelRepository->findOneBy(['code' => 'web'])->willReturn($webChannel);
$channelRepository->findOneBy(['code' => 'pos'])->willReturn($posChannel);

Expand Down
13 changes: 7 additions & 6 deletions spec/Assigner/ProductsAssignerSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\BitBag\SyliusCmsPlugin\Assigner;

use BitBag\SyliusCmsPlugin\Assigner\ProductsAssigner;
Expand All @@ -11,28 +13,27 @@

final class ProductsAssignerSpec extends ObjectBehavior
{
function let(ProductRepositoryInterface $productRepository): void
public function let(ProductRepositoryInterface $productRepository): void
{
$this->beConstructedWith($productRepository);
}

function it_is_initializable(): void
public function it_is_initializable(): void
{
$this->shouldHaveType(ProductsAssigner::class);
}

function it_implements_products_assigner_interface(): void
public function it_implements_products_assigner_interface(): void
{
$this->shouldHaveType(ProductsAssignerInterface::class);
}

function it_assigns_products(
public function it_assigns_products(
ProductRepositoryInterface $productRepository,
ProductInterface $mugProduct,
ProductInterface $tshirtProduct,
ProductsAwareInterface $productsAware
): void
{
): void {
$productRepository->findOneBy(['code' => 'mug'])->willReturn($mugProduct);
$productRepository->findOneBy(['code' => 't-shirt'])->willReturn($tshirtProduct);

Expand Down
13 changes: 7 additions & 6 deletions spec/Assigner/SectionsAssignerSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\BitBag\SyliusCmsPlugin\Assigner;

use BitBag\SyliusCmsPlugin\Assigner\SectionsAssigner;
Expand All @@ -11,28 +13,27 @@

final class SectionsAssignerSpec extends ObjectBehavior
{
function let(SectionRepositoryInterface $sectionRepository): void
public function let(SectionRepositoryInterface $sectionRepository): void
{
$this->beConstructedWith($sectionRepository);
}

function it_is_initializable(): void
public function it_is_initializable(): void
{
$this->shouldHaveType(SectionsAssigner::class);
}

function it_implements_sections_assigner_interface(): void
public function it_implements_sections_assigner_interface(): void
{
$this->shouldHaveType(SectionsAssignerInterface::class);
}

function it_assigns_sections(
public function it_assigns_sections(
SectionRepositoryInterface $sectionRepository,
SectionInterface $aboutSection,
SectionInterface $blogSection,
SectionableInterface $sectionsAware
): void
{
): void {
$sectionRepository->findOneBy(['code' => 'about'])->willReturn($aboutSection);
$sectionRepository->findOneBy(['code' => 'blog'])->willReturn($blogSection);

Expand Down
13 changes: 7 additions & 6 deletions spec/Assigner/TaxonsAssignerSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\BitBag\SyliusCmsPlugin\Assigner;

use BitBag\SyliusCmsPlugin\Assigner\TaxonsAssigner;
Expand All @@ -11,28 +13,27 @@

final class TaxonsAssignerSpec extends ObjectBehavior
{
function let(TaxonRepositoryInterface $taxonRepository): void
public function let(TaxonRepositoryInterface $taxonRepository): void
{
$this->beConstructedWith($taxonRepository);
}

function it_is_initializable(): void
public function it_is_initializable(): void
{
$this->shouldHaveType(TaxonsAssigner::class);
}

function it_implements_taxons_assigner_interface(): void
public function it_implements_taxons_assigner_interface(): void
{
$this->shouldHaveType(TaxonsAssignerInterface::class);
}

function it_assigns_taxons(
public function it_assigns_taxons(
TaxonRepositoryInterface $taxonRepository,
TaxonInterface $mugsTaxon,
TaxonInterface $stickersTaxon,
TaxonAwareInterface $taxonsAware
): void
{
): void {
$taxonRepository->findOneBy(['code' => 'mugs'])->willReturn($mugsTaxon);
$taxonRepository->findOneBy(['code' => 'stickers'])->willReturn($stickersTaxon);

Expand Down
6 changes: 3 additions & 3 deletions spec/Controller/Action/Admin/UploadEditorImageActionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@

final class UploadEditorImageActionSpec extends ObjectBehavior
{
function let(
public function let(
MediaProviderResolverInterface $mediaProviderResolver,
MediaRepositoryInterface $mediaRepository,
FactoryInterface $mediaFactory
) {
$this->beConstructedWith($mediaProviderResolver, $mediaRepository, $mediaFactory);
}

function it_is_initializable(): void
public function it_is_initializable(): void
{
$this->shouldHaveType(UploadEditorImageAction::class);
}

function it_uploads_media(
public function it_uploads_media(
Request $request,
FactoryInterface $mediaFactory,
MediaInterface $media,
Expand Down
16 changes: 8 additions & 8 deletions spec/Entity/BlockSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@

final class BlockSpec extends ObjectBehavior
{
function it_is_initializable(): void
public function it_is_initializable(): void
{
$this->shouldHaveType(Block::class);
}

function it_is_a_resource(): void
public function it_is_a_resource(): void
{
$this->shouldHaveType(ResourceInterface::class);
}

function it_implements_block_interface(): void
public function it_implements_block_interface(): void
{
$this->shouldHaveType(BlockInterface::class);
}

function it_toggles(): void
public function it_toggles(): void
{
$this->enable();
$this->isEnabled()->shouldReturn(true);
Expand All @@ -45,7 +45,7 @@ function it_toggles(): void
$this->isEnabled()->shouldReturn(false);
}

function it_associates_products(ProductInterface $firstProduct, ProductInterface $secondProduct): void
public function it_associates_products(ProductInterface $firstProduct, ProductInterface $secondProduct): void
{
$this->addProduct($firstProduct);
$this->hasProduct($firstProduct)->shouldReturn(true);
Expand All @@ -57,7 +57,7 @@ function it_associates_products(ProductInterface $firstProduct, ProductInterface
$this->hasProduct($firstProduct)->shouldReturn(false);
}

function it_associates_sections(SectionInterface $firstSection, SectionInterface $secondSection): void
public function it_associates_sections(SectionInterface $firstSection, SectionInterface $secondSection): void
{
$this->addSection($firstSection);
$this->hasSection($firstSection)->shouldReturn(true);
Expand All @@ -69,7 +69,7 @@ function it_associates_sections(SectionInterface $firstSection, SectionInterface
$this->hasSection($firstSection)->shouldReturn(false);
}

function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void
public function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void
{
$this->addChannel($firstChannel);
$this->hasChannel($firstChannel)->shouldReturn(true);
Expand All @@ -81,7 +81,7 @@ function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface
$this->hasChannel($firstChannel)->shouldReturn(false);
}

function it_associates_taxons(TaxonInterface $firstTaxon, TaxonInterface $secondTaxon): void
public function it_associates_taxons(TaxonInterface $firstTaxon, TaxonInterface $secondTaxon): void
{
$this->addTaxon($firstTaxon);
$this->hasTaxon($firstTaxon)->shouldReturn(true);
Expand Down
8 changes: 4 additions & 4 deletions spec/Entity/BlockTranslationSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@

final class BlockTranslationSpec extends ObjectBehavior
{
function it_is_initializable(): void
public function it_is_initializable(): void
{
$this->shouldHaveType(ResourceInterface::class);
}

function it_is_a_resource(): void
public function it_is_a_resource(): void
{
$this->shouldHaveType(ResourceInterface::class);
}

function it_implements_block_translation_interface(): void
public function it_implements_block_translation_interface(): void
{
$this->shouldHaveType(BlockTranslationInterface::class);
$this->shouldHaveType(TranslationInterface::class);
}

function it_allows_access_via_properties(): void
public function it_allows_access_via_properties(): void
{
$this->setName('Escobar favorite quote');
$this->getName()->shouldReturn('Escobar favorite quote');
Expand Down
12 changes: 6 additions & 6 deletions spec/Entity/FrequentlyAskedQuestionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@

final class FrequentlyAskedQuestionSpec extends ObjectBehavior
{
function it_is_initializable(): void
public function it_is_initializable(): void
{
$this->shouldHaveType(FrequentlyAskedQuestion::class);
}

function it_is_a_resource(): void
public function it_is_a_resource(): void
{
$this->shouldHaveType(ResourceInterface::class);
}

function it_implements_frequently_asked_question_interface(): void
public function it_implements_frequently_asked_question_interface(): void
{
$this->shouldHaveType(FrequentlyAskedQuestionInterface::class);
}

function it_allows_access_via_properties(): void
public function it_allows_access_via_properties(): void
{
$this->setCode('delivery_charges_for_orders');
$this->getCode()->shouldReturn('delivery_charges_for_orders');
Expand All @@ -45,7 +45,7 @@ function it_allows_access_via_properties(): void
$this->isEnabled()->shouldReturn(true);
}

function it_toggles(): void
public function it_toggles(): void
{
$this->enable();
$this->isEnabled()->shouldReturn(true);
Expand All @@ -54,7 +54,7 @@ function it_toggles(): void
$this->isEnabled()->shouldReturn(false);
}

function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void
public function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void
{
$this->addChannel($firstChannel);
$this->hasChannel($firstChannel)->shouldReturn(true);
Expand Down
Loading

0 comments on commit 34d1b7b

Please sign in to comment.