Skip to content

Commit fc47ca4

Browse files
loevgaardclaude
andcommitted
Fix static analysis errors and add rector to build tools
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 470d798 commit fc47ca4

4 files changed

Lines changed: 15 additions & 7 deletions

File tree

.githooks/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
22

3+
composer rector
34
composer fix-style

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
"analyse": "phpstan analyse",
9595
"check-style": "ecs check",
9696
"fix-style": "ecs check --fix",
97-
"phpunit": "phpunit"
97+
"phpunit": "phpunit",
98+
"rector": "rector process"
9899
}
99100
}

tests/Functional/Calculator/AverageRatingCalculatorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Setono\SyliusReviewPlugin\Calculator\AverageRatingCalculator;
99
use Sylius\Component\Core\Model\ProductInterface;
1010
use Sylius\Component\Core\Model\ProductReview;
11-
use Sylius\Component\Customer\Model\CustomerInterface;
11+
use Sylius\Component\Review\Model\ReviewerInterface;
1212
use Sylius\Component\Review\Model\ReviewInterface;
1313
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1414

@@ -20,7 +20,7 @@ final class AverageRatingCalculatorTest extends KernelTestCase
2020

2121
private ProductInterface $product;
2222

23-
private CustomerInterface $customer;
23+
private ReviewerInterface $customer;
2424

2525
protected function setUp(): void
2626
{
@@ -37,8 +37,8 @@ protected function setUp(): void
3737
self::assertNotNull($product, 'No fixture product found. Make sure Sylius fixtures are loaded.');
3838
$this->product = $product;
3939

40-
/** @var CustomerInterface|null $customer */
41-
$customer = $this->entityManager->getRepository(CustomerInterface::class)->findOneBy([]);
40+
/** @var ReviewerInterface|null $customer */
41+
$customer = $this->entityManager->getRepository(ReviewerInterface::class)->findOneBy([]);
4242
self::assertNotNull($customer, 'No fixture customer found. Make sure Sylius fixtures are loaded.');
4343
$this->customer = $customer;
4444

tests/Unit/Calculator/CachedAverageRatingCalculatorTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ public function it_caches_result_with_correct_key_format(): void
7474
}),
7575
Argument::type('callable'),
7676
)->will(function (array $args) use ($item) {
77-
return $args[1]($item->reveal());
77+
/** @var callable $callback */
78+
$callback = $args[1];
79+
80+
return $callback($item->reveal());
7881
})->shouldBeCalledOnce();
7982

8083
$calculator = new CachedAverageRatingCalculator($decorated->reveal(), $cache->reveal());
@@ -97,7 +100,10 @@ public function it_respects_custom_cache_lifetime(): void
97100
$cache = $this->prophesize(CacheInterface::class);
98101
$cache->get(Argument::type('string'), Argument::type('callable'))
99102
->will(function (array $args) use ($item) {
100-
return $args[1]($item->reveal());
103+
/** @var callable $callback */
104+
$callback = $args[1];
105+
106+
return $callback($item->reveal());
101107
})->shouldBeCalledOnce();
102108

103109
$calculator = new CachedAverageRatingCalculator($decorated->reveal(), $cache->reveal(), 1800);

0 commit comments

Comments
 (0)