Skip to content

Commit 7da82ab

Browse files
authored
Merge pull request #100 from lisiy50/support-of-php8.2-and-higher
Prepare the library for PHP 8.2 and higher.
2 parents 1322ff8 + 11dd53b commit 7da82ab

27 files changed

+322
-3565
lines changed

.github/workflows/push.yml

Lines changed: 49 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -1,175 +1,52 @@
1-
on:
2-
push:
3-
branches:
4-
- master
5-
pull_request:
6-
name: Qa workflow
7-
env:
8-
extensions: mbstring, intl, iconv, libxml, dom, json, simplexml, zlib, fileinfo
9-
key: cache-v1 # can be any string, change to clear the extension cache.
10-
defaultPHPVersion: '7.3'
11-
jobs:
12-
phpunit-with-coverage:
13-
runs-on: ubuntu-latest
14-
name: Unit tests
15-
steps:
16-
- uses: actions/checkout@v2
17-
18-
- name: Install graphviz
19-
run: sudo apt-get update && sudo apt-get install -y graphviz
20-
21-
- name: Setup PHP
22-
uses: shivammathur/setup-php@v2
23-
with:
24-
php-version: ${{ env.defaultPHPVersion }}
25-
ini-values: memory_limit=2G, display_errors=On, error_reporting=-1
26-
tools: phive
27-
28-
- name: Get composer cache directory
29-
id: composer-cache
30-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
31-
32-
- name: Cache composer dependencies
33-
uses: actions/cache@v2
34-
with:
35-
path: ${{ steps.composer-cache.outputs.dir }}
36-
key: composer-${{ hashFiles('**/composer.lock') }}
37-
restore-keys: composer-
38-
39-
- name: Install Composer dependencies
40-
run: |
41-
composer install --no-progress --prefer-dist --optimize-autoloader
42-
43-
- name: Run PHPUnit
44-
run: php vendor/bin/phpunit
45-
46-
phpunit:
47-
runs-on: ${{ matrix.operating-system }}
48-
strategy:
49-
matrix:
50-
operating-system:
51-
- ubuntu-latest
52-
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
53-
name: Unit tests for PHP version ${{ matrix.php-versions }} on ${{ matrix.operating-system }}
54-
needs:
55-
- phpunit-with-coverage
56-
steps:
57-
- uses: actions/checkout@v2
58-
59-
- name: Install graphviz
60-
run: sudo apt-get update && sudo apt-get install -y graphviz
61-
62-
- name: Setup PHP
63-
uses: shivammathur/setup-php@v2
64-
with:
65-
php-version: ${{ matrix.php-versions }}
66-
extension-csv: mbstring, simplexml
67-
ini-values: memory_limit=2G, display_errors=On, error_reporting=-1
68-
69-
- name: Get composer cache directory
70-
id: composer-cache
71-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
72-
73-
- name: Cache composer dependencies
74-
uses: actions/cache@v2
75-
with:
76-
path: ${{ steps.composer-cache.outputs.dir }}
77-
key: composer-${{ hashFiles('**/composer.lock') }}
78-
restore-keys: composer-
1+
# https://docs.github.com/en/actions
792

80-
- name: Install Composer dependencies
81-
run: |
82-
composer install --no-progress --prefer-dist --optimize-autoloader
3+
name: "Integrate"
834

