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

Fix type annotation for LineItemType enum #1

Closed
wants to merge 1 commit into from
Closed

Fix type annotation for LineItemType enum #1

wants to merge 1 commit into from

Conversation

Tobion
Copy link

@Tobion Tobion commented Jan 27, 2022

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.

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 vttn self-assigned this Jan 31, 2022
@vttn
Copy link
Contributor

vttn commented Jan 31, 2022

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

@Tobion
Copy link
Author

Tobion commented May 18, 2022

@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
Copy link
Contributor

vttn commented May 19, 2022

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.

@vttn vttn closed this May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants