Skip to content

Commit e3e073c

Browse files
authored
feat: add support for php8.2 (#16)
1 parent 1252182 commit e3e073c

File tree

6 files changed

+39
-9
lines changed

6 files changed

+39
-9
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
php-version: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
17+
php-version: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
1818

1919
steps:
2020
- uses: actions/checkout@v3
@@ -34,7 +34,7 @@ jobs:
3434
run: |
3535
mkdir ./coverage
3636
php -v > ./coverage/php${{ matrix.php-version }}_output.txt && echo '' >> ./coverage/php${{ matrix.php-version }}_output.txt
37-
./vendor/bin/phpunit --configuration ./tests/phpunit-${{ matrix.php-version }}.xml --coverage-clover ./coverage/php${{ matrix.php-version }}_coverage.clover >> ./coverage/php${{ matrix.php-version }}_output.txt
37+
./vendor/bin/phpunit -c ./tests/phpunit-${{ matrix.php-version }}.xml --coverage-clover ./coverage/php${{ matrix.php-version }}_coverage.clover >> ./coverage/php${{ matrix.php-version }}_output.txt
3838
cat ./coverage/php${{ matrix.php-version }}_output.txt
3939
4040
- name: Save coverage results

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.idea
22
composer.lock
33
vendor
4-
/coverage/
4+
/coverage/

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
<a href="https://github.com/rboonzaijer/php-array-to-xml/actions/workflows/tests.yml"><img src="https://shields.io/badge/style-7.4-green?label=php&style=flat-square"></a>
1616
<a href="https://github.com/rboonzaijer/php-array-to-xml/actions/workflows/tests.yml"><img src="https://shields.io/badge/style-8.0-green?label=php&style=flat-square"></a>
1717
<a href="https://github.com/rboonzaijer/php-array-to-xml/actions/workflows/tests.yml"><img src="https://shields.io/badge/style-8.1-green?label=php&style=flat-square"></a>
18-
18+
<a href="https://github.com/rboonzaijer/php-array-to-xml/actions/workflows/tests.yml"><img src="https://shields.io/badge/style-8.2-green?label=php&style=flat-square"></a>
19+
1920
</p>
2021

2122

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
}
2222
],
2323
"require": {
24-
"php" : "^8.0|^7.0"
24+
"php": "^8.0|^7.0"
2525
},
2626
"require-dev": {
27-
"phpunit/phpunit" : "^9.5|^8.5|^7.5|^6.5",
27+
"phpunit/phpunit": "^10.5|^9.5|^8.5|^7.5|^6.5",
2828
"mockery/mockery": "^1.0"
2929
},
3030
"autoload": {

src/Traits/DomDocumentBuilder.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,12 @@ protected function createXmlElement($name, $value = null, $cdata = false, $attri
184184

185185
return $element;
186186
}
187-
188-
$element = $this->_doc->createElement($name, $this->normalizeValue($value));
187+
$normalizedValue = $this->normalizeValue($value);
188+
$element = $this->_doc->createElement($name, $normalizedValue === null ? '' : $normalizedValue);
189189

190190
foreach ($attributes as $attribute_name => $attribute_value) {
191-
$element->setAttribute($attribute_name, $this->normalizeAttributeValue($attribute_value));
191+
$normalizedValue = $this->normalizeAttributeValue($attribute_value);
192+
$element->setAttribute($attribute_name, $normalizedValue === null ? '' : $normalizedValue);
192193
}
193194

194195
return $element;

tests/phpunit-8.2.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- PHPUnit 10 >= PHP 8.1 (https://phpunit.de/supported-versions.html) -->
3+
<phpunit
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
backupGlobals="false"
6+
bootstrap="./../vendor/autoload.php"
7+
colors="true"
8+
processIsolation="false"
9+
stopOnFailure="false"
10+
cacheResult="false"
11+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
12+
cacheDirectory=".phpunit.cache"
13+
backupStaticProperties="false">
14+
<testsuites>
15+
<testsuite name="PhpArrayToXml Test Suite">
16+
<directory>./../tests/</directory>
17+
</testsuite>
18+
</testsuites>
19+
<source>
20+
<include>
21+
<directory>./../src</directory>
22+
</include>
23+
<exclude>
24+
<directory>./../vendor</directory>
25+
<directory>./../tests</directory>
26+
</exclude>
27+
</source>
28+
</phpunit>

0 commit comments

Comments
 (0)