Skip to content

Commit 8c071d9

Browse files
authored
Merge pull request #62 from reactphp-parallel/2.x-switch-to-stubs-package
[2.x] Switch to stubs package
2 parents c43f258 + 9110802 commit 8c071d9

File tree

11 files changed

+2737
-1711
lines changed

11 files changed

+2737
-1711
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"wyrihaximus/metrics": "^2.1"
2020
},
2121
"require-dev": {
22+
"react-parallel/stubs": "^1.1",
2223
"wyrihaximus/async-test-utilities": "^5.0.25 || ^8.0.5"
2324
},
2425
"autoload": {

composer.lock

Lines changed: 2700 additions & 1496 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

etc/qa/phpstan.neon

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
parameters:
22
level: max
33
ignoreErrors:
4+
-
5+
message: '#Control structures using switch should not be used.#'
6+
path: ../../src/EventLoopBridge.php
7+
-
8+
message: '#Language construct isset\(\) should not be used.#'
9+
path: ../../src/EventLoopBridge.php
10+
-
11+
message: '#Property ReactParallel\\EventLoop\\Stream<T>::\$wait \(React\\Promise\\Deferred<ReactParallel\\EventLoop\\Done\|ReactParallel\\EventLoop\\Value>\) does not accept React\\Promise\\Deferred<mixed>.#'
12+
path: ../../src/Stream.php
413
-
514
message: '#Result of method ReactParallel\\EventLoop\\EventLoopBridge::await\(\) \(void\) is used.#'
615
path: ../../tests/Types.php
7-
# ergebnis:
8-
# noExtends:
9-
# classesAllowedToBeExtended:
10-
# - ReactParallel\EventLoop\CancelledException
11-
# - ReactParallel\EventLoop\CanceledFuture
12-
# - ReactParallel\EventLoop\KilledRuntime
13-
stubFiles:
14-
- ../../stubs/Event.stub
15-
# - ../../stubs/Events.stub
16-
- ../../stubs/Future.stub
17-
- ../../stubs/Channel.stub
18-
- ../../stubs/functions.stub
16+
-
17+
message: '#usleep blocks the event loop, use React\\Promise\\Timer\\sleep#'
18+
path: ../../tests/EventLoopBridgeTest.php
19+
-
20+
message: '#sleep blocks the event loop, use React\\Promise\\Timer\\sleep#'
21+
path: ../../tests/EventLoopBridgeTest.php
22+
ergebnis:
23+
noExtends:
24+
classesAllowedToBeExtended:
25+
- Exception
26+
- ReactParallel\EventLoop\CancelledException
27+
- ReactParallel\EventLoop\CanceledFuture
28+
- ReactParallel\EventLoop\KilledRuntime
1929

20-
#includes:
21-
# - ../../vendor/wyrihaximus/async-test-utilities/rules.neon
30+
includes:
31+
- ../../vendor/wyrihaximus/async-test-utilities/rules.neon
32+
- ../../vendor/react-parallel/stubs/extension.neon

etc/qa/psalm.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
</ignoreFiles>
1313
</projectFiles>
1414
<stubs>
15-
<file name="../../stubs/Channel.stub" />
16-
<file name="../../stubs/Event.stub" />
17-
<file name="../../stubs/functions.stub" />
18-
<file name="../../stubs/Future.stub" />
15+
<file name="../../vendor/react-parallel/stubs/stubs/Channel.stub" />
16+
<file name="../../vendor/react-parallel/stubs/stubs/Event.stub" />
17+
<file name="../../vendor/react-parallel/stubs/stubs/functions.stub" />
18+
<file name="../../vendor/react-parallel/stubs/stubs/Future.stub" />
19+
<file name="../../vendor/react-parallel/stubs/stubs/Runtime.stub" />
1920
</stubs>
2021
<issueHandlers>
2122

infection.json.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
"@default": true,
2020
"InstanceOf_": {
2121
"ignore": [
22+
"ReactParallel\\EventLoop\\EventLoopBridge::handleFutureReadEvent",
2223
"ReactParallel\\EventLoop\\EventLoopBridge::handleCancelEvent"
2324
]
2425
},
2526
"LogicalNot": {
2627
"ignore": [
28+
"ReactParallel\\EventLoop\\EventLoopBridge::handleFutureReadEvent",
2729
"ReactParallel\\EventLoop\\EventLoopBridge::handleCancelEvent"
2830
]
2931
},

stubs/Channel.stub

Lines changed: 0 additions & 82 deletions
This file was deleted.

stubs/Event.stub

Lines changed: 0 additions & 36 deletions
This file was deleted.

stubs/Future.stub

Lines changed: 0 additions & 54 deletions
This file was deleted.

stubs/functions.stub

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/EventLoopBridgeTest.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace ReactParallel\Tests\EventLoop;
66

77
use parallel\Channel;
8-
use parallel\Future;
98
use parallel\Runtime;
109
use React\EventLoop\Loop;
1110
use ReactParallel\EventLoop\CanceledFuture;
@@ -16,7 +15,6 @@
1615
use WyriHaximus\Metrics\Configuration;
1716
use WyriHaximus\Metrics\InMemory\Registry;
1817

19-
use function assert;
2018
use function bin2hex;
2119
use function dirname;
2220
use function parallel\run;
@@ -27,7 +25,6 @@
2725
use function React\Promise\all;
2826
use function React\Promise\resolve;
2927
use function sleep;
30-
use function time;
3128
use function usleep;
3229

3330
final class EventLoopBridgeTest extends AsyncTestCase
@@ -60,7 +57,6 @@ public function read(): void
6057

6158
return 'Elmo';
6259
});
63-
assert($future instanceof Future);
6460

6561
$promises = [];
6662
foreach ($channels as $channel) {
@@ -113,7 +109,6 @@ public function cancel(): void
113109
self::expectException(CanceledFuture::class);
114110

115111
$future = run(static fn () => sleep(3));
116-
assert($future instanceof Future);
117112

118113
$eventLoopBridge = (new EventLoopBridge())->withMetrics(Metrics::create(new Registry(Configuration::create())));
119114

@@ -129,14 +124,12 @@ public function kill(): void
129124
self::expectException(KilledRuntime::class);
130125

131126
$runtime = new Runtime();
132-
$future = $runtime->run(static function (): int {
127+
$future = $runtime->run(static function (): string {
133128
sleep(3);
134129

135-
return time();
130+
return 'hammer';
136131
});
137132

138-
assert($future instanceof Future);
139-
140133
$eventLoopBridge = (new EventLoopBridge())->withMetrics(Metrics::create(new Registry(Configuration::create())));
141134

142135
Loop::addTimer(1, static function () use ($runtime): void {
@@ -158,7 +151,6 @@ public function futureError(): void
158151

159152
throw new CookieMonsterException('Cookie Monster');
160153
});
161-
assert($future instanceof Future);
162154

163155
$eventLoopBridge = (new EventLoopBridge())->withMetrics(Metrics::create(new Registry(Configuration::create())));
164156

0 commit comments

Comments
 (0)