Skip to content

Commit 1be17d6

Browse files
committed
improved types for phpstan
1 parent 696bfd0 commit 1be17d6

File tree

5 files changed

+52
-10
lines changed

5 files changed

+52
-10
lines changed

src/Reader.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ public static function readFromJsonFile(string $fileName, string $baseType = Ope
8585
if (is_string($resolveReferences)) {
8686
$context->mode = $resolveReferences;
8787
}
88-
$spec->setDocumentContext($spec, new JsonPointer(''));
88+
if ($spec instanceof DocumentContextInterface) {
89+
$spec->setDocumentContext($spec, new JsonPointer(''));
90+
}
8991
$spec->resolveReferences();
9092
}
9193
return $spec;
@@ -126,7 +128,9 @@ public static function readFromYamlFile(string $fileName, string $baseType = Ope
126128
if (is_string($resolveReferences)) {
127129
$context->mode = $resolveReferences;
128130
}
129-
$spec->setDocumentContext($spec, new JsonPointer(''));
131+
if ($spec instanceof DocumentContextInterface) {
132+
$spec->setDocumentContext($spec, new JsonPointer(''));
133+
}
130134
$spec->resolveReferences();
131135
}
132136
return $spec;

src/ReferenceContext.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public function fetchReferencedFile($uri)
238238
* @param JsonPointer $pointer
239239
* @param array $data
240240
* @param string|null $toType
241-
* @return SpecObjectInterface|array
241+
* @return SpecObjectInterface|array|null
242242
*/
243243
public function resolveReferenceData($uri, JsonPointer $pointer, $data, $toType)
244244
{
@@ -255,7 +255,6 @@ public function resolveReferenceData($uri, JsonPointer $pointer, $data, $toType)
255255

256256
// transitive reference
257257
if (isset($referencedData['$ref'])) {
258-
/** @var Reference $referencedObject */
259258
return new Reference($referencedData, $toType);
260259
} else {
261260
/** @var SpecObjectInterface|array $referencedObject */

src/spec/Callback.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,25 @@
2222
*/
2323
class Callback implements SpecObjectInterface, DocumentContextInterface
2424
{
25+
/**
26+
* @var string|null
27+
*/
2528
private $_url;
29+
/**
30+
* @var PathItem
31+
*/
2632
private $_pathItem;
27-
33+
/**
34+
* @var array
35+
*/
2836
private $_errors = [];
29-
37+
/**
38+
* @var SpecObjectInterface|null
39+
*/
3040
private $_baseDocument;
41+
/**
42+
* @var JsonPointer|null
43+
*/
3144
private $_jsonPointer;
3245

3346

src/spec/Paths.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,17 @@ class Paths implements SpecObjectInterface, DocumentContextInterface, ArrayAcces
3434
* @var (PathItem|null)[]
3535
*/
3636
private $_paths = [];
37-
37+
/**
38+
* @var array
39+
*/
3840
private $_errors = [];
39-
41+
/**
42+
* @var SpecObjectInterface|null
43+
*/
4044
private $_baseDocument;
45+
/**
46+
* @var JsonPointer|null
47+
*/
4148
private $_jsonPointer;
4249

4350

src/spec/Reference.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,33 @@
2929
*/
3030
class Reference implements SpecObjectInterface, DocumentContextInterface
3131
{
32+
/**
33+
* @var string
34+
*/
3235
private $_to;
36+
/**
37+
* @var string
38+
*/
3339
private $_ref;
40+
/**
41+
* @var JsonReference|null
42+
*/
3443
private $_jsonReference;
44+
/**
45+
* @var ReferenceContext
46+
*/
3547
private $_context;
36-
48+
/**
49+
* @var SpecObjectInterface|null
50+
*/
3751
private $_baseDocument;
52+
/**
53+
* @var JsonPointer|null
54+
*/
3855
private $_jsonPointer;
39-
56+
/**
57+
* @var array
58+
*/
4059
private $_errors = [];
4160

4261
/**

0 commit comments

Comments
 (0)