Skip to content

Commit fcaa718

Browse files
authored
Merge pull request #1372 from JimTools/bugfix/cs-drift
CS Fixes
2 parents 4dbdbb5 + 44437dd commit fcaa718

File tree

448 files changed

+709
-1895
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

448 files changed

+709
-1895
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969

7070
- run: sed -i 's/525568/16777471/' vendor/kwn/php-rdkafka-stubs/stubs/constants.php
7171

72-
- run: ./bin/php-cs-fixer fix --config=.php_cs.php --no-interaction --dry-run --diff -v --path-mode=intersection -- ${{ env.GIT_DIFF_FILTERED }}
72+
- run: ./bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --no-interaction --dry-run --diff -v --path-mode=intersection -- ${{ env.GIT_DIFF_FILTERED }}
7373
if: env.GIT_DIFF_FILTERED
7474

7575
unit_tests:

.gitignore

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
*~
22
/.idea/
33
bin/doctrine*
4-
bin/php-cs-fixer
5-
bin/phpunit
6-
bin/sql-formatter
7-
bin/phpstan
8-
bin/jp.php
9-
bin/php-parse
10-
bin/google-cloud-batch
4+
bin/php-cs-fixer*
5+
bin/phpunit*
6+
bin/sql-formatter*
7+
bin/phpstan*
8+
bin/jp.php*
9+
bin/php-parse*
10+
bin/google-cloud-batch*
11+
bin/patch-type-declarations*
1112
bin/thruway
12-
bin/phpstan.phar
13-
bin/var-dump-server
14-
bin/yaml-lint
13+
bin/var-dump-server*
14+
bin/yaml-lint*
1515
vendor
1616
var
1717
.php_cs
1818
.php_cs.cache
1919
composer.lock
2020
.phpunit.result.cache
21+
.php-cs-fixer.cache

.php_cs.php .php-cs-fixer.dist.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
return (new PhpCsFixer\Config())
4+
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
45
->setRiskyAllowed(true)
56
->setRules(array(
67
'@Symfony' => true,

bin/fix-symfony-version.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22

33
if (empty($argv[1])) {
4-
throw new \LogicException('The new symfony version must be provided');
4+
throw new LogicException('The new symfony version must be provided');
55
}
66

77
$newVersion = $argv[1];
88

99
$composer = file_get_contents(__DIR__.'/../composer.json');
1010

11-
$updatedComposer = preg_replace('/"symfony\/(.*)": ".*"/', '"symfony/$1": "'.$newVersion.'"', $composer).PHP_EOL;
12-
echo $updatedComposer.PHP_EOL;
11+
$updatedComposer = preg_replace('/"symfony\/(.*)": ".*"/', '"symfony/$1": "'.$newVersion.'"', $composer).\PHP_EOL;
12+
echo $updatedComposer.\PHP_EOL;
1313

1414
file_put_contents(__DIR__.'/../composer.json', $updatedComposer);

composer.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"minimum-stability": "beta",
55
"homepage": "https://enqueue.forma-pro.com/",
66
"scripts": {
7-
"cs-fix": "bin/php-cs-fixer fix --config=.php_cs.php",
8-
"cs-lint": "bin/php-cs-fixer fix --config=.php_cs.php --no-interaction --dry-run --diff",
7+
"cs-fix": "bin/php-cs-fixer fix",
8+
"cs-lint": "bin/php-cs-fixer fix --no-interaction --dry-run --diff",
99
"phpstan": "bin/phpstan analyse --memory-limit=512M -c phpstan.neon"
1010
},
1111
"require": {
@@ -136,4 +136,3 @@
136136
}
137137
}
138138
}
139-

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
build:
88
context: docker
99
args:
10-
PHP_VERSION: "${PHP_VERSION:-7.4}"
10+
PHP_VERSION: "${PHP_VERSION:-8.1}"
1111
depends_on:
1212
- rabbitmq
1313
- mysql

docker/bin/refresh-mysql-database.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
require_once getcwd().'/vendor/autoload.php';
66

77
$dsn = getenv('DOCTRINE_DSN');
8-
$database = trim(parse_url($dsn, PHP_URL_PATH), '/');
8+
$database = trim(parse_url($dsn, \PHP_URL_PATH), '/');
99

1010
$dbalContext = (new DbalConnectionFactory($dsn))->createContext();
1111

1212
$dbalContext->getDbalConnection()->getSchemaManager()->dropAndCreateDatabase($database);
1313
$dbalContext->getDbalConnection()->exec('USE '.$database);
1414
$dbalContext->createDataBaseTable();
1515

16-
echo 'MySQL Database is updated'.PHP_EOL;
16+
echo 'MySQL Database is updated'.\PHP_EOL;

docker/bin/refresh-postgres-database.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
$dbalContext->getDbalConnection()->getSchemaManager()->dropAndCreateDatabase('postgres');
1212
$dbalContext->createDataBaseTable();
1313

14-
echo 'Postgresql Database is updated'.PHP_EOL;
14+
echo 'Postgresql Database is updated'.\PHP_EOL;

