Skip to content

Commit

Permalink
Mark most of the classes readonly (BC break)
Browse files Browse the repository at this point in the history
  • Loading branch information
xificurk committed Jan 10, 2024
1 parent 8b55d00 commit f40ca66
Show file tree
Hide file tree
Showing 24 changed files with 38 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/MessageBus/Commands/CommandHandlerLocator.php
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\Messenger\Handler\HandlerDescriptor;
use Symfony\Component\Messenger\Handler\HandlersLocatorInterface;

final class CommandHandlerLocator implements HandlersLocatorInterface
final readonly class CommandHandlerLocator implements HandlersLocatorInterface
{

private ContainerInterface $container;
Expand Down
2 changes: 1 addition & 1 deletion src/MessageBus/Commands/MessengerCommandBus.php
Expand Up @@ -6,7 +6,7 @@
use Symfony\Component\Messenger\Exception\HandlerFailedException;
use Symfony\Component\Messenger\MessageBusInterface;

final class MessengerCommandBus implements CommandBus
final readonly class MessengerCommandBus implements CommandBus
{

private MessageBusInterface $messageBus;
Expand Down
2 changes: 1 addition & 1 deletion src/MessageBus/Events/EventSubscribersLocator.php
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\Messenger\Handler\HandlerDescriptor;
use Symfony\Component\Messenger\Handler\HandlersLocatorInterface;

final class EventSubscribersLocator implements HandlersLocatorInterface
final readonly class EventSubscribersLocator implements HandlersLocatorInterface
{

private ContainerInterface $container;
Expand Down
2 changes: 1 addition & 1 deletion src/MessageBus/Events/MessengerEventDispatcher.php
Expand Up @@ -6,7 +6,7 @@
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Messenger\Stamp\DispatchAfterCurrentBusStamp;

final class MessengerEventDispatcher implements EventDispatcher
final readonly class MessengerEventDispatcher implements EventDispatcher
{

private MessageBusInterface $messageBus;
Expand Down
2 changes: 1 addition & 1 deletion src/MessageBus/Logging/LogMessageResolver.php
Expand Up @@ -7,7 +7,7 @@
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Exception\HandlerFailedException;

final class LogMessageResolver
final readonly class LogMessageResolver
{

public function getHandlingStartedMessage(Envelope $envelope): string
Expand Down
2 changes: 1 addition & 1 deletion src/MessageBus/Logging/MessageContextResolver.php
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\Messenger\Exception\HandlerFailedException;
use Symfony\Component\Messenger\Stamp\HandledStamp;

final class MessageContextResolver
final readonly class MessageContextResolver
{

private string $keyPrefix;
Expand Down
2 changes: 1 addition & 1 deletion src/MessageBus/Logging/PrivateClassPropertiesExtractor.php
Expand Up @@ -3,7 +3,7 @@

namespace Nepada\MessageBus\Logging;

final class PrivateClassPropertiesExtractor
final readonly class PrivateClassPropertiesExtractor
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/MessageBus/Middleware/LoggingMiddleware.php
Expand Up @@ -12,7 +12,7 @@
use Symfony\Component\Messenger\Middleware\MiddlewareInterface;
use Symfony\Component\Messenger\Middleware\StackInterface;

final class LoggingMiddleware implements MiddlewareInterface
final readonly class LoggingMiddleware implements MiddlewareInterface
{

private LogMessageResolver $logMessageResolver;
Expand Down
Expand Up @@ -14,7 +14,7 @@
use Nepada\MessageBus\StaticAnalysis\Rules\MethodReturnTypeIsVoidRule;
use Nepada\MessageBus\StaticAnalysis\Rules\ShortClassNameMatchesRule;

final class ConfigurableHandlerValidator implements MessageHandlerValidator
final readonly class ConfigurableHandlerValidator implements MessageHandlerValidator
{

private MessageHandlerValidationConfiguration $configuration;
Expand Down
2 changes: 1 addition & 1 deletion src/MessageBus/StaticAnalysis/HandlerType.php
Expand Up @@ -9,7 +9,7 @@
/**
* @template T of CommandHandler|EventSubscriber
*/
final class HandlerType
final readonly class HandlerType
{

/**
Expand Down
Expand Up @@ -6,7 +6,7 @@
use Nepada\MessageBus\Commands\Command;
use Nepada\MessageBus\Events\Event;

class MessageHandlerValidationConfiguration
readonly class MessageHandlerValidationConfiguration
{

private bool $handlerClassMustBeFinal;
Expand Down Expand Up @@ -48,30 +48,24 @@ public function __construct(

public static function command(bool $bleedingEdge = false): self
{
$configuration = new self();

$configuration->handleMethodParameterName = 'command';
$configuration->handleMethodParameterType = Command::class;

$configuration->messageClassSuffix = 'Command';
$configuration->handlerClassSuffix = 'Handler';
$configuration->handlerClassPrefixRegex = '';

return $configuration;
return new self(
handleMethodParameterName: 'command',
handleMethodParameterType: Command::class,
messageClassSuffix: 'Command',
handlerClassSuffix: 'Handler',
handlerClassPrefixRegex: '',
);
}

public static function event(bool $bleedingEdge = false): self
{
$configuration = new self();

$configuration->handleMethodParameterName = 'event';
$configuration->handleMethodParameterType = Event::class;

$configuration->messageClassSuffix = 'Event';
$configuration->handlerClassSuffix = '';
$configuration->handlerClassPrefixRegex = '(.+)On';

return $configuration;
return new self(
handleMethodParameterName: 'event',
handleMethodParameterType: Event::class,
messageClassSuffix: 'Event',
handlerClassSuffix: '',
handlerClassPrefixRegex: '(.+)On',
);
}

public function shouldHandlerClassBeFinal(): bool
Expand Down
2 changes: 1 addition & 1 deletion src/MessageBus/StaticAnalysis/MessageType.php
Expand Up @@ -7,7 +7,7 @@
use Nepada\MessageBus\Events\Event;
use Nepada\MessageBus\StaticAnalysis\Rules\ClassNameHasSuffixRule;

final class MessageType
final readonly class MessageType
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/MessageBus/StaticAnalysis/MessageTypeExtractor.php
Expand Up @@ -6,7 +6,7 @@
use Nepada\MessageBus\Commands\CommandHandler;
use Nepada\MessageBus\Events\EventSubscriber;

final class MessageTypeExtractor
final readonly class MessageTypeExtractor
{

public const METHOD_NAME = '__invoke';
Expand Down
2 changes: 1 addition & 1 deletion src/MessageBus/StaticAnalysis/ReflectionHelper.php
Expand Up @@ -3,7 +3,7 @@

namespace Nepada\MessageBus\StaticAnalysis;

final class ReflectionHelper
final readonly class ReflectionHelper
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/MessageBus/StaticAnalysis/Rules/ClassExistsRule.php
Expand Up @@ -6,7 +6,7 @@
use Nepada\MessageBus\StaticAnalysis\ReflectionHelper;
use Nepada\MessageBus\StaticAnalysis\StaticAnalysisFailedException;

final class ClassExistsRule
final readonly class ClassExistsRule
{

/**
Expand Down
Expand Up @@ -6,7 +6,7 @@
use Nepada\MessageBus\StaticAnalysis\ReflectionHelper;
use Nepada\MessageBus\StaticAnalysis\StaticAnalysisFailedException;

final class ClassHasPublicMethodRule
final readonly class ClassHasPublicMethodRule
{

private string $methodName;
Expand Down
2 changes: 1 addition & 1 deletion src/MessageBus/StaticAnalysis/Rules/ClassIsFinalRule.php
Expand Up @@ -6,7 +6,7 @@
use Nepada\MessageBus\StaticAnalysis\ReflectionHelper;
use Nepada\MessageBus\StaticAnalysis\StaticAnalysisFailedException;

final class ClassIsFinalRule
final readonly class ClassIsFinalRule
{

/**
Expand Down
Expand Up @@ -6,7 +6,7 @@
use Nepada\MessageBus\StaticAnalysis\ReflectionHelper;
use Nepada\MessageBus\StaticAnalysis\StaticAnalysisFailedException;

final class ClassIsReadOnlyRule
final readonly class ClassIsReadOnlyRule
{

/**
Expand Down
Expand Up @@ -6,7 +6,7 @@
use Nepada\MessageBus\StaticAnalysis\ReflectionHelper;
use Nepada\MessageBus\StaticAnalysis\StaticAnalysisFailedException;

final class ClassNameHasSuffixRule
final readonly class ClassNameHasSuffixRule
{

private string $suffix;
Expand Down
Expand Up @@ -6,7 +6,7 @@
use Nepada\MessageBus\StaticAnalysis\StaticAnalysisFailedException;
use ReflectionMethod;

final class MethodHasOneParameterRule
final readonly class MethodHasOneParameterRule
{

/**
Expand Down
Expand Up @@ -6,7 +6,7 @@
use Nepada\MessageBus\StaticAnalysis\StaticAnalysisFailedException;
use ReflectionParameter;

final class MethodParameterNameMatchesRule
final readonly class MethodParameterNameMatchesRule
{

private string $parameterName;
Expand Down
Expand Up @@ -6,7 +6,7 @@
use Nepada\MessageBus\StaticAnalysis\StaticAnalysisFailedException;
use ReflectionParameter;

final class MethodParameterTypeMatchesRule
final readonly class MethodParameterTypeMatchesRule
{

private string $parameterType;
Expand Down
Expand Up @@ -5,7 +5,7 @@

use Nepada\MessageBus\StaticAnalysis\StaticAnalysisFailedException;

final class MethodReturnTypeIsVoidRule
final readonly class MethodReturnTypeIsVoidRule
{

/**
Expand Down
Expand Up @@ -6,7 +6,7 @@
use Nepada\MessageBus\StaticAnalysis\ReflectionHelper;
use Nepada\MessageBus\StaticAnalysis\StaticAnalysisFailedException;

final class ShortClassNameMatchesRule
final readonly class ShortClassNameMatchesRule
{

private string $regexPattern;
Expand Down

0 comments on commit f40ca66

Please sign in to comment.