Skip to content

Commit b04b207

Browse files
committed
refactor: move condition check into function
1 parent d3ff8eb commit b04b207

File tree

2 files changed

+6
-25
lines changed

2 files changed

+6
-25
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,11 @@ parameters:
3030
count: 1
3131
path: src/JsonSchema/Constraints/BaseConstraint.php
3232

33-
-
34-
message: "#^Cannot access property \\$additionalItems on stdClass\\|null\\.$#"
35-
count: 3
36-
path: src/JsonSchema/Constraints/CollectionConstraint.php
37-
38-
-
39-
message: "#^Cannot access property \\$items on stdClass\\|null\\.$#"
40-
count: 6
41-
path: src/JsonSchema/Constraints/CollectionConstraint.php
42-
4333
-
4434
message: "#^Method JsonSchema\\\\Constraints\\\\CollectionConstraint\\:\\:validateItems\\(\\) has parameter \\$value with no value type specified in iterable type array\\.$#"
4535
count: 1
4636
path: src/JsonSchema/Constraints/CollectionConstraint.php
4737

48-
-
49-
message: "#^Parameter \\#1 \\$object_or_class of function property_exists expects object\\|string, stdClass\\|null given\\.$#"
50-
count: 1
51-
path: src/JsonSchema/Constraints/CollectionConstraint.php
52-
53-
-
54-
message: "#^Parameter \\#2 \\$schema of method JsonSchema\\\\Constraints\\\\CollectionConstraint\\:\\:validateItems\\(\\) expects stdClass\\|null, object given\\.$#"
55-
count: 1
56-
path: src/JsonSchema/Constraints/CollectionConstraint.php
57-
5838
-
5939
message: "#^Method JsonSchema\\\\Constraints\\\\Constraint\\:\\:checkObject\\(\\) has parameter \\$appliedDefaults with no type specified\\.$#"
6040
count: 1

src/JsonSchema/Constraints/CollectionConstraint.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
5050
}
5151
}
5252

53-
// Verify items
54-
if (isset($schema->items)) {
55-
$this->validateItems($value, $schema, $path, $i);
56-
}
53+
$this->validateItems($value, $schema, $path, $i);
5754
}
5855

5956
/**
@@ -65,7 +62,11 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
6562
*/
6663
protected function validateItems(&$value, $schema = null, ?JsonPointer $path = null, $i = null): void
6764
{
68-
if (is_bool($schema->items) && $schema->items === true) {
65+
if (\is_null($schema) || !isset($schema->items)) {
66+
return;
67+
}
68+
69+
if ($schema->items === true) {
6970
return;
7071
}
7172

0 commit comments

Comments
 (0)