Skip to content

Commit fbdce59

Browse files
committed
Refresh PHP 7.0 docs and CI
1 parent d32761b commit fbdce59

12 files changed

Lines changed: 1272 additions & 157 deletions

.github/workflows/coverage.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ php7.0 ]
66
pull_request:
7-
branches: [ main ]
7+
branches: [ php7.0 ]
88

99
jobs:
1010
tests:
@@ -15,11 +15,11 @@ jobs:
1515
- name: Checkout
1616
uses: actions/checkout@v4
1717

18-
- name: Setup PHP 8.3 with Xdebug
18+
- name: Setup PHP 7.0 with Xdebug
1919
uses: shivammathur/setup-php@v2
2020
with:
21-
php-version: '8.3'
22-
tools: composer:v2
21+
php-version: '7.0'
22+
tools: composer:v2.2
2323
coverage: xdebug
2424

2525
- name: Validate composer.json
@@ -38,13 +38,15 @@ jobs:
3838
--configuration ./continuous-integration/phpunit/phpunit.xml
3939
--colors=always
4040
--coverage-clover coverage.xml
41-
--coverage-filter ./src
41+
--whitelist ./src
4242
4343
- name: Upload coverage to Codecov
4444
uses: codecov/codecov-action@v5
4545
with:
4646
token: ${{ secrets.CODECOV_TOKEN }}
4747
files: ./coverage.xml
48+
flags: php7.0
49+
name: php7.0
4850
fail_ci_if_error: true
4951
env:
5052
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Static Analysis
2+
3+
on:
4+
push:
5+
branches: [ php7.0 ]
6+
pull_request:
7+
branches: [ php7.0 ]
8+
9+
jobs:
10+
phpstan:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 15
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup PHP 7.0
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: '7.0'
22+
tools: composer:v2.2
23+
coverage: none
24+
25+
- name: Validate composer.json
26+
run: composer validate --strict
27+
28+
- name: Install dependencies
29+
run: composer update --prefer-dist --no-interaction --no-progress
30+
31+
- name: Run PHPStan
32+
run: composer phpstan-check

README.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# XmlExtractKit
22

