pfpayments / php-sdk

PHP SDK for PostFinance Checkout
https://www.postfinance-checkout.ch
Apache License 2.0
20 stars 3 forks source link

Fix type annotation for LineItemType enum #1

Closed Tobion closed 2 years ago

Tobion commented 2 years ago

The annotation says it would expect an instance of LineItemType. But it expects a string (a constant from the LineItemType). This currently fails any autocomplete and static analysis.

Using LineItemType::* fixes this as allowed by phpstan, see https://phpstan.org/writing-php-code/phpdoc-types#literals-and-constants

But in general the same problem seems to apply to all enums in this library, e.g. also TransactionState. Is this generated code? Then it needs to be fixed in the generator I assume.

vttn commented 2 years ago

@Tobion thank you for the update. We will take an overall look at the enum annotations on the PHP sdk.

Tobion commented 2 years ago

@vttn any news one this one? It might also make sense to create a new version of the library requiring php 8.1 that can make use of native php enums.

vttn commented 2 years ago

Hello @Tobion,

We looked into changing the annotations and we discovered that the work around could not be found to apply this to all SDK classes in the library.

We are working on bringing out PHP 8.1 soon.