Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS Fixes #1372

Merged
merged 4 commits into from
Jan 18, 2025
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:

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

- run: ./bin/php-cs-fixer fix --config=.php_cs.php --no-interaction --dry-run --diff -v --path-mode=intersection -- ${{ env.GIT_DIFF_FILTERED }}
- 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 }}
if: env.GIT_DIFF_FILTERED

unit_tests:
Expand Down
21 changes: 11 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
*~
/.idea/
bin/doctrine*
bin/php-cs-fixer
bin/phpunit
bin/sql-formatter
bin/phpstan
bin/jp.php
bin/php-parse
bin/google-cloud-batch
bin/php-cs-fixer*
bin/phpunit*
bin/sql-formatter*
bin/phpstan*
bin/jp.php*
bin/php-parse*
bin/google-cloud-batch*
bin/patch-type-declarations*
bin/thruway
bin/phpstan.phar
bin/var-dump-server
bin/yaml-lint
bin/var-dump-server*
bin/yaml-lint*
vendor
var
.php_cs
.php_cs.cache
composer.lock
.phpunit.result.cache
.php-cs-fixer.cache
1 change: 1 addition & 0 deletions .php_cs.php → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

return (new PhpCsFixer\Config())
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
->setRiskyAllowed(true)
->setRules(array(
'@Symfony' => true,
Expand Down
6 changes: 3 additions & 3 deletions bin/fix-symfony-version.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

if (empty($argv[1])) {
throw new \LogicException('The new symfony version must be provided');
throw new LogicException('The new symfony version must be provided');
}

$newVersion = $argv[1];

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

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

file_put_contents(__DIR__.'/../composer.json', $updatedComposer);
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"minimum-stability": "beta",
"homepage": "https://enqueue.forma-pro.com/",
"scripts": {
"cs-fix": "bin/php-cs-fixer fix --config=.php_cs.php",
"cs-lint": "bin/php-cs-fixer fix --config=.php_cs.php --no-interaction --dry-run --diff",
"cs-fix": "bin/php-cs-fixer fix",
"cs-lint": "bin/php-cs-fixer fix --no-interaction --dry-run --diff",
"phpstan": "bin/phpstan analyse --memory-limit=512M -c phpstan.neon"
},
"require": {
Expand Down Expand Up @@ -136,4 +136,3 @@
}
}
}

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
build:
context: docker
args:
PHP_VERSION: "${PHP_VERSION:-7.4}"
PHP_VERSION: "${PHP_VERSION:-8.1}"
depends_on:
- rabbitmq
- mysql
Expand Down
4 changes: 2 additions & 2 deletions docker/bin/refresh-mysql-database.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
require_once getcwd().'/vendor/autoload.php';

$dsn = getenv('DOCTRINE_DSN');
$database = trim(parse_url($dsn, PHP_URL_PATH), '/');
$database = trim(parse_url($dsn, \PHP_URL_PATH), '/');

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

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

echo 'MySQL Database is updated'.PHP_EOL;
echo 'MySQL Database is updated'.\PHP_EOL;
2 changes: 1 addition & 1 deletion docker/bin/refresh-postgres-database.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
$dbalContext->getDbalConnection()->getSchemaManager()->dropAndCreateDatabase('postgres');
$dbalContext->createDataBaseTable();

echo 'Postgresql Database is updated'.PHP_EOL;
echo 'Postgresql Database is updated'.\PHP_EOL;
2 changes: 1 addition & 1 deletion docker/bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ waitForService localstack 4566 50
php docker/bin/refresh-mysql-database.php || exit 1
php docker/bin/refresh-postgres-database.php || exit 1
php pkg/job-queue/Tests/Functional/app/console doctrine:database:create --if-not-exists || exit 1
php pkg/job-queue/Tests/Functional/app/console doctrine:schema:update --force || exit 1
php pkg/job-queue/Tests/Functional/app/console doctrine:schema:update --force --complete || exit 1

#php pkg/enqueue-bundle/Tests/Functional/app/console.php config:dump-reference enqueue
bin/phpunit "$@"
10 changes: 5 additions & 5 deletions pkg/amqp-bunny/AmqpConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AmqpConnectionFactory implements InteropAmqpConnectionFactory, DelayStrate
private $client;

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

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

if ($this->config->getHeartbeat()) {
$bunnyConfig['heartbeat'] = $this->config->getHeartbeat();
Expand Down
4 changes: 2 additions & 2 deletions pkg/amqp-bunny/AmqpConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(AmqpContext $context, InteropAmqpQueue $queue)
$this->flags = self::FLAG_NOPARAM;
}

public function setConsumerTag(string $consumerTag = null): void
public function setConsumerTag(?string $consumerTag = null): void
{
$this->consumerTag = $consumerTag;
}
Expand Down Expand Up @@ -98,7 +98,7 @@ public function receive(int $timeout = 0): ?Message
return $message;
}

