Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Make StoreApiResponse generic and add proper typing #100

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
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
5 changes: 0 additions & 5 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ parameters:
paths:
- tests/Pos/Util/InformationDefaultServiceTest.php

- # ignore shopware v6.7 native type deprecations
message: '#.*tag:v6.7.0 - Will be natively typed|Native type for property ".*" is missing#'
paths:
- src/Checkout/TokenResponse.php

services:
- # register the class, so we can decorate it, but don't tag it as a rule, so only our decorator is used by PHPStan
class: Symplify\PHPStanRules\Rules\NoReturnSetterMethodRule
Expand Down
3 changes: 0 additions & 3 deletions src/Administration/PayPalPaymentMethodController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ public function __construct(
) {
}

/**
* @phpstan-ignore-next-line
*/
#[OA\Post(
path: '/_action/paypal/saleschannel-default',
operationId: 'setPayPalAsDefault',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
use Shopware\Core\System\SalesChannel\StoreApiResponse;
use Swag\PayPal\RestApi\V2\Api\Order\PaymentSource\PayUponInvoice;

/**
* @extends StoreApiResponse<ArrayStruct<string, string>>
*/
#[Package('checkout')]

Check failure on line 18 in src/Checkout/PUI/SalesChannel/PUIPaymentInstructionsResponse.php

View workflow job for this annotation

GitHub Actions / phpstan (trunk)

PHPDoc tag @extends contains generic type Shopware\Core\System\SalesChannel\StoreApiResponse<iterable<string, string>&Shopware\Core\Framework\Struct\ArrayStruct> but class Shopware\Core\System\SalesChannel\StoreApiResponse is not generic.
class PUIPaymentInstructionsResponse extends StoreApiResponse
{
protected PayUponInvoice $paymentInstructions;
Expand Down
3 changes: 0 additions & 3 deletions src/Checkout/SalesChannel/MethodEligibilityRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ public function getDecorated(): AbstractMethodEligibilityRoute
throw new DecorationPatternException(self::class);
}

/**
* @phpstan-ignore-next-line
*/
#[OA\Post(
path: '/paypal/payment-method-eligibility',
operationId: 'setPaymentMethodEligibility',
Expand Down
8 changes: 3 additions & 5 deletions src/Checkout/TokenResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
use Shopware\Core\Framework\Struct\ArrayStruct;
use Shopware\Core\System\SalesChannel\StoreApiResponse;

/**
* @extends StoreApiResponse<ArrayStruct<string, string>>
*/
#[Package('checkout')]

Check failure on line 17 in src/Checkout/TokenResponse.php

View workflow job for this annotation

GitHub Actions / phpstan (trunk)

PHPDoc tag @extends contains generic type Shopware\Core\System\SalesChannel\StoreApiResponse<iterable<string, string>&Shopware\Core\Framework\Struct\ArrayStruct> but class Shopware\Core\System\SalesChannel\StoreApiResponse is not generic.
class TokenResponse extends StoreApiResponse
{
/**
* @var ArrayStruct<string, string>
*/
mitelg marked this conversation as resolved.
Show resolved Hide resolved
protected $object;

public function __construct(string $token)
{
parent::__construct(new ArrayStruct(['token' => $token]));
Expand All @@ -26,6 +24,6 @@

public function getToken(): string
{
return $this->object->get('token');

Check failure on line 27 in src/Checkout/TokenResponse.php

View workflow job for this annotation

GitHub Actions / phpstan (trunk)

Access to deprecated property $object of class Shopware\Core\System\SalesChannel\StoreApiResponse: tag:v6.7.0 - Will be natively typed

Check failure on line 27 in src/Checkout/TokenResponse.php

View workflow job for this annotation

GitHub Actions / phpstan (trunk)

Call to an undefined method Shopware\Core\Framework\Struct\Struct::get().
}
}
Loading