84-
- name: Run PHPUnit
85-
run: php vendor/bin/phpunit
86-
87-
codestyle:
88-
runs-on: ubuntu-latest
89-
steps:
90-
- uses: actions/checkout@v2
91-
- name: Restore/cache vendor folder
92-
uses: actions/cache@v1
93-
with:
94-
path: vendor
95-
key: all-build-${{ hashFiles('**/composer.lock') }}
96-
restore-keys: |
97-
all-build-${{ hashFiles('**/composer.lock') }}
98-
all-build-
99-
- name: Restore/cache tools folder
100-
uses: actions/cache@v1
101-
with:
102-
path: tools
103-
key: all-tools-${{ github.sha }}
104-
restore-keys: |
105-
all-tools-${{ github.sha }}-
106-
all-tools-
107-
- name: Code style check
108-
uses: docker://phpdoc/phpcs-ga:latest
109-
env:
110-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111-
with:
112-
args: -d memory_limit=1024M
113-
114-
phpstan:
115-
runs-on: ubuntu-latest
116-
steps:
117-
- uses: actions/checkout@v2
118-
- name: Setup PHP
119-
uses: shivammathur/setup-php@v2
120-
with:
121-
php-version: ${{ env.defaultPHPVersion }}
122-
ini-values: memory_limit=2G, display_errors=On, error_reporting=-1
123-
tools: pecl
124-
125-
- name: Get composer cache directory
126-
id: composer-cache
127-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
128-
129-
- name: Cache composer dependencies
130-
uses: actions/cache@v2
131-
with:
132-
path: ${{ steps.composer-cache.outputs.dir }}
133-
key: composer-${{ hashFiles('**/composer.lock') }}
134-
restore-keys: composer-
135-
136-
- name: Install Composer dependencies
137-
run: |
138-
composer install --no-progress --prefer-dist --optimize-autoloader
139-
140-
- name: PHPStan
141-
uses: phpDocumentor/phpstan-ga@master
142-
env:
143-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
144-
with:
145-
args: analyse src tests --configuration phpstan.neon
146-
147-
psalm:
148-
runs-on: ubuntu-latest
149-
steps:
150-
- uses: actions/checkout@v2
151-
152-
- name: Setup PHP
153-
uses: shivammathur/setup-php@v2
154-
with:
155-
php-version: 7.3
156-
ini-values: memory_limit=2G, display_errors=On, error_reporting=-1
157-
tools: pecl, psalm
158-
159-
- name: Get composer cache directory
160-
id: composer-cache
161-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
162-
163-
- name: Cache composer dependencies
164-
uses: actions/cache@v2
165-
with:
166-
path: ${{ steps.composer-cache.outputs.dir }}
167-
key: composer-${{ hashFiles('**/composer.lock') }}
168-
restore-keys: composer-
169-
170-
- name: Install Composer dependencies
171-
run: |
172-
composer install --no-progress --prefer-dist --optimize-autoloader
5+
on: # yamllint disable-line rule:truthy
6+
push:
7+
branches:
8+
- "master"
9+
pull_request: null
10+
schedule:
11+
- cron: "0 14 * * 1"
12+
# Allow manually triggering the workflow.
13+
workflow_dispatch: true
17314

174-
- name: Psalm
175-
run: vendor/bin/psalm.phar --output-format=github
15+
jobs:
16+
code-coverage:
17+
name: "Code Coverage"
18+
uses: "phpDocumentor/.github/.github/workflows/code-coverage.yml@main"
19+
with:
20+
composer-root-version: "1.x-dev"
21+
22+
coding-standards:
23+
name: "Coding Standards"
24+
uses: "phpDocumentor/.github/.github/workflows/[email protected]"
25+
with:
26+
composer-root-version: "1.x-dev"
27+
28+
dependency-analysis:
29+
name: "Dependency analysis"
30+
uses: "phpDocumentor/.github/.github/workflows/[email protected]"
31+
with:
32+
composer-root-version: "1.x-dev"
33+
34+
lint-root:
35+
name: "Lint root"
36+
uses: "phpDocumentor/.github/.github/workflows/lint.yml@main"
37+
with:
38+
composer-options: "--no-check-publish --ansi"
39+
40+
static-analysis:
41+
name: "Static analysis"
42+
uses: "phpDocumentor/.github/.github/workflows/[email protected]"
43+
with:
44+
php-extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, fileinfo, pcntl, posix"
45+
composer-root-version: "1.x-dev"
46+
47+
unit-tests:
48+
name: "Unit test"
49+
uses: "phpDocumentor/.github/.github/workflows/[email protected]"
50+
with:
51+
composer-root-version: "1.x-dev"
52+
upcoming-releases: true

Makefile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,26 @@ setup: install-phive
1414
phpcbf:
1515
docker run -it --rm -v${CURDIR}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest phpcbf ${ARGS}
1616

17+
18+
.PHONY: build-test-image
19+
build-test-image:
20+
docker build -t php-graphviz -f tests/Resources/Dockerfile tests/Resources
21+
1722
.PHONY: phpcs
18-
phpcs:
19-
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest -d memory_limit=1024M -s
23+
phpcs: build-test-image
24+
docker run -it --rm -v${CURDIR}:/data -w /data php-graphviz vendor/bin/phpcs
2025

2126
.PHONY: phpstan
22-
phpstan:
23-
docker run -it --rm -v${CURDIR}:/opt/project -w /opt/project phpdoc/phpstan-ga:latest analyse src tests --configuration phpstan.neon ${ARGS}
27+
phpstan: build-test-image
28+
docker run -it --rm -v${CURDIR}:/data -w /data php-graphviz ./vendor/phpstan/phpstan/phpstan analyse src ${ARGS}
2429

2530
.PHONY: psalm
26-
psalm:
27-
docker run -it --rm -v${CURDIR}:/data -w /data php:7.3 vendor/bin/psalm.phar
31+
psalm: build-test-image
32+
docker run -it --rm -v${CURDIR}:/data -w /data php-graphviz vendor/bin/psalm.phar
2833

2934
.PHONY: test
30-
test:
31-
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.3 vendor/bin/phpunit
35+
test: build-test-image
36+
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php-graphviz ./vendor/bin/phpunit
3237

3338
.PHONY: pre-commit-test
3439
pre-commit-test: phpcs phpstan psalm test

