From 9e3e7064874330c9abbabaccbadaa8633bd6546d Mon Sep 17 00:00:00 2001 From: Aleksandr Denisyuk Date: Tue, 19 Nov 2024 19:04:38 +0300 Subject: [PATCH 1/2] Update .gitattributes --- .gitattributes | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index 6fc21e5..969e5f8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,5 +15,5 @@ /psalm-baseline.xml export-ignore /psalm.xml export-ignore /tests/ export-ignore -/.Dockerfile export-ignore -/.Makefile export-ignore +/Dockerfile export-ignore +/Makefile export-ignore From e5716705f48ab215a0b89656583533baa9bdaba0 Mon Sep 17 00:00:00 2001 From: Aleksandr Denisyuk Date: Tue, 19 Nov 2024 19:04:56 +0300 Subject: [PATCH 2/2] Fix php-cs-fixer issues --- src/Cluster/ClusterPool.php | 6 +++--- src/Collection/InMemoryCollection.php | 8 ++++---- src/MultipleThrottler.php | 4 ++-- src/RoundRobinThrottler.php | 2 +- src/SmoothWeightedRoundRobinThrottler.php | 2 +- src/WeightedRoundRobinThrottler.php | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Cluster/ClusterPool.php b/src/Cluster/ClusterPool.php index 6b98c0f..167c2b2 100644 --- a/src/Cluster/ClusterPool.php +++ b/src/Cluster/ClusterPool.php @@ -27,7 +27,7 @@ public function __construct(ClusterSet ...$clusterSets) foreach ($clusterSet->clusterNames as $clusterName) { if (isset($this->clusterNames[$clusterName])) { - throw new \UnexpectedValueException(sprintf('The cluster "%s" has already been added.', $clusterName)); // @codeCoverageIgnore + throw new \UnexpectedValueException(\sprintf('The cluster "%s" has already been added.', $clusterName)); // @codeCoverageIgnore } $this->clusterNames[$clusterName] = $id; @@ -42,11 +42,11 @@ public function pick(CollectionInterface $collection, array $context = []): Node } if (!\is_string($context['cluster'])) { - throw new \RuntimeException(sprintf('The parameter "cluster" must be as a string, %s given.', get_debug_type($context['cluster']))); // @codeCoverageIgnore + throw new \RuntimeException(\sprintf('The parameter "cluster" must be as a string, %s given.', get_debug_type($context['cluster']))); // @codeCoverageIgnore } if (!isset($this->clusterNames[$context['cluster']])) { - throw new \RuntimeException(sprintf('The cluster "%s" is undefined.', $context['cluster'])); // @codeCoverageIgnore + throw new \RuntimeException(\sprintf('The cluster "%s" is undefined.', $context['cluster'])); // @codeCoverageIgnore } $throttler = $this->throttlers[$this->clusterNames[$context['cluster']]]; diff --git a/src/Collection/InMemoryCollection.php b/src/Collection/InMemoryCollection.php index c57f9ae..863fbfc 100644 --- a/src/Collection/InMemoryCollection.php +++ b/src/Collection/InMemoryCollection.php @@ -28,7 +28,7 @@ public function __construct(array $nodes = []) foreach ($nodes as $node) { if ($this->has($node)) { - throw new \InvalidArgumentException(sprintf('All nodes must be unique, "%s" given as duplicate.', $node->getName())); + throw new \InvalidArgumentException(\sprintf('All nodes must be unique, "%s" given as duplicate.', $node->getName())); } $this->nodes[] = $node; @@ -39,7 +39,7 @@ public function __construct(array $nodes = []) public function add(NodeInterface $node): self { if ($this->has($node)) { - throw new \UnexpectedValueException(sprintf('The node "%s" has been already added.', $node->getName())); + throw new \UnexpectedValueException(\sprintf('The node "%s" has been already added.', $node->getName())); } $self = clone $this; @@ -52,7 +52,7 @@ public function add(NodeInterface $node): self public function get(int $key): NodeInterface { if (!isset($this->nodes[$key])) { - throw new \OutOfRangeException(sprintf('Can\'t get node at key "%d".', $key)); + throw new \OutOfRangeException(\sprintf('Can\'t get node at key "%d".', $key)); } return $this->nodes[$key]; @@ -66,7 +66,7 @@ public function has(NodeInterface $node): bool public function remove(NodeInterface $node): self { if (!$this->has($node)) { - throw new \UnexpectedValueException(sprintf('The node "%s" hasn\'t been already added.', $node->getName())); + throw new \UnexpectedValueException(\sprintf('The node "%s" hasn\'t been already added.', $node->getName())); } $self = clone $this; diff --git a/src/MultipleThrottler.php b/src/MultipleThrottler.php index 28bf7f8..b4c96cb 100644 --- a/src/MultipleThrottler.php +++ b/src/MultipleThrottler.php @@ -31,11 +31,11 @@ public function pick(CollectionInterface $collection, array $context = []): Node } if (!isset($this->throttlers[$context['throttler']])) { - throw new \RuntimeException(sprintf('The throttler "%s" is undefined.', $context['throttler'])); // @codeCoverageIgnore + throw new \RuntimeException(\sprintf('The throttler "%s" is undefined.', $context['throttler'])); // @codeCoverageIgnore } if (!class_exists($context['throttler']) || !is_a($context['throttler'], ThrottlerInterface::class, true)) { - throw new \UnexpectedValueException(sprintf('The throttler must be a class that exists and implements "%s" interface, "%s" given.', ThrottlerInterface::class, get_debug_type($context['throttler']))); // @codeCoverageIgnore + throw new \UnexpectedValueException(\sprintf('The throttler must be a class that exists and implements "%s" interface, "%s" given.', ThrottlerInterface::class, get_debug_type($context['throttler']))); // @codeCoverageIgnore } $throttler = $this->throttlers[$context['throttler']]; diff --git a/src/RoundRobinThrottler.php b/src/RoundRobinThrottler.php index aa1e140..af6ce33 100644 --- a/src/RoundRobinThrottler.php +++ b/src/RoundRobinThrottler.php @@ -25,7 +25,7 @@ public function pick(CollectionInterface $collection, array $context = []): Node } if (isset($context['counter']) && !\is_string($context['counter'])) { - throw new \RuntimeException(sprintf('The parameter "counter" must be as a string, %s given.', get_debug_type($context['counter']))); // @codeCoverageIgnore + throw new \RuntimeException(\sprintf('The parameter "counter" must be as a string, %s given.', get_debug_type($context['counter']))); // @codeCoverageIgnore } $counter = $context['counter'] ?? spl_object_hash($collection); diff --git a/src/SmoothWeightedRoundRobinThrottler.php b/src/SmoothWeightedRoundRobinThrottler.php index 1c0d893..48ebfd8 100644 --- a/src/SmoothWeightedRoundRobinThrottler.php +++ b/src/SmoothWeightedRoundRobinThrottler.php @@ -28,7 +28,7 @@ public function pick(CollectionInterface $collection, array $context = []): Node } if (isset($context['counter']) && !\is_string($context['counter'])) { - throw new \RuntimeException(sprintf('The parameter "counter" must be as a string, %s given.', get_debug_type($context['counter']))); // @codeCoverageIgnore + throw new \RuntimeException(\sprintf('The parameter "counter" must be as a string, %s given.', get_debug_type($context['counter']))); // @codeCoverageIgnore } $counter = $context['counter'] ?? spl_object_hash($collection); diff --git a/src/WeightedRoundRobinThrottler.php b/src/WeightedRoundRobinThrottler.php index 80a5465..3ea0f5f 100644 --- a/src/WeightedRoundRobinThrottler.php +++ b/src/WeightedRoundRobinThrottler.php @@ -38,7 +38,7 @@ public function pick(CollectionInterface $collection, array $context = []): Node } if (isset($context['counter']) && !\is_string($context['counter'])) { - throw new \RuntimeException(sprintf('The parameter "counter" must be as a string, %s given.', get_debug_type($context['counter']))); // @codeCoverageIgnore + throw new \RuntimeException(\sprintf('The parameter "counter" must be as a string, %s given.', get_debug_type($context['counter']))); // @codeCoverageIgnore } $counter = $context['counter'] ?? spl_object_hash($collection);