Skip to content

Commit e2346c0

Browse files
committed
Support PHP 8.0
1 parent 07a017c commit e2346c0

File tree

6 files changed

+47
-38
lines changed

6 files changed

+47
-38
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
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

Lines changed: 19 additions & 4 deletions
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
@@ -29,20 +31,33 @@ test-package: package test-package-tools
2931
cd tests/phar && ./tools/phpunit
3032
.PHONY: test-package
3133

34+
35+
ifeq ($(IS_PHP8),1)
36+
cs:
37+
else
3238
cs: tools/php-cs-fixer
3339
PHP_CS_FIXER_IGNORE_ENV=1 tools/php-cs-fixer --dry-run --allow-risky=yes --no-interaction --ansi fix
40+
endif
3441
.PHONY: cs
3542

43+
ifeq ($(IS_PHP8),1)
44+
cs-fix:
45+
else
3646
cs-fix: tools/php-cs-fixer
3747
PHP_CS_FIXER_IGNORE_ENV=1 tools/php-cs-fixer --allow-risky=yes --no-interaction --ansi fix
48+
endif
3849
.PHONY: cs-fix
3950

4051
deptrac: tools/deptrac
4152
tools/deptrac --no-interaction --ansi --formatter-graphviz-display=0
4253
.PHONY: deptrac
4354

55+
ifeq ($(IS_PHP8),1)
56+
infection:
57+
else
4458
infection: tools/infection tools/infection.pubkey
4559
phpdbg -qrr ./tools/infection --no-interaction --formatter=progress --min-msi=100 --min-covered-msi=100 --only-covered --ansi
60+
endif
4661
.PHONY: infection
4762

4863
phpunit: tools/phpunit
@@ -90,16 +105,16 @@ tools/php-cs-fixer:
90105
curl -Ls http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -o tools/php-cs-fixer && chmod +x tools/php-cs-fixer
91106

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

95110
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
111+
curl -Ls https://github.com/infection/infection/releases/download/0.20.2/infection.phar -o tools/infection && chmod +x tools/infection
97112

98113
tools/infection.pubkey:
99-
curl -Ls https://github.com/infection/infection/releases/download/0.16.1/infection.phar.pubkey -o tools/infection.pubkey
114+
curl -Ls https://github.com/infection/infection/releases/download/0.20.2/infection.phar.pubkey -o tools/infection.pubkey
100115

101116
tools/box:
102-
curl -Ls https://github.com/humbug/box/releases/download/3.8.4/box.phar -o tools/box && chmod +x tools/box
117+
curl -Ls https://github.com/humbug/box/releases/download/3.10.0test_it_finds_classes_that_implement_given_interface/box.phar -o tools/box && chmod +x tools/box
103118

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

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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"
@@ -16,7 +16,7 @@
1616
"symfony/framework-bundle": "^3.4 || ^4.4 || ^5.0",
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": {
File renamed without changes.

phpunit.xml.dist

Lines changed: 20 additions & 29 deletions
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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ 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+
return $this->extractTokens($tokens, $index - 2, 3) === [T_NAMESPACE, T_WHITESPACE, T_NAME_QUALIFIED];
7376
}
7477

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

0 commit comments

Comments
 (0)