Skip to content

Commit

Permalink
Update to PHP 8.1 syntax (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
fre5h authored Jul 28, 2022
1 parent cb3e104 commit b693c5c
Show file tree
Hide file tree
Showing 20 changed files with 26 additions and 94 deletions.
5 changes: 1 addition & 4 deletions Attribute/JsonSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@
#[Attribute(Attribute::TARGET_CLASS)]
class JsonSchema
{
private readonly string $jsonSchemaName;

/**
* @param string $jsonSchemaName
*/
public function __construct(string $jsonSchemaName)
public function __construct(private readonly string $jsonSchemaName)
{
$this->jsonSchemaName = $jsonSchemaName;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions Event/User/AbstractUserEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@
*/
abstract class AbstractUserEvent extends Event
{
private readonly UserInterface $user;

/**
* @param UserInterface $user
*/
public function __construct(UserInterface $user)
public function __construct(private readonly UserInterface $user)
{
$this->user = $user;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions EventListener/JWT/JwtSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@ final class JwtSubscriber implements EventSubscriberInterface
{
private const ON_AUTHENTICATION_FAILURE_RESPONSE_FUNCTION = 'onAuthenticationFailureResponse';

private readonly TranslatorInterface $translator;

/**
* @param TranslatorInterface $translator
*/
public function __construct(TranslatorInterface $translator)
public function __construct(private readonly TranslatorInterface $translator)
{
$this->translator = $translator;
}

/**
Expand Down
7 changes: 2 additions & 5 deletions EventListener/JWT/TokenBlackListSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@
*/
final class TokenBlackListSubscriber implements EventSubscriberInterface
{
private readonly JwtBlackListService $jwtBlackListService;

/**
* @param JwtBlackListService $tokenBlackListService
*/
public function __construct(JwtBlackListService $tokenBlackListService)
public function __construct(private readonly JwtBlackListService $tokenBlackListService)
{
$this->jwtBlackListService = $tokenBlackListService;
}

/**
Expand All @@ -46,6 +43,6 @@ public static function getSubscribedEvents(): iterable
*/
public function addCurrentJwtTokenToBlackList(): void
{
$this->jwtBlackListService->addCurrentTokenToBlackList();
$this->tokenBlackListService->addCurrentTokenToBlackList();
}
}
11 changes: 1 addition & 10 deletions EventListener/Kernel/ApiExceptionFormatterListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,14 @@ final class ApiExceptionFormatterListener implements EventSubscriberInterface

private const PROD_ENV = 'prod';

private readonly string $apiHost;
private readonly string $environment;
private readonly ExceptionResponseProcessorInterface $exceptionResponseProcessor;
private readonly ExceptionResponseFactory $exceptionResponseFactory;

/**
* @param string $apiHost
* @param string $environment
* @param ExceptionResponseProcessorInterface $exceptionResponseProcessor
* @param ExceptionResponseFactory $exceptionResponseFactory
*/
public function __construct(string $apiHost, string $environment, ExceptionResponseProcessorInterface $exceptionResponseProcessor, ExceptionResponseFactory $exceptionResponseFactory)
public function __construct(private readonly string $apiHost, private readonly string $environment, private readonly ExceptionResponseProcessorInterface $exceptionResponseProcessor, private readonly ExceptionResponseFactory $exceptionResponseFactory)
{
$this->apiHost = $apiHost;
$this->environment = $environment;
$this->exceptionResponseProcessor = $exceptionResponseProcessor;
$this->exceptionResponseFactory = $exceptionResponseFactory;
}

/**
Expand Down
4 changes: 1 addition & 3 deletions EventListener/ORM/Aggregate/AggregatePartListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ final class AggregatePartListener
{
/** @var array<AggregateRootInterface> */
private array $aggregateRoots = [];
private readonly DateTimeHelper $dateTimeHelper;

/**
* @param DateTimeHelper $dateTimeHelper
*/
public function __construct(DateTimeHelper $dateTimeHelper)
public function __construct(private readonly DateTimeHelper $dateTimeHelper)
{
$this->dateTimeHelper = $dateTimeHelper;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions EventListener/Security/CheckVerifiedUserSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@
*/
final class CheckVerifiedUserSubscriber implements EventSubscriberInterface
{
private readonly JwtBlackListService $tokenBlackListService;

/**
* @param JwtBlackListService $tokenBlackListService
*/
public function __construct(JwtBlackListService $tokenBlackListService)
public function __construct(private readonly JwtBlackListService $tokenBlackListService)
{
$this->tokenBlackListService = $tokenBlackListService;
}

/**
Expand Down
7 changes: 1 addition & 6 deletions Request/DtoExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,12 @@
*/
class DtoExtractor
{
private readonly DtoAttributeProcessor $dtoAttributeProcessor;
private readonly SerializerInterface $serializer;

/**
* @param DtoAttributeProcessor $dtoAttributeProcessor
* @param SerializerInterface $serializer
*/
public function __construct(DtoAttributeProcessor $dtoAttributeProcessor, SerializerInterface $serializer)
public function __construct(private readonly DtoAttributeProcessor $dtoAttributeProcessor, private readonly SerializerInterface $serializer)
{
$this->dtoAttributeProcessor = $dtoAttributeProcessor;
$this->serializer = $serializer;
}

/**
Expand Down
8 changes: 1 addition & 7 deletions Security/JwtBlackListService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,15 @@
*/
class JwtBlackListService
{
private readonly JWSProviderInterface $jwsProvider;
private readonly JwtTokenHelper $jwtTokenHelper;
private readonly JwtCacheHelper $jwtCacheHelper;
private Client $redisClientJwtBlackList;

/**
* @param JWSProviderInterface $jwsProvider
* @param JwtTokenHelper $jwtTokenHelper
* @param JwtCacheHelper $jwtCacheHelper
*/
public function __construct(JWSProviderInterface $jwsProvider, JwtTokenHelper $jwtTokenHelper, JwtCacheHelper $jwtCacheHelper)
public function __construct(private readonly JWSProviderInterface $jwsProvider, private readonly JwtTokenHelper $jwtTokenHelper, private readonly JwtCacheHelper $jwtCacheHelper)
{
$this->jwsProvider = $jwsProvider;
$this->jwtTokenHelper = $jwtTokenHelper;
$this->jwtCacheHelper = $jwtCacheHelper;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions Security/JwtTokenHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@
*/
class JwtTokenHelper
{
private readonly TokenStorageInterface $tokenStorage;

/**
* @param TokenStorageInterface $tokenStorage
*/
public function __construct(TokenStorageInterface $tokenStorage)
public function __construct(private readonly TokenStorageInterface $tokenStorage)
{
$this->tokenStorage = $tokenStorage;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions Serializer/Normalizer/ConstraintViolationListNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@
*/
class ConstraintViolationListNormalizer implements NormalizerInterface
{
private SymfonyConstraintViolationListNormalizer $symfonyConstraintViolationListNormalizer;

/**
* @param SymfonyConstraintViolationListNormalizer $symfonyConstraintViolationListNormalizer
*/
public function __construct(SymfonyConstraintViolationListNormalizer $symfonyConstraintViolationListNormalizer)
public function __construct(private readonly SymfonyConstraintViolationListNormalizer $symfonyConstraintViolationListNormalizer)
{
$this->symfonyConstraintViolationListNormalizer = $symfonyConstraintViolationListNormalizer;
}

/**
Expand Down
8 changes: 2 additions & 6 deletions Serializer/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@ class Serializer
{
public const DEFAULT_FORMAT = 'json';

/** @var SerializerInterface|BaseSerializer */
protected readonly SerializerInterface|BaseSerializer $symfonySerializer;

/**
* @param SerializerInterface|BaseSerializer $serializer
* @param SerializerInterface|BaseSerializer $symfonySerializer
*/
public function __construct(SerializerInterface|BaseSerializer $serializer)
public function __construct(protected readonly SerializerInterface|BaseSerializer $symfonySerializer)
{
$this->symfonySerializer = $serializer;
}

/**
Expand Down
9 changes: 1 addition & 8 deletions Service/AttributeProcessor/JsonSchemaAttributeProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ class JsonSchemaAttributeProcessor
{
private const JSON_FILE_EXTENSION = '.json';

private readonly DtoAttributeProcessor $dtoAttributeProcessor;
private readonly FileReader $fileReader;
private readonly string $jsonSchemaDir;

/** @var array */
private array $cachedClasses = [];

Expand All @@ -36,11 +32,8 @@ class JsonSchemaAttributeProcessor
* @param FileReader $fileReader
* @param string $jsonSchemaDir
*/
public function __construct(DtoAttributeProcessor $dtoAttributeProcessor, FileReader $fileReader, string $jsonSchemaDir)
public function __construct(private readonly DtoAttributeProcessor $dtoAttributeProcessor, private readonly FileReader $fileReader, private readonly string $jsonSchemaDir)
{
$this->dtoAttributeProcessor = $dtoAttributeProcessor;
$this->fileReader = $fileReader;
$this->jsonSchemaDir = $jsonSchemaDir;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@
*/
class ExceptionResponseProcessor implements ExceptionResponseProcessorInterface
{
/** @var CustomAppExceptionResponseProcessorInterface[]|iterable */
private readonly iterable $errorResponseProcessors;

/**
* @param iterable|CustomAppExceptionResponseProcessorInterface[] $errorResponseProcessors
*/
public function __construct(iterable $errorResponseProcessors)
public function __construct(private readonly iterable $errorResponseProcessors)
{
$this->errorResponseProcessors = $errorResponseProcessors;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace StfalconStudio\ApiBundle\Service\Exception\ResponseProcessor;

use JetBrains\PhpStorm\ArrayShape;
use StfalconStudio\ApiBundle\Exception\CustomAppExceptionInterface;
use StfalconStudio\ApiBundle\Exception\Http\Validation\InvalidEntityException;
use StfalconStudio\ApiBundle\Exception\RuntimeException;
Expand All @@ -32,6 +33,7 @@ public function supports(CustomAppExceptionInterface $exception): bool
/**
* {@inheritdoc}
*/
#[ArrayShape(['violations' => 'mixed'])]
public function processResponse(CustomAppExceptionInterface $exception): array
{
if (!$exception instanceof InvalidEntityException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace StfalconStudio\ApiBundle\Service\Exception\ResponseProcessor;

use JetBrains\PhpStorm\ArrayShape;
use StfalconStudio\ApiBundle\Exception\CustomAppExceptionInterface;
use StfalconStudio\ApiBundle\Exception\Http\Json\InvalidJsonSchemaException;
use StfalconStudio\ApiBundle\Exception\RuntimeException;
Expand All @@ -21,14 +22,11 @@
*/
class InvalidJsonSchemaExceptionProcessor implements CustomAppExceptionResponseProcessorInterface
{
private readonly string $environment;

/**
* @param string $environment
*/
public function __construct(string $environment)
public function __construct(private readonly string $environment)
{
$this->environment = $environment;
}

/**
Expand All @@ -42,6 +40,7 @@ public function supports(CustomAppExceptionInterface $exception): bool
/**
* {@inheritdoc}
*/
#[ArrayShape(['violations' => 'mixed', 'jsonSchema' => 'mixed'])]
public function processResponse(CustomAppExceptionInterface $exception): array
{
if (!$exception instanceof InvalidJsonSchemaException) {
Expand Down
2 changes: 1 addition & 1 deletion Traits/SymfonySerializerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
trait SymfonySerializerTrait
{
/** @var SerializerInterface|Serializer */
protected SerializerInterface $symfonySerializer;
protected SerializerInterface|Serializer $symfonySerializer;

/**
* @param SerializerInterface|Serializer $symfonySerializer
Expand Down
5 changes: 1 addition & 4 deletions Util/Canonical/Canonicalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@
*/
class Canonicalizer
{
private readonly EncodingDetector $encodingDetector;

/**
* @param EncodingDetector $encodingDetector
*/
public function __construct(EncodingDetector $encodingDetector)
public function __construct(private readonly EncodingDetector $encodingDetector)
{
$this->encodingDetector = $encodingDetector;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@
*/
class PasswordMeetSpecialRequirementsValidator extends ConstraintValidator
{
private readonly PasswordRequirementsValidator $passwordRequirementsValidator;

/**
* @param PasswordRequirementsValidator $passwordRequirementsValidator
*/
public function __construct(PasswordRequirementsValidator $passwordRequirementsValidator)
public function __construct(private readonly PasswordRequirementsValidator $passwordRequirementsValidator)
{
$this->passwordRequirementsValidator = $passwordRequirementsValidator;
}

/**
Expand Down
9 changes: 2 additions & 7 deletions Validator/JsonSchemaValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,12 @@ class JsonSchemaValidator
{
use Traits\SymfonySerializerTrait;

private readonly Validator $validator;
private readonly JsonSchemaAttributeProcessor $jsonSchemaAttributeProcessor;

/**
* @param Validator $validator
* @param JsonSchemaAttributeProcessor $dtoAttributeProcessor
* @param JsonSchemaAttributeProcessor $jsonSchemaAttributeProcessor
*/
public function __construct(Validator $validator, JsonSchemaAttributeProcessor $dtoAttributeProcessor)
public function __construct(private readonly Validator $validator, private readonly JsonSchemaAttributeProcessor $jsonSchemaAttributeProcessor)
{
$this->validator = $validator;
$this->jsonSchemaAttributeProcessor = $dtoAttributeProcessor;
}

/**
Expand Down

0 comments on commit b693c5c

Please sign in to comment.