Skip to content

Incorrect type declarations #24

@indykoning

Description

@indykoning

On my journey to find a fix for paynl/magento2-graphql#2 i ran into \PayNL\Sdk\Model\Request\TransactionStatusRequest which works for the most part.

The thing i run into is PayNL\Sdk\Model\Pay\PayOrder::getCapturedAmount(): Return value must be of type PayNL\Sdk\Model\Amount, null returned

Which makes sense as

public function getCapturedAmount(): Amount

claims it always returns an amount.

While this is not required, and even skipped in the construct.

if (in_array($_key, ['amount', 'capturedAmount', 'authorizedAmount'])) {

If setCapturedAmount is not called externally, getCapturedAmount will return null.

I recommend adding phpstan to the repo to prevent these kinds of issues in the future.

I reckon
turning

protected $capturedAmount;

into

-    /**
-     * @var Amount
-     */
-    protected $capturedAmount;
+    protected ?Amount $capturedAmount;

would help phpstan in determining wether the value should be set on construct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions