Skip to content

Commit 6eb3168

Browse files
committed
Update dev tools
1 parent 4e9f57d commit 6eb3168

22 files changed

+466
-91
lines changed

phpstan-baseline.neon

Lines changed: 381 additions & 9 deletions
Large diffs are not rendered by default.

src/JsonSchema/Constraints/FormatConstraint.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public function check(&$element, $schema = null, ?JsonPointer $path = null, $i =
3939
$this->addError(ConstraintError::FORMAT_DATE(), $path, [
4040
'date' => $element,
4141
'format' => $schema->format
42-
]);
42+
]
43+
);
4344
}
4445
break;
4546

@@ -48,7 +49,8 @@ public function check(&$element, $schema = null, ?JsonPointer $path = null, $i =
4849
$this->addError(ConstraintError::FORMAT_TIME(), $path, [
4950
'time' => json_encode($element),
5051
'format' => $schema->format,
51-
]);
52+
]
53+
);
5254
}
5355
break;
5456

@@ -57,7 +59,8 @@ public function check(&$element, $schema = null, ?JsonPointer $path = null, $i =
5759
$this->addError(ConstraintError::FORMAT_DATE_TIME(), $path, [
5860
'dateTime' => json_encode($element),
5961
'format' => $schema->format
60-
]);
62+
]
63+
);
6164
}
6265
break;
6366

@@ -74,7 +77,8 @@ public function check(&$element, $schema = null, ?JsonPointer $path = null, $i =
7477
$this->addError(ConstraintError::FORMAT_REGEX(), $path, [
7578
'value' => $element,
7679
'format' => $schema->format
77-
]);
80+
]
81+
);
7882
}
7983
break;
8084

@@ -165,7 +169,7 @@ public function check(&$element, $schema = null, ?JsonPointer $path = null, $i =
165169
}
166170
}
167171

168-
protected function validateDateTime($datetime, $format): bool
172+
protected function validateDateTime($datetime, $format)
169173
{
170174
$dt = \DateTime::createFromFormat($format, (string) $datetime);
171175

@@ -180,7 +184,7 @@ protected function validateDateTime($datetime, $format): bool
180184
return false;
181185
}
182186

183-
protected function validateRegex($regex): bool
187+
protected function validateRegex($regex)
184188
{
185189
if (!is_string($regex)) {
186190
return true;
@@ -189,7 +193,7 @@ protected function validateRegex($regex): bool
189193
return false !== @preg_match(self::jsonPatternToPhpRegex($regex), '');
190194
}
191195

192-
protected function validateColor($color): bool
196+
protected function validateColor($color)
193197
{
194198
if (!is_string($color)) {
195199
return true;
@@ -201,30 +205,30 @@ protected function validateColor($color): bool
201205
return true;
202206
}
203207

204-
return 1 === preg_match('/^#([a-f0-9]{3}|[a-f0-9]{6})$/i', $color);
208+
return preg_match('/^#([a-f0-9]{3}|[a-f0-9]{6})$/i', $color);
205209
}
206210

207-
protected function validateStyle($style): bool
211+
protected function validateStyle($style)
208212
{
209213
$properties = explode(';', rtrim($style, ';'));
210214
$invalidEntries = preg_grep('/^\s*[-a-z]+\s*:\s*.+$/i', $properties, PREG_GREP_INVERT);
211215

212216
return empty($invalidEntries);
213217
}
214218

215-
protected function validatePhone($phone): bool
219+
protected function validatePhone($phone)
216220
{
217-
return 1 === preg_match('/^\+?(\(\d{3}\)|\d{3}) \d{3} \d{4}$/', $phone);
221+
return preg_match('/^\+?(\(\d{3}\)|\d{3}) \d{3} \d{4}$/', $phone);
218222
}
219223

220-
protected function validateHostname($host): bool
224+
protected function validateHostname($host)
221225
{
222226
if (!is_string($host)) {
223227
return true;
224228
}
225229

226230
$hostnameRegex = '/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/i';
227231

228-
return 1 === preg_match($hostnameRegex, $host);
232+
return preg_match($hostnameRegex, $host);
229233
}
230234
}

src/JsonSchema/Constraints/NumberConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function check(&$element, $schema = null, ?JsonPointer $path = null, $i =
7070
$this->checkFormat($element, $schema, $path, $i);
7171
}
7272

