Skip to content

Commit

Permalink
Merge pull request #495 from erayd/backport-527
Browse files Browse the repository at this point in the history
Backports for 5.2.7
  • Loading branch information
bighappyface authored Feb 14, 2018
2 parents d283e11 + abac02d commit 8560d43
Show file tree
Hide file tree
Showing 37 changed files with 69 additions and 64 deletions.
6 changes: 3 additions & 3 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

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

/* Based on ^2.1 of php-cs-fixer */
Expand All @@ -15,16 +15,16 @@ $config
'array_syntax' => array('syntax' => 'long'),
'binary_operator_spaces' => false,
'concat_space' => array('spacing' => 'one'),
'no_unused_imports' => false,
'increment_style' => false,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => true,
'phpdoc_no_package' => false,
'phpdoc_order' => true,
'phpdoc_summary' => false,
'pre_increment' => false,
'trailing_comma_in_multiline_array' => false,
'simplified_null_return' => false,
'trailing_comma_in_multiline_array' => false,
'yoda_style' => null,
))
->setFinder($finder)
Expand Down
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ sudo: false
language: php

cache:
directories:
- $HOME/.composer/cache
- $HOME/.phpcsfixer
directories:
- $HOME/.composer/cache
- $HOME/.phpcsfixer

matrix:
fast_finish: true
Expand All @@ -17,6 +17,7 @@ matrix:
- php: 7.0
env: WITH_COVERAGE=true WITH_PHPCSFIXER=true
- php: 7.1
- php: 7.2
- php: 'nightly'
- php: hhvm
dist: trusty
Expand All @@ -25,7 +26,6 @@ matrix:

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

install:
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"require-dev": {
"json-schema/JSON-Schema-Test-Suite": "1.2.0",
"friendsofphp/php-cs-fixer": "^2.1",
"phpunit/phpunit": "^4.8.22"
"phpunit/phpunit": "^4.8.35"
},
"autoload": {
"psr-4": { "JsonSchema\\": "src/JsonSchema/" }
Expand All @@ -56,10 +56,10 @@
}
},
"scripts": {
"test" : "vendor/bin/phpunit",
"testOnly" : "vendor/bin/phpunit --colors --filter",
"coverage" : "vendor/bin/phpunit --coverage-text",
"style-check" : "vendor/bin/php-cs-fixer fix --dry-run --verbose --diff",
"style-fix" : "vendor/bin/php-cs-fixer fix --verbose"
"test" : "phpunit",
"testOnly" : "phpunit --colors --filter",
"coverage" : "phpunit --coverage-text",
"style-check" : "php-cs-fixer fix --dry-run --verbose --diff",
"style-fix" : "php-cs-fixer fix --verbose"
}
}
3 changes: 0 additions & 3 deletions src/JsonSchema/Constraints/Constraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
namespace JsonSchema\Constraints;

use JsonSchema\Entity\JsonPointer;
use JsonSchema\SchemaStorage;
use JsonSchema\Uri\UriRetriever;
use JsonSchema\UriRetrieverInterface;

