Skip to content

Commit 28ffbd4

Browse files
authored
Merge pull request #36 from jakzal/php-8.0
Support PHP 8.0
2 parents 07a017c + 52d014e commit 28ffbd4

File tree

6 files changed

+62
-44
lines changed

6 files changed

+62
-44
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
name: Build and test
1616
strategy:
1717
matrix:
18-
php: [7.4]
18+
php: [7.4, 8.0]
1919
deps: [high]
2020
include:
21-
- php: 7.4
21+
- php: 8.0
2222
deps: low
2323

2424
steps:

Makefile

+29-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
IS_PHP8:=$(shell php -r 'echo (int)version_compare(PHP_VERSION, "8.0", ">=");')
2+
13
default: build
24

35
build: install test
@@ -25,24 +27,41 @@ test: vendor cs deptrac phpunit infection
2527
test-min: update-min cs deptrac phpunit infection
2628
.PHONY: test-min
2729

30+
ifeq ($(IS_PHP8),1)
31+
test-package:
32+
else
2833
test-package: package test-package-tools
2934
cd tests/phar && ./tools/phpunit
35+
endif
3036
.PHONY: test-package
3137

38+
39+
ifeq ($(IS_PHP8),1)
40+
cs:
41+
else
3242
cs: tools/php-cs-fixer
33-
PHP_CS_FIXER_IGNORE_ENV=1 tools/php-cs-fixer --dry-run --allow-risky=yes --no-interaction --ansi fix
43+
PHP_CS_FIXER_IGNORE_ENV=1 tools/php-cs-fixer --dry-run --allow-risky=yes --no-interaction --ansi --diff fix
44+
endif
3445
.PHONY: cs
3546

47+
ifeq ($(IS_PHP8),1)
48+
cs-fix:
49+
else
3650
cs-fix: tools/php-cs-fixer
3751
PHP_CS_FIXER_IGNORE_ENV=1 tools/php-cs-fixer --allow-risky=yes --no-interaction --ansi fix
52+
endif
3853
.PHONY: cs-fix
3954

4055
deptrac: tools/deptrac
4156
tools/deptrac --no-interaction --ansi --formatter-graphviz-display=0
4257
.PHONY: deptrac
4358

59+
ifeq ($(IS_PHP8),1)
60+
infection:
61+
else
4462
infection: tools/infection tools/infection.pubkey
45-
phpdbg -qrr ./tools/infection --no-interaction --formatter=progress --min-msi=100 --min-covered-msi=100 --only-covered --ansi
63+
phpdbg -qrr ./tools/infection --no-interaction --formatter=progress --min-msi=95 --min-covered-msi=95 --only-covered --ansi
64+
endif
4665
.PHONY: infection
4766

4867
phpunit: tools/phpunit
@@ -62,6 +81,9 @@ clean:
6281
find tests/phar/tools -not -path '*/\.*' -type f -delete
6382
.PHONY: clean
6483

84+
ifeq ($(IS_PHP8),1)
85+
package:
86+
else
6587
package: tools/box
6688
$(eval VERSION=$(shell (git describe --abbrev=0 --tags 2>/dev/null || echo "0.1-dev") | sed -e 's/^v//'))
6789
@rm -rf build/phar && mkdir -p build/phar
@@ -77,6 +99,7 @@ package: tools/box
7799
tools/box compile
78100

79101
@rm -rf build/phar
102+
endif
80103
.PHONY: package
81104

82105
vendor: install
@@ -90,16 +113,16 @@ tools/php-cs-fixer:
90113
curl -Ls http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -o tools/php-cs-fixer && chmod +x tools/php-cs-fixer
91114

92115
tools/deptrac:
93-
curl -Ls http://get.sensiolabs.de/deptrac.phar -o tools/deptrac && chmod +x tools/deptrac
116+
curl -Ls https://github.com/sensiolabs-de/deptrac/releases/download/0.10.0/deptrac.phar -o tools/deptrac && chmod +x tools/deptrac
94117

95118
tools/infection: tools/infection.pubkey
96-
curl -Ls https://github.com/infection/infection/releases/download/0.16.1/infection.phar -o tools/infection && chmod +x tools/infection
119+
curl -Ls https://github.com/infection/infection/releases/download/0.20.2/infection.phar -o tools/infection && chmod +x tools/infection
97120

98121
tools/infection.pubkey:
99-
curl -Ls https://github.com/infection/infection/releases/download/0.16.1/infection.phar.pubkey -o tools/infection.pubkey
122+
curl -Ls https://github.com/infection/infection/releases/download/0.20.2/infection.phar.pubkey -o tools/infection.pubkey
100123

