Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
/infection.json.dist export-ignore
/node_modules export-ignore
/phpunit.xml.dist export-ignore
/psalm-baseline.xml export-ignore
/psalm.xml export-ignore
/rector.php export-ignore
/tests export-ignore
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/.phpunit.result.cache

/.claude/*.local.json

# Symfony CLI https://symfony.com/doc/current/setup/symfony_server.html#different-php-settings-per-project
/.php-version
/php.ini
16 changes: 16 additions & 0 deletions infection.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"source": {
"directories": [
"src"
]
},
"logs": {
"text": "php://stderr",
"github": true,
"stryker": {
"badge": "master"
}
},
"minMsi": 100.00,
"minCoveredMsi": 100.00
}
14 changes: 7 additions & 7 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ parameters:

ignoreErrors:
-
identifier: missingType.iterableValue
identifiers:
- missingType.iterableValue
- doctrine.associationType
- doctrine.columnType
- missingType.generics
-
identifier: doctrine.associationType
-
identifier: doctrine.columnType
-
identifier: missingType.generics
path: src/Form
identifier: class.notFound
message: '#League\\Flysystem\\#'
5 changes: 5 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_81,
]);

$rectorConfig->skip([
\Rector\Php81\Rector\Class_\SpatieEnumClassToEnumRector::class,
\Rector\Php81\Rector\MethodCall\SpatieEnumMethodCallToEnumConstRector::class,
]);
};
6 changes: 1 addition & 5 deletions src/Command/ProcessFeedsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ final class ProcessFeedsCommand extends Command
{
protected static $defaultName = 'setono:sylius-feed:process';

private FeedProcessorInterface $feedProcessor;

public function __construct(FeedProcessorInterface $feedProcessor)
public function __construct(private readonly FeedProcessorInterface $feedProcessor)
{
parent::__construct();

$this->feedProcessor = $feedProcessor;
}

protected function configure(): void
Expand Down
26 changes: 4 additions & 22 deletions src/Controller/Action/Admin/ProcessFeedAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,14 @@
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* @psalm-suppress UndefinedClass
* @psalm-suppress MixedArgument
* @psalm-suppress UndefinedInterfaceMethod
* @psalm-suppress MixedAssignment
*/
final class ProcessFeedAction
{
private MessageBusInterface $commandBus;

private UrlGeneratorInterface $urlGenerator;

private FlashBagInterface|RequestStack $flashBag;

private TranslatorInterface $translator;

public function __construct(
MessageBusInterface $commandBus,
UrlGeneratorInterface $urlGenerator,
FlashBagInterface|RequestStack $requestStackOrFlashBag,
TranslatorInterface $translator,
private readonly MessageBusInterface $commandBus,
private readonly UrlGeneratorInterface $urlGenerator,
private readonly FlashBagInterface|RequestStack $flashBag,
private readonly TranslatorInterface $translator,
) {
$this->commandBus = $commandBus;
$this->urlGenerator = $urlGenerator;
$this->flashBag = $requestStackOrFlashBag;
$this->translator = $translator;
}

public function __invoke(int $id): RedirectResponse
Expand Down
12 changes: 4 additions & 8 deletions src/Controller/Action/Admin/SeverityCountAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@

final class SeverityCountAction
{
private ViolationRepositoryInterface $violationRepository;

private Environment $twig;

public function __construct(ViolationRepositoryInterface $violationRepository, Environment $twig)
{
$this->violationRepository = $violationRepository;
$this->twig = $twig;
public function __construct(
private readonly ViolationRepositoryInterface $violationRepository,
private readonly Environment $twig,
) {
}

public function __invoke(int $feed = null): Response
Expand Down
31 changes: 5 additions & 26 deletions src/Controller/Action/Shop/ShowFeedAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,22 @@
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Mime\MimeTypesInterface;

/**
* @psalm-suppress UndefinedDocblockClass
* @psalm-suppress UndefinedClass
*/
final class ShowFeedAction
{
private FeedRepositoryInterface $repository;

private ChannelContextInterface $channelContext;

private LocaleContextInterface $localeContext;

private FeedPathGeneratorInterface $feedPathGenerator;

/** @var FilesystemInterface|FilesystemOperator */
private $filesystem;

private MimeTypesInterface $mimeTypes;

/**
* @psalm-suppress UndefinedDocblockClass
*
* @param FilesystemInterface|FilesystemOperator $filesystem
*/
public function __construct(
FeedRepositoryInterface $repository,
ChannelContextInterface $channelContext,
LocaleContextInterface $localeContext,
FeedPathGeneratorInterface $feedPathGenerator,
private readonly FeedRepositoryInterface $repository,
private readonly ChannelContextInterface $channelContext,
private readonly LocaleContextInterface $localeContext,
private readonly FeedPathGeneratorInterface $feedPathGenerator,
$filesystem,
MimeTypesInterface $mimeTypes,
private readonly MimeTypesInterface $mimeTypes,
) {
$this->repository = $repository;
$this->channelContext = $channelContext;
$this->localeContext = $localeContext;
$this->feedPathGenerator = $feedPathGenerator;
if (interface_exists(FilesystemInterface::class) && $filesystem instanceof FilesystemInterface) {
$this->filesystem = $filesystem;
} elseif ($filesystem instanceof FilesystemOperator) {
Expand All @@ -63,7 +43,6 @@
FilesystemOperator::class,
));
}
$this->mimeTypes = $mimeTypes;
}

public function __invoke(string $code): StreamedResponse
Expand All @@ -90,7 +69,7 @@
}

/** @var resource|false $stream */
$stream = $filesystem->readStream((string) $feedPath);

Check failure on line 72 in src/Controller/Action/Shop/ShowFeedAction.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.2 | Deps: highest | SF~6.4.0)

