Skip to content

Commit 4daa137

Browse files
committed
PHP 8.5 support
1 parent 4cc0660 commit 4daa137

File tree

9 files changed

+45
-23
lines changed

9 files changed

+45
-23
lines changed

.github/workflows/phpunit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
matrix:
88
# windows-latest, macOS-latest
99
operating-system: [ubuntu-latest]
10-
php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
10+
php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
1111
name: PHP ${{ matrix.php-version }} Test on ${{ matrix.operating-system }}
1212
steps:
1313
- name: Checkout

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ PSR-7 (HttpMessage) & PSR-17 (HttpFactory) Implementations
1616
* ContentType: common mime-type constants
1717
* HttpFoundationBridge: create ServerRequest and Response from HttpFoundation request and response
1818
* ParseStr: PHP's `parse_str()`, but does not convert dots and spaces to '_' by default
19-
* Response:
20-
* `emit(ResponseInterface $response)` - Output response headers and body
19+
* Response:
20+
* `emit(ResponseInterface $response)` - Output response headers and body
2121
* `codePhrase(int|string $code): string` - Get standard code phrase for given HTTP status code
2222
* ServerRequest:
2323
* `fromGlobals(): ServerRequestInterface`
2424
* Stream
2525
* `getContent(StreamInterface): string` - Get stream contents without affecting pointer
26-
* Uri:
26+
* Uri:
2727
* `fromGlobals(): UriInterface`
2828
* `fromParsed(array): UriInterface`
2929
* `isCrossOrigin(UriInterface $uri1, UriInterface $uri2): bool`
30-
* `parseUrl(string|UriInterface): array` - like php's `parse_url` but with bug fixes backported
30+
* `parseUrl(string|UriInterface): array` - like php's `parse_url` but with bug fixes backported
3131
* `resolve(UriInterface $base, UriInterface $rel): UriInterface` - Converts the relative URI into a new URI that is resolved against the base URI.
3232

33-
### Installation
33+
### Installation
3434

3535
`composer require bdk/http-message`
3636

@@ -48,7 +48,5 @@ http://bradkent.com/php/httpmessage
4848

4949
## Tests / Quality
5050

