Skip to content

Commit

Permalink
Up PHP code style to 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Feb 26, 2024
1 parent 094fcf3 commit 61d5148
Show file tree
Hide file tree
Showing 28 changed files with 13 additions and 201 deletions.
3 changes: 0 additions & 3 deletions src/Assigner/ProductsAssigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

final class ProductsAssigner implements ProductsAssignerInterface
{
/**
* @inheritdoc
*/
public function assign(BrandInterface $brand, array $products): void
{
foreach ($products as $product) {
Expand Down
3 changes: 0 additions & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@

final class Configuration implements ConfigurationInterface
{
/**
* @inheritdoc
*/
public function getConfigTreeBuilder(): TreeBuilder
{
if (method_exists(TreeBuilder::class, 'getRootNode')) {
Expand Down
2 changes: 0 additions & 2 deletions src/DependencyInjection/LoevgaardSyliusBrandExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
final class LoevgaardSyliusBrandExtension extends AbstractResourceExtension
{
/**
* @inheritdoc
*
* @throws \Exception
*/
public function load(array $config, ContainerBuilder $container): void
Expand Down
6 changes: 0 additions & 6 deletions src/Doctrine/ORM/BrandImageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

class BrandImageRepository extends EntityRepository implements BrandImageRepositoryInterface
{
/**
* @inheritdoc
*/
public function createListQueryBuilder(string $brandCode): QueryBuilder
{
return $this->createQueryBuilder('o')
Expand All @@ -22,9 +19,6 @@ public function createListQueryBuilder(string $brandCode): QueryBuilder
;
}

/**
* @inheritdoc
*/
public function createPaginatorForBrandAndType(BrandInterface $brand, string $type): iterable
{
$queryBuilder = $this->createQueryBuilder('o')
Expand Down
3 changes: 0 additions & 3 deletions src/Doctrine/ORM/BrandRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

class BrandRepository extends EntityRepository implements BrandRepositoryInterface
{
/**
* @inheritdoc
*/
public function findByPhrase(string $phrase): array
{
return $this->createQueryBuilder('o')
Expand Down
3 changes: 0 additions & 3 deletions src/Doctrine/ORM/ProductRepositoryTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ trait ProductRepositoryTrait
*/
abstract public function createQueryBuilder($alias, $indexBy = null);

/**
* @inheritdoc
*/
public function createPaginatorForBrand(BrandInterface $brand): iterable
{
return $this->createQueryBuilder('o')
Expand Down
7 changes: 1 addition & 6 deletions src/Event/BrandMenuBuilderEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@

class BrandMenuBuilderEvent extends MenuBuilderEvent
{
/** @var BrandInterface */
private $brand;

public function __construct(FactoryInterface $factory, ItemInterface $menu, BrandInterface $brand)
public function __construct(FactoryInterface $factory, ItemInterface $menu, private readonly BrandInterface $brand)
{
parent::__construct($factory, $menu);

$this->brand = $brand;
}

public function getBrand(): BrandInterface
Expand Down
6 changes: 1 addition & 5 deletions src/EventListener/ImageUploadListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@

final class ImageUploadListener
{
/** @var ImageUploaderInterface */
private $uploader;

public function __construct(ImageUploaderInterface $uploader)
public function __construct(private readonly ImageUploaderInterface $uploader)
{
$this->uploader = $uploader;
}

public function uploadImage(ResourceControllerEvent $event): void
Expand Down
12 changes: 1 addition & 11 deletions src/Factory/BrandImageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,10 @@

class BrandImageFactory implements BrandImageFactoryInterface
{
/** @var FactoryInterface */
private $factory;

public function __construct(FactoryInterface $factory)
public function __construct(private readonly FactoryInterface $factory)
{
$this->factory = $factory;
}

/**
* @inheritdoc
*/
public function createNew(): BrandImageInterface
{
/** @var BrandImageInterface $brandImage */
Expand All @@ -29,9 +22,6 @@ public function createNew(): BrandImageInterface
return $brandImage;
}

/**
* @inheritdoc
*/
public function createForBrand(BrandInterface $brand): BrandImageInterface
{
/** @var BrandImageInterface $brandImage */
Expand Down
2 changes: 1 addition & 1 deletion src/Fixture/Factory/BrandExampleFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected function createImages(BrandInterface $brand, array $options): void
if (is_array($imagePath)) {
$imagePath = $imagePath[array_key_first($imagePath)];
}
$uploadedImage = new UploadedFile($imagePath, basename($imagePath));
$uploadedImage = new UploadedFile($imagePath, basename((string) $imagePath));

/** @var BrandImageInterface $brandImage */
$brandImage = $this->productImageFactory->createNew();
Expand Down
6 changes: 0 additions & 6 deletions src/Form/Extension/Api/ProductTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

class ProductTypeExtension extends AbstractTypeExtension
{
/**
* @inheritdoc
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('brand', BrandChoiceType::class, [
Expand All @@ -23,9 +20,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
]);
}

/**
* @inheritdoc
*/
public static function getExtendedTypes(): iterable
{
return [
Expand Down
6 changes: 0 additions & 6 deletions src/Form/Extension/ProductTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

class ProductTypeExtension extends AbstractTypeExtension
{
/**
* @inheritdoc
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('brand', BrandAutocompleteChoiceType::class, [
Expand All @@ -23,9 +20,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
]);
}

/**
* @inheritdoc
*/
public static function getExtendedTypes(): iterable
{
return [
Expand Down
12 changes: 0 additions & 12 deletions src/Form/Type/BrandAutocompleteChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

final class BrandAutocompleteChoiceType extends AbstractType
{
/**
* @inheritdoc
*/
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
Expand All @@ -24,26 +21,17 @@ public function configureOptions(OptionsResolver $resolver): void
]);
}

/**
* @inheritdoc
*/
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['remote_criteria_type'] = 'contains';
$view->vars['remote_criteria_name'] = 'phrase';
}

/**
* @inheritdoc
*/
public function getBlockPrefix(): string
{
return 'loevgaard_sylius_brand_autocomplete_choice';
}

/**
* @inheritdoc
*/
public function getParent(): string
{
return ResourceAutocompleteChoiceType::class;
Expand Down
22 changes: 2 additions & 20 deletions src/Form/Type/BrandChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,32 @@

final class BrandChoiceType extends AbstractType
{
/** @var RepositoryInterface */
private $brandRepository;

public function __construct(RepositoryInterface $brandRepository)
public function __construct(private readonly RepositoryInterface $brandRepository)
{
$this->brandRepository = $brandRepository;
}

/**
* @inheritdoc
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
if ($options['multiple']) {
$builder->addModelTransformer(new CollectionToArrayTransformer());
}
}

/**
* @inheritdoc
*/
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'choices' => function (Options $options) {
return $this->brandRepository->findAll();
},
'choices' => fn (Options $options) => $this->brandRepository->findAll(),
'choice_value' => 'code',
'choice_label' => 'name',
'choice_translation_domain' => false,
]);
}

/**
* @inheritdoc
*/
public function getParent(): string
{
return ChoiceType::class;
}

/**
* @inheritdoc
*/
public function getBlockPrefix(): string
{
return 'loevgaard_sylius_brand_choice';
Expand Down
3 changes: 0 additions & 3 deletions src/Form/Type/BrandImageType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

final class BrandImageType extends ImageType
{
/**
* @inheritdoc
*/
public function getBlockPrefix(): string
{
return 'loevgaard_sylius_brand_brand_image';
Expand Down
6 changes: 0 additions & 6 deletions src/Form/Type/BrandType.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

final class BrandType extends AbstractResourceType
{
/**
* @inheritdoc
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
Expand All @@ -33,9 +30,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
]);
}

/**
* @inheritdoc
*/
public function getBlockPrefix(): string
{
return 'loevgaard_sylius_brand_brand';
Expand Down
3 changes: 0 additions & 3 deletions src/LoevgaardSyliusBrandPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ final class LoevgaardSyliusBrandPlugin extends AbstractResourceBundle
{
use SyliusPluginTrait;

/**
* @inheritdoc
*/
public function getSupportedDrivers(): array
{
return [
Expand Down
11 changes: 3 additions & 8 deletions src/Menu/BrandFormMenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,12 @@ final class BrandFormMenuBuilder
{
public const EVENT_NAME = 'loevgaard_sylius_brand.menu.admin.brand.form';

/** @var FactoryInterface */
private $factory;

/** @var EventDispatcherInterface */
private $eventDispatcher;

public function __construct(FactoryInterface $factory, EventDispatcherInterface $eventDispatcher)
public function __construct(private readonly FactoryInterface $factory, EventDispatcherInterface $eventDispatcher)
{
$this->factory = $factory;

if (class_exists('Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy')) {
if (class_exists(\Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy::class)) {
/**
* It could return null only if we pass null, but we pass not null in any case
*
Expand Down Expand Up @@ -59,7 +54,7 @@ public function createMenu(array $options = []): ItemInterface
->setLabel('sylius.ui.media')
;

if (class_exists('Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy')) {
if (class_exists(\Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy::class)) {
$this->eventDispatcher->dispatch(
new BrandMenuBuilderEvent($this->factory, $menu, $options['brand']),
self::EVENT_NAME,
Expand Down
12 changes: 0 additions & 12 deletions src/Model/Brand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,11 @@ public function __construct()
$this->__productsAwareTraitConstruct();
}

/**
* @inheritdoc
*/
public function __toString(): string
{
return (string) $this->getName();
}

/**
* @inheritdoc
*/
public function getId(): ?int
{
return $this->id;
Expand All @@ -60,17 +54,11 @@ public function setCode(?string $code): void
$this->code = $code;
}

/**
* @inheritdoc
*/
public function getName(): ?string
{
return $this->name;
}

/**
* @inheritdoc
*/
public function setName(?string $name): void
{
$this->name = $name;
Expand Down
6 changes: 0 additions & 6 deletions src/Model/BrandImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ public function isLogo(): bool
return $this->getType() === self::TYPE_LOGO;
}

/**
* @inheritdoc
*/
public function getBrand(): ?BrandInterface
{
/** @var BrandInterface|null $brand */
Expand All @@ -26,9 +23,6 @@ public function getBrand(): ?BrandInterface
return $brand;
}

/**
* @inheritdoc
*/
public function setBrand(?BrandInterface $brand): void
{
$this->setOwner($brand);
Expand Down
Loading

0 comments on commit 61d5148

Please sign in to comment.