Skip to content

Commit

Permalink
Merge pull request #285 from phil-davis/php-8.4-ci-for-2.2
Browse files Browse the repository at this point in the history
Add PHP 8.4 compliance for 2.2 branch
  • Loading branch information
phil-davis authored Jul 25, 2024
2 parents 07b73ef + 44d0553 commit b95e035
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ jobs:
matrix:
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
coverage: ['pcov']
code-style: ['no']
code-analysis: ['no']
include:
- php-versions: '7.1'
coverage: 'none'
code-style: 'yes'
code-analysis: 'yes'
- php-versions: '8.4'
coverage: 'pcov'
code-style: 'no'
code-analysis: 'yes'
steps:
- name: Checkout
Expand Down Expand Up @@ -48,8 +54,8 @@ jobs:
run: composer install --no-progress --prefer-dist --optimize-autoloader

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

- name: Code Analysis (PHPStan)
if: matrix.code-analysis == 'yes'
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"require-dev": {
"friendsofphp/php-cs-fixer": "~2.17.1",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit" : "^7.5 || ^8.5 || ^9.0"
"phpunit/phpunit" : "^7.5 || ^8.5 || ^9.6"
},
"scripts": {
"phpstan": [
Expand Down
2 changes: 1 addition & 1 deletion lib/LibXMLException.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class LibXMLException extends ParseException
* @param LibXMLError[] $errors
* @param Throwable $previousException
*/
public function __construct(array $errors, int $code = 0, Throwable $previousException = null)
public function __construct(array $errors, int $code = 0, ?Throwable $previousException = null)
{
$this->errors = $errors;
parent::__construct($errors[0]->message.' on line '.$errors[0]->line.', column '.$errors[0]->column, $code, $previousException);
Expand Down
4 changes: 2 additions & 2 deletions lib/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function parse(): array
* If the $elementMap argument is specified, the existing elementMap will
* be overridden while parsing the tree, and restored after this process.
*/
public function parseGetElements(array $elementMap = null): array
public function parseGetElements(?array $elementMap = null): array
{
$result = $this->parseInnerTree($elementMap);
if (!is_array($result)) {
Expand All @@ -126,7 +126,7 @@ public function parseGetElements(array $elementMap = null): array
*
* @return array|string|null
*/
public function parseInnerTree(array $elementMap = null)
public function parseInnerTree(?array $elementMap = null)
{
$text = null;
$elements = [];
Expand Down
8 changes: 4 additions & 4 deletions lib/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function getWriter(): Writer
*
* @return array|object|string
*/
public function parse($input, string $contextUri = null, string &$rootElementName = null)
public function parse($input, ?string $contextUri = null, ?string &$rootElementName = null)
{
if (is_resource($input)) {
// Unfortunately the XMLReader doesn't support streams. When it
Expand Down Expand Up @@ -153,7 +153,7 @@ public function parse($input, string $contextUri = null, string &$rootElementNam
*
* @return array|object|string
*/
public function expect($rootElementName, $input, string $contextUri = null)
public function expect($rootElementName, $input, ?string $contextUri = null)
{
if (is_resource($input)) {
// Unfortunately the XMLReader doesn't support streams. When it
Expand Down Expand Up @@ -204,7 +204,7 @@ public function expect($rootElementName, $input, string $contextUri = null)
*
* @return string
*/
public function write(string $rootElementName, $value, string $contextUri = null)
public function write(string $rootElementName, $value, ?string $contextUri = null)
{
$w = $this->getWriter();
$w->openMemory();
Expand Down Expand Up @@ -266,7 +266,7 @@ public function mapValueObject(string $elementName, string $className)
*
* @throws \InvalidArgumentException
*/
public function writeValueObject($object, string $contextUri = null)
public function writeValueObject($object, ?string $contextUri = null)
{
if (!isset($this->valueObjectMap[get_class($object)])) {
throw new \InvalidArgumentException('"'.get_class($object).'" is not a registered value object class. Register your class with mapValueObject.');
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
parameters:
level: 5
reportUnmatchedIgnoredErrors: false
ignoreErrors:
-
message: '!Parameter #3 \$namespace of method XMLWriter::startElementNs\(\) expects string, null given.!'
Expand Down

0 comments on commit b95e035

Please sign in to comment.