Skip to content

Commit a475b62

Browse files
committed
[TASK] Add phpstan, add GitHub workflows and add more tests
1 parent 3d844ab commit a475b62

26 files changed

+1116
-89
lines changed

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@
2525
/.* export-ignore
2626
/tests export-ignore
2727
/behat.yml export-ignore
28+
/phpunit.xml export-ignore
2829
/rector.php export-ignore
30+
/phpstan.neon export-ignore
31+
/phpstan-baseline.neon export-ignore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Based on https://github.com/spatie/package-skeleton-laravel/blob/main/.github/workflows/dependabot-auto-merge.yml
2+
name: dependabot-auto-merge
3+
on: pull_request_target
4+
5+
permissions:
6+
pull-requests: write
7+
contents: write
8+
9+
jobs:
10+
dependabot:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 5
13+
if: ${{ github.actor == 'dependabot[bot]' }}
14+
steps:
15+
16+
- name: Dependabot metadata
17+
id: metadata
18+
uses: dependabot/[email protected]
19+
with:
20+
github-token: "${{ secrets.GITHUB_TOKEN }}"
21+
22+
- name: Auto-merge Dependabot PRs for semver-minor updates
23+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
24+
run: gh pr merge --auto --squash "$PR_URL"
25+
env:
26+
PR_URL: ${{github.event.pull_request.html_url}}
27+
GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}"
28+
29+
- name: Auto-merge Dependabot PRs for semver-patch updates
30+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
31+
run: gh pr merge --auto --squash "$PR_URL"
32+
env:
33+
PR_URL: ${{github.event.pull_request.html_url}}
34+
GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}"

.github/workflows/phpstan.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# based on https://github.com/spatie/package-skeleton-laravel/blob/main/.github/workflows/phpstan.yml
2+
name: PHPStan
3+
4+
on:
5+
push:
6+
paths:
7+
- '**.php'
8+
- 'phpstan.neon.dist'
9+
- '.github/workflows/phpstan.yml'
10+
11+
jobs:
12+
phpstan:
13+
name: phpstan
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 5
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: '8.1'
24+
coverage: none
25+
26+
- name: Install composer dependencies
27+
uses: ramsey/composer-install@v2
28+
29+
- name: Run PHPStan
30+
run: vendor/bin/phpstan --error-format=github

.github/workflows/run-tests.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# based on https://github.com/spatie/package-skeleton-laravel/blob/main/.github/workflows/run-tests.yml
2+
name: run-tests
3+
4+
on:
5+
push:
6+
paths:
7+
- '**.php'
8+
- '.github/workflows/run-tests.yml'
9+
- 'phpunit.xml.dist'
10+
- 'composer.json'
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 5
16+
strategy:
17+
fail-fast: true
18+
matrix:
19+
php: [ 8.3, 8.2, 8.1 ]
20+
stability: [ prefer-lowest, prefer-stable ]
21+
22+
name: P${{ matrix.php }} - ${{ matrix.stability }}
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Setup PHP
29+
uses: shivammathur/setup-php@v2
30+
with:
31+
php-version: ${{ matrix.php }}
32+
extensions: simplexml
33+
coverage: none
34+
35+
- name: Cache dependencies installed with composer
36+
uses: actions/cache@v4
37+
with:
38+
key: "php${{ matrix.php }}-${{ matrix.stability }}-composer-${{ hashFiles('**/composer.json') }}"
39+
path: ~/.cache/composer
40+
restore-keys: "php${{ matrix.php }}-${{ matrix.stability }}-composer-\n"
41+
42+
- name: Setup problem matchers
43+
run: |
44+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
45+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
46+
47+
- name: Install dependencies
48+
run: |
49+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
50+
51+
- name: List Installed Dependencies
52+
run: composer show -D
53+
54+
- name: Execute tests
55+
run: vendor/bin/phpunit --no-coverage

.gitignore

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/.idea/
2+
/.phpunit.cache/
3+
/build/
24
/vendor/
3-
/reports/
45
/.php-cs-fixer.cache
5-
/.phpunit.result.cache
6+
/composer.lock
7+
/phpstan.neon
8+
/phpunit.xml

LICENSE LICENSE.md

File renamed without changes.

README.md

+23-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# PHP KML parser
22