PHPDoc tag `@var` with type resource|false is not subtype of type resource.

Check failure on line 72 in src/Controller/Action/Shop/ShowFeedAction.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.1 | Deps: highest | SF~6.4.0)

PHPDoc tag `@var` with type resource|false is not subtype of type resource.

Check failure on line 72 in src/Controller/Action/Shop/ShowFeedAction.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.3 | Deps: highest | SF~6.4.0)

PHPDoc tag `@var` with type resource|false is not subtype of type resource.

Check failure on line 72 in src/Controller/Action/Shop/ShowFeedAction.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.3 | Deps: lowest | SF~6.4.0)

PHPDoc tag `@var` with type resource|false is not subtype of type resource.

Check failure on line 72 in src/Controller/Action/Shop/ShowFeedAction.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.2 | Deps: lowest | SF~6.4.0)

PHPDoc tag `@var` with type resource|false is not subtype of type resource.

Check failure on line 72 in src/Controller/Action/Shop/ShowFeedAction.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.1 | Deps: lowest | SF~6.4.0)

PHPDoc tag `@var` with type resource|false is not subtype of type resource.
if (false === $stream) {
throw new RuntimeException(sprintf('An error occurred trying to read the feed file %s', $feedPath));
}
Expand Down
8 changes: 1 addition & 7 deletions src/DTO/SeverityCount.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@

