Skip to content

Commit 9d7546b

Browse files
committed
More-phpstan-typing
1 parent 53993fa commit 9d7546b

19 files changed

+32
-32
lines changed

src/JsonSchema/Constraints/CollectionConstraint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CollectionConstraint extends Constraint
2525
/**
2626
* {@inheritdoc}
2727
*/
28-
public function check(& $value, $schema = null, ?JsonPointer $path = null, $i = null): void
28+
public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = null): void
2929
{
3030
// Verify minItems
3131
if (isset($schema->minItems) && count($value) < $schema->minItems) {
@@ -63,7 +63,7 @@ public function check(& $value, $schema = null, ?JsonPointer $path = null, $i =
6363
* @param \stdClass $schema
6464
* @param string $i
6565
*/
66-
protected function validateItems(& $value, $schema = null, ?JsonPointer $path = null, $i = null): void
66+
protected function validateItems(&$value, $schema = null, ?JsonPointer $path = null, $i = null): void
6767
{
6868
if (is_object($schema->items)) {
6969
// just one type definition for the whole array

src/JsonSchema/Constraints/ConstConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ConstConstraint extends Constraint
2525
/**
2626
* {@inheritdoc}
2727
*/
28-
public function check(& $element, $schema = null, ?JsonPointer $path = null, $i = null): void
28+
public function check(&$element, $schema = null, ?JsonPointer $path = null, $i = null): void
2929
{
3030
// Only validate const if the attribute exists
3131
if ($element instanceof UndefinedConstraint && (!isset($schema->required) || !$schema->required)) {

src/JsonSchema/Constraints/Constraint.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected function incrementPath(?JsonPointer $path, $i): JsonPointer
6565
* @param mixed $schema
6666
* @param mixed $i
6767
*/
68-
protected function checkArray(& $value, $schema = null, ?JsonPointer $path = null, $i = null): void
68+
protected function checkArray(&$value, $schema = null, ?JsonPointer $path = null, $i = null): void
6969
{
7070
$validator = $this->factory->createInstanceFor('collection');
7171
$validator->check($value, $schema, $path, $i);
@@ -82,7 +82,7 @@ protected function checkArray(& $value, $schema = null, ?JsonPointer $path = nul
8282
* @param mixed $additionalProperties
8383
* @param mixed $patternProperties
8484
*/
85-
protected function checkObject(& $value, $schema = null, ?JsonPointer $path = null, $properties = null,
85+
protected function checkObject(&$value, $schema = null, ?JsonPointer $path = null, $properties = null,
8686
$additionalProperties = null, $patternProperties = null, $appliedDefaults = []): void
8787
{
8888
/** @var ObjectConstraint $validator */
@@ -99,7 +99,7 @@ protected function checkObject(& $value, $schema = null, ?JsonPointer $path = nu
9999
* @param mixed $schema
100100
* @param mixed $i
101101
*/
102-
protected function checkType(& $value, $schema = null, ?JsonPointer $path = null, $i = null): void
102+
protected function checkType(&$value, $schema = null, ?JsonPointer $path = null, $i = null): void
103103
{
104104
$validator = $this->factory->createInstanceFor('type');
105105
$validator->check($value, $schema, $path, $i);
@@ -114,7 +114,7 @@ protected function checkType(& $value, $schema = null, ?JsonPointer $path = null
114114
* @param mixed $schema
115115
* @param mixed $i
116116
*/
117-
protected function checkUndefined(& $value, $schema = null, ?JsonPointer $path = null, $i = null, $fromDefault = false): void
117+
protected function checkUndefined(&$value, $schema = null, ?JsonPointer $path = null, $i = null, $fromDefault = false): void
118118
{
119119
/** @var UndefinedConstraint $validator */
120120
$validator = $this->factory->createInstanceFor('undefined');

src/JsonSchema/Constraints/ConstraintInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ public function isValid(): bool;
5555
*
5656
* @throws \JsonSchema\Exception\ExceptionInterface
5757
*/
58-
public function check(& $value, $schema = null, ?JsonPointer $path = null, $i = null): void;
58+
public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = null): void;
5959
}

src/JsonSchema/Constraints/EnumConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class EnumConstraint extends Constraint
2626
/**
2727
* {@inheritdoc}
2828
*/
29-
public function check(& $element, $schema = null, ?JsonPointer $path = null, $i = null): void
29+
public function check(&$element, $schema = null, ?JsonPointer $path = null, $i = null): void
3030
{
3131
// Only validate enum if the attribute exists
3232
if ($element instanceof UndefinedConstraint && (!isset($schema->required) || !$schema->required)) {

src/JsonSchema/Constraints/FormatConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class FormatConstraint extends Constraint
2727
/**
2828
* {@inheritdoc}
2929
*/
30-
public function check(& $element, $schema = null, ?JsonPointer $path = null, $i = null): void
30+
public function check(&$element, $schema = null, ?JsonPointer $path = null, $i = null): void
3131
{
3232
if (!isset($schema->format) || $this->factory->getConfig(self::CHECK_MODE_DISABLE_FORMAT)) {
3333
return;

src/JsonSchema/Constraints/NumberConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class NumberConstraint extends Constraint
2525
/**
2626
* {@inheritdoc}
2727
*/
28-
public function check(& $element, $schema = null, ?JsonPointer $path = null, $i = null): void
28+
public function check(&$element, $schema = null, ?JsonPointer $path = null, $i = null): void
2929
{
3030
// Verify minimum
3131
if (isset($schema->exclusiveMinimum)) {

src/JsonSchema/Constraints/ObjectConstraint.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ObjectConstraint extends Constraint
3030
/**
3131
* {@inheritdoc}
3232
*/
33-
public function check(& $element, $schema = null, ?JsonPointer $path = null, $properties = null,
33+
public function check(&$element, $schema = null, ?JsonPointer $path = null, $properties = null,
3434
$additionalProp = null, $patternProperties = null, $appliedDefaults = []): void
3535
{
3636
if ($element instanceof UndefinedConstraint) {
@@ -131,7 +131,7 @@ public function validateElement($element, $matches, $schema = null, ?JsonPointer
131131
* @param \stdClass $properties Property definitions
132132
* @param JsonPointer|null $path Path?
133133
*/
134-
public function validateProperties(& $element, $properties = null, ?JsonPointer $path = null)
134+
public function validateProperties(&$element, $properties = null, ?JsonPointer $path = null)
135135
{
136136
$undefinedConstraint = $this->factory->createInstanceFor('undefined');
137137

@@ -155,7 +155,7 @@ public function validateProperties(& $element, $properties = null, ?JsonPointer
155155
*
156156
* @return mixed
157157
*/
158-
protected function &getProperty(& $element, $property, $fallback = null)
158+
protected function &getProperty(&$element, $property, $fallback = null)
159159
{
160160
if (is_array($element) && (isset($element[$property]) || array_key_exists($property, $element)) /*$this->checkMode == self::CHECK_MODE_TYPE_CAST*/) {
161161
return $element[$property];

src/JsonSchema/Constraints/SchemaConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SchemaConstraint extends Constraint
3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function check(& $element, $schema = null, ?JsonPointer $path = null, $i = null): void
34+
public function check(&$element, $schema = null, ?JsonPointer $path = null, $i = null): void
3535
{
3636
if ($schema !== null) {
3737
// passed schema

src/JsonSchema/Constraints/StringConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class StringConstraint extends Constraint
2525
/**
2626
* {@inheritdoc}
2727
*/
28-
public function check(& $element, $schema = null, ?JsonPointer $path = null, $i = null): void
28+
public function check(&$element, $schema = null, ?JsonPointer $path = null, $i = null): void
2929
{
3030
// Verify maxLength
3131
if (isset($schema->maxLength) && $this->strlen($element) > $schema->maxLength) {

src/JsonSchema/Constraints/TypeCheck/LooseTypeCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static function propertyGet($value, $property)
2929
return $value[$property];
3030
}
3131

32-
public static function propertySet(& $value, $property, $data)
32+
public static function propertySet(&$value, $property, $data)
3333
{
3434
if (is_object($value)) {
3535
$value->{$property} = $data;

src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static function propertyGet($value, $property)
2121
return $value->{$property};
2222
}
2323

24-
public static function propertySet(& $value, $property, $data)
24+
public static function propertySet(&$value, $property, $data)
2525
{
2626
$value->{$property} = $data;
2727
}

src/JsonSchema/Constraints/TypeCheck/TypeCheckInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static function isArray($value);
1212

1313
public static function propertyGet($value, $property);
1414

15-
public static function propertySet(& $value, $property, $data);
15+
public static function propertySet(&$value, $property, $data);
1616

1717
public static function propertyExists($value, $property);
1818

src/JsonSchema/Constraints/TypeConstraint.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class TypeConstraint extends Constraint
4242
/**
4343
* {@inheritdoc}
4444
*/
45-
public function check(& $value = null, $schema = null, ?JsonPointer $path = null, $i = null): void
45+
public function check(&$value = null, $schema = null, ?JsonPointer $path = null, $i = null): void
4646
{
4747
$type = isset($schema->type) ? $schema->type : null;
4848
$isValid = false;
@@ -90,7 +90,7 @@ public function check(& $value = null, $schema = null, ?JsonPointer $path = null
9090
* @param ?JsonPointer $path
9191
* @param bool $coerce
9292
*/
93-
protected function validateTypesArray(& $value, array $type, & $validTypesWording, & $isValid, $path, $coerce = false)
93+
protected function validateTypesArray(&$value, array $type, & $validTypesWording, & $isValid, $path, $coerce = false)
9494
{
9595
foreach ($type as $tp) {
9696
// already valid, so no need to waste cycles looping over everything
@@ -173,7 +173,7 @@ protected function validateTypeNameWording($type)
173173
*
174174
* @return bool
175175
*/
176-
protected function validateType(& $value, $type, $coerce = false)
176+
protected function validateType(&$value, $type, $coerce = false)
177177
{
178178
//mostly the case for inline schema
179179
if (!$type) {

src/JsonSchema/Constraints/UndefinedConstraint.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class UndefinedConstraint extends Constraint
3434
/**
3535
* {@inheritdoc}
3636
*/
37-
public function check(& $value, $schema = null, ?JsonPointer $path = null, $i = null, $fromDefault = false): void
37+
public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = null, $fromDefault = false): void
3838
{
3939
if (is_null($schema) || !is_object($schema)) {
4040
return;
@@ -63,7 +63,7 @@ public function check(& $value, $schema = null, ?JsonPointer $path = null, $i =
6363
* @param JsonPointer $path
6464
* @param string $i
6565
*/
66-
public function validateTypes(& $value, $schema, JsonPointer $path, $i = null)
66+
public function validateTypes(&$value, $schema, JsonPointer $path, $i = null)
6767
{
6868
// check array
6969
if ($this->getTypeCheck()->isArray($value)) {
@@ -114,7 +114,7 @@ public function validateTypes(& $value, $schema, JsonPointer $path, $i = null)
114114
* @param JsonPointer $path
115115
* @param string $i
116116
*/
117-
protected function validateCommonProperties(& $value, $schema, JsonPointer $path, $i = '')
117+
protected function validateCommonProperties(&$value, $schema, JsonPointer $path, $i = '')
118118
{
119119
// if it extends another schema, it must pass that schema as well
120120
if (isset($schema->extends)) {
@@ -243,7 +243,7 @@ private function shouldApplyDefaultValue($requiredOnly, $schema, $name = null, $
243243
* @param mixed $schema
244244
* @param JsonPointer $path
245245
*/
246-
protected function applyDefaultValues(& $value, $schema, $path): void
246+
protected function applyDefaultValues(&$value, $schema, $path): void
247247
{
248248
// only apply defaults if feature is enabled
249249
if (!$this->factory->getConfig(self::CHECK_MODE_APPLY_DEFAULTS)) {
@@ -310,7 +310,7 @@ protected function applyDefaultValues(& $value, $schema, $path): void
310310
* @param JsonPointer $path
311311
* @param string $i
312312
*/
313-
protected function validateOfProperties(& $value, $schema, JsonPointer $path, $i = '')
313+
protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i = '')
314314
{
315315
// Verify type
316316
if ($value instanceof self) {

src/JsonSchema/SchemaStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function addSchema($id, $schema = null)
8282
* @param mixed $schema
8383
* @param string $base
8484
*/
85-
private function expandRefs(& $schema, $base = null)
85+
private function expandRefs(&$schema, $base = null)
8686
{
8787
if (!is_object($schema)) {
8888
if (is_array($schema)) {

src/JsonSchema/Validator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Validator extends BaseConstraint
4747
* @phpstan-param int-mask-of<Constraint::CHECK_MODE_*> $checkMode
4848
* @phpstan-return int-mask-of<Validator::ERROR_*>
4949
*/
50-
public function validate(& $value, $schema = null, $checkMode = null)
50+
public function validate(&$value, $schema = null, $checkMode = null)
5151
{
5252
// reset errors prior to validation
5353
$this->reset();
@@ -94,7 +94,7 @@ public function check($value, $schema)
9494
*
9595
* @deprecated
9696
*/
97-
public function coerce(& $value, $schema)
97+
public function coerce(&$value, $schema)
9898
{
9999
return $this->validate($value, $schema, Constraint::CHECK_MODE_COERCE_TYPES);
100100
}

tests/Constraints/FactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class MyBadConstraint
2525

2626
class MyStringConstraint extends Constraint
2727
{
28-
public function check(& $value, $schema = null, ?JsonPointer $path = null, $i = null): void
28+
public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = null): void
2929
{
3030
}
3131
}

tests/Uri/UriRetrieverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function testResolveRelativeUri($childSchema, $parentSchema): void
108108
$this->assertTrue($this->validator->isValid());
109109
}
110110

111-
private static function setParentSchemaExtendsValue(& $parentSchema, $value): void
111+
private static function setParentSchemaExtendsValue(&$parentSchema, $value): void
112112
{
113113
$parentSchemaDecoded = json_decode($parentSchema, true);
114114
$parentSchemaDecoded['extends'] = $value;

0 commit comments

Comments
 (0)