docker/bin/test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ waitForService localstack 4566 50
4444
php docker/bin/refresh-mysql-database.php || exit 1
4545
php docker/bin/refresh-postgres-database.php || exit 1
4646
php pkg/job-queue/Tests/Functional/app/console doctrine:database:create --if-not-exists || exit 1
47-
php pkg/job-queue/Tests/Functional/app/console doctrine:schema:update --force || exit 1
47+
php pkg/job-queue/Tests/Functional/app/console doctrine:schema:update --force --complete || exit 1
4848

4949
#php pkg/enqueue-bundle/Tests/Functional/app/console.php config:dump-reference enqueue
5050
bin/phpunit "$@"

pkg/amqp-bunny/AmqpConnectionFactory.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AmqpConnectionFactory implements InteropAmqpConnectionFactory, DelayStrate
2626
private $client;
2727

2828
/**
29-
* @see \Enqueue\AmqpTools\ConnectionConfig for possible config formats and values
29+
* @see ConnectionConfig for possible config formats and values
3030
*
3131
* @param array|string|null $config
3232
*/
@@ -89,10 +89,10 @@ private function establishConnection(): BunnyClient
8989
$bunnyConfig['timeout'] = $this->config->getConnectionTimeout();
9090

9191
// @see https://github.com/php-enqueue/enqueue-dev/issues/229
92-
// $bunnyConfig['persistent'] = $this->config->isPersisted();
93-
// if ($this->config->isPersisted()) {
94-
// $bunnyConfig['path'] = 'enqueue';//$this->config->getOption('path', $this->config->getOption('vhost'));
95-
// }
92+
// $bunnyConfig['persistent'] = $this->config->isPersisted();
93+
// if ($this->config->isPersisted()) {
94+
// $bunnyConfig['path'] = 'enqueue';//$this->config->getOption('path', $this->config->getOption('vhost'));
95+
// }
9696

9797
if ($this->config->getHeartbeat()) {
9898
$bunnyConfig['heartbeat'] = $this->config->getHeartbeat();

pkg/amqp-bunny/AmqpConsumer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(AmqpContext $context, InteropAmqpQueue $queue)
4848
$this->flags = self::FLAG_NOPARAM;
4949
}
5050

51-
public function setConsumerTag(string $consumerTag = null): void
51+
public function setConsumerTag(?string $consumerTag = null): void
5252
{
5353
$this->consumerTag = $consumerTag;
5454
}
@@ -98,7 +98,7 @@ public function receive(int $timeout = 0): ?Message
9898
return $message;
9999
}
100100

101-
usleep(100000); //100ms
101+
usleep(100000); // 100ms
102102
}
103103

104104
return null;