final class SeverityCount
{
private string $severity;

private int $count;

public function __construct(string $severity, int $count)
public function __construct(private readonly string $severity, private readonly int $count)
{
$this->severity = $severity;
$this->count = $count;
}

public function getSeverity(): string
Expand Down
32 changes: 6 additions & 26 deletions src/DataProvider/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,17 @@

class DataProvider implements DataProviderInterface
{
private BatcherFactoryInterface $batcherFactory;

private QueryRebuilderInterface $queryRebuilder;

private EventDispatcherInterface $eventDispatcher;

private ManagerRegistry $managerRegistry;

private string $class;

/** @var CollectionBatcherInterface[] */
private array $batchers = [];

private int $batchSize;

public function __construct(
BatcherFactoryInterface $batcherFactory,
QueryRebuilderInterface $queryRebuilder,
EventDispatcherInterface $eventDispatcher,
ManagerRegistry $managerRegistry,
string $class,
int $batchSize = 100,
private readonly BatcherFactoryInterface $batcherFactory,
private readonly QueryRebuilderInterface $queryRebuilder,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly ManagerRegistry $managerRegistry,
private readonly string $class,
private readonly int $batchSize = 100,
) {
$this->batcherFactory = $batcherFactory;
$this->queryRebuilder = $queryRebuilder;
$this->eventDispatcher = $eventDispatcher;
$this->managerRegistry = $managerRegistry;
$this->class = $class;
$this->batchSize = $batchSize;
}

public function getClass(): string
Expand All @@ -69,11 +51,9 @@
return $this->getBatcher($channel, $locale)->getBatchCount($this->batchSize);
}

/** @psalm-suppress MixedReturnTypeCoercion */
public function getItems(BatchInterface $batch): iterable
{
/** @psalm-suppress MixedReturnTypeCoercion */
return $this->queryRebuilder->rebuild($batch)->getResult();

Check failure on line 56 in src/DataProvider/DataProvider.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.2 | Deps: highest | SF~6.4.0)

Method Setono\SyliusFeedPlugin\DataProvider\DataProvider::getItems() should return iterable<Sylius\Resource\Model\ResourceInterface> but returns mixed.

Check failure on line 56 in src/DataProvider/DataProvider.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.1 | Deps: highest | SF~6.4.0)

Method Setono\SyliusFeedPlugin\DataProvider\DataProvider::getItems() should return iterable<Sylius\Resource\Model\ResourceInterface> but returns mixed.

Check failure on line 56 in src/DataProvider/DataProvider.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.3 | Deps: highest | SF~6.4.0)

Method Setono\SyliusFeedPlugin\DataProvider\DataProvider::getItems() should return iterable<Sylius\Resource\Model\ResourceInterface> but returns mixed.

Check failure on line 56 in src/DataProvider/DataProvider.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.3 | Deps: lowest | SF~6.4.0)

Method Setono\SyliusFeedPlugin\DataProvider\DataProvider::getItems() should return iterable<Sylius\Resource\Model\ResourceInterface> but returns mixed.

Check failure on line 56 in src/DataProvider/DataProvider.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.2 | Deps: lowest | SF~6.4.0)

Method Setono\SyliusFeedPlugin\DataProvider\DataProvider::getItems() should return iterable<Sylius\Resource\Model\ResourceInterface> but returns mixed.

Check failure on line 56 in src/DataProvider/DataProvider.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.1 | Deps: lowest | SF~6.4.0)

Method Setono\SyliusFeedPlugin\DataProvider\DataProvider::getItems() should return iterable<Sylius\Resource\Model\ResourceInterface> but returns mixed.
}

private function getQueryBuilder(ChannelInterface $channel, LocaleInterface $locale): QueryBuilder
Expand All @@ -91,7 +71,7 @@
private function getManager(): EntityManagerInterface
{
/** @var EntityManagerInterface|null $manager */
$manager = $this->managerRegistry->getManagerForClass($this->class);

Check failure on line 74 in src/DataProvider/DataProvider.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.2 | Deps: highest | SF~6.4.0)

Parameter #1 $class of method Doctrine\Persistence\ManagerRegistry::getManagerForClass() expects class-string, string given.

Check failure on line 74 in src/DataProvider/DataProvider.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.1 | Deps: highest | SF~6.4.0)

Parameter #1 $class of method Doctrine\Persistence\ManagerRegistry::getManagerForClass() expects class-string, string given.

Check failure on line 74 in src/DataProvider/DataProvider.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.3 | Deps: highest | SF~6.4.0)

Parameter #1 $class of method Doctrine\Persistence\ManagerRegistry::getManagerForClass() expects class-string, string given.

Check failure on line 74 in src/DataProvider/DataProvider.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.3 | Deps: lowest | SF~6.4.0)

Parameter #1 $class of method Doctrine\Persistence\ManagerRegistry::getManagerForClass() expects class-string, string given.

