Skip to content

Commit 8560d43

Browse files
authored
Merge pull request #495 from erayd/backport-527
Backports for 5.2.7
2 parents d283e11 + abac02d commit 8560d43

37 files changed

+69
-64
lines changed

.php_cs.dist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
$finder = new PhpCsFixer\Finder();
4-
$config = new PhpCsFixer\Config('json-schema', 'json-schema style guide');
4+
$config = new PhpCsFixer\Config('json-schema');
55
$finder->in(__DIR__);
66

77
/* Based on ^2.1 of php-cs-fixer */
@@ -15,16 +15,16 @@ $config
1515
'array_syntax' => array('syntax' => 'long'),
1616
'binary_operator_spaces' => false,
1717
'concat_space' => array('spacing' => 'one'),
18-
'no_unused_imports' => false,
18+
'increment_style' => false,
1919
'no_useless_else' => true,
2020
'no_useless_return' => true,
2121
'ordered_imports' => true,
2222
'phpdoc_no_package' => false,
2323
'phpdoc_order' => true,
2424
'phpdoc_summary' => false,
2525
'pre_increment' => false,
26-
'trailing_comma_in_multiline_array' => false,
2726
'simplified_null_return' => false,
27+
'trailing_comma_in_multiline_array' => false,
2828
'yoda_style' => null,
2929
))
3030
->setFinder($finder)

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ sudo: false
22
language: php
33

44
cache:
5-
directories:
6-
- $HOME/.composer/cache
7-
- $HOME/.phpcsfixer
5+
directories:
6+
- $HOME/.composer/cache
7+
- $HOME/.phpcsfixer
88

99
matrix:
1010
fast_finish: true
@@ -17,6 +17,7 @@ matrix:
1717
- php: 7.0
1818
env: WITH_COVERAGE=true WITH_PHPCSFIXER=true
1919
- php: 7.1
20+
- php: 7.2
2021
- php: 'nightly'
2122
- php: hhvm
2223
dist: trusty
@@ -25,7 +26,6 @@ matrix:
2526

2627
before_install:
2728
- if [[ "$WITH_COVERAGE" != "true" && "$TRAVIS_PHP_VERSION" != "hhvm" && "$TRAVIS_PHP_VERSION" != "nightly" && "$TRAVIS_PHP_VERSION" != "7.1" ]]; then phpenv config-rm xdebug.ini; fi
28-
- composer selfupdate
2929
- if [[ "$TRAVIS_PHP_VERSION" = "hhvm" || "$TRAVIS_PHP_VERSION" = "nightly" ]]; then sed -i '/^.*friendsofphp\/php-cs-fixer.*$/d' composer.json; fi
3030

3131
install:

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"require-dev": {
4242
"json-schema/JSON-Schema-Test-Suite": "1.2.0",
4343
"friendsofphp/php-cs-fixer": "^2.1",
44-
"phpunit/phpunit": "^4.8.22"
44+
"phpunit/phpunit": "^4.8.35"
4545
},
4646
"autoload": {
4747
"psr-4": { "JsonSchema\\": "src/JsonSchema/" }
@@ -56,10 +56,10 @@
5656
}
5757
},
5858
"scripts": {
59-
"test" : "vendor/bin/phpunit",
60-
"testOnly" : "vendor/bin/phpunit --colors --filter",
61-
"coverage" : "vendor/bin/phpunit --coverage-text",
62-
"style-check" : "vendor/bin/php-cs-fixer fix --dry-run --verbose --diff",
63-
"style-fix" : "vendor/bin/php-cs-fixer fix --verbose"
59+
"test" : "phpunit",
60+
"testOnly" : "phpunit --colors --filter",
61+
"coverage" : "phpunit --coverage-text",
62+
"style-check" : "php-cs-fixer fix --dry-run --verbose --diff",
63+
"style-fix" : "php-cs-fixer fix --verbose"
6464
}
6565
}

src/JsonSchema/Constraints/Constraint.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
namespace JsonSchema\Constraints;
1111

1212
use JsonSchema\Entity\JsonPointer;
13-
use JsonSchema\SchemaStorage;
14-
use JsonSchema\Uri\UriRetriever;
15-
use JsonSchema\UriRetrieverInterface;
1613

1714
/**
1815
* The Base Constraints, all Validators should extend this class

src/JsonSchema/Constraints/Factory.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
namespace JsonSchema\Constraints;
1111

12-
use JsonSchema\Constraints\Constraint;
1312
use JsonSchema\Exception\InvalidArgumentException;
14-
use JsonSchema\Exception\InvalidConfigException;
1513
use JsonSchema\SchemaStorage;
1614
use JsonSchema\SchemaStorageInterface;
1715
use JsonSchema\Uri\UriRetriever;

src/JsonSchema/Constraints/SchemaConstraint.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use JsonSchema\Exception\InvalidArgumentException;
1414
use JsonSchema\Exception\InvalidSchemaException;
1515
use JsonSchema\Exception\RuntimeException;
16-
use JsonSchema\SchemaStorage;
1716
use JsonSchema\Validator;
1817

1918
/**

src/JsonSchema/Constraints/UndefinedConstraint.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ protected function applyDefaultValues(&$value, $schema, $path)
243243
if (isset($schema->properties) && LooseTypeCheck::isObject($value)) {
244244
// $value is an object or assoc array, and properties are defined - treat as an object
245245
foreach ($schema->properties as $currentProperty => $propertyDefinition) {
246+
$propertyDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($propertyDefinition);
246247
if (
247248
!LooseTypeCheck::propertyExists($value, $currentProperty)
248249
&& property_exists($propertyDefinition, 'default')
@@ -266,6 +267,7 @@ protected function applyDefaultValues(&$value, $schema, $path)
266267
}
267268
// $value is an array, and items are defined - treat as plain array
268269
foreach ($items as $currentItem => $itemDefinition) {
270+
$itemDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($itemDefinition);
269271
if (
270272
!array_key_exists($currentItem, $value)
271273
&& property_exists($itemDefinition, 'default')

src/JsonSchema/Validator.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
use JsonSchema\Constraints\BaseConstraint;
1313
use JsonSchema\Constraints\Constraint;
14-
use JsonSchema\Exception\InvalidConfigException;
15-
use JsonSchema\SchemaStorage;
1614

1715
/**
1816
* A JsonSchema Constraint

tests/Constraints/CoerciveTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use JsonSchema\Constraints\Constraint;
1313
use JsonSchema\Constraints\Factory;
1414
use JsonSchema\SchemaStorage;
15-
use JsonSchema\Uri\UriResolver;
1615
use JsonSchema\Validator;
1716

1817
class CoerciveTest extends BasicTypesTest

tests/Constraints/DefaultPropertiesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ public function getValidTests()
121121
),
122122
array(// #15 infinite recursion via $ref (object)
123123
'{}',
124-
'{"properties":{"propertyOne": {"$ref": "#","default": {}}}}',
124+
'{"properties":{"propertyOne": {"$ref": "#","default": {}}}, "default": "valueOne"}',
125125
'{"propertyOne":{}}'
126126
),
127127
array(// #16 infinite recursion via $ref (array)
128128
'[]',
129-
'{"items":[{"$ref":"#","default":[]}]}',
129+
'{"items":[{"$ref":"#","default":[]}], "default": "valueOne"}',
130130
'[[]]'
131131
),
132132
array(// #17 default top value does not overwrite defined null

0 commit comments

Comments
 (0)