Skip to content

Commit a319158

Browse files
committed
style: correct code style violations
1 parent 29b5eaf commit a319158

21 files changed

+23
-36
lines changed

src/JsonSchema/Constraints/Drafts/Draft06/AdditionalItemsConstraint.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
3232
if ($schema->additionalItems === true) {
3333
return;
3434
}
35-
if ($schema->additionalItems === false && ! property_exists($schema, 'items')) {
35+
if ($schema->additionalItems === false && !property_exists($schema, 'items')) {
3636
return;
3737
}
3838

@@ -58,7 +58,5 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
5858

5959
$this->addError(ConstraintError::ADDITIONAL_ITEMS(), $path, ['item' => $i, 'property' => $propertyName, 'additionalItems' => $schema->additionalItems]);
6060
}
61-
62-
6361
}
6462
}

src/JsonSchema/Constraints/Drafts/Draft06/AdditionalPropertiesConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
3939
$additionalProperties = get_object_vars($value);
4040

4141
if (isset($schema->properties)) {
42-
$additionalProperties = array_diff_key($additionalProperties, (array)$schema->properties);
42+
$additionalProperties = array_diff_key($additionalProperties, (array) $schema->properties);
4343
}
4444

4545
if (isset($schema->patternProperties)) {

src/JsonSchema/Constraints/Drafts/Draft06/AllOfConstraint.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use JsonSchema\Constraints\ConstraintInterface;
99
use JsonSchema\Entity\ErrorBagProxy;
1010
use JsonSchema\Entity\JsonPointer;
11-
use JsonSchema\Exception\ValidationException;
1211

1312
class AllOfConstraint implements ConstraintInterface
1413
{

src/JsonSchema/Constraints/Drafts/Draft06/AnyOfConstraint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
3838
if ($schemaConstraint->isValid()) {
3939
return;
4040
}
41-
} catch (ValidationException $e) {}
41+
} catch (ValidationException $e) {
42+
}
4243
}
4344

4445
$this->addError(ConstraintError::ANY_OF(), $path);
45-
4646
}
4747
}

src/JsonSchema/Constraints/Drafts/Draft06/ContainsConstraint.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class ContainsConstraint implements ConstraintInterface
1515

1616
/** @var Factory */
1717
private $factory;
18+
1819
public function __construct(?Factory $factory = null)
1920
{
2021
$this->factory = $factory ?: new Factory();

src/JsonSchema/Constraints/Drafts/Draft06/Draft06Constraint.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
2121
if ($schema === false) {
2222
$this->addError(ConstraintError::FALSE(), $path, []);
2323
}
24+
2425
return;
2526
}
2627

src/JsonSchema/Constraints/Drafts/Draft06/EnumConstraint.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use JsonSchema\ConstraintError;
88
use JsonSchema\Constraints\ConstraintInterface;
99
use JsonSchema\Constraints\Factory;
10-
use JsonSchema\Constraints\UndefinedConstraint;
1110
use JsonSchema\Entity\ErrorBagProxy;
1211
use JsonSchema\Entity\JsonPointer;
1312
use JsonSchema\Tool\DeepComparer;

src/JsonSchema/Constraints/Drafts/Draft06/FormatConstraint.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
111111
default:
112112
break;
113113
}
114-
115114
}
116115

117116
private function validateDateTime(string $datetime, string $format): bool

src/JsonSchema/Constraints/Drafts/Draft06/ItemsConstraint.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,18 @@
44

55
namespace JsonSchema\Constraints\Drafts\Draft06;
66

7-
use JsonSchema\ConstraintError;
87
use JsonSchema\Constraints\ConstraintInterface;
98
use JsonSchema\Constraints\Factory;
109
use JsonSchema\Entity\ErrorBagProxy;
1110
use JsonSchema\Entity\JsonPointer;
12-
use JsonSchema\Rfc3339;
13-
use JsonSchema\Tool\Validator\RelativeReferenceValidator;
14-
use JsonSchema\Tool\Validator\UriValidator;
1511