73-
private function fmod($number1, $number2): float
73+
private function fmod($number1, $number2)
7474
{
7575
$modulus = ($number1 - round($number1 / $number2) * $number2);
7676
$precision = 0.0000000001;

src/JsonSchema/Constraints/ObjectConstraint.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function check(&$element, $schema = null, ?JsonPointer $path = null, $pro
5454
$this->validateElement($element, $matches, $schema, $path, $properties, $additionalProp);
5555
}
5656

57-
public function validatePatternProperties($element, ?JsonPointer $path, $patternProperties): array
57+
public function validatePatternProperties($element, ?JsonPointer $path, $patternProperties)
5858
{
5959
$matches = [];
6060
foreach ($patternProperties as $pregex => $schema) {
@@ -87,7 +87,7 @@ public function validatePatternProperties($element, ?JsonPointer $path, $pattern
8787
* @param mixed $additionalProp Additional properties
8888
*/
8989
public function validateElement($element, $matches, $schema = null, ?JsonPointer $path = null,
90-
$properties = null, $additionalProp = null): void
90+
$properties = null, $additionalProp = null)
9191
{
9292
$this->validateMinMaxConstraint($element, $schema, $path);
9393

@@ -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): void
134+
public function validateProperties(&$element, $properties = null, ?JsonPointer $path = null)
135135
{
136136
$undefinedConstraint = $this->factory->createInstanceFor('undefined');
137137

@@ -173,7 +173,7 @@ protected function &getProperty(&$element, $property, $fallback = null)
173173
* @param \stdClass $objectDefinition ObjectConstraint definition
174174
* @param JsonPointer|null $path Path to test?
175175
*/
176-
protected function validateMinMaxConstraint($element, $objectDefinition, ?JsonPointer $path = null): void
176+
protected function validateMinMaxConstraint($element, $objectDefinition, ?JsonPointer $path = null)
177177
{
178178
// Verify minimum number of properties
179179
if (isset($objectDefinition->minProperties) && !is_object($objectDefinition->minProperties)) {

src/JsonSchema/Constraints/StringConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function check(&$element, $schema = null, ?JsonPointer $path = null, $i =
5151
$this->checkFormat($element, $schema, $path, $i);
5252
}
5353

54-
private function strlen($string): int
54+
private function strlen($string)
5555
{
5656
if (extension_loaded('mbstring')) {
5757
return mb_strlen($string, mb_detect_encoding($string));

src/JsonSchema/Constraints/TypeCheck/LooseTypeCheck.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,20 @@
66

77
class LooseTypeCheck implements TypeCheckInterface
88
{
9-
public static function isObject($value): bool
9+
public static function isObject($value)
1010
{
1111
return
1212
is_object($value)
1313
|| (is_array($value) && (count($value) == 0 || self::isAssociativeArray($value)));
1414
}
1515

16-
public static function isArray($value): bool
16+
public static function isArray($value)
1717
{
1818
return
1919
is_array($value)
2020
&& (count($value) == 0 || !self::isAssociativeArray($value));
2121
}
2222

23-
/**
24-
* @return mixed
25-
*/
2623
public static function propertyGet($value, $property)
2724
{
2825
if (is_object($value)) {
@@ -32,7 +29,7 @@ public static function propertyGet($value, $property)
3229
return $value[$property];
3330
}
3431

35-
public static function propertySet(&$value, $property, $data): void
32+
public static function propertySet(&$value, $property, $data)
3633
{
3734
if (is_object($value)) {
3835
$value->{$property} = $data;
@@ -41,7 +38,7 @@ public static function propertySet(&$value, $property, $data): void
4138
}
4239
}
4340

44-
public static function propertyExists($value, $property): bool
41+
public static function propertyExists($value, $property)
4542
{
4643
if (is_object($value)) {
4744
return property_exists($value, $property);
@@ -50,7 +47,7 @@ public static function propertyExists($value, $property): bool
5047
return array_key_exists($property, $value);
5148
}
5249

53-
public static function propertyCount($value): int
50+
public static function propertyCount($value)
5451
{
5552
if (is_object($value)) {
5653
return count(get_object_vars($value));

src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,32 @@
66

77
class StrictTypeCheck implements TypeCheckInterface
88
{
9-
public static function isObject($value): bool
9+
public static function isObject($value)
1010
{
1111
return is_object($value);
1212
}
1313

14-
public static function isArray($value): bool
14+
public static function isArray($value)
1515
{
1616
return is_array($value);
1717
}
1818

19-
/**
20-
* @return mixed
21-
*/
2219
public static function propertyGet($value, $property)
2320
{
2421
return $value->{$property};
2522
}
2623

27-
public static function propertySet(&$value, $property, $data): void
24+
public static function propertySet(&$value, $property, $data)
2825
{
2926
$value->{$property} = $data;
3027
}
3128

32-
public static function propertyExists($value, $property): bool
29+
public static function propertyExists($value, $property)
3330
{
3431
return property_exists($value, $property);
3532
}
3633

37-
public static function propertyCount($value): int
34+
public static function propertyCount($value)
3835
{
3936
if (!is_object($value)) {
4037
return 0;

src/JsonSchema/Constraints/TypeCheck/TypeCheckInterface.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@
66

77
interface TypeCheckInterface
88
{
9-
public static function isObject($value): bool;
9+
public static function isObject($value);
1010

11-
public static function isArray($value): bool;
11+
public static function isArray($value);
1212

13-
/**
14-
* @return mixed
15-
*/
1613
public static function propertyGet($value, $property);
1714

18-
public static function propertySet(&$value, $property, $data): void;
15+
public static function propertySet(&$value, $property, $data);
1916

20-
public static function propertyExists($value, $property): bool;
17+
public static function propertyExists($value, $property);
2118

22-
public static function propertyCount($value): int;
19+
public static function propertyCount($value);
2320
}

src/JsonSchema/Constraints/TypeConstraint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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): void
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
@@ -151,7 +151,7 @@ protected function implodeWith(array $elements, $delimiter = ', ', $listEnd = fa
151151
*
152152
* @throws StandardUnexpectedValueException
153153
*/
154-
protected function validateTypeNameWording($type): void
154+
protected function validateTypeNameWording($type)
155155
{
156156
if (!array_key_exists($type, self::$wording)) {
157157
throw new StandardUnexpectedValueException(

src/JsonSchema/Constraints/UndefinedConstraint.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
6363
* @param JsonPointer $path
6464
* @param string $i
6565
*/
66-
public function validateTypes(&$value, $schema, JsonPointer $path, $i = null): void
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): v
114114
* @param JsonPointer $path
115115
* @param string $i
116116
*/
117-
protected function validateCommonProperties(&$value, $schema, JsonPointer $path, $i = ''): void
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)) {
@@ -311,7 +311,7 @@ protected function applyDefaultValues(&$value, $schema, $path): void
311311
* @param JsonPointer $path
312312
* @param string $i
313313
*/
314-
protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i = ''): void
314+
protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i = '')
315315
{
316316
// Verify type
317317
if ($value instanceof self) {
@@ -385,7 +385,7 @@ protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i
385385
* @param JsonPointer $path
386386
* @param string $i
387387
*/
388-
protected function validateDependencies($value, $dependencies, JsonPointer $path, $i = ''): void
388+
protected function validateDependencies($value, $dependencies, JsonPointer $path, $i = '')
389389
{
390390
foreach ($dependencies as $key => $dependency) {
391391
if ($this->getTypeCheck()->propertyExists($value, $key)) {
@@ -415,7 +415,7 @@ protected function validateDependencies($value, $dependencies, JsonPointer $path
415415
}
416416
}
417417

418-
protected function validateUri($schema, $schemaUri = null): ?object
418+
protected function validateUri($schema, $schemaUri = null)
419419
{
420420
$resolver = new UriResolver();
421421
$retriever = $this->factory->getUriRetriever();

src/JsonSchema/Entity/JsonPointer.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,16 @@ class JsonPointer
3232
private $fromDefault = false;
3333

3434
/**
35+
* @param string $value
36+
*
3537
* @throws InvalidArgumentException when $value is not a string
3638
*/
37-
public function __construct(string $value)
39+
public function __construct($value)
3840
{
41+
if (!is_string($value)) {
42+
throw new InvalidArgumentException('Ref value must be a string');
43+
}
44+
3945
$splitRef = explode('#', $value, 2);
4046
$this->filename = $splitRef[0];
4147
if (array_key_exists(1, $splitRef)) {
@@ -140,7 +146,7 @@ public function __toString()
140146
/**
141147
* Mark the value at this path as being set from a schema default
142148
*/
143-
public function setFromDefault(): void
149+
public function setFromDefault()
144150
{
145151
$this->fromDefault = true;
146152
}

src/JsonSchema/Iterator/ObjectIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function count(): int
100100
/**
101101
* Initializer
102102
*/
103-
private function initialize(): void
103+
private function initialize()
104104
{
105105
if (!$this->initialized) {
106106
$this->data = $this->buildDataFromObject($this->object);

src/JsonSchema/SchemaStorage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function getUriResolver()
4545
/**
4646
* {@inheritdoc}
4747
*/
48-
public function addSchema($id, $schema = null): void
48+
public function addSchema($id, $schema = null)
4949
{
5050
if (is_null($schema) && $id !== self::INTERNAL_PROVIDED_SCHEMA_URI) {
5151
// if the schema was user-provided to Validator and is still null, then assume this is
@@ -82,7 +82,7 @@ public function addSchema($id, $schema = null): void
8282
* @param mixed $schema
8383
* @param string $base
8484
*/
85-
private function expandRefs(&$schema, $base = null): void
85+
private function expandRefs(&$schema, $base = null)
8686
{
8787
if (!is_object($schema)) {
8888
if (is_array($schema)) {

0 commit comments

Comments
 (0)