Skip to content

Commit b33d45e

Browse files
authored
Merge pull request #98 from marcelthole/use-phpstan-typehints
Add PHPStan Template
2 parents e58a977 + c5ce0f9 commit b33d45e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Reader.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class Reader
2222
{
2323
/**
2424
* Populate OpenAPI spec object from JSON data.
25+
* @phpstan-template T of SpecObjectInterface
26+
* @phpstan-param class-string<T> $baseType
27+
* @phpstan-return T
2528
* @param string $json the JSON string to decode.
2629
* @param string $baseType the base Type to instantiate. This must be an instance of [[SpecObjectInterface]].
2730
* The default is [[OpenApi]] which is the base type of a OpenAPI specification file.
@@ -37,6 +40,9 @@ public static function readFromJson(string $json, string $baseType = OpenApi::cl
3740

3841
/**
3942
* Populate OpenAPI spec object from YAML data.
43+
* @phpstan-template T of SpecObjectInterface
44+
* @phpstan-param class-string<T> $baseType
45+
* @phpstan-return T
4046
* @param string $yaml the YAML string to decode.
4147
* @param string $baseType the base Type to instantiate. This must be an instance of [[SpecObjectInterface]].
4248
* The default is [[OpenApi]] which is the base type of a OpenAPI specification file.
@@ -52,6 +58,9 @@ public static function readFromYaml(string $yaml, string $baseType = OpenApi::cl
5258

5359
/**
5460
* Populate OpenAPI spec object from a JSON file.
61+
* @phpstan-template T of SpecObjectInterface
62+
* @phpstan-param class-string<T> $baseType
63+
* @phpstan-return T
5564
* @param string $fileName the file name of the file to be read.
5665
* If `$resolveReferences` is true (the default), this should be an absolute URL, a `file://` URI or
5766
* an absolute path to allow resolving relative path references.
@@ -95,6 +104,9 @@ public static function readFromJsonFile(string $fileName, string $baseType = Ope
95104

96105
/**
97106
* Populate OpenAPI spec object from YAML file.
107+
* @phpstan-template T of SpecObjectInterface
108+
* @phpstan-param class-string<T> $baseType
109+
* @phpstan-return T
98110
* @param string $fileName the file name of the file to be read.
99111
* If `$resolveReferences` is true (the default), this should be an absolute URL, a `file://` URI or
100112
* an absolute path to allow resolving relative path references.

0 commit comments

Comments
 (0)