3-
[![Packagist Version](https://img.shields.io/packagist/v/sbwerewolf/xml-navigator?label=packagist)](https://packagist.org/packages/sbwerewolf/xml-navigator)
4-
[![Packagist Downloads](https://img.shields.io/packagist/dt/sbwerewolf/xml-navigator)](https://packagist.org/packages/sbwerewolf/xml-navigator)
5-
[![PHP 8.3+](https://img.shields.io/badge/PHP-8.3%2B-777BB4)](https://www.php.net/)
6-
[![Test Coverage](https://codecov.io/github/SbWereWolf/xml-navigator/graph/badge.svg?token=Q0BQ2COFTC)](https://codecov.io/github/SbWereWolf/xml-navigator)
3+
[![PHP 7.0-7.2](https://img.shields.io/badge/PHP-7.0--7.2-777BB4)](https://www.php.net/)
4+
[![Static Analysis](https://github.com/SbWereWolf/xml-navigator/actions/workflows/static-analysis.yml/badge.svg?branch=php7.0)](https://github.com/SbWereWolf/xml-navigator/actions/workflows/static-analysis.yml?query=branch%3Aphp7.0)
5+
[![Test Coverage](https://codecov.io/github/SbWereWolf/xml-navigator/graph/badge.svg?token=Q0BQ2COFTC&branch=php7.0)](https://codecov.io/github/SbWereWolf/xml-navigator/tree/php7.0)
76

87

98
**XmlExtractKit for PHP: Stream large XML, extract only what matters,
@@ -19,7 +18,7 @@ large XML → selected nodes → plain PHP arrays
1918
composer require sbwerewolf/xml-navigator
2019
```
2120

22-
For local test and coverage dependencies on a standard PHP 8.3 setup,
21+
For local test, coverage, and static-analysis dependencies for this branch,
2322
see [`tests/ENVIRONMENT.md`](tests/ENVIRONMENT.md).
2423

2524
## Why this package?
@@ -67,14 +66,16 @@ XML
6766
);
6867

6968
$reader = XMLReader::open($uri);
70-
foreach (
71-
FastXmlParser::extractHierarchy(
72-
$reader,
73-
static fn(XMLReader $cursor): bool =>
74-
$cursor->nodeType === XMLReader::ELEMENT
75-
&& $cursor->name === 'offer'
76-
) as $offer
77-
) {
69+
70+
$offers = FastXmlParser::extractHierarchy(
71+
$reader,
72+
static function (XMLReader $cursor): bool {
73+
return $cursor->nodeType === XMLReader::ELEMENT
74+
&& $cursor->name === 'offer';
75+
}
76+
);
77+
78+
foreach ($offers as $offer) {
7879
var_export($offer);
7980
echo PHP_EOL;
8081
}
@@ -151,7 +152,7 @@ array (
151152

152153
## Code test coverage
153154

154-
![Codecov graph](https://codecov.io/github/SbWereWolf/xml-navigator/graphs/tree.svg?token=Q0BQ2COFTC)
155+
![Codecov graph](https://codecov.io/github/SbWereWolf/xml-navigator/graphs/tree.svg?token=Q0BQ2COFTC&branch=php7.0)
155156

156157

157158
## Working examples
@@ -167,10 +168,10 @@ use SbWereWolf\XmlNavigator\Conversion\XmlConverter;
167168
require_once __DIR__ . '/vendor/autoload.php';
168169

169170
$converter = new XmlConverter(
170-
val: 'value',
171-
attr: 'attributes',
172-
name: 'name',
173-
seq: 'children',
171+
'value',
172+
'attributes',
173+
'name',
174+
'children'
174175
);
175176

176177
$hierarchy = $converter->toHierarchyOfElements(
@@ -228,9 +229,10 @@ $reader = XMLReader::open($uri);
228229

229230
$offers = FastXmlParser::extractHierarchy(
230231
$reader,
231-
static fn(XMLReader $cursor):
232-
bool => $cursor->nodeType === XMLReader::ELEMENT
233-
&& $cursor->name === 'offer'
232+
static function (XMLReader $cursor): bool {
233+
return $cursor->nodeType === XMLReader::ELEMENT
234+
&& $cursor->name === 'offer';
235+
}
234236
);
235237

236238
$reader->close();
@@ -279,7 +281,7 @@ foreach ($offer->attributes() as $attribute) {
279281
echo PHP_EOL;
280282
echo 'offer elements with name `tag`:' . PHP_EOL;
281283
$tagValues = array_map(
282-
static fn (XmlElement $tag): string => $tag->value(),
284+
static function (XmlElement $tag): string { return $tag->value(); },
283285
$offer->elements('tag')
284286
);
285287

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@
4848
"scripts": {
4949
"test": "php ./vendor/phpunit/phpunit/phpunit --configuration ./continuous-integration/phpunit/phpunit.xml --testdox",
5050
"test-coverage": "php ./vendor/phpunit/phpunit/phpunit --configuration ./continuous-integration/phpunit/phpunit.xml --testdox --coverage-html ./continuous-integration/autotests-coverage-report --whitelist ./src",
51+
"phpstan-check": "php ./vendor/bin/phpstan analyse -vvv --configuration continuous-integration/phpstan/phpstan.neon",
5152
"check-style": "php ./vendor/bin/phpcs --standard=continuous-integration/phpcs/phpcs.xml -v",
5253
"fix-style": "php ./vendor/bin/phpcbf --standard=continuous-integration/phpcs/phpcs.xml -v"
5354
},
5455
"require-dev": {
5556
"phpunit/phpunit": ">=6.5 <6.6",
57+
"phpstan/phpstan": "^0.8.5",
5658
"squizlabs/php_codesniffer": "^3.7",
5759
"sbwerewolf/json-serialize-trait": "^1"
5860
},

0 commit comments

Comments
 (0)