Skip to content
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
27 changes: 27 additions & 0 deletions .github/workflows/rector-cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Rector + PHP CS Fixer

on:
pull_request:
paths:
- 'config/**'
- 'src/**'
- 'tests/**'
- '.github/workflows/rector-cs.yml'
- 'composer.json'
- 'rector.php'
- '.php-cs-fixer.dist.php'

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
rector:
permissions:
contents: write # Required to commit automated Rector and CS fixes
uses: yiisoft/actions/.github/workflows/rector-cs.yml@master
with:
php: '8.1'
31 changes: 0 additions & 31 deletions .github/workflows/rector.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ phpunit.phar
# phpunit cache
.phpunit.result.cache
/phpunit.cache

# PHP CS Fixer
/.php-cs-fixer.cache
22 changes: 22 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
use Yiisoft\CodeStyle\ConfigBuilder;

$finder = (new Finder())->in([
__DIR__ . '/config',
__DIR__ . '/src',
__DIR__ . '/tests',
]);

return ConfigBuilder::build()
->setRiskyAllowed(true)
->setParallelConfig(ParallelConfigFactory::detect())
->setRules([
'@Yiisoft/Core' => true,
'@Yiisoft/Core:risky' => true,
])
->setFinder($finder);
85 changes: 0 additions & 85 deletions .styleci.yml

This file was deleted.

9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@
"yiisoft/queue": "dev-master"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.95",
"maglnet/composer-require-checker": "^4.7",
"phpunit/phpunit": "^10.5",
"rector/rector": "^1.0.3",
"rector/rector": "^2.5.5",
"roave/infection-static-analysis-plugin": "^1.34",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^5.16",
"yiisoft/code-style": "^1.0",
"yiisoft/test-support": "^3.0"
},
"autoload": {
Expand All @@ -69,5 +71,10 @@
"infection/extension-installer": true,
"composer/package-versions-deprecated": true
}
},
"scripts": {
"cs-fix": "php-cs-fixer fix",
"psalm": "psalm",
"rector": "rector"
}
}
5 changes: 4 additions & 1 deletion config/di.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

declare(strict_types=1);

use Yiisoft\Queue\Redis\QueueProvider;
use Yiisoft\Queue\Redis\QueueProviderInterface;

return [
Yiisoft\Queue\Redis\QueueProviderInterface::class => Yiisoft\Queue\Redis\QueueProvider::class,
QueueProviderInterface::class => QueueProvider::class,
];
28 changes: 11 additions & 17 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,22 @@

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
return RectorConfig::configure()
->withPaths([
__DIR__ . '/config',
__DIR__ . '/src',
__DIR__ . '/tests',
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_81,
]);

$rectorConfig->skip([
])
->withPhpSets(php81: true)
->withRules([
InlineConstructorDefaultToPropertyRector::class,
])
->withSkip([
ClosureToArrowFunctionRector::class,
JsonThrowOnErrorRector::class,
ReadOnlyPropertyRector::class,
NullToStrictStringFuncCallArgRector::class,
]);
};
17 changes: 9 additions & 8 deletions src/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
use Yiisoft\Queue\Message\Serializer\MessageSerializerInterface;
use Yiisoft\Queue\MessageStatus;

use function is_string;

final class Adapter implements AdapterInterface
{
public function __construct(
private QueueProviderInterface $provider,
private MessageSerializerInterface $serializer,
private LoopInterface $loop,
private int $timeout = 3
) {
}
private int $timeout = 3,
) {}

public function runExisting(callable $handlerCallback): void
{
Expand Down Expand Up @@ -90,6 +91,11 @@ public function withChannel(BackedEnum|string $channel): AdapterInterface
return $adapter;
}

public function getChannel(): string
{
return $this->provider->getChannelName();
}

private function reserve(): ?IdEnvelope
{
$reserve = $this->provider->reserve($this->timeout);
Expand All @@ -100,9 +106,4 @@ private function reserve(): ?IdEnvelope
$message = $this->serializer->unserialize($reserve->payload);
return new IdEnvelope($message, $reserve->id);
}

public function getChannel(): string
{
return $this->provider->getChannelName();
}
}
3 changes: 2 additions & 1 deletion src/Exception/NotConnectedRedisException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
namespace Yiisoft\Queue\Redis\Exception;

use Yiisoft\FriendlyException\FriendlyExceptionInterface;
use RuntimeException;

class NotConnectedRedisException extends \RuntimeException implements FriendlyExceptionInterface
class NotConnectedRedisException extends RuntimeException implements FriendlyExceptionInterface
{
public function getName(): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Message/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(
private string $handlerName,
private bool|int|float|string|array|null $payload,
private array $meta,
private int $delay = 0 //delay in seconds
private int $delay = 0, //delay in seconds
) {
if ($this->delay > 0) {
$this->meta[DelayEnvelope::META_DELAY_SECONDS] = $delay;
Expand Down
Loading