Skip to content

Commit

Permalink
Running php-cs-fixer
Browse files Browse the repository at this point in the history
Running php-cs-fixer to fix CS drift
  • Loading branch information
JimTools committed Jan 17, 2025
1 parent 67a1ad2 commit 4a84b80
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 62 deletions.
3 changes: 0 additions & 3 deletions BufferedStompClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ public function readMessageFrame(string $subscriptionId, int $timeout): ?Frame
}
}

/**
* {@inheritdoc}
*/
public function disconnect($sync = false)
{
parent::disconnect($sync);
Expand Down
6 changes: 3 additions & 3 deletions ExtensionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class ExtensionType
{
const ACTIVEMQ = 'activemq';
const RABBITMQ = 'rabbitmq';
const ARTEMIS = 'artemis';
public const ACTIVEMQ = 'activemq';
public const RABBITMQ = 'rabbitmq';
public const ARTEMIS = 'artemis';
}
4 changes: 2 additions & 2 deletions StompConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class StompConnectionFactory implements ConnectionFactory
{
const SUPPORTED_SCHEMES = [
public const SUPPORTED_SCHEMES = [
ExtensionType::ACTIVEMQ,
ExtensionType::RABBITMQ,
ExtensionType::ARTEMIS,
Expand Down Expand Up @@ -120,7 +120,7 @@ private function parseDsn(string $dsn): array
$dsn = Dsn::parseFirst($dsn);

if ('stomp' !== $dsn->getSchemeProtocol()) {
throw new \LogicException(sprintf('The given DSN is not supported. Must start with "stomp:".'));
throw new \LogicException('The given DSN is not supported. Must start with "stomp:".');
}

$schemeExtension = current($dsn->getSchemeExtensions());
Expand Down
6 changes: 3 additions & 3 deletions StompConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

class StompConsumer implements Consumer
{
const ACK_AUTO = 'auto';
const ACK_CLIENT = 'client';
const ACK_CLIENT_INDIVIDUAL = 'client-individual';
public const ACK_AUTO = 'auto';
public const ACK_CLIENT = 'client';
public const ACK_CLIENT_INDIVIDUAL = 'client-individual';

/**
* @var StompDestination
Expand Down
8 changes: 4 additions & 4 deletions StompContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function createMessage(string $body = '', array $properties = [], array $
*/
public function createQueue(string $name): Queue
{
if (0 !== strpos($name, '/')) {
if (!str_starts_with($name, '/')) {
$destination = new StompDestination($this->extensionType);
$destination->setType(StompDestination::TYPE_QUEUE);
$destination->setStompName($name);
Expand All @@ -101,7 +101,7 @@ public function createTemporaryQueue(): Queue
*/
public function createTopic(string $name): Topic
{
if (0 !== strpos($name, '/')) {
if (!str_starts_with($name, '/')) {
$destination = new StompDestination($this->extensionType);
$destination->setType($this->useExchangePrefix ? StompDestination::TYPE_EXCHANGE : StompDestination::TYPE_TOPIC);
$destination->setStompName($name);
Expand Down Expand Up @@ -130,7 +130,7 @@ public function createDestination(string $destination): StompDestination

foreach ($types as $_type) {
$typePrefix = '/'.$_type.'/';
if (0 === strpos($dest, $typePrefix)) {
if (str_starts_with($dest, $typePrefix)) {
$type = $_type;
$dest = substr($dest, strlen($typePrefix));

Expand Down Expand Up @@ -225,7 +225,7 @@ private function createStomp(): BufferedStompClient
$stomp = call_user_func($this->stompFactory);

if (false == $stomp instanceof BufferedStompClient) {
throw new \LogicException(sprintf('The factory must return instance of BufferedStompClient. It returns %s', is_object($stomp) ? get_class($stomp) : gettype($stomp)));
throw new \LogicException(sprintf('The factory must return instance of BufferedStompClient. It returns %s', is_object($stomp) ? $stomp::class : gettype($stomp)));
}

return $stomp;
Expand Down
20 changes: 10 additions & 10 deletions StompDestination.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

class StompDestination implements Topic, Queue
{
const TYPE_TOPIC = 'topic';
const TYPE_EXCHANGE = 'exchange';
const TYPE_QUEUE = 'queue';
const TYPE_AMQ_QUEUE = 'amq/queue';
const TYPE_TEMP_QUEUE = 'temp-queue';
const TYPE_REPLY_QUEUE = 'reply-queue';
public const TYPE_TOPIC = 'topic';
public const TYPE_EXCHANGE = 'exchange';
public const TYPE_QUEUE = 'queue';
public const TYPE_AMQ_QUEUE = 'amq/queue';
public const TYPE_TEMP_QUEUE = 'temp-queue';
public const TYPE_REPLY_QUEUE = 'reply-queue';

const HEADER_DURABLE = 'durable';
const HEADER_AUTO_DELETE = 'auto-delete';
const HEADER_EXCLUSIVE = 'exclusive';
public const HEADER_DURABLE = 'durable';
public const HEADER_AUTO_DELETE = 'auto-delete';
public const HEADER_EXCLUSIVE = 'exclusive';

/**
* @var string
Expand Down Expand Up @@ -122,7 +122,7 @@ public function getRoutingKey(): ?string
return $this->routingKey;
}

public function setRoutingKey(string $routingKey = null): void
public function setRoutingKey(?string $routingKey = null): void
{
$this->routingKey = $routingKey;
}
Expand Down
18 changes: 9 additions & 9 deletions StompHeadersEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

class StompHeadersEncoder
{
const PROPERTY_PREFIX = '_property_';
const TYPE_PREFIX = '_type_';
const TYPE_STRING = 's';
const TYPE_INT = 'i';
const TYPE_FLOAT = 'f';
const TYPE_BOOL = 'b';
const TYPE_NULL = 'n';
public const PROPERTY_PREFIX = '_property_';
public const TYPE_PREFIX = '_type_';
public const TYPE_STRING = 's';
public const TYPE_INT = 'i';
public const TYPE_FLOAT = 'f';
public const TYPE_BOOL = 'b';
public const TYPE_NULL = 'n';

public static function encode(array $headers = [], array $properties = []): array
{
Expand All @@ -36,7 +36,7 @@ public static function decode(array $headers = []): array

// separate headers/properties
foreach ($headers as $key => $value) {
if (0 === strpos($key, self::PROPERTY_PREFIX)) {
if (str_starts_with($key, self::PROPERTY_PREFIX)) {
$encodedProperties[substr($key, $prefixLength)] = $value;
} else {
$encodedHeaders[$key] = $value;
Expand Down Expand Up @@ -94,7 +94,7 @@ private static function doDecode(array $headers = []): array

foreach ($headers as $key => $value) {
// skip type header
if (0 === strpos($key, self::TYPE_PREFIX)) {
if (str_starts_with($key, self::TYPE_PREFIX)) {
continue;
}

Expand Down
10 changes: 5 additions & 5 deletions StompMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function setRedelivered(bool $redelivered): void
$this->redelivered = $redelivered;
}

public function setCorrelationId(string $correlationId = null): void
public function setCorrelationId(?string $correlationId = null): void
{
$this->setHeader('correlation_id', (string) $correlationId);
}
Expand All @@ -130,7 +130,7 @@ public function getCorrelationId(): ?string
return $this->getHeader('correlation_id');
}

public function setMessageId(string $messageId = null): void
public function setMessageId(?string $messageId = null): void
{
$this->setHeader('message_id', (string) $messageId);
}
Expand All @@ -147,7 +147,7 @@ public function getTimestamp(): ?int
return null === $value ? null : (int) $value;
}

public function setTimestamp(int $timestamp = null): void
public function setTimestamp(?int $timestamp = null): void
{
$this->setHeader('timestamp', $timestamp);
}
Expand All @@ -157,12 +157,12 @@ public function getFrame(): ?Frame
return $this->frame;
}

public function setFrame(Frame $frame = null): void
public function setFrame(?Frame $frame = null): void
{
$this->frame = $frame;
}

public function setReplyTo(string $replyTo = null): void
public function setReplyTo(?string $replyTo = null): void
{
$this->setHeader('reply-to', $replyTo);
}
Expand Down
6 changes: 3 additions & 3 deletions StompProducer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function send(Destination $destination, Message $message): void
/**
* @return $this|Producer
*/
public function setDeliveryDelay(int $deliveryDelay = null): Producer
public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
if (empty($deliveryDelay)) {
return $this;
Expand All @@ -64,7 +64,7 @@ public function getDeliveryDelay(): ?int
*
* @return $this|Producer
*/
public function setPriority(int $priority = null): Producer
public function setPriority(?int $priority = null): Producer
{
if (empty($priority)) {
return $this;
Expand All @@ -81,7 +81,7 @@ public function getPriority(): ?int
/**
* @return $this|Producer
*/
public function setTimeToLive(int $timeToLive = null): Producer
public function setTimeToLive(?int $timeToLive = null): Producer
{
if (empty($timeToLive)) {
return $this;
Expand Down
3 changes: 0 additions & 3 deletions Tests/Spec/StompMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

class StompMessageTest extends MessageSpec
{
/**
* {@inheritdoc}
*/
protected function createMessage()
{
return new StompMessage();
Expand Down
3 changes: 0 additions & 3 deletions Tests/StompConnectionFactoryConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ public function testThrowIfDsnCouldNotBeParsed()

/**
* @dataProvider provideConfigs
*
* @param mixed $config
* @param mixed $expectedConfig
*/
public function testShouldParseConfigurationAsExpected($config, $expectedConfig)
{
Expand Down
12 changes: 0 additions & 12 deletions Tests/StompHeadersEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ public function propertyValuesDataProvider()

/**
* @dataProvider headerValuesDataProvider
*
* @param mixed $originalValue
* @param mixed $encodedValue
*/
public function testShouldEncodeHeaders($originalValue, $encodedValue)
{
Expand All @@ -43,9 +40,6 @@ public function testShouldEncodeHeaders($originalValue, $encodedValue)

/**
* @dataProvider propertyValuesDataProvider
*
* @param mixed $originalValue
* @param mixed $encodedValue
*/
public function testShouldEncodeProperties($originalValue, $encodedValue)
{
Expand All @@ -54,9 +48,6 @@ public function testShouldEncodeProperties($originalValue, $encodedValue)

/**
* @dataProvider headerValuesDataProvider
*
* @param mixed $originalValue
* @param mixed $encodedValue
*/
public function testShouldDecodeHeaders($originalValue, $encodedValue)
{
Expand All @@ -65,9 +56,6 @@ public function testShouldDecodeHeaders($originalValue, $encodedValue)

/**
* @dataProvider propertyValuesDataProvider
*
* @param mixed $originalValue
* @param mixed $encodedValue
*/
public function testShouldDecodeProperties($originalValue, $encodedValue)
{
Expand Down
4 changes: 2 additions & 2 deletions Tests/StompMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function testShouldUnsetHeaderIfNullPassed()

$message->setHeader('aHeader', 'aVal');

//guard
// guard
$this->assertSame('aVal', $message->getHeader('aHeader'));

$message->setHeader('aHeader', null);
Expand All @@ -108,7 +108,7 @@ public function testShouldUnsetPropertyIfNullPassed()

$message->setProperty('aProperty', 'aVal');

//guard
// guard
$this->assertSame('aVal', $message->getProperty('aProperty'));

$message->setProperty('aProperty', null);
Expand Down

0 comments on commit 4a84b80

Please sign in to comment.