Skip to content

Commit 28e6fcd

Browse files
committed
Fix psalm issues; update composer.json; migrate phpunit config
1 parent fb7e0c8 commit 28e6fcd

File tree

5 files changed

+69
-19
lines changed

5 files changed

+69
-19
lines changed

composer.json

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,37 @@
55
"license": "MIT",
66
"authors": [
77
{
8-
"name": "Anton Titov / Wolfy-J",
8+
"name": "Anton Titov (Wolfy-J)",
99
"email": "[email protected]"
1010
},
11+
{
12+
"name": "Valery Piashchynski",
13+
"homepage": "https://github.com/rustatian"
14+
},
15+
{
16+
"name": "Aleksei Gagarin (roxblnfk)",
17+
"homepage": "https://github.com/roxblnfk"
18+
},
19+
{
20+
"name": "Pavel Buchnev (butschster)",
21+
"email": "[email protected]"
22+
},
23+
{
24+
"name": "Maksim Smakouz (msmakouz)",
25+
"email": "[email protected]"
26+
},
1127
{
1228
"name": "RoadRunner Community",
13-
"homepage": "https://github.com/spiral/roadrunner/graphs/contributors"
29+
"homepage": "https://github.com/roadrunner-server/roadrunner/graphs/contributors"
1430
}
1531
],
32+
"homepage": "https://spiral.dev/",
33+
"support": {
34+
"docs": "https://roadrunner.dev/docs",
35+
"issues": "https://github.com/roadrunner-server/roadrunner/issues",
36+
"forum": "https://forum.roadrunner.dev/",
37+
"chat": "https://discord.gg/V6EK4he"
38+
},
1639
"require": {
1740
"php": ">=8.1",
1841
"ext-json": "*",
@@ -26,7 +49,7 @@
2649
"phpunit/phpunit": "^10.0",
2750
"jetbrains/phpstorm-attributes": "^1.0",
2851
"symfony/process": "^6.2",
29-
"vimeo/psalm": "^5.8"
52+
"vimeo/psalm": "^5.9"
3053
},
3154
"autoload": {
3255
"psr-4": {
@@ -38,6 +61,12 @@
3861
"Spiral\\RoadRunner\\Tests\\Http\\": "tests"
3962
}
4063
},
64+
"funding": [
65+
{
66+
"type": "github",
67+
"url": "https://github.com/sponsors/roadrunner-server"
68+
}
69+
],
4170
"scripts": {
4271
"analyze": "psalm"
4372
},

phpunit.xml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
4-
backupGlobals="false"
5-
backupStaticAttributes="false"
6-
colors="true"
7-
verbose="true"
8-
convertErrorsToExceptions="true"
9-
convertNoticesToExceptions="true"
10-
convertWarningsToExceptions="true"
4+
backupGlobals="false" colors="true"
115
processIsolation="false"
126
executionOrder="random"
137
stopOnFailure="false"
148
stopOnError="false"
159
stderr="true"
10+
cacheDirectory=".phpunit.cache"
1611
>
1712
<testsuites>
1813
<testsuite name="RR Worker Tests">
1914
<directory>tests</directory>
2015
</testsuite>
2116
</testsuites>
22-
2317
<coverage>
2418
<include>
2519
<directory>src</directory>

src/HttpWorker.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
* @psalm-import-type UploadedFilesList from Request
2323
* @psalm-import-type CookiesList from Request
2424
*
25-
* @psalm-type RequestContext = array {
26-
* remoteAddr: string,
27-
* protocol: string,
28-
* method: string,
25+
* @psalm-type RequestContext = array{
26+
* remoteAddr: non-empty-string,
27+
* protocol: non-empty-string,
28+
* method: non-empty-string,
2929
* uri: string,
3030
* attributes: AttributesList,
3131
* headers: HeadersList,

src/Request.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
/**
1717
* @psalm-immutable
1818
*
19-
* @psalm-type UploadedFile = array {
20-
* name: string,
19+
* @psalm-type UploadedFile = array{
20+
* name: non-empty-string,
2121
* error: int<0, max>,
22-
* tmpName: string,
22+
* tmpName: non-empty-string,
2323
* size: int<0, max>,
2424
* mime: string
2525
* }

tests/Feature/StreamResponseTest.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Spiral\RoadRunner\Tests\Http\Feature;
66

77
use PHPUnit\Framework\TestCase;
8-
use Spiral\Goridge\Frame;
98
use Spiral\Goridge\SocketRelay;
109
use Spiral\RoadRunner\Http\HttpWorker;
1110
use Spiral\RoadRunner\Payload;
@@ -94,6 +93,34 @@ public function testStopStreamResponse(): void
9493
self::assertSame(\implode("\n", ['Hel', 'lo,']), \trim(ServerRunner::getBuffer()));
9594
}
9695

96+
/**
97+
* StopStream should be ignored if stream is already ended.
98+
*/
99+
public function testStopStreamAfterStreamEnd(): void
100+
{
101+
$httpWorker = $this->makeHttpWorker();
102+
103+
// Flush buffer
104+
ServerRunner::getBuffer();
105+
106+
$httpWorker->respond(
107+
200,
108+
(function () {
109+
yield 'Hello';
110+
yield 'World!';
111+
})(),
112+
);
113+
114+
$this->assertFalse($this->getWorker()->hasPayload(\Spiral\RoadRunner\Message\Command\StreamStop::class));
115+
$this->sendCommand(new StreamStop());
116+
117+
118+
\usleep(200_000);
119+
self::assertSame(\implode("\n", ['Hello', 'World!']), \trim(ServerRunner::getBuffer()));
120+
$this->assertTrue($this->getWorker()->hasPayload(\Spiral\RoadRunner\Message\Command\StreamStop::class));
121+
$this->assertFalse($this->getWorker()->hasPayload());
122+
}
123+
97124
private function getRelay(): SocketRelay
98125
{
99126
return $this->relay ??= SocketRelay::create($this->serverAddress);

0 commit comments

Comments
 (0)