Check failure on line 74 in src/DataProvider/DataProvider.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.2 | Deps: lowest | SF~6.4.0)

Parameter #1 $class of method Doctrine\Persistence\ManagerRegistry::getManagerForClass() expects class-string, string given.

Check failure on line 74 in src/DataProvider/DataProvider.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.1 | Deps: lowest | SF~6.4.0)

Parameter #1 $class of method Doctrine\Persistence\ManagerRegistry::getManagerForClass() expects class-string, string given.

if (null === $manager) {
throw new InvalidArgumentException(sprintf('No manager for class %s', $this->class));
Expand Down
7 changes: 0 additions & 7 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@

final class Configuration implements ConfigurationInterface
{
/**
* @psalm-suppress MixedMethodCall
* @psalm-suppress UndefinedInterfaceMethod
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('setono_sylius_feed');
Expand Down Expand Up @@ -56,9 +52,6 @@ public function getConfigTreeBuilder(): TreeBuilder
return $treeBuilder;
}

/**
* @psalm-suppress MixedMethodCall, UndefinedInterfaceMethod
*/
private function addResourcesSection(ArrayNodeDefinition $node): void
{
$node
Expand Down
5 changes: 1 addition & 4 deletions src/Event/BatchGeneratedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@

final class BatchGeneratedEvent
{
private FeedInterface $feed;

public function __construct(FeedInterface $feed)
public function __construct(private readonly FeedInterface $feed)
{
$this->feed = $feed;
}

public function getFeed(): FeedInterface
Expand Down
11 changes: 5 additions & 6 deletions src/Event/FeedShowMenuBuilderEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@

final class FeedShowMenuBuilderEvent extends MenuBuilderEvent
{
private FeedInterface $feed;

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

$this->feed = $feed;
}

public function getFeed(): FeedInterface
Expand Down
29 changes: 8 additions & 21 deletions src/Event/GenerateBatchItemEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,17 @@

final class GenerateBatchItemEvent
{
private FeedInterface $feed;

private FeedTypeInterface $feedType;

private ChannelInterface $channel;

private LocaleInterface $locale;

/** @var object|array */
private $item;

private ?object $rootItem;

/**
* @param object|array $item
*/
public function __construct(FeedInterface $feed, FeedTypeInterface $feedType, ChannelInterface $channel, LocaleInterface $locale, $item, object $rootItem = null)
{
$this->feed = $feed;
$this->feedType = $feedType;
$this->channel = $channel;
$this->locale = $locale;
$this->item = $item;
$this->rootItem = $rootItem;
public function __construct(
private readonly FeedInterface $feed,
private readonly FeedTypeInterface $feedType,
private readonly ChannelInterface $channel,
private readonly LocaleInterface $locale,
private $item,
private readonly ?object $rootItem = null,
) {
}

public function getFeed(): FeedInterface
Expand Down
29 changes: 8 additions & 21 deletions src/Event/GenerateBatchViolationEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,17 @@

final class GenerateBatchViolationEvent
{
private FeedInterface $feed;

private FeedTypeInterface $feedType;

private ChannelInterface $channel;

private LocaleInterface $locale;

/** @var object|array */
private $item;

private ConstraintViolationListInterface $constraintViolationList;

/**
* @param object|array $item
*/
public function __construct(FeedInterface $feed, FeedTypeInterface $feedType, ChannelInterface $channel, LocaleInterface $locale, $item, ConstraintViolationListInterface $constraintViolationList)
{
$this->feed = $feed;
$this->feedType = $feedType;
$this->channel = $channel;
$this->locale = $locale;
$this->item = $item;
$this->constraintViolationList = $constraintViolationList;
public function __construct(
private readonly FeedInterface $feed,
private readonly FeedTypeInterface $feedType,
private readonly ChannelInterface $channel,
private readonly LocaleInterface $locale,
private $item,
private readonly ConstraintViolationListInterface $constraintViolationList,
) {
}

public function getFeed(): FeedInterface
Expand Down
Loading
Loading