Skip to content

Commit cd60e0c

Browse files
committed
fix(internal): phpstan errors
1 parent f9cb4a0 commit cd60e0c

File tree

13 files changed

+30
-17
lines changed

13 files changed

+30
-17
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
},
1717
"require-dev": {
1818
"phpstan/phpstan": "^2.1.2",
19-
"friendsofphp/php-cs-fixer": "^3.66"
19+
"friendsofphp/php-cs-fixer": "^3.66",
20+
"shopwarelabs/phpstan-shopware": "^0.1.8"
2021
},
2122
"scripts": {
2223
"phpstan": "phpstan analyse --memory-limit=2G",

phpstan.neon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ parameters:
44
- src
55
scanDirectories:
66
- ../../../vendor
7+
8+
includes:
9+
- vendor/shopwarelabs/phpstan-shopware/rules.neon

src/Action/RefreshAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ public function __construct(
2020
) {
2121
}
2222

23-
public function execute(bool $async = true): void
23+
public function execute(Context $context, bool $async = true): void
2424
{
2525
$now = new \DateTime();
2626
$this->loadIndexAction->execute();
2727

2828
$this->cleanupPluginsTask->execute(
29-
Context::createDefaultContext(),
29+
$context,
3030
$now,
3131
);
3232

src/Command/RefreshCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace NuonicPluginInstaller\Command;
66

77
use NuonicPluginInstaller\Action\RefreshAction;
8+
use Shopware\Core\Framework\Context;
89
use Symfony\Component\Console\Attribute\AsCommand;
910
use Symfony\Component\Console\Command\Command;
1011
use Symfony\Component\Console\Input\InputInterface;
@@ -21,7 +22,7 @@ public function __construct(
2122

2223
protected function execute(InputInterface $input, OutputInterface $output): int
2324
{
24-
$this->refreshAction->execute(false);
25+
$this->refreshAction->execute(Context::createCLIContext(), false);
2526

2627
return Command::SUCCESS;
2728
}

src/Controller/InstallController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function execute(Request $request, Context $context): Response
5353
$this->malformedRequestError();
5454
}
5555

56-
/** @var AvailableOpensourcePluginEntity $plugin */
56+
/** @var AvailableOpensourcePluginEntity|null $plugin */
5757
$plugin = $this->openSourcePluginRepository->search(new Criteria([$requestData['openSourcePluginId']]), $context)
5858
->first();
5959

src/Core/Framework/Plugin/AvailableOpensourcePlugin/AvailableOpensourcePluginDefinition.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ protected function defineFields(): FieldCollection
4343
{
4444
return new FieldCollection([
4545
(new IdField('id', 'id'))->addFlags(new Required(), new PrimaryKey()),
46-
(new TranslatedField('name', 'name'))->addFlags(new Required()),
47-
(new TranslatedField('description', 'description'))->addFlags(new Required()),
46+
(new TranslatedField('name'))->addFlags(new Required()),
47+
(new TranslatedField('description'))->addFlags(new Required()),
4848
(new StringField('package_name', 'packageName'))->addFlags(new Required()),
4949
(new StringField('manufacturer', 'manufacturer'))->addFlags(new Required()),
5050
(new StringField('manufacturer_link', 'manufacturerLink'))->addFlags(new Required()),

src/Core/Framework/Plugin/AvailableOpensourcePlugin/AvailableOpensourcePluginEntity.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace NuonicPluginInstaller\Core\Framework\Plugin\AvailableOpensourcePlugin;
66

7+
use Shopware\Core\Content\Media\MediaEntity;
78
use Shopware\Core\Framework\DataAbstractionLayer\Entity;
89
use Shopware\Core\Framework\DataAbstractionLayer\EntityIdTrait;
910
use Shopware\Core\Framework\Plugin\PluginEntity;
@@ -24,6 +25,7 @@ class AvailableOpensourcePluginEntity extends Entity
2425

2526
protected ?string $icon;
2627

28+
/** @var MediaEntity[]|null */
2729
protected ?array $images;
2830

2931
protected string $license;
@@ -100,11 +102,18 @@ public function setIcon(?string $icon): void
100102
$this->icon = $icon;
101103
}
102104

105+
/**
106+
* @return MediaEntity[]|null
107+
*/
103108
public function getImages(): ?array
104109
{
105110
return $this->images;
106111
}
107112

113+
/**
114+
* @param MediaEntity[]|null $images
115+
* @return void
116+
*/
108117
public function setImages(?array $images): void
109118
{
110119
$this->images = $images;

src/NuonicPluginInstaller.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,11 @@ public function uninstall(UninstallContext $uninstallContext): void
5353

5454
public function postInstall(InstallContext $installContext): void
5555
{
56-
if ($action = $this->container->get(RefreshAction::class)) {
57-
$action->execute();
58-
}
56+
$this->container->get(RefreshAction::class)->execute($installContext->getContext());
5957
}
6058

6159
public function postUpdate(UpdateContext $updateContext): void
6260
{
63-
if ($action = $this->container->get(RefreshAction::class)) {
64-
$action->execute();
65-
}
61+
$this->container->get(RefreshAction::class)->execute($updateContext->getContext());
6662
}
6763
}

src/ScheduledTask/LoadIndex/LoadIndexScheduledTask.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public static function getTaskName(): string
1515

1616
public static function getDefaultInterval(): int
1717
{
18-
return 1_800;
18+
return 3_600; // 1 hour
1919
}
2020
}

src/ScheduledTask/LoadPluginInfo/LoadPluginInfoScheduledTask.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public static function getTaskName(): string
1515

1616
public static function getDefaultInterval(): int
1717
{
18-
return 1_800;
18+
return 3_600; // 1 hour
1919
}
2020
}

0 commit comments

Comments
 (0)