Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .cs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

## Requirements

* PHP 8.1+
* PHP 8.1 - 8.4
* The openssl extension
* A X.509 digital certificate

Expand Down
17 changes: 9 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
],
"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": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3",
"phpstan/phpstan": "^1",
"phpstan/phpstan": "^2",
"phpunit/phpunit": "^10",
"squizlabs/php_codesniffer": "^3",
"squizlabs/php_codesniffer": "^4",
"starkbank/ecdsa": "^2.0"
},
"autoload": {
Expand All @@ -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",
Expand All @@ -55,6 +53,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"
]
}
}
3 changes: 2 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
parameters:
level: 8
checkGenericClassInNonGenericObjectType: false
reportUnmatchedIgnoredErrors: false
treatPhpDocTypesAsCertain: 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#'
Expand Down
2 changes: 1 addition & 1 deletion src/Algorithm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/XmlReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Selective\XmlDSig;

use DOMNameSpaceNode;
use DOMNode;
use DOMXPath;
use UnexpectedValueException;
Expand All @@ -20,9 +21,9 @@ 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): DOMNode
public function queryDomNode(DOMXPath $xpath, string $expression, DOMNode $contextNode): DOMNameSpaceNode|DOMNode
{
$nodeList = $xpath->query($expression, $contextNode);

Expand Down
4 changes: 2 additions & 2 deletions src/XmlSigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down