cebe / php-openapi

Read and write OpenAPI yaml/json files and make the content accessible in PHP objects.
MIT License
466 stars 88 forks source link

Add PHPStan Template #98

Closed marcelthole closed 3 years ago

marcelthole commented 3 years ago

Hi,

are you open for PHPStan specific Annotations? The following PR will fix following use case:

$spec = cebe\openapi\Reader::readFromYamlFile($inputFile, cebe\openapi\spec\OpenApi::class);
// this is required because the method returns only a SpecObjectInterface as annotation
assert($spec instanceof cebe\openapi\spec\OpenApi);

With the @phpstan-template annotation, PHPStan knowns, that the second parameter defines the return type and the paramater must be a class string and an instanceof SpecObjectInterface.

This should help other people who uses PHPStan and your library.

If you are fine with this, i will try to add more PHPStan specific type hints. But first i wanted to know if you would support that annotations.

cebe commented 3 years ago

Hi @marcelthole, thanks for the suggestion. I am fine with adding these.

cebe commented 3 years ago

Thank you!