Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds partial PHP 8.1 support #402

Merged
merged 1 commit into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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