Skip to content

Commit 9d8d916

Browse files
authoredDec 8, 2020
* allow php 8 (#1)
* update code tools * add LICENSE
1 parent 96f0815 commit 9d8d916

13 files changed

+104
-66
lines changed
 

‎.github/workflows/checks.yml

+15-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ on: [push, pull_request]
55
jobs:
66
build:
77

8+
strategy:
9+
matrix:
10+
php: ["7.4", "8.0"]
11+
812
runs-on: ubuntu-latest
913
container:
10-
image: eventjet/checks-7.3:latest
14+
image: eventjet/checks-${{ matrix.php }}:latest
15+
16+
env:
17+
COMPOSER_ARGS: ''
1118

1219
steps:
1320
- name: Checkout
@@ -18,8 +25,12 @@ jobs:
1825
mkdir -p /root/.ssh
1926
ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts
2027
28+
- name: Ignore Plaform Reqs if on PHP8
29+
if: ${{ matrix.php == '8.0' }}
30+
run: echo "COMPOSER_ARGS=--ignore-platform-reqs" >> $GITHUB_ENV
31+
2132
- name: Composer Cache
22-
uses: actions/cache@v1
33+
uses: actions/cache@v2
2334
with:
2435
path: $(composer config cache-files-dir)
2536
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
@@ -28,7 +39,7 @@ jobs:
2839
2940
- name: Install dependencies
3041
run: |
31-
composer install --no-progress --no-suggest --no-interaction > /dev/null
42+
composer install --no-progress --no-suggest --no-interaction ${{ env.COMPOSER_ARGS }} > /dev/null
3243
3344
- name: Static analysis
3445
run: |
@@ -44,7 +55,7 @@ jobs:
4455
4556
- name: Monitor coverage
4657
if: github.event_name == 'pull_request'
47-
uses: slavcodev/coverage-monitor-action@1.0.1
58+
uses: slavcodev/coverage-monitor-action@v1
4859
with:
4960
github_token: ${{ secrets.GITHUB_TOKEN }}
5061
clover_file: "coverage.xml"

‎CHANGELOG.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file, in reverse chronological order by release.
4+
5+
File automatically generated with [phly/keep-a-changelog](https://github.com/phly/keep-a-changelog)
6+
7+
## 0.3.1 - 2020-12-08
8+
9+
### Added
10+
11+
- [#1](https://github.com/trinet-at/mezzio-test/pull/1) adds support for PHP 8
12+
13+
### Changed
14+
15+
- Nothing.
16+
17+
### Deprecated
18+
19+
- Nothing.
20+
21+
### Removed
22+
23+
- Nothing.
24+
25+
### Fixed
26+
27+
- Nothing.

‎LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 trinet e.U.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎composer.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Testing helpers for mezzio projects",
55
"license": "MIT",
66
"require": {
7-
"php": "^7.3",
7+
"php": "^7.3 || ^8.0",
88
"fig/http-message-util": "^1.1",
99
"laminas/laminas-config-aggregator": "^1.2",
1010
"laminas/laminas-diactoros": "^2.2",
@@ -13,21 +13,22 @@
1313
"mezzio/mezzio-router": "^3.1",
1414
"psr/container": "^1.0",
1515
"psr/http-message": "^1.0",
16-
"thecodingmachine/safe": "^0.1 || ^1.0"
16+
"thecodingmachine/safe": "^1.0"
1717
},
1818
"require-dev": {
1919
"eventjet/coding-standard": "^3.1",
20-
"infection/infection": "^0.16",
20+
"infection/infection": "^0.20",
2121
"laminas/laminas-servicemanager": "^3.4",
2222
"maglnet/composer-require-checker": "^2.0",
2323
"mezzio/mezzio-fastroute": "^3.0",
2424
"phpstan/extension-installer": "^1.0",
2525
"phpstan/phpstan": "^0.12.5",
2626
"phpstan/phpstan-phpunit": "^0.12.6",
2727
"phpstan/phpstan-strict-rules": "^0.12.1",
28-
"phpunit/phpunit": "^9.0",
29-
"thecodingmachine/phpstan-safe-rule": "^0.1 || ^1.0",
30-
"vimeo/psalm": "^3.8"
28+
"phpunit/phpunit": "^9.4",
29+
"psalm/plugin-phpunit": "^0.13.0",
30+
"thecodingmachine/phpstan-safe-rule": "^1.0",
31+
"vimeo/psalm": "^4.0"
3132
},
3233
"config": {
3334
"sort-packages": true
@@ -56,7 +57,7 @@
5657
"check-deps": "vendor/bin/composer-require-checker",
5758
"cs-check": "vendor/bin/phpcs",
5859
"cs-fix": "vendor/bin/phpcbf",
59-
"infection": "vendor/bin/infection --threads=4 --min-msi=86 --min-covered-msi=92",
60+
"infection": "vendor/bin/infection --threads=4",
6061
"infection-xdebug": "@composer run --timeout=0 infection -- --initial-tests-php-options='-d zend_extension=xdebug.so'",
6162
"phpstan": "vendor/bin/phpstan analyse",
6263
"phpunit": "vendor/bin/phpunit",

‎infection.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@
77
},
88
"logs": {
99
"text": "infection-log.txt"
10-
}
10+
},
11+
"minMsi": 86,
12+
"minCoveredMsi": 92
1113
}

‎phpcs.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?xml version="1.0"?>
22
<ruleset>
3-
<rule ref="EventjetStrict"/>
3+
<rule ref="EventjetStrict">
4+
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint"/>
5+
</rule>
46
<file>src</file>
57
<file>tests</file>
68
</ruleset>

‎phpunit.xml

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
5+
beStrictAboutChangesToGlobalState="true"
6+
beStrictAboutOutputDuringTests="true"
7+
verbose="true"
58
>
69
<testsuites>
710
<testsuite name="Trinet\MezzioTest\Unit">
@@ -11,9 +14,9 @@
1114
<directory>tests/functional</directory>
1215
</testsuite>
1316
</testsuites>
14-
<filter>
15-
<whitelist>
17+
<coverage>
18+
<include>
1619
<directory>src</directory>
17-
</whitelist>
18-
</filter>
20+
</include>
21+
</coverage>
1922
</phpunit>

‎psalm.xml

+4-45
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<psalm
33
strictBinaryOperands="true"
4-
totallyTyped="false"
4+
errorLevel="2"
55
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
66
xmlns="https://getpsalm.org/schema/config"
77
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
@@ -13,48 +13,7 @@
1313
<directory name="vendor"/>
1414
</ignoreFiles>
1515
</projectFiles>
16-
17-
<issueHandlers>
18-
<LessSpecificReturnType errorLevel="info"/>
19-
20-
<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->
21-
22-
<DeprecatedMethod errorLevel="info"/>
23-
<DeprecatedProperty errorLevel="info"/>
24-
<DeprecatedClass errorLevel="info"/>
25-
<DeprecatedConstant errorLevel="info"/>
26-
<DeprecatedFunction errorLevel="info"/>
27-
<DeprecatedInterface errorLevel="info"/>
28-
<DeprecatedTrait errorLevel="info"/>
29-
30-
<InternalMethod errorLevel="info"/>
31-
<InternalProperty errorLevel="info"/>
32-
<InternalClass errorLevel="info"/>
33-
34-
<MissingClosureReturnType errorLevel="info"/>
35-
<MissingReturnType errorLevel="info"/>
36-
<MissingPropertyType errorLevel="info"/>
37-
<InvalidDocblock errorLevel="info"/>
38-
<MisplacedRequiredParam errorLevel="info"/>
39-
40-
<PropertyNotSetInConstructor errorLevel="info">
41-
<errorLevel type="suppress">
42-
<directory name="tests"/>
43-
</errorLevel>
44-
</PropertyNotSetInConstructor>
45-
<MissingConstructor errorLevel="info"/>
46-
<MissingClosureParamType errorLevel="info"/>
47-
<MissingParamType errorLevel="info"/>
48-
49-
<RedundantCondition errorLevel="info"/>
50-
51-
<DocblockTypeContradiction errorLevel="info"/>
52-
<RedundantConditionGivenDocblockType errorLevel="info"/>
53-
54-
<UnresolvableInclude errorLevel="info"/>
55-
56-
<RawObjectIteration errorLevel="info"/>
57-
58-
<InvalidStringClass errorLevel="info"/>
59-
</issueHandlers>
16+
<plugins>
17+
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
18+
</plugins>
6019
</psalm>

‎src/MezzioTestEnvironment.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424

2525
final class MezzioTestEnvironment
2626
{
27-
/** @var ContainerInterface */
27+
/** @var ContainerInterface|null */
2828
private $container;
29-
/** @var Application */
29+
/** @var Application|null */
3030
private $app;
3131
/** @var string */
3232
private $basePath;
@@ -80,6 +80,9 @@ public function dispatchRequest(ServerRequestInterface $request): ResponseInterf
8080
return $this->app()->handle($request);
8181
}
8282

83+
/**
84+
* @psalm-suppress UnresolvableInclude
85+
*/
8386
public function container(): ContainerInterface
8487
{
8588
if ($this->container !== null) {
@@ -107,6 +110,9 @@ static function (Throwable $error): void {
107110
);
108111
}
109112

113+
/**
114+
* @psalm-suppress UnresolvableInclude
115+
*/
110116
private function app(): Application
111117
{
112118
if ($this->app !== null) {

‎src/Util.php

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use RuntimeException;
88
use UnexpectedValueException;
99

10+
use function dirname;
1011
use function file_exists;
1112
use function strlen;
1213
use function trim;

‎tests/functional/MezzioTestEnvironmentTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Trinet\MezzioTest\MezzioTestEnvironment;
1515
use Trinet\Test\Functional\MezzioTest\TestDouble\RequestLoggerCallback;
1616

17+
use function dirname;
18+
1719
class MezzioTestEnvironmentTest extends TestCase
1820
{
1921
/** @var MezzioTestEnvironment */

‎tests/functional/TestDouble/RequestLoggerCallback.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
namespace Trinet\Test\Functional\MezzioTest\TestDouble;
66

77
use Laminas\Diactoros\Response;
8+
use Laminas\Diactoros\ServerRequest;
89
use Psr\Http\Message\ResponseInterface;
910
use Psr\Http\Message\ServerRequestInterface;
1011

1112
final class RequestLoggerCallback
1213
{
13-
/** @var ServerRequestInterface */
14+
/** @var ServerRequestInterface|null */
1415
private $request;
1516

1617
public function __invoke(ServerRequestInterface $request): ResponseInterface
@@ -21,6 +22,6 @@ public function __invoke(ServerRequestInterface $request): ResponseInterface
2122

2223
public function getRequest(): ServerRequestInterface
2324
{
24-
return $this->request;
25+
return $this->request ?? new ServerRequest();
2526
}
2627
}

‎tests/unit/UtilTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Trinet\MezzioTest\Util;
99
use UnexpectedValueException;
1010

11+
use function dirname;
12+
1113
class UtilTest extends TestCase
1214
{
1315
public function testBasePath(): void

0 commit comments

Comments
 (0)
Please sign in to comment.