usleep(100000); //100ms
usleep(100000); // 100ms
}

return null;
Expand Down
6 changes: 1 addition & 5 deletions pkg/amqp-bunny/AmqpContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class AmqpContext implements InteropAmqpContext, DelayStrategyAware
* Callable must return instance of \Bunny\Channel once called.
*
* @param Channel|callable $bunnyChannel
* @param array $config
*/
public function __construct($bunnyChannel, array $config)
{
Expand Down Expand Up @@ -294,10 +293,7 @@ public function getBunnyChannel(): Channel
if (false == $this->bunnyChannel) {
$bunnyChannel = call_user_func($this->bunnyChannelFactory);
if (false == $bunnyChannel instanceof Channel) {
throw new \LogicException(sprintf(
'The factory must return instance of \Bunny\Channel. It returned %s',
is_object($bunnyChannel) ? get_class($bunnyChannel) : gettype($bunnyChannel)
));
throw new \LogicException(sprintf('The factory must return instance of \Bunny\Channel. It returned %s', is_object($bunnyChannel) ? $bunnyChannel::class : gettype($bunnyChannel)));
}

$this->bunnyChannel = $bunnyChannel;
Expand Down
6 changes: 3 additions & 3 deletions pkg/amqp-bunny/AmqpProducer.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function send(Destination $destination, Message $message): void
/**
* @return self
*/
public function setDeliveryDelay(int $deliveryDelay = null): Producer
public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
if (null === $this->delayStrategy) {
throw DeliveryDelayNotSupportedException::providerDoestNotSupportIt();
Expand All @@ -98,7 +98,7 @@ public function getDeliveryDelay(): ?int
/**
* @return self
*/
public function setPriority(int $priority = null): Producer
public function setPriority(?int $priority = null): Producer
{
$this->priority = $priority;

Expand All @@ -113,7 +113,7 @@ public function getPriority(): ?int
/**
* @return self
*/
public function setTimeToLive(int $timeToLive = null): Producer
public function setTimeToLive(?int $timeToLive = null): Producer
{
$this->timeToLive = $timeToLive;

Expand Down
6 changes: 3 additions & 3 deletions pkg/amqp-bunny/AmqpSubscriptionConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function consume(int $timeout = 0): void
try {
$this->context->getBunnyChannel()->getClient()->run(0 !== $timeout ? $timeout / 1000 : null);
} catch (ClientException $e) {
if (0 === strpos($e->getMessage(), 'stream_select() failed') && $signalHandler->wasThereSignal()) {
if (str_starts_with($e->getMessage(), 'stream_select() failed') && $signalHandler->wasThereSignal()) {
return;
}

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

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

if (false == $consumer->getConsumerTag()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ public function test()
$this->markTestIncomplete();
}

/**
* {@inheritdoc}
*/
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
Expand All @@ -31,8 +28,6 @@ protected function createContext()

/**
* @param AmqpContext $context
*
* {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
*/
class AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest extends SendAndReceiveDelayedMessageFromQueueSpec
{
/**
* {@inheritdoc}
*/
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
Expand All @@ -26,8 +23,6 @@ protected function createContext()

/**
* @param AmqpContext $context
*
* {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
*/
class AmqpSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceivePriorityMessagesFromQueueSpec
{
/**
* {@inheritdoc}
*/
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
Expand All @@ -23,8 +20,6 @@ protected function createContext()
}

/**
* {@inheritdoc}
*
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
*/
class AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTimeToLiveMessagesFromQueueSpec
{
/**
* {@inheritdoc}
*/
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
Expand All @@ -23,8 +20,6 @@ protected function createContext()
}

/**
* {@inheritdoc}
*
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
*/
class AmqpSendAndReceiveTimestampAsIntegerTest extends SendAndReceiveTimestampAsIntegerSpec
{
/**
* {@inheritdoc}
*/
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
*/
class AmqpSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
{
/**
* {@inheritdoc}
*/
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
Expand All @@ -23,8 +20,6 @@ protected function createContext()
}

/**
* {@inheritdoc}
*
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
*/
class AmqpSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec
{
/**
* {@inheritdoc}
*/
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
Expand All @@ -24,8 +21,6 @@ protected function createContext()
}

/**
* {@inheritdoc}
*
* @param AmqpContext $context
*/
protected function createTopic(Context $context, $topicName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
*/
class AmqpSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec
{
/**
* {@inheritdoc}
*/
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
Expand All @@ -23,8 +20,6 @@ protected function createContext()
}

/**
* {@inheritdoc}
*
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
*/
class AmqpSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitFromTopicSpec
{
/**
* {@inheritdoc}
*/
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
Expand All @@ -24,8 +21,6 @@ protected function createContext()
}

/**
* {@inheritdoc}
*
* @param AmqpContext $context
*/
protected function createTopic(Context $context, $topicName)
Expand Down
Loading
Loading