From 2a9b5d594faddb78eb9429ef6d81964e12dd265d Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 8 Mar 2024 18:29:04 -0600 Subject: [PATCH 01/12] Update license year to 2024 --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 18969ea..2620422 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 - 2022 Carlos C Soto +Copyright (c) 2016 - 2024 Carlos C Soto https://eclipxe.com.mx/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 9449cd34ab4f35064fedb78a1e5c6af998fc329a Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 8 Mar 2024 18:30:10 -0600 Subject: [PATCH 02/12] Update coding standards --- .editorconfig | 18 ++++++++++++++++++ .php-cs-fixer.dist.php | 2 +- phpcs.xml.dist | 12 ++++++------ 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1671c9b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 + +[docker-compose.yml] +indent_size = 4 diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 6c8dffc..b6e74fd 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -22,7 +22,7 @@ 'whitespace_after_comma_in_array' => true, 'no_empty_statement' => true, 'no_extra_blank_lines' => true, - 'function_typehint_space' => true, + 'type_declaration_spaces' => true, 'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arrays']], 'no_blank_lines_after_phpdoc' => true, 'object_operator_without_whitespace' => true, diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 1c40448..15acfe5 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,9 +1,6 @@ - - - The EngineWorks (PSR-12 based) coding standard. - - src - tests + + + Personal coding standard. @@ -11,6 +8,9 @@ + src/ + tests/ + From 9b304cc54d455b744038a231783139b1d7a36fcb Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 8 Mar 2024 18:32:03 -0600 Subject: [PATCH 03/12] Update GitHub actions to version 4 --- .github/workflows/build.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cdfc776..dfb49c4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -33,7 +33,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -53,7 +53,7 @@ jobs: php-versions: ['7.3', '7.4', '8.0', '8.1', '8.2'] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -66,7 +66,7 @@ jobs: id: composer-cache run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} @@ -81,7 +81,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -94,7 +94,7 @@ jobs: id: composer-cache run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} @@ -109,7 +109,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -122,7 +122,7 @@ jobs: id: composer-cache run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} @@ -139,7 +139,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -152,7 +152,7 @@ jobs: id: composer-cache run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} From f467ca844ad2622a3fc913885a904a28f46589e3 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 8 Mar 2024 18:32:30 -0600 Subject: [PATCH 04/12] Run jobs using PHP 8.3 --- .github/workflows/build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dfb49c4..7eafab9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.3' coverage: none tools: cs2pr, phpcs env: @@ -37,7 +37,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.3' coverage: none tools: cs2pr, php-cs-fixer env: @@ -85,7 +85,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.3' coverage: none tools: composer:v2, phpstan env: @@ -113,7 +113,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.3' coverage: none tools: composer:v2, psalm env: @@ -143,7 +143,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.3' coverage: xdebug tools: composer:v2, infection env: From 1362d3b63440bcccd55c2f54a8f0bf3cdf7bd06c Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 8 Mar 2024 18:33:00 -0600 Subject: [PATCH 05/12] Rename matrix variable name php-version (singular) --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7eafab9..6a2bb1f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,18 +46,18 @@ jobs: run: php-cs-fixer fix --dry-run --format=checkstyle | cs2pr phpunit: - name: Tests on PHP ${{ matrix.php-versions }} + name: Tests on PHP ${{ matrix.php-version }} runs-on: "ubuntu-latest" strategy: matrix: - php-versions: ['7.3', '7.4', '8.0', '8.1', '8.2'] + php-version: ['7.3', '7.4', '8.0', '8.1', '8.2'] steps: - name: Checkout uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-versions }} + php-version: ${{ matrix.php-version }} coverage: none tools: composer:v2 env: From 0001ec09667d042056a5af85cebc9dff1f8ece3c Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 8 Mar 2024 18:33:20 -0600 Subject: [PATCH 06/12] Add PHP 8.3 to test matrix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a2bb1f..d980ee1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: runs-on: "ubuntu-latest" strategy: matrix: - php-version: ['7.3', '7.4', '8.0', '8.1', '8.2'] + php-version: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] steps: - name: Checkout uses: actions/checkout@v4 From f146592c556446e4d3cf211e7c9b63a2028728a7 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 8 Mar 2024 18:33:52 -0600 Subject: [PATCH 07/12] Update code analysis titles --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d980ee1..c260652 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -77,7 +77,7 @@ jobs: run: vendor/bin/phpunit --testdox --verbose phpstan: - name: Static analysis (phpstan) + name: Code analysis (phpstan) runs-on: "ubuntu-latest" steps: - name: Checkout @@ -101,11 +101,11 @@ jobs: restore-keys: ${{ runner.os }}-composer- - name: Install project dependencies run: composer upgrade --no-interaction --no-progress --prefer-dist - - name: Static analysis (phpstan) + - name: Code analysis (phpstan) run: phpstan analyse --no-progress --verbose psalm: - name: Static analysis (psalm) + name: Code analysis (psalm) runs-on: "ubuntu-latest" steps: - name: Checkout @@ -131,7 +131,7 @@ jobs: run: composer upgrade --no-interaction --no-progress --prefer-dist - name: Show psalm version run: psalm --version - - name: Static analysis (psalm) + - name: Code analysis (psalm) run: psalm --no-progress infection: From c11b1cbd7160e2f33930524e2f4f684bd77fdfab Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 8 Mar 2024 18:37:02 -0600 Subject: [PATCH 08/12] Update development tools --- .phive/phars.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.phive/phars.xml b/.phive/phars.xml index d7d5d31..35dae24 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,9 +1,9 @@ - - - - - - + + + + + + From e296abc640a019faa657b8d23c8ec9b878aeb9f2 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 8 Mar 2024 18:50:13 -0600 Subject: [PATCH 09/12] Fix falsy comparisons (Psalm) Add test to probe case where lookupPrefix return null --- src/SchemaValidator.php | 4 ++-- src/Schemas.php | 2 +- tests/Unit/SchemaValidatorTest.php | 11 +++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/SchemaValidator.php b/src/SchemaValidator.php index e0f98bb..5508ec5 100644 --- a/src/SchemaValidator.php +++ b/src/SchemaValidator.php @@ -142,8 +142,8 @@ public function buildSchemas(): Schemas $xpath = new DOMXPath($this->document); // get the http://www.w3.org/2001/XMLSchema-instance namespace (it could not be 'xsi') - $xsi = $this->document->lookupPrefix('http://www.w3.org/2001/XMLSchema-instance'); - if (! $xsi) { // the namespace is not registered, no need to continue + $xsi = strval($this->document->lookupPrefix('http://www.w3.org/2001/XMLSchema-instance')); + if ('' === $xsi) { // the namespace is not registered, no need to continue return $schemas; } diff --git a/src/Schemas.php b/src/Schemas.php index 4f8afa1..d80ad11 100644 --- a/src/Schemas.php +++ b/src/Schemas.php @@ -42,7 +42,7 @@ public function getImporterXsd(): string $node->setAttribute('schemaLocation', str_replace('\\', '/', $schema->getLocation())); $document->appendChild($node); } - return $xsd->saveXML() ?: ''; + return strval($xsd->saveXML()); } /** diff --git a/tests/Unit/SchemaValidatorTest.php b/tests/Unit/SchemaValidatorTest.php index a19007f..30c5b12 100644 --- a/tests/Unit/SchemaValidatorTest.php +++ b/tests/Unit/SchemaValidatorTest.php @@ -186,6 +186,17 @@ public function testBuildSchemas(): void $this->assertSame($expected, $retrieved); } + public function testBuildSchemasWithoutXmlSchemaDefinition(): void + { + $content = <<< XML + + + XML; + $validator = SchemaValidator::createFromString($content); + $schemas = $validator->buildSchemas(); + $this->assertSame([], $schemas->all()); + } + public function testBuildSchemasFromSchemaLocationValue(): void { $validator = $this->utilCreateValidator('books-valid.xml'); From f5049d18d5eb35d590c1a75893bc728a0ecb0f97 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 8 Mar 2024 18:59:21 -0600 Subject: [PATCH 10/12] Prepare version 3.0.4 --- docs/CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 4ccfad0..7462af8 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -9,6 +9,19 @@ classes. The library will not export any of these objects outside its own scope. Unreleased changes will be listed here. +## Version 3.0.4 2024-03-08 + +- Fix falsy comparisons (Psalm). +- Update license year to 2024. +- Update coding standards. +- Improve GitHub workflow: + - Add PHP 8.3 to test matrix. + - Run jobs using PHP 8.3. + - Update GitHub actions to version 4. + - Update code analysis titles. + - Rename matrix variable name php-version (singular). +- Update development tools. + ## Version 3.0.3 2022-12-19 When split the content of a *schema location* value, must reindex the list of values. From 613f731936b4a054d4cb9af84ec021d59b394cf9 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 8 Mar 2024 18:59:07 -0600 Subject: [PATCH 11/12] Fix indent size and space after header --- docs/CHANGELOG.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 7462af8..5f30c8b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -28,6 +28,7 @@ When split the content of a *schema location* value, must reindex the list of va The following code wasn't interpreted correctly: ```xml +