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/.github/workflows/build.yml b/.github/workflows/build.yml
index cdfc776..c260652 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -16,11 +16,11 @@ 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:
- php-version: '8.1'
+ php-version: '8.3'
coverage: none
tools: cs2pr, phpcs
env:
@@ -33,11 +33,11 @@ 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:
- php-version: '8.1'
+ php-version: '8.3'
coverage: none
tools: cs2pr, php-cs-fixer
env:
@@ -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', '8.3']
steps:
- name: Checkout
- uses: actions/checkout@v3
+ 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:
@@ -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') }}
@@ -77,15 +77,15 @@ jobs:
run: vendor/bin/phpunit --testdox --verbose
phpstan:
- name: Static analysis (phpstan)
+ name: Code analysis (phpstan)
runs-on: "ubuntu-latest"
steps:
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
- php-version: '8.1'
+ php-version: '8.3'
coverage: none
tools: composer:v2, phpstan
env:
@@ -94,26 +94,26 @@ 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') }}
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
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
- php-version: '8.1'
+ php-version: '8.3'
coverage: none
tools: composer:v2, psalm
env:
@@ -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') }}
@@ -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:
@@ -139,11 +139,11 @@ 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:
- php-version: '8.1'
+ php-version: '8.3'
coverage: xdebug
tools: composer:v2, infection
env:
@@ -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') }}
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 @@
-
-
-
-
-
-
+
+
+
+
+
+
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/.scrutinizer.yml b/.scrutinizer.yml
index 2bbb685..e252d0e 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -3,11 +3,12 @@ filter:
- 'vendor/'
excluded_paths:
- 'tests/'
+ - 'tools/'
build:
dependencies:
override:
- - composer upgrade --no-interaction --prefer-dist
+ - composer update --no-interaction --no-progress --prefer-dist
nodes:
analysis: # see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/
environment:
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
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 4ccfad0..5f30c8b 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -9,12 +9,26 @@ 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.
The following code wasn't interpreted correctly:
```xml
+
-
- The EngineWorks (PSR-12 based) coding standard.
-
- src
- tests
+
+
+ Personal coding standard.
@@ -11,6 +8,9 @@
+ src/
+ tests/
+
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');