From fbda5063e2b3c73d3ac80c17cdb0e4637f269189 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Tue, 17 Jul 2018 16:05:40 -0500 Subject: [PATCH 1/6] update dependencies using composer-require-checker --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e0a6a4c..1986267 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,8 @@ ], "require": { "php": ">=7.0", - "ext-xml": "*" + "ext-dom": "*", + "ext-libxml": "*" }, "require-dev": { "phpunit/phpunit": "^6.2", From 4da3eaec34d8293472c565088f858e03af444b36 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Tue, 17 Jul 2018 16:06:37 -0500 Subject: [PATCH 2/6] use phplint instead of php-parallel-lint --- .phplint.yml | 11 +++++++++++ .travis.yml | 2 +- composer.json | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .phplint.yml diff --git a/.phplint.yml b/.phplint.yml new file mode 100644 index 0000000..790809c --- /dev/null +++ b/.phplint.yml @@ -0,0 +1,11 @@ +# config file for phplint +# see https://github.com/overtrue/phplint + +path: ./ +cache: build/phplint.cache +jobs: 10 +extensions: + - php +exclude: + - vendor + - build diff --git a/.travis.yml b/.travis.yml index 6d82e29..8fae51b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ before_script: script: - mkdir -p build/tests/ - - vendor/bin/parallel-lint src/ tests/ + - vendor/bin/phplint - vendor/bin/phpcs -sp src/ tests/ - vendor/bin/php-cs-fixer fix --using-cache=no --dry-run --verbose - vendor/bin/phpunit --coverage-text --coverage-clover=build/tests/coverage.xml diff --git a/composer.json b/composer.json index 1986267..1196a3c 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ }, "require-dev": { "phpunit/phpunit": "^6.2", - "jakub-onderka/php-parallel-lint": "^0.9", + "overtrue/phplint": "^1.0", "squizlabs/php_codesniffer": "^3.0", "friendsofphp/php-cs-fixer": "^2.4" }, From cbd24766198efdd5ea36c2120e2f157736bece9e Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Tue, 17 Jul 2018 16:07:41 -0500 Subject: [PATCH 3/6] improve building, add phpstan --- .travis.yml | 18 ++++++++++++++---- composer.json | 3 ++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8fae51b..f3c23fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,25 +4,35 @@ language: php php: - 7.0 - 7.1 + - 7.2 # This triggers builds to run on the new TravisCI infrastructure. # See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/ sudo: false +env: + - FULL_BUILD_PHP_VERSION="7.0" + before_script: - - travis_retry composer self-update - - travis_retry composer install --no-interaction --prefer-dist + - phpenv config-rm xdebug.ini + - travis_retry composer install --no-interaction --no-progress --prefer-dist script: - mkdir -p build/tests/ - vendor/bin/phplint - vendor/bin/phpcs -sp src/ tests/ - vendor/bin/php-cs-fixer fix --using-cache=no --dry-run --verbose - - vendor/bin/phpunit --coverage-text --coverage-clover=build/tests/coverage.xml + - | + if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then + php -dzend_extension=xdebug.so vendor/bin/phpunit --coverage-text --coverage-clover=build/tests/coverage.xml + else + vendor/bin/phpunit + fi + - vendor/bin/phpstan.phar --no-progress analyse --level max src/ tests/ after_script: - | - if [[ $TRAVIS_PHP_VERSION == '7.0' ]]; then + if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then wget https://scrutinizer-ci.com/ocular.phar php ocular.phar code-coverage:upload --format=php-clover build/tests/coverage.xml fi diff --git a/composer.json b/composer.json index 1196a3c..d908639 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "phpunit/phpunit": "^6.2", "overtrue/phplint": "^1.0", "squizlabs/php_codesniffer": "^3.0", - "friendsofphp/php-cs-fixer": "^2.4" + "friendsofphp/php-cs-fixer": "^2.4", + "phpstan/phpstan-shim": "^0.9.1" }, "autoload": { "psr-4": { From 68c72c3143659c004dc7f39bf50d02161c13f9f1 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Tue, 17 Jul 2018 16:08:28 -0500 Subject: [PATCH 4/6] Add docblock to buildSchemas --- src/XmlSchemaValidator/SchemaValidator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/XmlSchemaValidator/SchemaValidator.php b/src/XmlSchemaValidator/SchemaValidator.php index 84cccd9..a87a822 100644 --- a/src/XmlSchemaValidator/SchemaValidator.php +++ b/src/XmlSchemaValidator/SchemaValidator.php @@ -93,7 +93,7 @@ public function validateWithSchemas(Schemas $schemas) * Retrieve a list of namespaces based on the schemaLocation attributes * * @throws SchemaValidatorException if the content of schemaLocation is not an even number of uris - * @return Schemas + * @return Schemas|Schema[] */ public function buildSchemas(): Schemas { From 54d5b0198656632467fc78be414799e9a2810028 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Tue, 17 Jul 2018 16:10:01 -0500 Subject: [PATCH 5/6] Fix bug when using backslash in schemaLocation --- src/XmlSchemaValidator/Schema.php | 10 --------- src/XmlSchemaValidator/Schemas.php | 2 +- .../SchemaValidatorTest.php | 22 +++++++++++++++++++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/XmlSchemaValidator/Schema.php b/src/XmlSchemaValidator/Schema.php index 0d7ef2e..0ac4222 100644 --- a/src/XmlSchemaValidator/Schema.php +++ b/src/XmlSchemaValidator/Schema.php @@ -12,27 +12,17 @@ class Schema /** @var string */ private $location; - /** - * @param string $namespace - * @param string $location - */ public function __construct(string $namespace, string $location) { $this->namespace = $namespace; $this->location = $location; } - /** - * @return string - */ public function getNamespace(): string { return $this->namespace; } - /** - * @return string - */ public function getLocation(): string { return $this->location; diff --git a/src/XmlSchemaValidator/Schemas.php b/src/XmlSchemaValidator/Schemas.php index d7c2199..aa42b85 100644 --- a/src/XmlSchemaValidator/Schemas.php +++ b/src/XmlSchemaValidator/Schemas.php @@ -22,7 +22,7 @@ public function getImporterXsd(): string foreach ($this->schemas as $schema) { $node = $xsd->createElementNS('http://www.w3.org/2001/XMLSchema', 'import'); $node->setAttribute('namespace', $schema->getNamespace()); - $node->setAttribute('schemaLocation', $schema->getLocation()); + $node->setAttribute('schemaLocation', str_replace('\\', '/', $schema->getLocation())); $xsd->documentElement->appendChild($node); } return $xsd->saveXML(); diff --git a/tests/XmlSchemaValidatorTests/SchemaValidatorTest.php b/tests/XmlSchemaValidatorTests/SchemaValidatorTest.php index 9b214b1..6e4305a 100644 --- a/tests/XmlSchemaValidatorTests/SchemaValidatorTest.php +++ b/tests/XmlSchemaValidatorTests/SchemaValidatorTest.php @@ -1,6 +1,7 @@ assertFalse($validator->validate()); $this->assertContains("The attribute 'serie' is required but missing", $validator->getLastError()); } + + public function testValidateWithSchemasUsingRemote() + { + $validator = $this->utilCreateValidator('books-valid.xml'); + $schemas = new Schemas(); + $schemas->create('http://test.org/schemas/books', 'http://localhost:8999/xsd/books.xsd'); + $validator->validateWithSchemas($schemas); + $this->assertTrue(true, 'validateWithSchemas did not throw any exception'); + } + + public function testValidateWithSchemasUsingLocal() + { + $validator = $this->utilCreateValidator('books-valid.xml'); + $schemas = new Schemas(); + $schemas->create( + 'http://test.org/schemas/books', + str_replace('/', '\\', dirname(__DIR__)) . '/public/xsd/books.xsd' // simulate windows path + ); + $validator->validateWithSchemas($schemas); + $this->assertTrue(true, 'validateWithSchemas did not throw any exception'); + } } From 9f7c7f083355c255d99de665ea24a1bd49db9232 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Tue, 17 Jul 2018 16:12:05 -0500 Subject: [PATCH 6/6] Version 2.0.1 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05197f0..1cdb278 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# Version 2.0.1 +- Fix bug when using windows path (backslashs), it does not validate +- Add docblock to buildSchemas +- Improve building, add phpstan +- Use phplint instead of php-parallel-lint +- Update dependencies using composer-require-checker + # Version 2.0.0 - This version does not include `Locator` nor `DownloaderInterface` implementations. That functionality is actually outside the scope of this library and that is the reason