Skip to content

Commit 241723e

Browse files
[Maintenance] Boost phpstan
1 parent f530e47 commit 241723e

26 files changed

+42
-33
lines changed

phpstan.neon.dist

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@ includes:
33
- vendor/phpstan/phpstan-webmozart-assert/extension.neon
44

55
parameters:
6-
level: 3
7-
8-
reportUnmatchedIgnoredErrors: false
6+
level: 6
97

108
paths:
11-
- 'src/'
9+
- src
1210

1311
excludePaths:
1412
# Makes PHPStan crash
1513
- 'src/DependencyInjection/Configuration.php'
16-
- 'src/DependencyInjection/SyliusPayPalExtension.php'
1714

18-
# Test dependencies
19-
- 'tests/Application/app/**.php'
20-
- 'tests/Application/src/**.php'
15+
ignoreErrors:
16+
- identifier: missingType.iterableValue
17+
18+
- '/Dead catch - Sylius\\PayPalPlugin\\Exception\\PayPalWebhookUrlNotValidException is never thrown in the try block\./' # architectural smell

src/Api/CacheAuthorizeClientApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
final readonly class CacheAuthorizeClientApi implements CacheAuthorizeClientApiInterface
2424
{
25+
/** @param ObjectRepository<PayPalCredentialsInterface> $payPalCredentialsRepository */
2526
public function __construct(
2627
private ObjectManager $payPalCredentialsManager,
2728
private ObjectRepository $payPalCredentialsRepository,
@@ -32,7 +33,6 @@ public function __construct(
3233

3334
public function authorize(PaymentMethodInterface $paymentMethod): string
3435
{
35-
/** @var PayPalCredentialsInterface|null $payPalCredentials */
3636
$payPalCredentials = $this->payPalCredentialsRepository->findOneBy(['paymentMethod' => $paymentMethod]);
3737
if ($payPalCredentials !== null && !$payPalCredentials->isExpired()) {
3838
return $payPalCredentials->accessToken();

src/Console/Command/CompletePaidPaymentsCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
)]
3636
final class CompletePaidPaymentsCommand extends Command
3737
{
38+
/** @param PaymentRepositoryInterface<PaymentInterface> $paymentRepository */
3839
public function __construct(
3940
private readonly PaymentRepositoryInterface $paymentRepository,
4041
private readonly ObjectManager $paymentManager,

src/Controller/CancelLastPayPalPaymentAction.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
final readonly class CancelLastPayPalPaymentAction
2727
{
28+
/** @param OrderRepositoryInterface<OrderInterface> $orderRepository */
2829
public function __construct(
2930
private ObjectManager $objectManager,
3031
private StateMachineInterface $stateMachineFactory,

src/Controller/CancelPayPalOrderAction.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Sylius\PayPalPlugin\Controller;
1515

16+
use Sylius\Component\Core\Model\OrderInterface;
1617
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
1718
use Sylius\PayPalPlugin\Provider\FlashBagProvider;
1819
use Sylius\PayPalPlugin\Provider\PaymentProviderInterface;
@@ -22,6 +23,7 @@
2223

2324
final readonly class CancelPayPalOrderAction
2425
{
26+
/** @param OrderRepositoryInterface<OrderInterface>|null $orderRepository */
2527
public function __construct(
2628
private ?PaymentProviderInterface $paymentProvider,
2729
private ?OrderRepositoryInterface $orderRepository,

src/Controller/DownloadPayoutsReportAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
final readonly class DownloadPayoutsReportAction
2424
{
25+
/** @param PaymentMethodRepositoryInterface<PaymentMethodInterface> $paymentMethodRepository */
2526
public function __construct(
2627
private PayoutsReportDownloaderInterface $payoutsReportDownloader,
2728
private PaymentMethodRepositoryInterface $paymentMethodRepository,
@@ -30,7 +31,6 @@ public function __construct(
3031

3132
public function __invoke(Request $request): Response
3233
{
33-
/** @var PaymentMethodInterface|null $paymentMethod */
3434
$paymentMethod = $this->paymentMethodRepository->find($request->attributes->getInt('id'));
3535
Assert::notNull($paymentMethod);
3636

src/Controller/EnableSellerAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
final readonly class EnableSellerAction
2727
{
28+
/** @param PaymentMethodRepositoryInterface<PaymentMethodInterface> $paymentMethodRepository */
2829
public function __construct(
2930
private PaymentMethodRepositoryInterface $paymentMethodRepository,
3031
private PaymentMethodEnablerInterface $paymentMethodEnabler,
@@ -33,7 +34,6 @@ public function __construct(
3334

3435
public function __invoke(Request $request): Response
3536
{
36-
/** @var PaymentMethodInterface $paymentMethod */
3737
$paymentMethod = $this->paymentMethodRepository->find($request->attributes->getInt('id'));
3838
/** @var FlashBagInterface $flashBag */
3939
$flashBag = $request->getSession()->getBag('flashes');

src/Controller/PayPalButtonsController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
final readonly class PayPalButtonsController
3030
{
31+
/** @param OrderRepositoryInterface<OrderInterface> $orderRepository */
3132
public function __construct(
3233
private Environment $twig,
3334
private UrlGeneratorInterface $router,

src/Controller/PayWithPayPalFormAction.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
final readonly class PayWithPayPalFormAction
3030
{
31+
/** @param PaymentRepositoryInterface<PaymentInterface> $paymentRepository */
3132
public function __construct(
3233
private Environment $twig,
3334
private PaymentRepositoryInterface $paymentRepository,

src/Controller/ProcessPayPalOrderAction.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,30 @@
1616
use Doctrine\Persistence\ObjectManager;
1717
use Sylius\Abstraction\StateMachine\StateMachineInterface;
1818
use Sylius\Component\Core\Factory\AddressFactoryInterface;
19+
use Sylius\Component\Core\Model\AddressInterface;
1920
use Sylius\Component\Core\Model\CustomerInterface;
2021
use Sylius\Component\Core\Model\PaymentInterface;
2122
use Sylius\Component\Core\Model\PaymentMethodInterface;
2223
use Sylius\Component\Core\OrderCheckoutTransitions;
2324
use Sylius\Component\Core\Repository\CustomerRepositoryInterface;
24-
use Sylius\Component\Resource\Factory\FactoryInterface;
2525
use Sylius\PayPalPlugin\Api\CacheAuthorizeClientApiInterface;
2626
use Sylius\PayPalPlugin\Api\OrderDetailsApiInterface;
2727
use Sylius\PayPalPlugin\Exception\PaymentAmountMismatchException;
2828
use Sylius\PayPalPlugin\Manager\PaymentStateManagerInterface;
2929
use Sylius\PayPalPlugin\Provider\OrderProviderInterface;
3030
use Sylius\PayPalPlugin\Verifier\PaymentAmountVerifierInterface;
31+
use Sylius\Resource\Factory\FactoryInterface;
3132
use Symfony\Component\HttpFoundation\JsonResponse;
3233
use Symfony\Component\HttpFoundation\Request;
3334
use Symfony\Component\HttpFoundation\Response;
3435

3536
final readonly class ProcessPayPalOrderAction
3637
{
38+
/**
39+
* @param CustomerRepositoryInterface<CustomerInterface> $customerRepository
40+
* @param FactoryInterface<CustomerInterface> $customerFactory
41+
* @param AddressFactoryInterface<AddressInterface> $addressFactory
42+
*/
3743
public function __construct(
3844
private CustomerRepositoryInterface $customerRepository,
3945
private FactoryInterface $customerFactory,
@@ -85,6 +91,7 @@ public function __invoke(Request $request): Response
8591

8692
if ($order->isShippingRequired()) {
8793
$name = explode(' ', $purchaseUnit['shipping']['name']['full_name']);
94+
/** @phpstan-ignore-next-line false positive */
8895
$address->setLastName(array_pop($name) ?? '');
8996
$address->setFirstName(implode(' ', $name));
9097
$address->setStreet($purchaseUnit['shipping']['address']['address_line_1']);

0 commit comments

Comments
 (0)