Skip to content

Commit

Permalink
Adds partial PHP 8.1 support (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro authored Oct 13, 2021
1 parent b6010b9 commit 38895fa
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.0]
php: [8.0, 8.1]
laravel: [^8.35]

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"orchestra/testbench": "^6.16",
"phpunit/phpunit": "^9.3",
"spatie/laravel-ray": "^1.14",
"spiral/roadrunner": "^2.0",
"swoole/ide-helper": "^4.6"
"spiral/roadrunner": "^2.0"
},
"bin": [
"bin/roadrunner-worker",
Expand Down
4 changes: 4 additions & 0 deletions src/RequestContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,25 @@ public function __construct(public array $data = [])
{
}

#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return isset($this->data[$offset]);
}

#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->data[$offset];
}

#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
$this->data[$offset] = $value;
}

#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->data[$offset]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __invoke($swooleRequest, string $phpSapi): Request
$swooleRequest->rawContent(),
);

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

Expand Down
12 changes: 11 additions & 1 deletion tests/BinaryBootstrapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ public function test_it_can_retrieve_base_path_from_environment_variable()

$process->mustRun();

$this->assertSame($basePath, $process->getOutput());
$output = $process->getOutput();

if (\PHP_VERSION_ID >= 80100) {
$output = array_filter(explode("\n", $output), function ($output) {
return ! empty($output) && ! str_starts_with($output, 'Deprecated:');
});

$output = implode('', $output);
}

$this->assertSame($basePath, $output);
}

/**
Expand Down

0 comments on commit 38895fa

Please sign in to comment.