From 09253cde0c04ed30f4651857002c3cf5ac14bd3c Mon Sep 17 00:00:00 2001 From: heinrichschiller Date: Wed, 15 Oct 2025 18:46:16 +0200 Subject: [PATCH 01/13] upgrading from phpstan 1x to 2x and updating config --- composer.json | 2 +- phpstan.neon | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 601e0b7..174d5a7 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", - "phpstan/phpstan": "^1", + "phpstan/phpstan": "^2", "phpunit/phpunit": "^10", "squizlabs/php_codesniffer": "^3", "starkbank/ecdsa": "^2.0" diff --git a/phpstan.neon b/phpstan.neon index ae2b4ba..4950ca2 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,10 +1,10 @@ parameters: level: 8 - checkGenericClassInNonGenericObjectType: false reportUnmatchedIgnoredErrors: false paths: - src ignoreErrors: + - identifier: missingType.generics - '#has unknown class OpenSSLAsymmetricKey as its type#' - '#(.*)OpenSSLAsymmetricKey(.*)null(.*) does not accept resource#' - '#openssl_free_key expects resource(.*) OpenSSLAsymmetricKey given#' From e08dc0c84271f556b990dec5b7d59989a4bdb34a Mon Sep 17 00:00:00 2001 From: heinrichschiller Date: Wed, 15 Oct 2025 18:51:58 +0200 Subject: [PATCH 02/13] Fix nullable types for PHP 8.4 --- src/Algorithm.php | 2 +- src/XmlSigner.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Algorithm.php b/src/Algorithm.php index 54151c8..f8a3058 100644 --- a/src/Algorithm.php +++ b/src/Algorithm.php @@ -56,7 +56,7 @@ final class Algorithm * @param string $signatureMethodAlgorithm * @param string|null $digestMethodAlgorithm */ - public function __construct(string $signatureMethodAlgorithm, string $digestMethodAlgorithm = null) + public function __construct(string $signatureMethodAlgorithm, ?string $digestMethodAlgorithm = null) { $this->setSignatureMethodAlgorithm($signatureMethodAlgorithm); $this->setDigestMethodAlgorithm($digestMethodAlgorithm ?? $signatureMethodAlgorithm); diff --git a/src/XmlSigner.php b/src/XmlSigner.php index 1b28466..7d73a16 100644 --- a/src/XmlSigner.php +++ b/src/XmlSigner.php @@ -63,7 +63,7 @@ public function signXml(string $data): string * * @return string The signed XML as string */ - public function signDocument(DOMDocument $document, DOMElement $element = null): string + public function signDocument(DOMDocument $document, ?DOMElement $element = null): string { $element = $element ?? $document->documentElement; From 07b190f5e2df7b6c522cdeded5dbd9ac648f5f80 Mon Sep 17 00:00:00 2001 From: heinrichschiller Date: Wed, 15 Oct 2025 18:55:14 +0200 Subject: [PATCH 03/13] fix, XmlReader::queryDomNode() should return DOMNode but returns DOMNameSpaceNode|DOMNode. --- src/XmlReader.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/XmlReader.php b/src/XmlReader.php index 59d6e7f..05f00f9 100644 --- a/src/XmlReader.php +++ b/src/XmlReader.php @@ -2,6 +2,7 @@ namespace Selective\XmlDSig; +use DOMNameSpaceNode; use DOMNode; use DOMXPath; use UnexpectedValueException; @@ -22,7 +23,7 @@ final class XmlReader * * @return DOMNode The first item */ - public function queryDomNode(DOMXPath $xpath, string $expression, DOMNode $contextNode): DOMNode + public function queryDomNode(DOMXPath $xpath, string $expression, DOMNode $contextNode): DOMNameSpaceNode|DOMNode { $nodeList = $xpath->query($expression, $contextNode); From a169fbd475da17067e1a8271e7ae9c7d8e4e74a3 Mon Sep 17 00:00:00 2001 From: heinrichschiller Date: Wed, 15 Oct 2025 18:57:10 +0200 Subject: [PATCH 04/13] Oops --- src/XmlReader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/XmlReader.php b/src/XmlReader.php index 05f00f9..dc2d41a 100644 --- a/src/XmlReader.php +++ b/src/XmlReader.php @@ -21,7 +21,7 @@ final class XmlReader * * @throws UnexpectedValueException * - * @return DOMNode The first item + * @return DOMNameSpaceNode|DOMNode The first item */ public function queryDomNode(DOMXPath $xpath, string $expression, DOMNode $contextNode): DOMNameSpaceNode|DOMNode { From 09f04c1ea36e241d7c98466aa5d2c821a797f063 Mon Sep 17 00:00:00 2001 From: heinrichschiller Date: Wed, 15 Oct 2025 19:01:23 +0200 Subject: [PATCH 05/13] Instanceof between DOMElement and DOMElement will always evaluate to true. Turn off this check by setting --- phpstan.neon | 1 + 1 file changed, 1 insertion(+) diff --git a/phpstan.neon b/phpstan.neon index 4950ca2..2f3be6d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,7 @@ parameters: level: 8 reportUnmatchedIgnoredErrors: false + treatPhpDocTypesAsCertain: false paths: - src ignoreErrors: From d57d35d87d6aa2cdf0cd1bec5f4cec5e78690cf9 Mon Sep 17 00:00:00 2001 From: heinrichschiller Date: Wed, 15 Oct 2025 19:05:15 +0200 Subject: [PATCH 06/13] Add support for PHP 8.4 and update test:coverage --- composer.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 174d5a7..916d7ab 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "homepage": "https://github.com/selective-php/xmldsig", "require": { - "php": "~8.1 || ~8.2", + "php": "8.1.* || 8.2.* || 8.3.* || 8.4.*", "ext-dom": "*", "ext-openssl": "*" }, @@ -55,6 +55,9 @@ "@stan", "@test" ], - "test:coverage": "php -d xdebug.mode=coverage -r \"require 'vendor/bin/phpunit';\" -- --configuration phpunit.xml --do-not-cache-result --colors=always --coverage-clover build/logs/clover.xml --coverage-html build/coverage" + "test:coverage": [ + "@putenv XDEBUG_MODE=coverage", + "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always --display-warnings --display-deprecations --coverage-clover build/coverage/clover.xml --coverage-html build/coverage --coverage-text" + ] } } From 1292973cc92ca416cb262e100c110f9c90192a5d Mon Sep 17 00:00:00 2001 From: heinrichschiller Date: Wed, 15 Oct 2025 19:15:05 +0200 Subject: [PATCH 07/13] update license year --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index bf7a9a3..bfcf021 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2023 odan +Copyright (c) 2025 odan 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 61d2f14dbe60815ce31596e9c1d3d2b33e28bc35 Mon Sep 17 00:00:00 2001 From: heinrichschiller Date: Wed, 15 Oct 2025 19:17:04 +0200 Subject: [PATCH 08/13] update requirements --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9dc1c85..c62b69c 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ ## Requirements -* PHP 8.1+ +* PHP 8.1 - 8.4 * The openssl extension * A X.509 digital certificate From 3640ca912886517ca3f108e61641d5c322eb96eb Mon Sep 17 00:00:00 2001 From: heinrichschiller Date: Wed, 15 Oct 2025 19:24:02 +0200 Subject: [PATCH 09/13] fixed PHP_CS_FIXER_IGNORE_ENV deprecation --- composer.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 916d7ab..1c868bf 100644 --- a/composer.json +++ b/composer.json @@ -38,12 +38,10 @@ }, "scripts": { "cs:check": [ - "@putenv PHP_CS_FIXER_IGNORE_ENV=1", - "php-cs-fixer fix --dry-run --format=txt --verbose --diff --config=.cs.php --ansi" + "php-cs-fixer fix --dry-run --format=txt --verbose --diff --config=.cs.php --ansi --allow-unsupported-php-version=yes" ], "cs:fix": [ - "@putenv PHP_CS_FIXER_IGNORE_ENV=1", - "php-cs-fixer fix --config=.cs.php --ansi --verbose" + "php-cs-fixer fix --config=.cs.php --ansi --verbose --allow-unsupported-php-version=yes" ], "sniffer:check": "phpcs --standard=phpcs.xml", "sniffer:fix": "phpcbf --standard=phpcs.xml", From 8e9fb22abcb1cc2ee3d7e17ba25f8551fd2c9210 Mon Sep 17 00:00:00 2001 From: heinrichschiller Date: Wed, 15 Oct 2025 19:25:07 +0200 Subject: [PATCH 10/13] fixed compact_nullable_typehint deprecation --- .cs.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.cs.php b/.cs.php index 2bba5e9..52c4c3e 100644 --- a/.cs.php +++ b/.cs.php @@ -19,7 +19,7 @@ 'array_syntax' => ['syntax' => 'short'], 'cast_spaces' => ['space' => 'none'], 'concat_space' => ['spacing' => 'one'], - 'compact_nullable_typehint' => true, + 'compact_nullable_type_declaration' => true, 'declare_equal_normalize' => ['space' => 'single'], 'general_phpdoc_annotation_remove' => [ 'annotations' => [ @@ -36,7 +36,11 @@ 'phpdoc_order' => true, // psr-5 'phpdoc_no_useless_inheritdoc' => false, 'protected_to_private' => false, - 'yoda_style' => false, + 'yoda_style' => [ + 'equal' => false, + 'identical' => false, + 'less_and_greater' => false + ], 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], 'ordered_imports' => [ 'sort_algorithm' => 'alpha', From 1ff5e1e9dfa0935e762bf55b6fee6c1170940b79 Mon Sep 17 00:00:00 2001 From: heinrichschiller Date: Fri, 17 Oct 2025 11:39:40 +0200 Subject: [PATCH 11/13] fixed DOMXPath class name --- src/XmlSigner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/XmlSigner.php b/src/XmlSigner.php index 7d73a16..c00a78b 100644 --- a/src/XmlSigner.php +++ b/src/XmlSigner.php @@ -180,7 +180,7 @@ private function appendSignature(DOMDocument $xml, string $digestValue): void $signatureValue = $this->cryptoSigner->computeSignature($c14nSignedInfo); - $xpath = new DOMXpath($xml); + $xpath = new DOMXPath($xml); $signatureValueElement = $this->xmlReader->queryDomNode($xpath, '//SignatureValue', $signatureElement); $signatureValueElement->nodeValue = base64_encode($signatureValue); } From 3c23d73ad9fb4864a4f8cc1fa57964f0fc45e9b7 Mon Sep 17 00:00:00 2001 From: heinrichschiller Date: Fri, 17 Oct 2025 11:45:42 +0200 Subject: [PATCH 12/13] upgrading squizlabs/php_codesniffer from ^3 to ^4 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1c868bf..8a78d14 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "friendsofphp/php-cs-fixer": "^3", "phpstan/phpstan": "^2", "phpunit/phpunit": "^10", - "squizlabs/php_codesniffer": "^3", + "squizlabs/php_codesniffer": "^4", "starkbank/ecdsa": "^2.0" }, "autoload": { From 350c541633ac05f2bd3a59e7682f326c116f18f5 Mon Sep 17 00:00:00 2001 From: heinrichschiller Date: Mon, 20 Oct 2025 17:10:31 +0200 Subject: [PATCH 13/13] added php versions 8.3 and 8,4 --- .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 a736a1f..aea8726 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: operating-system: [ ubuntu-latest ] - php-versions: [ '8.1', '8.2' ] + php-versions: [ '8.1', '8.2', '8,3', '8.4' ] name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} steps: