Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow installing and build on PHP 8 #1267

Merged
merged 7 commits into from
Dec 2, 2020
Merged
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
59 changes: 59 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# yamllint disable rule:line-length
# yamllint disable rule:braces

name: Continuous Integration

on:
pull_request:
push:
branches:
- main
- master

jobs:
tests:
runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
operating-system: [ubuntu-latest]
php-version: [7.2, 7.3, 7.4]
dependencies: ['']
include:
- { operating-system: 'ubuntu-latest', php-version: '8.0', dependencies: '--ignore-platform-req=php' }

name: CI on ${{ matrix.operating-system }} with PHP ${{ matrix.php-version }} ${{ matrix.dependencies }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v2
extensions: pdo_sqlite

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-${{ matrix.dependencies }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-

- name: Install dependencies
run: |
composer update --no-interaction --prefer-dist --no-progress ${{ matrix.dependencies }}

- name: Run tests
run: |
vendor/bin/phpunit
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ matrix:

- php: 7.4
env: VERY_LATEST=1
- php: 8.0snapshot
env: COMPOSER_FLAGS='--ignore-platform-req=php'
fast_finish: true

install:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": "^7.2",
"php": "^7.2||^8.0",
"doctrine/annotations": "^1.0",
"doctrine/instantiator": "^1.0.3",
"doctrine/lexer": "^1.1",
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<php>
<ini name="error_reporting" value="-1" />
<ini name="serialize_precision" value="14"/>
<ini name="date.timezone" value="UTC"/>
</php>

<testsuites>
Expand Down
11 changes: 8 additions & 3 deletions src/XmlDeserializationVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public function prepare($data)
$previous = libxml_use_internal_errors(true);
libxml_clear_errors();

$previousEntityLoaderState = libxml_disable_entity_loader($this->disableExternalEntities);
if (\LIBXML_VERSION < 20900) {
$previousEntityLoaderState = libxml_disable_entity_loader($this->disableExternalEntities);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as of libxml 2.9.0 entity substitution is disabled by default, so there is no need to disable the loading of external entities.

https://www.php.net/manual/en/function.libxml-disable-entity-loader.php


if (false !== stripos($data, '<!doctype')) {
$internalSubset = $this->getDomDocumentTypeEntitySubset($data);
Expand All @@ -92,7 +94,10 @@ public function prepare($data)
$doc = simplexml_load_string($data, 'SimpleXMLElement', $this->options);

libxml_use_internal_errors($previous);
libxml_disable_entity_loader($previousEntityLoaderState);

if (\LIBXML_VERSION < 20900) {
libxml_disable_entity_loader($previousEntityLoaderState);
}

if (false === $doc) {
throw new XmlErrorException(libxml_get_last_error());
Expand Down Expand Up @@ -202,7 +207,7 @@ public function visitArray($data, array $type): array
$nodes = $data->xpath($entryName);
}

if (!\count($nodes)) {
if (null === $nodes || !\count($nodes)) {
return [];
}

Expand Down