Skip to content

Commit

Permalink
Merge pull request #30 from php-service-bus/master
Browse files Browse the repository at this point in the history
update amphp version to 2.6 & update dependencies
  • Loading branch information
mmasiukevich authored Dec 4, 2021
2 parents b362ee6 + bafab44 commit 97d2750
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: composer install -ov

- name: Run phpstan/phpstan
run: ./vendor/bin/phpstan analyse src --level 7
run: ./vendor/bin/phpstan analyse src --level 9

phpunit:
name: PHPUnit
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
],
"require": {
"php": ">=8.0",
"amphp/amp": "v2.5.*",
"amphp/amp": "v2.6.*",
"amphp/socket": "v1.1.*",
"phpinnacle/buffer": "v1.2.*"
},
"require-dev": {
"phpunit/phpunit": "v9.5.*",
"vimeo/psalm": "v4.3.*",
"phpstan/phpstan": "v0.12.*"
"vimeo/psalm": "v4.13.*",
"phpstan/phpstan": "v1.2.*"
},
"prefer-stable": true,
"autoload": {
Expand All @@ -41,7 +41,7 @@
},
"scripts": {
"psalm": "./vendor/bin/psalm --config=psalm.xml",
"phpstan": "./vendor/bin/phpstan analyse src --level 7",
"phpstan": "./vendor/bin/phpstan analyse src --level 9",
"tests": "./vendor/bin/phpunit --configuration phpunit.xml --verbose",
"coverage": "./vendor/bin/phpunit --configuration phpunit.xml --coverage-html ./coverage --verbose"
},
Expand Down
16 changes: 4 additions & 12 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
parameters:
checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
ignoreErrors:
-
message: '#Unable to resolve the template type#'
path: %currentWorkingDirectory%/src
-
message: '#AbstractFrame given#'
path: %currentWorkingDirectory%/src/Channel.php
-
message: '#AbstractFrame given#'
path: %currentWorkingDirectory%/src/Client.php
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
- '#Cannot cast mixed to int#'
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
totallyTyped="true"
useDocblockTypes="true"
useDocblockPropertyTypes="true"
allowPhpStormGenerics="true"
strictBinaryOperands="true"
findUnusedPsalmSuppress="true"
ignoreInternalFunctionFalseReturn="false"
Expand All @@ -21,5 +20,6 @@

<issueHandlers>
<PropertyNotSetInConstructor errorLevel="suppress"/>
<UnnecessaryVarAnnotation errorLevel="suppress"/>
</issueHandlers>
</psalm>
8 changes: 3 additions & 5 deletions src/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,7 @@ public function doPublish
$buffer->appendUint8(206);

if (!empty($body)) {
/* @phpstan-ignore-next-line */
$chunks = \str_split($body, $this->properties->maxFrame());

if ($chunks !== false) {
Expand All @@ -1126,23 +1127,20 @@ public function doPublish
}

/**
* @template T
* @template T of Protocol\AbstractFrame
* @psalm-param class-string<T> $frame
* @psalm-return Promise<T>
*
* @return Promise<Protocol\AbstractFrame>
*/
private function await(string $frame): Promise
{
/** @psalm-var Deferred<T> $deferred */
$deferred = new Deferred;

/** @psalm-var class-string<Protocol\AbstractFrame> $frame */

$this->connection->subscribe(
$this->id,
$frame,
static function (Protocol\AbstractFrame $frame) use ($deferred) {
/** @psalm-var T $frame */
$deferred->resolve($frame);

return true;
Expand Down
7 changes: 3 additions & 4 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function () use ($code, $reason) {
if ($code === 0) {
$promises = [];

foreach ($this->channels as $id => $channel) {
foreach ($this->channels as $channel) {
$promises[] = $channel->close($code, $reason);
}

Expand Down Expand Up @@ -400,7 +400,7 @@ private function findChannelId(): int
}

/**
* @template T
* @template T of Protocol\AbstractFrame
* @psalm-param class-string<T> $frame
* @psalm-return Promise<T>
*/
Expand All @@ -409,12 +409,11 @@ private function await(string $frame, int $channel = 0): Promise
/** @psalm-var Deferred<T> $deferred */
$deferred = new Deferred;

/** @psalm-var class-string<Protocol\AbstractFrame> $frame */

$this->connection->subscribe(
$channel,
$frame,
static function (Protocol\AbstractFrame $frame) use ($deferred) {
/** @psalm-var T $frame */
$deferred->resolve($frame);

return true;
Expand Down
3 changes: 0 additions & 3 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,9 @@ function () {
$this->parser->append($chunk);

while ($frame = $this->parser->parse()) {
/** @var AbstractFrame $frame */

$class = \get_class($frame);

/**
* @psalm-var int $i
* @psalm-var callable(AbstractFrame):Promise<bool> $callback
*/
foreach ($this->callbacks[(int)$frame->channel][$class] ?? [] as $i => $callback) {
Expand Down
8 changes: 4 additions & 4 deletions src/Properties.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ public function __construct(string $platform, string $product, string $version,

/**
* @psalm-param array{
* platform: string,
* product: string,
* version: string,
* capabilities: array<string, bool>
* platform: string|null,
* product: string|null,
* version: string|null,
* capabilities: array<string, bool>|null
* } $config
*/
public static function create(array $config): self
Expand Down

0 comments on commit 97d2750

Please sign in to comment.