Skip to content

Commit 38895fa

Browse files
authored
Adds partial PHP 8.1 support (#402)
1 parent b6010b9 commit 38895fa

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: true
1515
matrix:
16-
php: [8.0]
16+
php: [8.0, 8.1]
1717
laravel: [^8.35]
1818

1919
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
"orchestra/testbench": "^6.16",
2828
"phpunit/phpunit": "^9.3",
2929
"spatie/laravel-ray": "^1.14",
30-
"spiral/roadrunner": "^2.0",
31-
"swoole/ide-helper": "^4.6"
30+
"spiral/roadrunner": "^2.0"
3231
},
3332
"bin": [
3433
"bin/roadrunner-worker",

src/RequestContext.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,25 @@ public function __construct(public array $data = [])
1010
{
1111
}
1212

13+
#[\ReturnTypeWillChange]
1314
public function offsetExists($offset)
1415
{
1516
return isset($this->data[$offset]);
1617
}
1718

19+
#[\ReturnTypeWillChange]
1820
public function offsetGet($offset)
1921
{
2022
return $this->data[$offset];
2123
}
2224

25+
#[\ReturnTypeWillChange]
2326
public function offsetSet($offset, $value)
2427
{
2528
$this->data[$offset] = $value;
2629
}
2730

31+
#[\ReturnTypeWillChange]
2832
public function offsetUnset($offset)
2933
{
3034
unset($this->data[$offset]);

src/Swoole/Actions/ConvertSwooleRequestToIlluminateRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __invoke($swooleRequest, string $phpSapi): Request
3333
$swooleRequest->rawContent(),
3434
);
3535

36-
if (str_starts_with($request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded') &&
36+
if (str_starts_with((string) $request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded') &&
3737
in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), ['PUT', 'PATCH', 'DELETE'])) {
3838
parse_str($request->getContent(), $data);
3939

tests/BinaryBootstrapTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,17 @@ public function test_it_can_retrieve_base_path_from_environment_variable()
1717

1818
$process->mustRun();
1919

20-
$this->assertSame($basePath, $process->getOutput());
20+
$output = $process->getOutput();
21+
22+
if (\PHP_VERSION_ID >= 80100) {
23+
$output = array_filter(explode("\n", $output), function ($output) {
24+
return ! empty($output) && ! str_starts_with($output, 'Deprecated:');
25+
});
26+
27+
$output = implode('', $output);
28+
}
29+
30+
$this->assertSame($basePath, $output);
2131
}
2232

2333
/**

0 commit comments

Comments
 (0)