/**
* The Base Constraints, all Validators should extend this class
Expand Down
2 changes: 0 additions & 2 deletions src/JsonSchema/Constraints/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

namespace JsonSchema\Constraints;

use JsonSchema\Constraints\Constraint;
use JsonSchema\Exception\InvalidArgumentException;
use JsonSchema\Exception\InvalidConfigException;
use JsonSchema\SchemaStorage;
use JsonSchema\SchemaStorageInterface;
use JsonSchema\Uri\UriRetriever;
Expand Down
1 change: 0 additions & 1 deletion src/JsonSchema/Constraints/SchemaConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use JsonSchema\Exception\InvalidArgumentException;
use JsonSchema\Exception\InvalidSchemaException;
use JsonSchema\Exception\RuntimeException;
use JsonSchema\SchemaStorage;
use JsonSchema\Validator;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/UndefinedConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ protected function applyDefaultValues(&$value, $schema, $path)
if (isset($schema->properties) && LooseTypeCheck::isObject($value)) {
// $value is an object or assoc array, and properties are defined - treat as an object
foreach ($schema->properties as $currentProperty => $propertyDefinition) {
$propertyDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($propertyDefinition);
if (
!LooseTypeCheck::propertyExists($value, $currentProperty)
&& property_exists($propertyDefinition, 'default')
Expand All @@ -266,6 +267,7 @@ protected function applyDefaultValues(&$value, $schema, $path)
}
// $value is an array, and items are defined - treat as plain array
foreach ($items as $currentItem => $itemDefinition) {
$itemDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($itemDefinition);
if (
!array_key_exists($currentItem, $value)
&& property_exists($itemDefinition, 'default')
Expand Down
2 changes: 0 additions & 2 deletions src/JsonSchema/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

use JsonSchema\Constraints\BaseConstraint;
use JsonSchema\Constraints\Constraint;
use JsonSchema\Exception\InvalidConfigException;
use JsonSchema\SchemaStorage;

/**
* A JsonSchema Constraint
Expand Down
1 change: 0 additions & 1 deletion tests/Constraints/CoerciveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use JsonSchema\Constraints\Constraint;
use JsonSchema\Constraints\Factory;
use JsonSchema\SchemaStorage;
use JsonSchema\Uri\UriResolver;
use JsonSchema\Validator;

class CoerciveTest extends BasicTypesTest
Expand Down
4 changes: 2 additions & 2 deletions tests/Constraints/DefaultPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ public function getValidTests()
),
array(// #15 infinite recursion via $ref (object)
'{}',
'{"properties":{"propertyOne": {"$ref": "#","default": {}}}}',
'{"properties":{"propertyOne": {"$ref": "#","default": {}}}, "default": "valueOne"}',
'{"propertyOne":{}}'
),
array(// #16 infinite recursion via $ref (array)
'[]',
'{"items":[{"$ref":"#","default":[]}]}',
'{"items":[{"$ref":"#","default":[]}], "default": "valueOne"}',
'[[]]'
),
array(// #17 default top value does not overwrite defined null
Expand Down
2 changes: 1 addition & 1 deletion tests/Constraints/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use JsonSchema\Constraints\Constraint;
use JsonSchema\Constraints\Factory;
use JsonSchema\Entity\JsonPointer;
use PHPUnit_Framework_TestCase as TestCase;
use PHPUnit\Framework\TestCase;

/**
* Class MyBadConstraint
Expand Down
2 changes: 1 addition & 1 deletion tests/Constraints/FormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function testInvalidFormat($string, $format)
$schema->format = $format;

$validator->check($string, $schema);
$this->assertEquals(1, count($validator->getErrors()), 'Expected 1 error');
$this->assertCount(1, $validator->getErrors(), 'Expected 1 error');
}

/**
Expand Down
7 changes: 0 additions & 7 deletions tests/Constraints/LongArraysTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,4 @@ public function testLongIntegerArray()
$validator->check($checkValue, $schema);
$this->assertTrue($validator->isValid(), print_r($validator->getErrors(), true));
}

private static function millis()
{
$mt = explode(' ', microtime());

return $mt[1] * 1000 + round($mt[0] * 1000);
}
}
3 changes: 2 additions & 1 deletion tests/Constraints/PointerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
namespace JsonSchema\Tests\Constraints;

use JsonSchema\Validator;
use PHPUnit\Framework\TestCase;

class PointerTest extends \PHPUnit_Framework_TestCase
class PointerTest extends TestCase
{
protected $validateSchema = true;

Expand Down
3 changes: 2 additions & 1 deletion tests/Constraints/SchemaValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

use JsonSchema\Constraints\Constraint;
use JsonSchema\Validator;
use PHPUnit\Framework\TestCase;

class SchemaValidationTest extends \PHPUnit_Framework_TestCase
class SchemaValidationTest extends TestCase
{
protected $validateSchema = true;

Expand Down
7 changes: 4 additions & 3 deletions tests/Constraints/TypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
use JsonSchema\Constraints\TypeConstraint;
use PHPUnit\Framework\TestCase;

/**
* Class TypeTest
Expand All @@ -19,7 +20,7 @@
*
* @author hakre <https://github.com/hakre>
*/
class TypeTest extends \PHPUnit_Framework_TestCase
class TypeTest extends TestCase
{
/**
* @see testIndefiniteArticleForTypeInTypeCheckErrorMessage
Expand Down Expand Up @@ -57,7 +58,7 @@ public function testIndefiniteArticleForTypeInTypeCheckErrorMessage($type, $word
*/
public function testLooseTypeChecking()
{
$v = new \StdClass();
$v = new \stdClass();
$v->property = 'dataOne';
LooseTypeCheck::propertySet($v, 'property', 'dataTwo');
$this->assertEquals('dataTwo', $v->property);
Expand Down Expand Up @@ -110,7 +111,7 @@ public function testValidateTypeNameWording()
public function testValidateTypeException()
{
$t = new TypeConstraint();
$data = new \StdClass();
$data = new \stdClass();
$schema = json_decode('{"type": "notAValidTypeName"}');

$this->setExpectedException(
Expand Down
3 changes: 2 additions & 1 deletion tests/Constraints/ValidationExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
use JsonSchema\Constraints\Constraint;
use JsonSchema\Exception\ValidationException;
use JsonSchema\Validator;
use PHPUnit\Framework\TestCase;

class ValidationExceptionTest extends \PHPUnit_Framework_TestCase
class ValidationExceptionTest extends TestCase
{
public function testValidationException()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Constraints/VeryBaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@

namespace JsonSchema\Tests\Constraints;

use PHPUnit\Framework\TestCase;
use Prophecy\Argument;

/**
* @package JsonSchema\Tests\Constraints
*/
abstract class VeryBaseTestCase extends \PHPUnit_Framework_TestCase
abstract class VeryBaseTestCase extends TestCase
{
/** @var object */
private $jsonSchemaDraft03;
Expand Down
2 changes: 0 additions & 2 deletions tests/Drafts/Draft3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

namespace JsonSchema\Tests\Drafts;

use JsonSchema\Constraints\Constraint;

/**
* @package JsonSchema\Tests\Drafts
*/
Expand Down
3 changes: 2 additions & 1 deletion tests/Entity/JsonPointerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
namespace JsonSchema\Tests\Entity;

use JsonSchema\Entity\JsonPointer;
use PHPUnit\Framework\TestCase;

/**
* @package JsonSchema\Tests\Entity
*
* @author Joost Nijhuis <[email protected]>
*/
class JsonPointerTest extends \PHPUnit_Framework_TestCase
class JsonPointerTest extends TestCase
{
/**
* @dataProvider getTestData
Expand Down
3 changes: 2 additions & 1 deletion tests/Exception/InvalidArgumentExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace JsonSchema\Tests\Exception;

use JsonSchema\Exception\InvalidArgumentException;
use PHPUnit\Framework\TestCase;

class InvalidArgumentExceptionTest extends \PHPUnit_Framework_TestCase
class InvalidArgumentExceptionTest extends TestCase
{
public function testHierarchy()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Exception/InvalidSchemaMediaTypeExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace JsonSchema\Tests\Exception;

use JsonSchema\Exception\InvalidSchemaMediaTypeException;
use PHPUnit\Framework\TestCase;

class InvalidSchemaMediaTypeExceptionTest extends \PHPUnit_Framework_TestCase
class InvalidSchemaMediaTypeExceptionTest extends TestCase
{
public function testHierarchy()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Exception/InvalidSourceUriExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace JsonSchema\Tests\Exception;

use JsonSchema\Exception\InvalidSourceUriException;
use PHPUnit\Framework\TestCase;

class InvalidSourceUriExceptionTest extends \PHPUnit_Framework_TestCase
class InvalidSourceUriExceptionTest extends TestCase
{
public function testHierarchy()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Exception/JsonDecodingExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace JsonSchema\Tests\Exception;

use JsonSchema\Exception\JsonDecodingException;
use PHPUnit\Framework\TestCase;

class JsonDecodingExceptionTest extends \PHPUnit_Framework_TestCase
class JsonDecodingExceptionTest extends TestCase
{
public function testHierarchy()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Exception/ResourceNotFoundExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace JsonSchema\Tests\Exception;

use JsonSchema\Exception\ResourceNotFoundException;
use PHPUnit\Framework\TestCase;

class ResourceNotFoundExceptionTest extends \PHPUnit_Framework_TestCase
class ResourceNotFoundExceptionTest extends TestCase
{
public function testHierarchy()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Exception/RuntimeExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace JsonSchema\Tests\Exception;

use JsonSchema\Exception\RuntimeException;
use PHPUnit\Framework\TestCase;

class RuntimeExceptionTest extends \PHPUnit_Framework_TestCase
class RuntimeExceptionTest extends TestCase
{
public function testHierarchy()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Exception/UnresolvableJsonPointerExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace JsonSchema\Tests\Exception;

use JsonSchema\Exception\UnresolvableJsonPointerException;
use PHPUnit\Framework\TestCase;

class UnresolvableJsonPointerExceptionTest extends \PHPUnit_Framework_TestCase
class UnresolvableJsonPointerExceptionTest extends TestCase
{
public function testHierarchy()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Exception/UriResolverExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace JsonSchema\Tests\Exception;

use JsonSchema\Exception\UriResolverException;
use PHPUnit\Framework\TestCase;

class UriResolverExceptionTest extends \PHPUnit_Framework_TestCase
class UriResolverExceptionTest extends TestCase
{
public function testHierarchy()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Iterators/ObjectIteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
namespace JsonSchema\Tests\Iterators;

use JsonSchema\Iterator\ObjectIterator;
use PHPUnit\Framework\TestCase;

class ObjectIteratorTest extends \PHPUnit_Framework_TestCase
class ObjectIteratorTest extends TestCase
{
protected $testObject;

Expand Down
Loading

0 comments on commit 8560d43

Please sign in to comment.