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

Add generics PHPDoc tags to ParseNode methods #42

Merged
merged 1 commit into from
Mar 10, 2023
Merged

Conversation

Ndiritu
Copy link
Contributor

@Ndiritu Ndiritu commented Mar 10, 2023

PHP doesn't support generics. The return type of our ParseNode object methods is a Parsable and Enum for enum-related methods yet model setters expect a concrete type. This causes static analysis failures like:

Error: Parameter #1 $value of method Integration\Test\Client\Models\AppPermissions::setPages() expects Integration\Test\Client\Models\AppPermissions_pages|null, Microsoft\Kiota\Abstractions\Enum|null given.
Error: Parameter #1 $value of method Integration\Test\Client\Models\TestList::setItems() expects array<Integration\Test\Client\Models\TestList_items>|null, array<Microsoft\Kiota\Abstractions\Serialization\Parsable>|null given.
Error: Parameter #1 $value of method Integration\Test\Client\Models\TestList_items::setAdditional() expects Integration\Test\Client\Models\TestList_items_additional|null, Microsoft\Kiota\Abstractions\Serialization\Parsable|null given.

This change tells PHPStan that a generic type will be passed and returned.

Impact of this change can be viewed at https://github.com/microsoft/kiota-samples/actions/runs/4383543674/jobs/7673923173 where PHPStan is run using abstractions changes from this branch. The only existing issue is around arrays of primitive types. Arrays of Parsable implementations/Arrays of Enums are handled.

Still need to figure out a fix for the PHPDoc for getCollectionOfPrimitiveValues. The generic PHPDoc format doesn't match primitive types.

part of microsoft/kiota#2378

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Ndiritu Ndiritu marked this pull request as ready for review March 10, 2023 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants