Skip to content

fix response DTO type-hint#85

Merged
Sammyjo20 merged 1 commit intosaloonphp:v1from
Gummibeer:patch-1
Oct 7, 2022
Merged

fix response DTO type-hint#85
Sammyjo20 merged 1 commit intosaloonphp:v1from
Gummibeer:patch-1

Conversation

@Gummibeer
Copy link
Copy Markdown
Contributor

@Gummibeer Gummibeer commented Oct 6, 2022

The native type-hint is mixed - like everywhere else - but the php-doc type-hint says object|null which will be true in most cases but it's possible and mixed allows it to also return a scalar value.
Even if it's not the primary/intended use case the whole package allows to return of a single scalar value.

This is helpful for APIs which also only return a single value - like success, number of something or similar.
For example the @ecologi public reporting API:

This PRsadjusts the php-doc type to match the native one. And solves phpstan errors like the following:

RequestCollections/Reporting.php                                                                                        

Method Astrotomic\Ecologi\RequestCollections\Reporting::getTrees() should return int but returns object|null.           
Method Astrotomic\Ecologi\RequestCollections\Reporting::getCarbonOffset() should return float but returns object|null.  

I assume that this fix should also be applied to the v2 - but haven't checked yet if this problem still exists.

Copy link
Copy Markdown
Member

@Sammyjo20 Sammyjo20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@Sammyjo20 Sammyjo20 merged commit c9a0930 into saloonphp:v1 Oct 7, 2022
@Gummibeer Gummibeer deleted the patch-1 branch October 7, 2022 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants