Skip to content

Commit 57f2354

Browse files
committed
Prepare the library for PHP 8.2 and higher.
Remove dependency on PHPStan in the main codebase, which blocked updating other dependencies.
1 parent 1322ff8 commit 57f2354

27 files changed

+276
-3396
lines changed

.github/workflows/push.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
matrix:
5050
operating-system:
5151
- ubuntu-latest
52-
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
52+
php-versions: ['8.2', '8.3', '8.4']
5353
name: Unit tests for PHP version ${{ matrix.php-versions }} on ${{ matrix.operating-system }}
5454
needs:
5555
- phpunit-with-coverage
@@ -142,7 +142,7 @@ jobs:
142142
env:
143143
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
144144
with:
145-
args: analyse src tests --configuration phpstan.neon
145+
args: analyse src
146146

147147
psalm:
148148
runs-on: ubuntu-latest
@@ -152,7 +152,7 @@ jobs:
152152
- name: Setup PHP
153153
uses: shivammathur/setup-php@v2
154154
with:
155-
php-version: 7.3
155+
php-version: 8.2
156156
ini-values: memory_limit=2G, display_errors=On, error_reporting=-1
157157
tools: pecl, psalm
158158

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>

src/phpDocumentor/GraphViz/Attribute.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@
2121
* Class representing a single GraphViz attribute.
2222
*
2323
* @link http://phpdoc.org
24+
*
25+
* @psalm-suppress ClassMustBeFinal
2426
*/
2527
class Attribute
2628
{
27-
/** @var string The name of this attribute */
28-
protected $key = '';
29+
/** The name of this attribute */
30+
protected string $key = '';
2931

30-
/** @var string The value of this attribute */
31-
protected $value = '';
32+
/** The value of this attribute */
33+
protected string $value = '';
3234

3335
/**
3436
* Creating a new attribute.

0 commit comments

Comments
 (0)