Skip to content

Commit a30538e

Browse files
committed
php8.4 support among other improvements
1 parent a3d2bee commit a30538e

File tree

12 files changed

+140
-47
lines changed

12 files changed

+140
-47
lines changed

.gitattributes

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
* text=auto eol=lf
22

3-
/tests export-ignore
4-
.editorconfig export-ignore
5-
.gitattributes export-ignore
6-
.gitignore export-ignore
7-
.php_cs export-ignore
8-
.travis.yml export-ignore
9-
phpcs.xml.dist export-ignore
10-
phpunit.xml.dist export-ignore
3+
/tests export-ignore
4+
.editorconfig export-ignore
5+
.gitattributes export-ignore
6+
.gitignore export-ignore
7+
.php-cs-fixer.php export-ignore
8+
phpcs.xml.dist export-ignore
9+
phpunit.xml.dist export-ignore
10+
.phpstan.neon export-ignore

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ vendor
22
composer.lock
33
coverage
44
*.cache
5+
.idea
6+
kit

.php-cs-fixer.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
return My\PhpCsFixerConfig::create()
4+
->setFinder(
5+
PhpCsFixer\Finder::create()
6+
->files()
7+
->name('*.php')
8+
->in(__DIR__.'/src')
9+
->in(__DIR__.'/tests')
10+
);

.phpstan.neon

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
parameters:
2+
reportUnmatchedIgnoredErrors: false
3+
inferPrivatePropertyTypeFromConstructor: true
4+
level: 8
5+
paths:
6+
- src
7+
- tests
8+
ignoreErrors:
9+
- "#expects GdImage, resource given#"
10+
- "#should return resource but returns#"

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2019
3+
Copyright (c) 2019-2025
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

composer.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020
},
2121
"require": {
2222
"php": "^7.2 || ^8.0",
23-
"middlewares/utils": "^3.0 || ^4.0",
24-
"psr/http-server-middleware": "^1.0"
23+
"middlewares/utils": "^2 || ^3 || ^4",
24+
"psr/http-server-middleware": "^1",
25+
"ext-gd": "*"
2526
},
2627
"require-dev": {
27-
"phpunit/phpunit": "^8|^9",
28-
"friendsofphp/php-cs-fixer": "^2.0",
29-
"squizlabs/php_codesniffer": "^3.0",
30-
"oscarotero/php-cs-fixer-config": "^1.0",
31-
"phpstan/phpstan": "^0.12",
32-
"laminas/laminas-diactoros": "^2|^3"
28+
"phpunit/phpunit": "^8 || ^9",
29+
"friendsofphp/php-cs-fixer": "^3",
30+
"squizlabs/php_codesniffer": "^3",
31+
"oscarotero/php-cs-fixer-config": "^2",
32+
"phpstan/phpstan": "^1 || ^2",
33+
"laminas/laminas-diactoros": "^2 || ^3"
3334
},
3435
"autoload": {
3536
"psr-4": {
@@ -49,4 +50,4 @@
4950
"coverage": "phpunit --coverage-text",
5051
"coverage-html": "phpunit --coverage-html=coverage"
5152
}
52-
}
53+
}

phpcs.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Middlewares coding standard">
3+
<description>Middlewares coding standard</description>
4+
5+
<!-- display progress -->
6+
<arg value="p"/>
7+
<arg name="report" value="full"/>
8+
<arg name="colors"/>
9+
10+
<!-- coding standard -->
11+
<rule ref="PSR2"/>
12+
13+
<!-- Paths to check -->
14+
<file>src</file>
15+
<file>tests</file>
16+
</ruleset>

phpunit.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="vendor/autoload.php"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5+
backupGlobals="false"
6+
backupStaticAttributes="false"
7+
beStrictAboutOutputDuringTests="true"
8+
beStrictAboutTestsThatDoNotTestAnything="true"
9+
beStrictAboutTodoAnnotatedTests="true"
10+
colors="true"
11+
verbose="true"
12+
convertErrorsToExceptions="true"
13+
convertNoticesToExceptions="true"
14+
convertWarningsToExceptions="true"
15+
processIsolation="false"
16+
stopOnFailure="false"
17+
failOnWarning="true">
18+
<testsuites>
19+
<testsuite name="ErrorHandler test suite">
20+
<directory>tests</directory>
21+
</testsuite>
22+
</testsuites>
23+
24+
<filter>
25+
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="true">
26+
<directory>./src</directory>
27+
<exclude>
28+
<directory>./tests</directory>
29+
<directory>./vendor</directory>
30+
</exclude>
31+
</whitelist>
32+
</filter>
33+
<logging>
34+
<log type="coverage-text" target="php://stdout"/>
35+
<log type="coverage-clover" target="build/logs/clover.xml"/>
36+
<log type="coverage-html" target="build/coverage"/>
37+
</logging>
38+
</phpunit>

src/ErrorFormatter/AbstractFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ abstract class AbstractFormatter implements FormatterInterface
2323
protected $contentTypes = [];
2424

2525
public function __construct(
26-
ResponseFactoryInterface $responseFactory = null,
27-
StreamFactoryInterface $streamFactory = null
26+
?ResponseFactoryInterface $responseFactory = null,
27+
?StreamFactoryInterface $streamFactory = null
2828
) {
2929
$this->responseFactory = $responseFactory ?? Factory::getResponseFactory();
3030
$this->streamFactory = $streamFactory ?? Factory::getStreamFactory();

src/ErrorFormatter/ImageFormatter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,13 @@ private function createImage(Throwable $error)
5151
$size = 200;
5252
$image = imagecreatetruecolor($size, $size);
5353
$textColor = imagecolorallocate($image, 255, 255, 255);
54+
55+
/* @phpstan-ignore-next-line */
5456
imagestring($image, 5, 10, 10, "$type $code", $textColor);
5557

58+
/* @phpstan-ignore-next-line */
5659
foreach (str_split($message, intval($size / 10)) as $line => $text) {
60+
/* @phpstan-ignore-next-line */
5761
imagestring($image, 5, 10, ($line * 18) + 28, $text, $textColor);
5862
}
5963

0 commit comments

Comments
 (0)