33
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/simonschaufi/10)
4-
[![Latest Stable Version](https://poser.pugx.org/simonschaufi/php-libkml/v/stable)](https://packagist.org/packages/simonschaufi/php-libkml)
5-
[![Total Downloads](https://poser.pugx.org/simonschaufi/php-libkml/downloads)](https://packagist.org/packages/simonschaufi/php-libkml)
4+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/simonschaufi/php-libkml.svg)](https://packagist.org/packages/simonschaufi/php-libkml)
5+
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/simonschaufi/php-libkml/run-tests.yml?branch=main&label=tests)](https://github.com/simonschaufi/php-libkml/actions?query=workflow%3Arun-tests+branch%3Amain)
6+
[![Total Downloads](https://img.shields.io/packagist/dt/simonschaufi/php-libkml.svg)](https://packagist.org/packages/simonschaufi/php-libkml)
67
[![License](https://poser.pugx.org/simonschaufi/php-libkml/license)](https://packagist.org/packages/simonschaufi/php-libkml)
78

89
A php library to parse KML/KMZ files.
@@ -32,19 +33,24 @@ Future features:
3233
* GeoJson
3334
* WKT
3435

35-
## Usage
36-
37-
### Installation
38-
39-
The recommended way to install the extension is using [Composer][1].
36+
## Installation
4037

41-
Run the following command within your Composer based TYPO3 project:
38+
You can install the package via composer:
4239

4340
```bash
4441
composer require simonschaufi/php-libkml
4542
```
4643

47-
### Contribution
44+
## Usage
45+
46+
```php
47+
$kmlReader = new KmlReader();
48+
$kmlDocument = $kmlReader->fromString($kml);
49+
// or
50+
$kmlDocument = $kmlReader->fromKmlFile($kmlFilePath);
51+
```
52+
53+
## Contributing
4854

4955
**Pull Requests** are gladly welcome!
5056

@@ -69,4 +75,11 @@ Execute acceptance tests:
6975
composer local:tests:acceptance
7076
```
7177

72-
[1]: https://getcomposer.org/
78+
## Credits
79+
80+
- [Simon Schaufelberger](https://github.com/simonschaufi)
81+
- [All Contributors](../../contributors)
82+
83+
## License
84+
85+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

composer.json

+16-6
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@
2020
"dvdoug/behat-code-coverage": "^5.3.2",
2121
"ergebnis/composer-normalize": "^2.42.0",
2222
"friendsofphp/php-cs-fixer": "^3.49.0",
23+
"phpstan/extension-installer": "^1.3.1",
24+
"phpstan/phpstan": "^1.10.59",
25+
"phpstan/phpstan-deprecation-rules": "^1.0",
26+
"phpstan/phpstan-phpunit": "^1.3.16",
27+
"phpstan/phpstan-strict-rules": "^1.5.2",
2328
"phpunit/phpunit": "^10.5.10",
2429
"rector/rector": "^1.0.1",
30+
"spaze/phpstan-disallowed-calls": "^3.1",
2531
"squizlabs/php_codesniffer": "^3.9.0"
2632
},
2733
"minimum-stability": "dev",
@@ -39,20 +45,24 @@
3945
"config": {
4046
"allow-plugins": {
4147
"dealerdirect/phpcodesniffer-composer-installer": true,
42-
"ergebnis/composer-normalize": true
48+
"ergebnis/composer-normalize": true,
49+
"phpstan/extension-installer": true
4350
}
4451
},
4552
"scripts": {
4653
"ci:composer:normalize": "@composer normalize --no-check-lock --dry-run",
4754
"ci:php:php-cs-fixer": "vendor/bin/php-cs-fixer fix -v --dry-run --diff",
48-
"ci:tests:acceptance": "XDEBUG_MODE=coverage vendor/bin/behat --no-colors --no-snippets --format junit --out reports",
49-
"ci:tests:unit": "vendor/bin/phpunit --colors=never",
55+
"ci:php:stan": "vendor/bin/phpstan analyse --no-progress",
5056
"ci:rector": "vendor/bin/rector process --dry-run",
57+
"ci:tests:acceptance": "vendor/bin/behat --no-colors --no-snippets --format junit --out reports",
58+
"ci:tests:unit": "vendor/bin/phpunit --no-coverage --colors=never",
5159
"fix:composer:normalize": "@composer normalize --no-check-lock",
5260
"fix:php:php-cs-fixer": "vendor/bin/php-cs-fixer fix",
5361
"fix:rector": "vendor/bin/rector process",
54-
"local:clean": "rm -Rf reports",
55-
"local:tests:acceptance": "XDEBUG_MODE=coverage vendor/bin/behat --colors --no-snippets",
56-
"local:tests:unit": "vendor/bin/phpunit --colors=always"
62+
"local:clean": "rm -Rf build",
63+
"local:tests:acceptance": "vendor/bin/behat --colors --no-snippets",
64+
"local:tests:unit": "vendor/bin/phpunit --no-coverage",
65+
"local:tests:unit-coverage": "vendor/bin/phpunit --coverage",
66+
"phpstan:baseline": "vendor/bin/phpstan --generate-baseline --allow-empty-baseline"
5767
}
5868
}

0 commit comments

Comments
 (0)