README.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,3 @@ GraphViz
1313

1414
GraphViz is a library meant for generating .dot files for GraphViz with a
1515
fluent interface.
16-
17-
18-
### PHPStan extension
19-
20-
This library contains a number of magic methods to set attributes on `Node`, `Graph` and `Edge`
21-
this will result in errors when using the library with checks by PHPStan. For your convenience this
22-
library provides an phpStan extension so your code can be checked correctly by phpstan.
23-
24-
```
25-
includes:
26-
- vendor/phpdocumentor/graphviz/extension.neon
27-
```

composer.json

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,35 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^7.2 || ^8.0"
13+
"php": "^8.2"
1414
},
1515
"autoload": {
1616
"psr-4": {
17-
"phpDocumentor\\GraphViz\\": "src/phpDocumentor/GraphViz",
18-
"phpDocumentor\\GraphViz\\PHPStan\\": "./src/phpDocumentor/PHPStan"
17+
"phpDocumentor\\GraphViz\\": "src/phpDocumentor/GraphViz"
1918
}
2019
},
2120
"autoload-dev": {
2221
"psr-4": {
23-
"phpDocumentor\\GraphViz\\Test\\": "./tests/phpDocumentor/GraphViz/Test",
24-
"phpDocumentor\\GraphViz\\PHPStan\\": "./tests/phpDocumentor/PHPStan"
22+
"phpDocumentor\\GraphViz\\Test\\": "./tests/phpDocumentor/GraphViz/Test"
2523
}
2624
},
2725
"require-dev": {
28-
"phpunit/phpunit": "^8.2 || ^9.2",
29-
"mockery/mockery": "^1.2",
30-
"phpstan/phpstan": "^0.12",
26+
"phpunit/phpunit": "^11.0",
27+
"mockery/mockery": "@stable",
28+
"phpstan/phpstan": "@stable",
3129
"ext-simplexml": "*",
32-
"psalm/phar": "^4.15 || ^5.0"
30+
"psalm/phar": "@stable",
31+
"squizlabs/php_codesniffer": "@stable",
32+
"phpstan/phpstan-mockery": "@stable"
3333
},
3434
"extra": {
3535
"branch-alias": {
36-
"dev-master": "2.x-dev"
36+
"dev-master": "3.x-dev"
37+
}
38+
},
39+
"config": {
40+
"allow-plugins": {
41+
"ondrejmirtes/composer-attribute-collector": true
3742
}
3843
}
3944
}

extension.neon

Lines changed: 0 additions & 9 deletions
This file was deleted.

phpcs.xml.dist

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
<file>tests</file>
77
<arg value="p"/>
88
<rule ref="PSR2" />
9-
<rule ref="Doctrine">
10-
<exclude name="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint.UselessDocComment" />
11-
</rule>
129

1310
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
1411
<exclude-pattern>tests/phpDocumentor/GraphViz/Test/GraphTest\.php</exclude-pattern>

phpstan.neon

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
includes:
2-
- /composer/vendor/phpstan/phpstan-mockery/extension.neon
3-
- ./extension.neon
2+
- ./vendor/phpstan/phpstan-mockery/extension.neon
43

54
parameters:
65
level: max
76
ignoreErrors:
87
#We have some runtime protection that needs to be tested. Ignore these errors
9-
- '#Call to an undefined method phpDocumentor\\GraphViz\\Edge::someNonExcistingMethod\(\)\.#'
10-
- '#Call to an undefined method phpDocumentor\\GraphViz\\Graph::MyMethod\(\)\.#'
11-
- '#Call to an undefined method phpDocumentor\\GraphViz\\Graph::getNotExisting\(\)\.#'
12-
- '#Call to an undefined method phpDocumentor\\GraphViz\\Node::someNonExistingMethod\(\)\.#'
8+
- '#Cannot cast mixed to string#'

phpunit.xml.dist

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
<testsuite name="Graphviz suite">
1717
<directory>./tests/phpDocumentor/GraphViz</directory>
1818
</testsuite>
19-
<testsuite name="PHPStan suite">
20-
<directory>./tests/phpDocumentor/PHPStan</directory>
21-
</testsuite>
2219
</testsuites>
2320
<logging>
2421
<log type="coverage-clover" target="build/logs/clover.xml" />

psalm.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0"?>
22
<psalm
3-
resolveFromConfigFile="true"
43
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
54
xmlns="https://getpsalm.org/schema/config"
65
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
@@ -22,5 +21,7 @@
2221
<file name="src/phpDocumentor/GraphViz/Graph.php" />
2322
</errorLevel>
2423
</MixedArgumentTypeCoercion>
24+
<PossiblyUnusedMethod errorLevel="suppress" />
25+
<MissingOverrideAttribute errorLevel="suppress" />
2526
</issueHandlers>
2627
</psalm>

0 commit comments

Comments
 (0)