Skip to content

Commit 6c271c1

Browse files
authored
Merge pull request #12 from http-interop/chore/implicit-nullable
Fix implicit nullability deprecation
2 parents fbfa7a1 + dd775b4 commit 6c271c1

File tree

7 files changed

+107
-52
lines changed

7 files changed

+107
-52
lines changed

.github/workflows/ci.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [ master ]
7+
8+
jobs:
9+
run:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php:
15+
- '7.3'
16+
- '7.4'
17+
- '8.0'
18+
- '8.1'
19+
- '8.2'
20+
- '8.3'
21+
- '8.4'
22+
- '8.5'
23+
minimum_versions: [false]
24+
coverage: ['none']
25+
include:
26+
- description: 'Minimum version'
27+
php: '7.3'
28+
minimum_versions: true
29+
- description: 'Log Code Coverage'
30+
php: '8.4'
31+
coverage: 'xdebug'
32+
33+
name: PHP ${{ matrix.php }} ${{ matrix.description }}
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v5
37+
38+
- uses: actions/cache@v4
39+
with:
40+
path: ~/.composer/cache/files
41+
key: ${{ matrix.php }}
42+
43+
- name: Setup PHP
44+
uses: shivammathur/setup-php@v2
45+
with:
46+
php-version: ${{ matrix.php }}
47+
coverage: ${{ matrix.coverage }}
48+
49+
- name: Install dependencies
50+
run: composer install
51+
if: matrix.minimum_versions == false
52+
53+
- name: Install dependencies (lowest versions)
54+
run: composer update --no-interaction --prefer-lowest
55+
if: matrix.minimum_versions == true
56+
57+
- name: Run PHPUnit tests
58+
run: vendor/bin/phpunit
59+
60+
- name: Upload code coverage
61+
uses: codecov/codecov-action@v4
62+
if: matrix.coverage == 'xdebug'
63+
with:
64+
token: ${{ secrets.CODECOV_TOKEN }}
65+
file: './build/logs/clover.xml'
66+
fail_ci_if_error: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
composer.phar
22
composer.lock
33
phpunit.xml
4+
.phpunit.result*
45
build/
56
vendor/

.travis.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@
1111
"authors": [
1212
{
1313
"name": "PHP-FIG",
14-
"homepage": "http://www.php-fig.org/"
14+
"homepage": "https://www.php-fig.org/"
1515
}
1616
],
1717
"provide": {
1818
"psr/http-factory-implementation": "^1.0"
1919
},
2020
"require": {
21+
"php": ">=7.3",
2122
"psr/http-factory": "^1.0",
2223
"slim/slim": "^3.0"
2324
},
2425
"require-dev": {
25-
"http-interop/http-factory-tests": "^0.5",
26-
"phpunit/phpunit": "^6.5"
26+
"http-interop/http-factory-tests": "^0.9",
27+
"phpunit/phpunit": "^9.5"
2728
},
2829
"autoload": {
2930
"psr-4": {

phpunit.xml.dist

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="true" bootstrap="vendor/autoload.php" colors="true">
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
5+
backupGlobals="true"
6+
bootstrap="vendor/autoload.php"
7+
colors="true">
8+
<coverage>
9+
<include>
10+
<directory suffix=".php">src/</directory>
11+
</include>
12+
<report>
13+
<clover outputFile="build/logs/clover.xml"/>
14+
<html outputDirectory="build/coverage"/>
15+
<text outputFile="php://stdout"/>
16+
</report>
17+
</coverage>
18+
<logging>
19+
<junit outputFile="build/phpunit/junit.xml"/>
20+
</logging>
321
<testsuites>
422
<testsuite name="Integration tests">
523
<directory>vendor/http-interop/http-factory-tests/test</directory>
624
</testsuite>
725
</testsuites>
8-
926
<php>
1027
<const name="REQUEST_FACTORY" value="Http\Factory\Slim\RequestFactory"/>
1128
<const name="RESPONSE_FACTORY" value="Http\Factory\Slim\ResponseFactory"/>
@@ -14,15 +31,4 @@
1431
<const name="UPLOADED_FILE_FACTORY" value="Http\Factory\Slim\UploadedFileFactory"/>
1532
<const name="URI_FACTORY" value="Http\Factory\Slim\UriFactory"/>
1633
</php>
17-
18-
<filter>
19-
<whitelist>
20-
<directory>./src/</directory>
21-
</whitelist>
22-
</filter>
23-
<logging>
24-
<log type="coverage-text" target="php://stdout"/>
25-
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
26-
<log type="coverage-clover" target="build/logs/clover.xml"/>
27-
</logging>
2834
</phpunit>

src/StreamFactory.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,20 @@ public function createStream(string $content = ''): StreamInterface
1919

2020
public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface
2121
{
22-
$resource = fopen($file, $mode);
22+
try {
23+
$resource = fopen($file, $mode);
24+
} catch (\Throwable $e) {
25+
throw new \RuntimeException(
26+
sprintf(
27+
'Unable to open "%s" using mode "%s": "%s',
28+
$file,
29+
$mode,
30+
$e->getMessage(),
31+
),
32+
0,
33+
$e,
34+
);
35+
}
2336

2437
return $this->createStreamFromResource($resource);
2538
}

src/UploadedFileFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ class UploadedFileFactory implements UploadedFileFactoryInterface
1111
{
1212
public function createUploadedFile(
1313
StreamInterface $stream,
14-
int $size = null,
14+
?int $size = null,
1515
int $error = \UPLOAD_ERR_OK,
16-
string $clientFilename = null,
17-
string $clientMediaType = null
16+
?string $clientFilename = null,
17+
?string $clientMediaType = null
1818
): UploadedFileInterface {
1919
if ($size === null) {
2020
$size = $stream->getSize();

0 commit comments

Comments
 (0)