File tree 14 files changed +68
-58
lines changed
14 files changed +68
-58
lines changed Original file line number Diff line number Diff line change 13
13
- name : Install PHP
14
14
uses : shivammathur/setup-php@v2
15
15
with :
16
- php-version : 8.0
16
+ php-version : 8.1
17
17
coverage : none
18
18
tools : composer:v2
19
19
33
33
- name : Install PHP
34
34
uses : shivammathur/setup-php@v2
35
35
with :
36
- php-version : 8.0
36
+ php-version : 8.1
37
37
coverage : none
38
38
tools : composer:v2
39
39
68
68
- name : Install PHP with extensions
69
69
uses : shivammathur/setup-php@v2
70
70
with :
71
- php-version : 8.0
71
+ php-version : 8.1
72
72
extensions : ${{ env.PHP_EXTENSIONS }}
73
73
ini-values : ${{ env.PHP_INI_VALUES }}
74
74
tools : composer:v2
Original file line number Diff line number Diff line change 18
18
}
19
19
],
20
20
"require" : {
21
- "php" : " >=8.0 " ,
21
+ "php" : " >=8.1 " ,
22
22
"amphp/amp" : " v2.6.*" ,
23
23
"amphp/socket" : " v1.2.*" ,
24
24
"phpinnacle/buffer" : " v1.2.*" ,
25
25
"evenement/evenement" : " v3.0.*"
26
26
},
27
27
"require-dev" : {
28
- "phpunit/phpunit" : " v9.5 .*" ,
29
- "vimeo/psalm" : " v4.19 .*" ,
30
- "phpstan/phpstan" : " v1.4.* "
28
+ "phpunit/phpunit" : " 10.* || 11 .*" ,
29
+ "vimeo/psalm" : " 5 .*" ,
30
+ "phpstan/phpstan" : " ^1.10 "
31
31
},
32
32
"prefer-stable" : true ,
33
33
"autoload" : {
43
43
"scripts" : {
44
44
"psalm" : " ./vendor/bin/psalm --config=psalm.xml" ,
45
45
"phpstan" : " ./vendor/bin/phpstan analyse src --level 9" ,
46
- "tests" : " ./vendor/bin/phpunit --configuration phpunit.xml --verbose " ,
46
+ "tests" : " ./vendor/bin/phpunit --configuration phpunit.xml" ,
47
47
"coverage" : " ./vendor/bin/phpunit --configuration phpunit.xml --coverage-html ./coverage --verbose"
48
48
},
49
49
"extra" : {
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" UTF-8" ?>
2
- <phpunit xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" bootstrap =" vendor/autoload.php" backupGlobals =" false"
3
- backupStaticAttributes =" false" beStrictAboutTestsThatDoNotTestAnything =" false" colors =" true" verbose =" true"
4
- convertErrorsToExceptions =" true" convertNoticesToExceptions =" true" convertWarningsToExceptions =" true"
5
- failOnRisky =" true" failOnWarning =" true" stopOnFailure =" false"
6
- xsi : noNamespaceSchemaLocation =" https://schema.phpunit.de/9.3/phpunit.xsd" >
7
- <coverage >
8
- <include >
9
- <directory >./</directory >
10
- </include >
11
- <exclude >
12
- <directory >./tests</directory >
13
- <directory >./vendor</directory >
14
- </exclude >
15
- </coverage >
16
- <php >
17
- <ini name =" error_reporting" value =" -1" />
18
- <
env name =
" RIDGE_TEST_DSN" value =
" amqp://guest:[email protected] :5672/?heartbeat=0" />
19
- </php >
20
- <testsuites >
21
- <testsuite name =" PHPinnacle Test Suite" >
22
- <directory >./tests/</directory >
23
- </testsuite >
24
- </testsuites >
2
+ <phpunit xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3
+ bootstrap =" vendor/autoload.php"
4
+ backupGlobals =" false"
5
+ beStrictAboutTestsThatDoNotTestAnything =" false"
6
+ colors =" true"
7
+ failOnRisky =" true"
8
+ failOnWarning =" true"
9
+ stopOnFailure =" false"
10
+ xsi : noNamespaceSchemaLocation =" https://schema.phpunit.de/10.5/phpunit.xsd" >
11
+ <php >
12
+ <ini name =" error_reporting" value =" -1" />
13
+ <
env name =
" RIDGE_TEST_DSN" value =
" amqp://guest:[email protected] :5672/?heartbeat=0" />
14
+ </php >
15
+ <testsuites >
16
+ <testsuite name =" PHPinnacle Test Suite" >
17
+ <directory >./tests/</directory >
18
+ </testsuite >
19
+ </testsuites >
20
+ <source >
21
+ <include >
22
+ <directory >./</directory >
23
+ </include >
24
+ <exclude >
25
+ <directory >./tests</directory >
26
+ <directory >./vendor</directory >
27
+ </exclude >
28
+ </source >
25
29
</phpunit >
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" ?>
2
2
<psalm
3
- totallyTyped =" true"
4
- useDocblockTypes =" true"
5
3
useDocblockPropertyTypes =" true"
6
4
strictBinaryOperands =" true"
7
5
findUnusedPsalmSuppress =" true"
21
19
<issueHandlers >
22
20
<PropertyNotSetInConstructor errorLevel =" suppress" />
23
21
<UnnecessaryVarAnnotation errorLevel =" suppress" />
22
+ <RiskyTruthyFalsyComparison errorLevel =" suppress" />
24
23
</issueHandlers >
25
24
</psalm >
Original file line number Diff line number Diff line change @@ -149,6 +149,9 @@ function () use ($outOfBand) {
149
149
}
150
150
151
151
/**
152
+ * @psalm-suppress InvalidReturnType
153
+ * @psalm-suppress InvalidReturnStatement
154
+ *
152
155
* @return Promise<void>
153
156
*
154
157
* @throws \PHPinnacle\Ridge\Exception\ChannelException
@@ -1148,9 +1151,12 @@ public function doPublish
1148
1151
$ buffer ->appendUint8 (206 );
1149
1152
1150
1153
if (!empty ($ body )) {
1151
- /* @phpstan-ignore-next-line */
1154
+ /**
1155
+ * @phpstan-ignore-next-line
1156
+ * @psalm-suppress ArgumentTypeCoercion
1157
+ */
1152
1158
$ chunks = \str_split ($ body , $ this ->properties ->maxFrame ());
1153
-
1159
+ /** @psalm-suppress RedundantConditionGivenDocblockType */
1154
1160
if ($ chunks !== false ) {
1155
1161
foreach ($ chunks as $ chunk ) {
1156
1162
$ buffer
@@ -1197,6 +1203,8 @@ static function (Protocol\AbstractFrame $frame) use ($deferred) {
1197
1203
public function forceClose (\Throwable $ exception ): void
1198
1204
{
1199
1205
if ($ this ->state !== self ::STATE_CLOSED ) {
1206
+ $ this ->connection ->cancel ($ this ->id );
1207
+
1200
1208
$ this ->state = self ::STATE_CLOSED ;
1201
1209
$ this ->commandWaitQueue ->cancel ($ exception );
1202
1210
$ this ->emit (self ::EVENT_CHANNEL_CLOSED , [$ exception ]);
Original file line number Diff line number Diff line change @@ -83,6 +83,8 @@ public function __construct(Config $config)
83
83
}
84
84
$ this ->channels = [];
85
85
$ this ->commandWaitQueue ->cancel ($ exception );
86
+
87
+ throw $ exception ;
86
88
}
87
89
});
88
90
}
@@ -186,6 +188,9 @@ function(): void
186
188
}
187
189
188
190
/**
191
+ * @psalm-suppress InvalidReturnType
192
+ * @psalm-suppress InvalidReturnStatement
193
+ *
189
194
* @return Promise<void>
190
195
*
191
196
* @throws \PHPinnacle\Ridge\Exception\ClientException
Original file line number Diff line number Diff line change @@ -160,9 +160,12 @@ function () {
160
160
$ this ->lastRead = Loop::now ();
161
161
162
162
/**
163
- * @psalm-var callable(AbstractFrame):Promise<bool> $callback
163
+ * @psalm-suppress PossiblyInvalidArgument
164
+ *
165
+ * @var callable(AbstractFrame):Promise<bool> $callback
164
166
*/
165
167
foreach ($ this ->callbacks [(int )$ frame ->channel ][$ class ] ?? [] as $ i => $ callback ) {
168
+ /** @phpstan-ignore-next-line */
166
169
if (yield call ($ callback , $ frame )) {
167
170
unset($ this ->callbacks [(int )$ frame ->channel ][$ class ][$ i ]);
168
171
}
@@ -187,9 +190,9 @@ public function heartbeat(int $timeout): void
187
190
* We run the callback even more often to avoid race conditions if the loop is a bit under pressure
188
191
* otherwise we could miss heartbeats in rare conditions
189
192
*/
190
- $ interval = $ timeout / 2 ;
193
+ $ interval = ( int ) ( $ timeout / 2 ) ;
191
194
$ this ->heartbeatWatcherId = Loop::repeat (
192
- $ interval / 3 ,
195
+ ( int ) ( $ interval / 3 ) ,
193
196
function (string $ watcherId ) use ($ interval , $ timeout ){
194
197
$ currentTime = Loop::now ();
195
198
Original file line number Diff line number Diff line change 13
13
use Amp \Loop ;
14
14
use function Amp \call ;
15
15
16
- abstract class AsyncTest extends RidgeTest
16
+ abstract class AsyncTestCase extends RidgeTestCase
17
17
{
18
18
/**
19
- * @var string
19
+ * @var string|null
20
20
*/
21
21
private $ realTestName ;
22
22
23
- /**
24
- * @codeCoverageIgnore Invoked before code coverage data is being collected.
25
- *
26
- * @param string $name
27
- */
28
- public function setName (string $ name ): void
23
+ protected function runTest (): mixed
29
24
{
30
- parent :: setName ( $ name );
25
+ $ this -> realTestName = $ this -> name ( );
31
26
32
- $ this ->realTestName = $ name ;
33
- }
34
-
35
- protected function runTest ()
36
- {
37
27
parent ::setName ('runTestAsync ' );
38
28
39
29
return parent ::runTest ();
@@ -49,6 +39,7 @@ protected function runTestAsync(...$args)
49
39
50
40
yield $ client ->connect ();
51
41
42
+ $ args = $ args ?: [];
52
43
\array_unshift ($ args , $ client );
53
44
54
45
$ return = yield call ([$ this , $ this ->realTestName ], ...$ args );
Original file line number Diff line number Diff line change 13
13
use PHPinnacle \Ridge \Buffer ;
14
14
use PHPinnacle \Ridge \Exception ;
15
15
16
- class BufferTest extends RidgeTest
16
+ class BufferTest extends RidgeTestCase
17
17
{
18
18
public function testTimestamp ()
19
19
{
Original file line number Diff line number Diff line change 18
18
use PHPinnacle \Ridge \Message ;
19
19
use PHPinnacle \Ridge \Queue ;
20
20
21
- class ChannelTest extends AsyncTest
21
+ class ChannelTest extends AsyncTestCase
22
22
{
23
23
public function testOpenNotReadyChannel (Client $ client )
24
24
{
Original file line number Diff line number Diff line change 16
16
use PHPinnacle \Ridge \Client ;
17
17
use PHPinnacle \Ridge \Message ;
18
18
19
- class ClientConnectTest extends RidgeTest
19
+ class ClientConnectTest extends RidgeTestCase
20
20
{
21
21
public function testConnect ()
22
22
{
Original file line number Diff line number Diff line change 14
14
use PHPinnacle \Ridge \Client ;
15
15
use PHPinnacle \Ridge \Message ;
16
16
17
- class ClientTest extends AsyncTest
17
+ class ClientTest extends AsyncTestCase
18
18
{
19
19
public function testOpenChannel (Client $ client )
20
20
{
Original file line number Diff line number Diff line change 12
12
13
13
use PHPinnacle \Ridge \Config ;
14
14
15
- class ConfigTest extends RidgeTest
15
+ class ConfigTestCase extends RidgeTestCase
16
16
{
17
17
public function testCreate ()
18
18
{
Original file line number Diff line number Diff line change 15
15
use PHPinnacle \Ridge \Config ;
16
16
use PHPUnit \Framework \TestCase ;
17
17
18
- abstract class RidgeTest extends TestCase
18
+ abstract class RidgeTestCase extends TestCase
19
19
{
20
20
/**
21
21
* @param mixed $value
You can’t perform that action at this time.
0 commit comments