Skip to content

Commit b95e035

Browse files
authored
Merge pull request #285 from phil-davis/php-8.4-ci-for-2.2
Add PHP 8.4 compliance for 2.2 branch
2 parents 07b73ef + 44d0553 commit b95e035

File tree

6 files changed

+17
-10
lines changed

6 files changed

+17
-10
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@ jobs:
1414
matrix:
1515
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
1616
coverage: ['pcov']
17+
code-style: ['no']
1718
code-analysis: ['no']
1819
include:
1920
- php-versions: '7.1'
2021
coverage: 'none'
22+
code-style: 'yes'
23+
code-analysis: 'yes'
24+
- php-versions: '8.4'
25+
coverage: 'pcov'
26+
code-style: 'no'
2127
code-analysis: 'yes'
2228
steps:
2329
- name: Checkout
@@ -48,8 +54,8 @@ jobs:
4854
run: composer install --no-progress --prefer-dist --optimize-autoloader
4955

5056
- name: Code Analysis (PHP CS-Fixer)
51-
if: matrix.code-analysis == 'yes'
52-
run: php vendor/bin/php-cs-fixer fix --dry-run --diff
57+
if: matrix.code-style == 'yes'
58+
run: PHP_CS_FIXER_IGNORE_ENV=true php vendor/bin/php-cs-fixer fix --dry-run --diff
5359

5460
- name: Code Analysis (PHPStan)
5561
if: matrix.code-analysis == 'yes'

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"require-dev": {
4747
"friendsofphp/php-cs-fixer": "~2.17.1",
4848
"phpstan/phpstan": "^0.12",
49-
"phpunit/phpunit" : "^7.5 || ^8.5 || ^9.0"
49+
"phpunit/phpunit" : "^7.5 || ^8.5 || ^9.6"
5050
},
5151
"scripts": {
5252
"phpstan": [

lib/LibXMLException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class LibXMLException extends ParseException
3333
* @param LibXMLError[] $errors
3434
* @param Throwable $previousException
3535
*/
36-
public function __construct(array $errors, int $code = 0, Throwable $previousException = null)
36+
public function __construct(array $errors, int $code = 0, ?Throwable $previousException = null)
3737
{
3838
$this->errors = $errors;
3939
parent::__construct($errors[0]->message.' on line '.$errors[0]->line.', column '.$errors[0]->column, $code, $previousException);

lib/Reader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function parse(): array
103103
* If the $elementMap argument is specified, the existing elementMap will
104104
* be overridden while parsing the tree, and restored after this process.
105105
*/
106-
public function parseGetElements(array $elementMap = null): array
106+
public function parseGetElements(?array $elementMap = null): array
107107
{
108108
$result = $this->parseInnerTree($elementMap);
109109
if (!is_array($result)) {
@@ -126,7 +126,7 @@ public function parseGetElements(array $elementMap = null): array
126126
*
127127
* @return array|string|null
128128
*/
129-
public function parseInnerTree(array $elementMap = null)
129+
public function parseInnerTree(?array $elementMap = null)
130130
{
131131
$text = null;
132132
$elements = [];

lib/Service.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function getWriter(): Writer
109109
*
110110
* @return array|object|string
111111
*/
112-
public function parse($input, string $contextUri = null, string &$rootElementName = null)
112+
public function parse($input, ?string $contextUri = null, ?string &$rootElementName = null)
113113
{
114114
if (is_resource($input)) {
115115
// Unfortunately the XMLReader doesn't support streams. When it
@@ -153,7 +153,7 @@ public function parse($input, string $contextUri = null, string &$rootElementNam
153153
*
154154
* @return array|object|string
155155
*/
156-
public function expect($rootElementName, $input, string $contextUri = null)
156+
public function expect($rootElementName, $input, ?string $contextUri = null)
157157
{
158158
if (is_resource($input)) {
159159
// Unfortunately the XMLReader doesn't support streams. When it
@@ -204,7 +204,7 @@ public function expect($rootElementName, $input, string $contextUri = null)
204204
*
205205
* @return string
206206
*/
207-
public function write(string $rootElementName, $value, string $contextUri = null)
207+
public function write(string $rootElementName, $value, ?string $contextUri = null)
208208
{
209209
$w = $this->getWriter();
210210
$w->openMemory();
@@ -266,7 +266,7 @@ public function mapValueObject(string $elementName, string $className)
266266
*
267267
* @throws \InvalidArgumentException
268268
*/
269-
public function writeValueObject($object, string $contextUri = null)
269+
public function writeValueObject($object, ?string $contextUri = null)
270270
{
271271
if (!isset($this->valueObjectMap[get_class($object)])) {
272272
throw new \InvalidArgumentException('"'.get_class($object).'" is not a registered value object class. Register your class with mapValueObject.');

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
parameters:
22
level: 5
3+
reportUnmatchedIgnoredErrors: false
34
ignoreErrors:
45
-
56
message: '!Parameter #3 \$namespace of method XMLWriter::startElementNs\(\) expects string, null given.!'

0 commit comments

Comments
 (0)