101124
tools/box:
102-
curl -Ls https://github.com/humbug/box/releases/download/3.8.4/box.phar -o tools/box && chmod +x tools/box
125+
curl -Ls https://github.com/humbug/box/releases/download/3.10.0/box.phar -o tools/box && chmod +x tools/box
103126

104127
tests/phar/tools/phpunit:
105128
curl -Ls https://phar.phpunit.de/phpunit-9.phar -o tests/phar/tools/phpunit && chmod +x tests/phar/tools/phpunit

composer.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
"description": "Injects services from a PSR-11 dependency injection container to PHPUnit test cases",
44
"type": "library",
55
"require": {
6-
"php": "^7.4,<8.0",
6+
"php": "^7.4 || ~8.0.0",
77
"phpunit/phpunit": "^9.0",
88
"psr/container": "^1.0",
99
"zalas/injector": "^2.0"
1010
},
1111
"require-dev": {
12-
"symfony/config": "^3.4 || ^4.4 || ^5.0",
13-
"symfony/dependency-injection": "^3.4 || ^4.4 || ^5.0",
14-
"symfony/http-kernel": "^3.4 || ^4.4 || ^5.0",
12+
"symfony/config": "^4.4.12 || ^5.2",
13+
"symfony/dependency-injection": "^4.4.12 || ^5.2",
14+
"symfony/http-kernel": "^4.4.12 || ^5.2",
1515
"zalas/phpunit-globals": "^2.0",
16-
"symfony/framework-bundle": "^3.4 || ^4.4 || ^5.0",
16+
"symfony/framework-bundle": "^4.4.12 || ^5.2",
1717
"zalas/phpunit-doubles": "^1.5",
1818
"phpspec/prophecy": "^1.9",
19-
"phpspec/prophecy-phpunit": "dev-master"
19+
"phpspec/prophecy-phpunit": "^2.0"
2020
},
2121
"autoload": {
2222
"psr-4": {

depfile.yml depfile.yaml

File renamed without changes.

phpunit.xml.dist

+20-29
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.1/phpunit.xsd"
4-
bootstrap="vendor/autoload.php"
5-
beStrictAboutOutputDuringTests="true"
6-
beStrictAboutTodoAnnotatedTests="true"
7-
colors="true"
8-
verbose="true">
9-
10-
<testsuites>
11-
<testsuite name="default">
12-
<directory suffix="Test.php">tests</directory>
13-
<exclude>tests/phar</exclude>
14-
</testsuite>
15-
</testsuites>
16-
17-
<extensions>
18-
<extension class="Zalas\PHPUnit\Globals\AnnotationExtension" />
19-
</extensions>
20-
21-
<filter>
22-
<whitelist processUncoveredFilesFromWhitelist="true">
23-
<directory suffix=".php">src</directory>
24-
</whitelist>
25-
</filter>
26-
27-
<logging>
28-
<log type="coverage-html" target="build/coverage" lowUpperBound="50" highLowerBound="95"/>
29-
<log type="coverage-clover" target="build/coverage.xml"/>
30-
</logging>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" beStrictAboutOutputDuringTests="true" beStrictAboutTodoAnnotatedTests="true" colors="true" verbose="true">
3+
<coverage processUncoveredFiles="true">
4+
<include>
5+
<directory suffix=".php">src</directory>
6+
</include>
7+
<report>
8+
<clover outputFile="build/coverage.xml"/>
9+
<html outputDirectory="build/coverage" lowUpperBound="50" highLowerBound="95"/>
10+
</report>
11+
</coverage>
12+
<testsuites>
13+
<testsuite name="default">
14+
<directory suffix="Test.php">tests</directory>
15+
<exclude>tests/phar</exclude>
16+
</testsuite>
17+
</testsuites>
18+
<extensions>
19+
<extension class="Zalas\PHPUnit\Globals\AnnotationExtension"/>
20+
</extensions>
21+
<logging/>
3122
</phpunit>

src/Symfony/Compiler/Discovery/ClassFinder.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ private function findClassInFile(\SplFileInfo $phpFile): ?string
6969

7070
private function isNamespaceToken($tokens, int $index): bool
7171
{
72-
return $this->extractTokens($tokens, $index - 2, 3) === [T_NAMESPACE, T_WHITESPACE, T_STRING];
72+
if (PHP_VERSION_ID < 80000) {
73+
return $this->extractTokens($tokens, $index - 2, 3) === [T_NAMESPACE, T_WHITESPACE, T_STRING];
74+
}
75+
76+
return $this->extractTokens($tokens, $index - 2, 3) === [T_NAMESPACE, T_WHITESPACE, T_NAME_QUALIFIED];
7377
}
7478

7579
private function isClassNameToken($tokens, int $index): bool

0 commit comments

Comments
 (0)