Skip to content

Commit

Permalink
Run CS fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
mbabker committed Aug 16, 2024
1 parent a5ac1be commit aada5c4
Show file tree
Hide file tree
Showing 21 changed files with 52 additions and 61 deletions.
9 changes: 0 additions & 9 deletions rector.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
<?php declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddSeeTestAnnotationRector;

return RectorConfig::configure()
->withPaths([
__DIR__.'/src',
__DIR__.'/tests',
])
->withSkip([
/*
* Skip selected rules
*/
AddLiteralSeparatorToNumberRector::class,
AddSeeTestAnnotationRector::class,
])
->withImportNames(importShortClasses: false)
->withPHPStanConfigs([
__DIR__ . '/vendor/phpstan/phpstan-phpunit/extension.neon',
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Middleware/RestrictToAllowedOrigins.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function onOpen(Connection $connection): void
$request = $connection->getAttributeStore()->get('http.request');

if (!$request instanceof RequestInterface) {
throw new MissingRequest(sprintf('The "%s" middleware requires the HTTP request has been processed. Ensure the "%s" middleware (or a custom middleware setting the "http.request" in the attribute store) has been run.', self::class, ParseHttpRequest::class));
throw new MissingRequest(\sprintf('The "%s" middleware requires the HTTP request has been processed. Ensure the "%s" middleware (or a custom middleware setting the "http.request" in the attribute store) has been run.', self::class, ParseHttpRequest::class));
}

if ([] !== $this->allowedOrigins) {
Expand Down
2 changes: 1 addition & 1 deletion src/Session/Middleware/InitializeSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function onOpen(Connection $connection): void
$request = $connection->getAttributeStore()->get('http.request');

if (!$request instanceof RequestInterface) {
throw new MissingRequest(sprintf('The "%s" middleware requires the HTTP request has been processed. Ensure the "%s" middleware (or a custom middleware setting the "http.request" in the attribute store) has been run.', self::class, ParseHttpRequest::class));
throw new MissingRequest(\sprintf('The "%s" middleware requires the HTTP request has been processed. Ensure the "%s" middleware (or a custom middleware setting the "http.request" in the attribute store) has been run.', self::class, ParseHttpRequest::class));
}

$session = $this->sessionFactory->createSession();
Expand Down
10 changes: 5 additions & 5 deletions src/Session/Reader/PhpReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ private function getSerializedSegmentLength(string $data): int|false
case 'N':
return 2;

// Boolean value
// Boolean value
case 'b':
return 4;

// Integer or floating point value
// Integer or floating point value
case 'i':
case 'd':
$end = strpos($data, ';');

return false === $end ? false : $end + 1;

// String value
// String value
case 's':
if (!preg_match('/^s:\d+:"/', $data, $matches)) {
return false;
Expand All @@ -83,7 +83,7 @@ private function getSerializedSegmentLength(string $data): int|false
// Add characters for the closing quote and semicolon
return \strlen($matches[0]) + (int) substr($matches[0], 2, -2) + 2;

// Array value
// Array value
case 'a':
if (!preg_match('/^a:\d+:\{/', $data, $matches)) {
return false;
Expand Down Expand Up @@ -116,7 +116,7 @@ private function getSerializedSegmentLength(string $data): int|false
// Add characters for the closing brace
return $offset + 1;

// Unsupported value
// Unsupported value
default:
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Session/Storage/Proxy/ReadOnlySessionHandlerProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getId(): string
public function setId(string $id): void
{
if (null !== $this->sessionId) {
throw new ReadOnlySession(sprintf('The session ID cannot be changed once set in "%s".', self::class));
throw new ReadOnlySession(\sprintf('The session ID cannot be changed once set in "%s".', self::class));
}

$this->sessionId = $id;
Expand All @@ -49,7 +49,7 @@ public function getName(): string
*/
public function setName(string $name): never
{
throw new ReadOnlySession(sprintf('The session name cannot be changed in "%s".', self::class));
throw new ReadOnlySession(\sprintf('The session name cannot be changed in "%s".', self::class));
}

public function open(string $path, string $name): bool
Expand Down
8 changes: 4 additions & 4 deletions src/Session/Storage/ReadOnlyNativeSessionStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ public function getName(): string
*/
public function setName(string $name): never
{
throw new ReadOnlySession(sprintf('The session name cannot be changed in "%s".', self::class));
throw new ReadOnlySession(\sprintf('The session name cannot be changed in "%s".', self::class));
}

/**
* @throws ReadOnlySession
*/
public function regenerate(bool $destroy = false, ?int $lifetime = null): never
{
throw new ReadOnlySession(sprintf('The session cannot be regenerated in "%s".', self::class));
throw new ReadOnlySession(\sprintf('The session cannot be regenerated in "%s".', self::class));
}

public function save(): void
Expand Down Expand Up @@ -154,7 +154,7 @@ public function registerBag(SessionBagInterface $bag): void
public function getBag(string $name): SessionBagInterface
{
if (!isset($this->bags[$name])) {
throw new \InvalidArgumentException(sprintf('The SessionBagInterface "%s" is not registered.', $name));
throw new \InvalidArgumentException(\sprintf('The SessionBagInterface "%s" is not registered.', $name));
}

if (!$this->started) {
Expand Down Expand Up @@ -232,7 +232,7 @@ private function createReader(): Reader
'php' => new PhpReader(),
'php_binary' => new PhpBinaryReader(),
'php_serialize' => new PhpSerializeReader(),
default => throw new SessionMisconfigured(sprintf('The "%s" serialize handler is not supported in "%s", set the PHP "session.serialize_handler" option to a supported handler or inject your own "%s" instance.', $this->optionsHandler->get('session.serialize_handler'), self::class, Reader::class)),
default => throw new SessionMisconfigured(\sprintf('The "%s" serialize handler is not supported in "%s", set the PHP "session.serialize_handler" option to a supported handler or inject your own "%s" instance.', $this->optionsHandler->get('session.serialize_handler'), self::class, Reader::class)),
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/WAMP/ArrayTopicRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class ArrayTopicRegistry implements TopicRegistry
public function add(Topic $topic): void
{
if ($this->has($topic->id)) {
throw new TopicAlreadyRegistered(sprintf('A topic for URI "%s" is already registered.', $topic->id));
throw new TopicAlreadyRegistered(\sprintf('A topic for URI "%s" is already registered.', $topic->id));
}

$this->topics[$topic->id] = $topic;
Expand All @@ -40,7 +40,7 @@ public function all(): iterable
*/
public function get(string $id): Topic
{
return $this->topics[$id] ?? throw new TopicNotFound(sprintf('A topic for URI "%s" is not registered.', $id));
return $this->topics[$id] ?? throw new TopicNotFound(\sprintf('A topic for URI "%s" is not registered.', $id));
}

public function has(string $id): bool
Expand Down
2 changes: 1 addition & 1 deletion src/WAMP/DefaultWAMPConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getConnection(): Connection
public function send(string|DataInterface $data): void
{
if ($data instanceof DataInterface && !$this->connection instanceof WebSocketConnection) {
throw new UnsupportedConnection(sprintf('To send a "%s" implementation, "%s" must decorate an instance of "%s".', DataInterface::class, self::class, WebSocketConnection::class));
throw new UnsupportedConnection(\sprintf('To send a "%s" implementation, "%s" must decorate an instance of "%s".', DataInterface::class, self::class, WebSocketConnection::class));
}

if ($this->connection instanceof WebSocketConnection) {
Expand Down
10 changes: 5 additions & 5 deletions src/WAMP/MessageHandler/DefaultMessageHandlerResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,29 @@ final class DefaultMessageHandlerResolver implements MessageHandlerResolver
public function findMessageHandler(WAMPMessageRequest $request): MessageHandler|MessageMiddleware
{
if (!$handler = $request->attributes->get('_controller')) {
throw new InvalidRequest(sprintf('Cannot resolve a message handler in "%s" when the "_controller" parameter is not set in the request attributes.', self::class));
throw new InvalidRequest(\sprintf('Cannot resolve a message handler in "%s" when the "_controller" parameter is not set in the request attributes.', self::class));
}

if ($handler instanceof MessageHandler || $handler instanceof MessageMiddleware) {
return $handler;
}

if (!\is_string($handler)) {
throw new InvalidRequest(sprintf('The "%s" class only supports strings or an instance of "%s" or "%s" as the "_controller" parameter in the request attributes, "%s" given.', self::class, MessageHandler::class, MessageMiddleware::class, get_debug_type($handler)));
throw new InvalidRequest(\sprintf('The "%s" class only supports strings or an instance of "%s" or "%s" as the "_controller" parameter in the request attributes, "%s" given.', self::class, MessageHandler::class, MessageMiddleware::class, get_debug_type($handler)));
}

if (!class_exists($handler)) {
throw new UnknownMessageHandler(sprintf('Message handler "%s" does not exist.', $handler));
throw new UnknownMessageHandler(\sprintf('Message handler "%s" does not exist.', $handler));
}

try {
$handler = new $handler();
} catch (\ArgumentCountError $exception) {
throw new CannotInstantiateMessageHandler($handler, sprintf('Cannot instantiate message handler "%s" in "%s", only handlers with no constructors can be instantiated by this resolver.', $handler, self::class), 0, $exception);
throw new CannotInstantiateMessageHandler($handler, \sprintf('Cannot instantiate message handler "%s" in "%s", only handlers with no constructors can be instantiated by this resolver.', $handler, self::class), 0, $exception);
}

if (!$handler instanceof MessageHandler && !$handler instanceof MessageMiddleware) {
throw new InvalidMessageHandler(sprintf('A message handler resolver can only return instances of "%s" or "%s", ensure "%s" implements the right interface.', MessageHandler::class, MessageMiddleware::class, $handler::class));
throw new InvalidMessageHandler(\sprintf('A message handler resolver can only return instances of "%s" or "%s", ensure "%s" implements the right interface.', MessageHandler::class, MessageMiddleware::class, $handler::class));
}

return $handler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ public function __construct(private ContainerInterface $container) {}
public function findMessageHandler(WAMPMessageRequest $request): MessageHandler|MessageMiddleware
{
if (!$handler = $request->attributes->get('_controller')) {
throw new InvalidRequest(sprintf('Cannot resolve a message handler in "%s" when the "_controller" parameter is not set in the request attributes.', self::class));
throw new InvalidRequest(\sprintf('Cannot resolve a message handler in "%s" when the "_controller" parameter is not set in the request attributes.', self::class));
}

if ($handler instanceof MessageHandler || $handler instanceof MessageMiddleware) {
return $handler;
}

if (!\is_string($handler)) {
throw new InvalidRequest(sprintf('The "%s" class only supports strings or an instance of "%s" or "%s" as the "_controller" parameter in the request attributes, "%s" given.', self::class, MessageHandler::class, MessageMiddleware::class, get_debug_type($handler)));
throw new InvalidRequest(\sprintf('The "%s" class only supports strings or an instance of "%s" or "%s" as the "_controller" parameter in the request attributes, "%s" given.', self::class, MessageHandler::class, MessageMiddleware::class, get_debug_type($handler)));
}

if (!$this->container->has($handler)) {
throw new UnknownMessageHandler(sprintf('A message handler for service ID "%s" does not exist in the container.', $handler));
throw new UnknownMessageHandler(\sprintf('A message handler for service ID "%s" does not exist in the container.', $handler));
}

$handler = $this->container->get($handler);

if (!$handler instanceof MessageHandler && !$handler instanceof MessageMiddleware) {
throw new InvalidMessageHandler(sprintf('A message handler resolver can only return instances of "%s" or "%s", "%s" returned.', MessageHandler::class, MessageMiddleware::class, get_debug_type($handler)));
throw new InvalidMessageHandler(\sprintf('A message handler resolver can only return instances of "%s" or "%s", "%s" returned.', MessageHandler::class, MessageMiddleware::class, get_debug_type($handler)));
}

return $handler;
Expand Down
Loading

0 comments on commit aada5c4

Please sign in to comment.