Skip to content

Commit 8c58cc6

Browse files
committed
Unset *outside* the loops (performance)
1 parent e0c601a commit 8c58cc6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/JsonSchema/Constraints/CollectionConstraint.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ protected function validateItems(&$value, $schema = null, JsonPointer $path = nu
8383
$typeValidator->check($v, $schema->items, $k_path, $i);
8484

8585
$validator->check($v, $schema->items, $k_path, $i);
86-
unset($v); // remove dangling reference to prevent any future bugs
87-
// caused by accidentally using $v elsewhere
8886
}
87+
unset($v); // remove dangling reference to prevent any future bugs
88+
// caused by accidentally using $v elsewhere
8989
$this->addErrors($typeValidator->getErrors());
9090
$this->addErrors($validator->getErrors());
9191
} else {
@@ -107,9 +107,9 @@ protected function validateItems(&$value, $schema = null, JsonPointer $path = nu
107107
} elseif (isset($secondErrors) && count($secondErrors) === count($this->getErrors())) {
108108
$this->errors = $initErrors;
109109
}
110-
unset($v); // remove dangling reference to prevent any future bugs
111-
// caused by accidentally using $v elsewhere
112110
}
111+
unset($v); // remove dangling reference to prevent any future bugs
112+
// caused by accidentally using $v elsewhere
113113
}
114114
} else {
115115
// Defined item type definitions
@@ -130,9 +130,9 @@ protected function validateItems(&$value, $schema = null, JsonPointer $path = nu
130130
$this->checkUndefined($v, new \stdClass(), $path, $k);
131131
}
132132
}
133-
unset($v); // remove dangling reference to prevent any future bugs
134-
// caused by accidentally using $v elsewhere
135133
}
134+
unset($v); // remove dangling reference to prevent any future bugs
135+
// caused by accidentally using $v elsewhere
136136

137137
// Treat when we have more schema definitions than values, not for empty arrays
138138
if (count($value) > 0) {

0 commit comments

Comments
 (0)