pkg/amqp-bunny/AmqpContext.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class AmqpContext implements InteropAmqpContext, DelayStrategyAware
5151
* Callable must return instance of \Bunny\Channel once called.
5252
*
5353
* @param Channel|callable $bunnyChannel
54-
* @param array $config
5554
*/
5655
public function __construct($bunnyChannel, array $config)
5756
{
@@ -294,10 +293,7 @@ public function getBunnyChannel(): Channel
294293
if (false == $this->bunnyChannel) {
295294
$bunnyChannel = call_user_func($this->bunnyChannelFactory);
296295
if (false == $bunnyChannel instanceof Channel) {
297-
throw new \LogicException(sprintf(
298-
'The factory must return instance of \Bunny\Channel. It returned %s',
299-
is_object($bunnyChannel) ? get_class($bunnyChannel) : gettype($bunnyChannel)
300-
));
296+
throw new \LogicException(sprintf('The factory must return instance of \Bunny\Channel. It returned %s', is_object($bunnyChannel) ? $bunnyChannel::class : gettype($bunnyChannel)));
301297
}
302298

303299
$this->bunnyChannel = $bunnyChannel;

pkg/amqp-bunny/AmqpProducer.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function send(Destination $destination, Message $message): void
7979
/**
8080
* @return self
8181
*/
82-
public function setDeliveryDelay(int $deliveryDelay = null): Producer
82+
public function setDeliveryDelay(?int $deliveryDelay = null): Producer
8383
{
8484
if (null === $this->delayStrategy) {
8585
throw DeliveryDelayNotSupportedException::providerDoestNotSupportIt();
@@ -98,7 +98,7 @@ public function getDeliveryDelay(): ?int
9898
/**
9999
* @return self
100100
*/
101-
public function setPriority(int $priority = null): Producer
101+
public function setPriority(?int $priority = null): Producer
102102
{
103103
$this->priority = $priority;
104104

@@ -113,7 +113,7 @@ public function getPriority(): ?int
113113
/**
114114
* @return self
115115
*/
116-
public function setTimeToLive(int $timeToLive = null): Producer
116+
public function setTimeToLive(?int $timeToLive = null): Producer
117117
{
118118
$this->timeToLive = $timeToLive;
119119

pkg/amqp-bunny/AmqpSubscriptionConsumer.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function consume(int $timeout = 0): void
4747
try {
4848
$this->context->getBunnyChannel()->getClient()->run(0 !== $timeout ? $timeout / 1000 : null);
4949
} catch (ClientException $e) {
50-
if (0 === strpos($e->getMessage(), 'stream_select() failed') && $signalHandler->wasThereSignal()) {
50+
if (str_starts_with($e->getMessage(), 'stream_select() failed') && $signalHandler->wasThereSignal()) {
5151
return;
5252
}
5353

@@ -63,7 +63,7 @@ public function consume(int $timeout = 0): void
6363
public function subscribe(Consumer $consumer, callable $callback): void
6464
{
6565
if (false == $consumer instanceof AmqpConsumer) {
66-
throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, get_class($consumer)));
66+
throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, $consumer::class));
6767
}
6868

6969
if ($consumer->getConsumerTag() && array_key_exists($consumer->getConsumerTag(), $this->subscribers)) {
@@ -110,7 +110,7 @@ public function subscribe(Consumer $consumer, callable $callback): void
110110
public function unsubscribe(Consumer $consumer): void
111111
{
112112
if (false == $consumer instanceof AmqpConsumer) {
113-
throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, get_class($consumer)));
113+
throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, $consumer::class));
114114
}
115115

116116
if (false == $consumer->getConsumerTag()) {

pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php

-5
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ public function test()
1818
$this->markTestIncomplete();
1919
}
2020

21-
/**
22-
* {@inheritdoc}
23-
*/
2421
protected function createContext()
2522
{
2623
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -31,8 +28,6 @@ protected function createContext()
3128

3229
/**
3330
* @param AmqpContext $context
34-
*
35-
* {@inheritdoc}
3631
*/
3732
protected function createQueue(Context $context, $queueName)
3833
{

pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php

-5
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
*/
1414
class AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest extends SendAndReceiveDelayedMessageFromQueueSpec
1515
{
16-
/**
17-
* {@inheritdoc}
18-
*/
1916
protected function createContext()
2017
{
2118
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -26,8 +23,6 @@ protected function createContext()
2623

2724
/**
2825
* @param AmqpContext $context
29-
*
30-
* {@inheritdoc}
3126
*/
3227
protected function createQueue(Context $context, $queueName)
3328
{

pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php

-5
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
*/
1313
class AmqpSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceivePriorityMessagesFromQueueSpec
1414
{
15-
/**
16-
* {@inheritdoc}
17-
*/
1815
protected function createContext()
1916
{
2017
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -23,8 +20,6 @@ protected function createContext()
2320
}
2421

2522
/**
26-
* {@inheritdoc}
27-
*
2823
* @param AmqpContext $context
2924
*/
3025
protected function createQueue(Context $context, $queueName)

pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php

-5
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
*/
1313
class AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTimeToLiveMessagesFromQueueSpec
1414
{
15-
/**
16-
* {@inheritdoc}
17-
*/
1815
protected function createContext()
1916
{
2017
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -23,8 +20,6 @@ protected function createContext()
2320
}
2421

2522
/**
26-
* {@inheritdoc}
27-
*
2823
* @param AmqpContext $context
2924
*/
3025
protected function createQueue(Context $context, $queueName)

pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimestampAsIntegerTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
*/
1111
class AmqpSendAndReceiveTimestampAsIntegerTest extends SendAndReceiveTimestampAsIntegerSpec
1212
{
13-
/**
14-
* {@inheritdoc}
15-
*/
1613
protected function createContext()
1714
{
1815
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));

pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php

-5
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
*/
1313
class AmqpSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
1414
{
15-
/**
16-
* {@inheritdoc}
17-
*/
1815
protected function createContext()
1916
{
2017
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -23,8 +20,6 @@ protected function createContext()
2320
}
2421

2522
/**
26-
* {@inheritdoc}
27-
*
2823
* @param AmqpContext $context
2924
*/
3025
protected function createQueue(Context $context, $queueName)

pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php

-5
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
*/
1414
class AmqpSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec
1515
{
16-
/**
17-
* {@inheritdoc}
18-
*/
1916
protected function createContext()
2017
{
2118
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -24,8 +21,6 @@ protected function createContext()
2421
}
2522

2623
/**
27-
* {@inheritdoc}
28-
*
2924
* @param AmqpContext $context
3025
*/
3126
protected function createTopic(Context $context, $topicName)

pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php

-5
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
*/
1313
class AmqpSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec
1414
{
15-
/**
16-
* {@inheritdoc}
17-
*/
1815
protected function createContext()
1916
{
2017
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -23,8 +20,6 @@ protected function createContext()
2320
}
2421

2522
/**
26-
* {@inheritdoc}
27-
*
2823
* @param AmqpContext $context
2924
*/
3025
protected function createQueue(Context $context, $queueName)

pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php

-5
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
*/
1414
class AmqpSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitFromTopicSpec
1515
{
16-
/**
17-
* {@inheritdoc}
18-
*/
1916
protected function createContext()
2017
{
2118
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -24,8 +21,6 @@ protected function createContext()
2421
}
2522

2623
/**
27-
* {@inheritdoc}
28-
*
2924
* @param AmqpContext $context
3025
*/
3126
protected function createTopic(Context $context, $topicName)

0 commit comments

Comments
 (0)