1612
class ItemsConstraint implements ConstraintInterface
1713
{
1814
use ErrorBagProxy;
1915

2016
/** @var \JsonSchema\Constraints\Drafts\Draft06\Factory */
2117
private $factory;
18+
2219
public function __construct(?Factory $factory = null)
2320
{
2421
$this->factory = $factory ?: new Factory();

src/JsonSchema/Constraints/Drafts/Draft06/MultipleOfConstraint.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
3434
}
3535

3636
$this->addError(ConstraintError::MULTIPLE_OF(), $path, ['multipleOf' => $schema->multipleOf, 'found' => $value]);
37-
38-
3937
}
4038

4139
private function isMultipleOf(string $value, string $multipleOf): bool
@@ -45,6 +43,7 @@ private function isMultipleOf(string $value, string $multipleOf): bool
4543
}
4644

4745
$div = bcdiv($value, $multipleOf, 20);
46+
4847
return bccomp(bcmod($div, '1', 20), '0', 20) === 0;
4948
}
5049
}

src/JsonSchema/Constraints/Drafts/Draft06/NotConstraint.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99
use JsonSchema\Constraints\Factory;
1010
use JsonSchema\Entity\ErrorBagProxy;
1111
use JsonSchema\Entity\JsonPointer;
12-
use JsonSchema\Rfc3339;
13-
use JsonSchema\Tool\Validator\RelativeReferenceValidator;
14-
use JsonSchema\Tool\Validator\UriValidator;
1512