51-
![Supported PHP versions](https://img.shields.io/static/v1?label=PHP&message=5.4%20-%208.4&color=blue)
51+
![Supported PHP versions](https://img.shields.io/static/v1?label=PHP&message=5.4%20-%208.5&color=blue)
5252
![Build Status](https://img.shields.io/github/actions/workflow/status/bkdotcom/HttpMessage/phpunit.yml.svg?logo=github)
53-
[![Maintainability](https://img.shields.io/codeclimate/maintainability/bkdotcom/HttpMessage.svg?logo=codeclimate)](https://codeclimate.com/github/bkdotcom/HttpMessage)
54-
[![Coverage](https://img.shields.io/codeclimate/coverage/bkdotcom/HttpMessage.svg?logo=codeclimate)](https://codeclimate.com/github/bkdotcom/HttpMessage)

tests/HttpFactory/TestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ class TestCase extends TestCaseBase
2323

2424
public static function setUpBeforeClass(): void
2525
{
26-
self::$errorHandler = \set_error_handler(static function ($type, $msg) {
26+
self::$errorHandler = \set_error_handler(static function ($type, $msg, $file, $line) {
2727
if ($type & E_USER_DEPRECATED) {
2828
return true;
2929
}
30-
throw new RuntimeException($msg);
30+
throw new RuntimeException($msg . ': ' . $file . '(' . $line . ')');
3131
});
3232
}
3333

tests/HttpMessage/MessageTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ public function testSetHeaders()
8888
];
8989
$reflection = new ReflectionObject($message);
9090
$setHeaders = $reflection->getMethod('setHeaders');
91-
$setHeaders->setAccessible(true);
91+
if (PHP_VERSION_ID < 80100) {
92+
$setHeaders->setAccessible(true);
93+
}
9294
$setHeaders->invokeArgs($message, [$testArray]);
9395
$this->assertEquals($expectedArray, $message->getHeaders());
9496
$this->assertTrue($message instanceof Message);

tests/HttpMessage/ServerRequestTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ public function testProperties()
125125

126126
foreach ($properties as $k => $vExpect) {
127127
$prop = $reflection->getProperty($k);
128-
$prop->setAccessible(true);
128+
if (PHP_VERSION_ID < 80100) {
129+
$prop->setAccessible(true);
130+
}
129131
$this->assertSame($vExpect, $prop->getValue($serverRequest), $k);
130132
unset($prop);
131133
}

tests/HttpMessage/StreamTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ public function testExceptionSetResourceFileError()
274274
$stream->write('Foo Bar');
275275

276276
$reflectionMethod = new ReflectionMethod($stream, 'setResourceFile');
277-
$reflectionMethod->setAccessible(true);
277+
if (PHP_VERSION_ID < 80100) {
278+
$reflectionMethod->setAccessible(true);
279+
}
278280
$reflectionMethod->invoke($stream, 'some/readonly/file');
279281
}
280282

@@ -405,7 +407,9 @@ public static function setPrivateProp($obj, $prop, $val)
405407
$prop
406408
));
407409
}
408-
$refProp->setAccessible(true);
410+
if (PHP_VERSION_ID < 80100) {
411+
$refProp->setAccessible(true);
412+
}
409413
\is_string($obj) || $refProp->isStatic()
410414
? $refProp->setValue(null, $val)
411415
: $refProp->setValue($obj, $val);

tests/HttpMessage/UploadedFileTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ public function testGetErrorMessage()
111111
$this->assertSame('', $uploadedFile->getErrorMessage());
112112

113113
$reflection = new ReflectionProperty($uploadedFile, 'error');
114-
$reflection->setAccessible(true);
114+
if (PHP_VERSION_ID < 80100) {
115+
$reflection->setAccessible(true);
116+
}
115117

116118
$reflection->setValue($uploadedFile, UPLOAD_ERR_INI_SIZE);
117119
$this->assertSame(
@@ -239,7 +241,9 @@ public function testExceptionMoveToFileIsMoved()
239241
);
240242

241243
$reflection = new ReflectionProperty($uploadedFile, 'isMoved');
242-
$reflection->setAccessible(true);
244+
if (PHP_VERSION_ID < 80100) {
245+
$reflection->setAccessible(true);
246+
}
243247
$reflection->setValue($uploadedFile, true);
244248

245249
$targetPath = self::getTestFilepath('logo_moved.png');
@@ -296,7 +300,9 @@ public function testExceptionMoveError()
296300

297301
$this->expectException('RuntimeException');
298302
$reflection = new ReflectionMethod($uploadedFile, 'moveFile');
299-
$reflection->setAccessible(true);
303+
if (PHP_VERSION_ID < 80100) {
304+
$reflection->setAccessible(true);
305+
}
300306
// Exception => The target path "/tmp/folder-not-exists/test.png" is not writable.
301307
$reflection->invoke($uploadedFile, 'some/bogus/path');
302308
}
@@ -317,7 +323,9 @@ public function testExceptionMoveToFileNotUploaded()
317323
);
318324

319325
$reflection = new ReflectionProperty($uploadedFile, 'sapi');
320-
$reflection->setAccessible(true);
326+
if (PHP_VERSION_ID < 80100) {
327+
$reflection->setAccessible(true);
328+
}
321329
$reflection->setValue($uploadedFile, 'apache');
322330
// Exception => not an uploaded file
323331
$uploadedFile->moveTo($targetPath);

tests/HttpMessage/UriTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ public function testProperties()
6666

6767
foreach ($properties as $k => $v) {
6868
$prop = $reflection->getProperty($k);
69-
$prop->setAccessible(true);
69+
if (PHP_VERSION_ID < 80100) {
70+
$prop->setAccessible(true);
71+
}
7072
$this->assertSame($v, $prop->getValue($uri));
7173
unset($prop);
7274
}

tests/HttpMessage/Utility/ServerRequestTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ public function testExceptionWithUploadedFile()
201201
];
202202
$serverRequestUtil = new ServerRequestUtil();
203203
$reflectionMethod = new ReflectionMethod($serverRequestUtil, 'filesFromGlobals');
204-
$reflectionMethod->setAccessible(true);
204+
if (PHP_VERSION_ID < 80100) {
205+
$reflectionMethod->setAccessible(true);
206+
}
205207
$reflectionMethod->invokeArgs($serverRequestUtil, array(
206208
$files,
207209
));
@@ -222,7 +224,9 @@ public function testExceptionWithUploadedFile2()
222224
];
223225
$serverRequestUtil = new ServerRequestUtil();
224226
$reflectionMethod = new ReflectionMethod($serverRequestUtil, 'filesFromGlobals');
225-
$reflectionMethod->setAccessible(true);
227+
if (PHP_VERSION_ID < 80100) {
228+
$reflectionMethod->setAccessible(true);
229+
}
226230
$reflectionMethod->invokeArgs($serverRequestUtil, array(
227231
$files,
228232
));
@@ -398,7 +402,9 @@ public function testParseUploadedFiles()
398402

399403
$serverRequestUtil = new ServerRequestUtil();
400404
$reflectionMethod = new ReflectionMethod($serverRequestUtil, 'filesFromGlobals');
401-
$reflectionMethod->setAccessible(true);
405+
if (PHP_VERSION_ID < 80100) {
406+
$reflectionMethod->setAccessible(true);
407+
}
402408

403409
$uploadedFiles = $reflectionMethod->invokeArgs($serverRequestUtil, array(
404410
$files,

0 commit comments

Comments
 (0)