1613
class NotConstraint implements ConstraintInterface
1714
{
1815
use ErrorBagProxy;
1916

2017
/** @var \JsonSchema\Constraints\Drafts\Draft06\Factory */
2118
private $factory;
19+
2220
public function __construct(?Factory $factory = null)
2321
{
2422
$this->factory = $factory ?: new Factory();
@@ -34,7 +32,7 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
3432
$schemaConstraint = $this->factory->createInstanceFor('schema');
3533
$schemaConstraint->check($value, $schema->not, $path, $i);
3634

37-
if (! $schemaConstraint->isValid()) {
35+
if (!$schemaConstraint->isValid()) {
3836
return;
3937
}
4038

src/JsonSchema/Constraints/Drafts/Draft06/OneOfConstraint.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use JsonSchema\Constraints\ConstraintInterface;
99
use JsonSchema\Entity\ErrorBagProxy;
1010
use JsonSchema\Entity\JsonPointer;
11-
use JsonSchema\Exception\ValidationException;
1211

1312
class OneOfConstraint implements ConstraintInterface
1413
{

src/JsonSchema/Constraints/Drafts/Draft06/PatternPropertiesConstraint.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace JsonSchema\Constraints\Drafts\Draft06;
66

7-
use JsonSchema\ConstraintError;
87
use JsonSchema\Constraints\ConstraintInterface;
98
use JsonSchema\Entity\ErrorBagProxy;
109
use JsonSchema\Entity\JsonPointer;

src/JsonSchema/Constraints/Drafts/Draft06/PropertiesConstraint.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,18 @@
44

55
namespace JsonSchema\Constraints\Drafts\Draft06;
66

7-
use JsonSchema\ConstraintError;
87
use JsonSchema\Constraints\ConstraintInterface;
98
use JsonSchema\Constraints\Factory;
109
use JsonSchema\Entity\ErrorBagProxy;
1110
use JsonSchema\Entity\JsonPointer;
12-
use JsonSchema\Rfc3339;
13-
use JsonSchema\Tool\Validator\RelativeReferenceValidator;
14-
use JsonSchema\Tool\Validator\UriValidator;
1511

1612
class PropertiesConstraint implements ConstraintInterface
1713
{
1814
use ErrorBagProxy;
1915

2016
/** @var \JsonSchema\Constraints\Drafts\Draft06\Factory */
2117
private $factory;
18+
2219
public function __construct(?Factory $factory = null)
2320
{
2421
$this->factory = $factory ?: new Factory();
@@ -37,7 +34,7 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
3734

3835
foreach ($schema->properties as $propertyName => $propertySchema) {
3936
$schemaConstraint = $this->factory->createInstanceFor('schema');
40-
if (! property_exists($value, $propertyName)) {
37+
if (!property_exists($value, $propertyName)) {
4138
continue;
4239
}
4340

src/JsonSchema/Constraints/Drafts/Draft06/PropertiesNamesConstraint.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
4141
foreach ($propertyNames as $propertyName => $_) {
4242
$this->addError(ConstraintError::PROPERTY_NAMES(), $path, ['propertyNames' => $schema->propertyNames, 'violating' => 'false', 'name' => $propertyName]);
4343
}
44+
4445
return;
4546
}
4647

47-
if (property_exists($schema->propertyNames, "maxLength")) {
48+
if (property_exists($schema->propertyNames, 'maxLength')) {
4849
foreach ($propertyNames as $propertyName => $_) {
4950
$length = mb_strlen($propertyName);
5051
if ($length > $schema->propertyNames->maxLength) {
@@ -53,7 +54,7 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
5354
}
5455
}
5556

56-
if (property_exists($schema->propertyNames, "pattern")) {
57+
if (property_exists($schema->propertyNames, 'pattern')) {
5758
foreach ($propertyNames as $propertyName => $_) {
5859
if (!preg_match('/' . str_replace('/', '\/', $schema->propertyNames->pattern) . '/', $propertyName)) {
5960
$this->addError(ConstraintError::PROPERTY_NAMES(), $path, ['propertyNames' => $schema->propertyNames, 'violating' => 'pattern', 'name' => $propertyName]);

src/JsonSchema/Constraints/Drafts/Draft06/TypeConstraint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
2525
return;
2626
}
2727

28-
$schemaTypes = (array) $schema->type;
28+
$schemaTypes = (array) $schema->type;
2929
$valueType = strtolower(gettype($value));
3030
// All specific number types are a number
3131
$valueIsNumber = $valueType === 'double' || $valueType === 'integer';
@@ -40,7 +40,7 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
4040
if ($type === 'number' && $valueIsNumber) {
4141
return;
4242
}
43-
if ($type === 'integer' && $isInteger) {
43+
if ($type === 'integer' && $isInteger) {
4444
return;
4545
}
4646
}

src/JsonSchema/Constraints/Drafts/Draft06/UniqueItemsConstraint.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
3636
for ($y = $x + 1; $y < $count; $y++) {
3737
if (DeepComparer::isEqual($value[$x], $value[$y])) {
3838
$this->addError(ConstraintError::UNIQUE_ITEMS(), $path);
39+
3940
return;
4041
}
4142
}

src/JsonSchema/Entity/ErrorBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function addError(ConstraintError $constraint, ?JsonPointer $path = null,
8484
/** @param ErrorList $errors */
8585
public function addErrors(array $errors): void
8686
{
87-
if (! $errors) {
87+
if (!$errors) {
8888
return;
8989
}
9090

src/JsonSchema/Validator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public function validate(&$value, $schema = null, ?int $checkMode = null): int
7171
if ($schema === false) {
7272
$this->addError(ConstraintError::FALSE());
7373
}
74+
7475
return $this->getErrorMask();
7576
}
7677

tests/Constraints/VeryBaseTestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ abstract class VeryBaseTestCase extends TestCase
1919

2020
/**
2121
* @param object|bool|null $schema
22+
*
2223
* @return object
2324
*/
2425
protected function getUriRetrieverMock($schema): object

tests/JsonSchemaTestSuiteTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class JsonSchemaTestSuiteTest extends TestCase
2020
* @dataProvider casesDataProvider
2121
*
2222
* @param \stdClass|bool $schema
23-
* @param mixed $data
23+
* @param mixed $data
2424
*/
2525
public function testTestCaseValidatesCorrectly(
2626
string $testCaseDescription,
@@ -29,8 +29,7 @@ public function testTestCaseValidatesCorrectly(
2929
$data,
3030
bool $expectedValidationResult,
3131
bool $optional
32-
): void
33-
{
32+
): void {
3433
$schemaStorage = new SchemaStorage();
3534
$id = is_object($schema) && property_exists($schema, 'id') ? $schema->id : SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI;
3635
$schemaStorage->addSchema($id, $schema);
@@ -110,7 +109,6 @@ function ($file) {
110109
'optional' => str_contains($file->getPathname(), '/optional/')
111110
];
112111
}
113-
114112
}
115113
}
116114
}
@@ -163,5 +161,4 @@ private function is32Bit(): bool
163161
{
164162
return PHP_INT_SIZE === 4;
165163
}
166-
167164
}

0 commit comments

Comments
 (0)