From 6353f5efab185bfe8fa0a67e0efdd966891e1dce Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 21 Jul 2023 18:41:43 +0200 Subject: [PATCH] Add types to private and internal properties --- .../Messenger/AbstractDoctrineMiddleware.php | 4 +- ...octrineOpenTransactionLoggerMiddleware.php | 7 ++- .../Command/ServerDumpPlaceholderCommand.php | 2 +- .../Console/Descriptor/Descriptor.php | 5 +- .../Controller/ExceptionPanelController.php | 4 +- .../Controller/ProfilerController.php | 15 +++--- .../Controller/RouterController.php | 10 ++-- .../Csp/ContentSecurityPolicyHandler.php | 4 +- .../Profiler/TemplateManager.php | 6 +-- .../Twig/WebProfilerExtension.php | 10 +--- .../Exception/AssetNotFoundException.php | 2 +- .../Compiler/CssAssetUrlCompiler.php | 8 +-- .../Compiler/JavaScriptImportPathCompiler.php | 8 +-- .../Component/BrowserKit/AbstractBrowser.php | 43 ++++----------- .../Cache/Adapter/AbstractAdapter.php | 3 +- .../Component/Cache/Adapter/NullAdapter.php | 2 +- src/Symfony/Component/Cache/LockRegistry.php | 10 ++-- .../Config/Definition/Builder/TreeBuilder.php | 6 +-- .../Console/Command/CompleteCommand.php | 4 +- .../Console/Completion/CompletionInput.php | 10 ++-- .../Completion/CompletionSuggestions.php | 4 +- .../Tester/CommandCompletionTester.php | 2 +- .../AttributeAutoconfigurationPass.php | 8 +-- .../RegisterAutoconfigureAttributesPass.php | 4 +- .../DependencyInjection/Container.php | 2 +- .../Component/Dotenv/Command/DebugCommand.php | 4 +- .../Component/ErrorHandler/ErrorHandler.php | 1 + .../ExpressionLanguage/Node/ArrayNode.php | 2 +- .../Component/ExpressionLanguage/Token.php | 4 +- .../Component/Filesystem/Filesystem.php | 2 +- src/Symfony/Component/Filesystem/Path.php | 7 +-- .../Iterator/VcsIgnoredFilterIterator.php | 9 ++-- .../Form/ChoiceList/View/ChoiceListView.php | 4 +- .../HttpClient/Internal/PushedResponse.php | 21 +++----- .../HttpClient/Response/AsyncResponse.php | 4 +- .../HttpClient/Response/CurlResponse.php | 2 +- .../HttpClient/Response/StreamWrapper.php | 2 +- .../HttpClient/RetryableHttpClient.php | 7 ++- .../Component/HttpFoundation/Request.php | 2 +- .../Component/HttpFoundation/Response.php | 6 --- .../Component/HttpKernel/Bundle/Bundle.php | 6 +-- .../EventListener/AbstractSessionListener.php | 4 +- .../Fragment/RoutableFragmentRenderer.php | 2 +- .../Ldap/Adapter/ExtLdap/Connection.php | 8 +-- .../Ldap/Adapter/ExtLdap/EntryManager.php | 14 ++--- .../Component/Ldap/Adapter/ExtLdap/Query.php | 40 +++----------- .../Adapter/ExtLdap/EntryManagerTest.php | 3 -- src/Symfony/Component/Lock/Lock.php | 43 +++++++-------- src/Symfony/Component/Lock/LockFactory.php | 14 +++-- .../Component/Lock/Store/CombinedStore.php | 20 ++++--- .../Store/DoctrineDbalPostgreSqlStore.php | 2 +- .../Transport/PostmarkApiTransport.php | 2 +- .../Transport/PostmarkSmtpTransport.php | 2 +- .../Bridge/Doctrine/Transport/Connection.php | 7 +-- .../Command/AbstractFailedMessagesCommand.php | 2 +- .../Middleware/HandleMessageMiddleware.php | 17 +++--- .../Middleware/SendMessageMiddleware.php | 20 +++---- .../Component/Messenger/Stamp/AckStamp.php | 8 ++- .../Stamp/FlushBatchHandlersStamp.php | 2 +- .../Messenger/Stamp/NoAutoAckStamp.php | 2 +- .../Mime/Part/AbstractMultipartPart.php | 4 +- src/Symfony/Component/Mime/Part/DataPart.php | 10 ++-- src/Symfony/Component/Mime/Part/File.php | 2 +- .../Component/Mime/Part/MessagePart.php | 2 +- .../Mime/Part/Multipart/FormDataPart.php | 2 +- .../Mime/Part/Multipart/RelatedPart.php | 2 +- src/Symfony/Component/Mime/Part/SMimePart.php | 12 ++--- src/Symfony/Component/Mime/Part/TextPart.php | 21 +++----- src/Symfony/Component/Mime/RawMessage.php | 2 +- .../Bridge/Engagespot/EngagespotTransport.php | 4 +- .../Notifier/Bridge/Expo/ExpoOptions.php | 6 +-- .../Notifier/Bridge/Expo/ExpoTransport.php | 3 +- .../Bridge/Mattermost/MattermostOptions.php | 2 +- .../Bridge/OneSignal/OneSignalOptions.php | 2 +- .../Bridge/OneSignal/OneSignalTransport.php | 6 +-- .../Notifier/Bridge/Sms77/Sms77Transport.php | 4 +- .../Bridge/Twitter/TwitterTransport.php | 2 +- .../Bridge/Vonage/VonageTransport.php | 6 +-- .../Notifier/Message/PushMessage.php | 10 ++-- .../Test/Constraint/NotificationCount.php | 6 +-- .../NotificationSubjectContains.php | 2 +- .../NotificationTransportIsEqual.php | 2 +- .../Debug/OptionsResolverIntrospector.php | 2 +- .../OptionsResolver/OptionConfigurator.php | 4 +- .../OptionsResolver/OptionsResolver.php | 34 ++++++------ .../Exception/ProcessFailedException.php | 2 +- .../Exception/ProcessSignaledException.php | 2 +- .../Exception/ProcessTimedOutException.php | 4 +- .../Component/Process/ExecutableFinder.php | 2 +- src/Symfony/Component/Process/InputStream.php | 9 ++-- .../Component/Process/PhpExecutableFinder.php | 2 +- .../Component/Process/Pipes/AbstractPipes.php | 6 +-- .../Component/Process/Pipes/UnixPipes.php | 6 +-- .../Component/Process/Pipes/WindowsPipes.php | 10 ++-- src/Symfony/Component/Process/Process.php | 54 +++++++++---------- .../PropertyAccess/PropertyAccessor.php | 33 ++++-------- .../PropertyAccessorBuilder.php | 25 +++------ .../Component/PropertyAccess/PropertyPath.php | 14 ++--- .../PropertyAccess/PropertyPathBuilder.php | 4 +- .../Extractor/ConstructorExtractor.php | 8 ++- .../Extractor/PhpDocExtractor.php | 18 +++---- .../Extractor/PhpStanExtractor.php | 21 +++----- .../Extractor/ReflectionExtractor.php | 21 ++++---- .../Extractor/SerializerExtractor.php | 8 ++- .../PropertyInfo/PhpStan/NameScope.php | 6 +-- .../PropertyInfoCacheExtractor.php | 12 ++--- .../PropertyInfo/PropertyInfoExtractor.php | 20 +++---- .../PropertyInfo/PropertyReadInfo.php | 24 +++------ .../PropertyInfo/PropertyWriteInfo.php | 24 ++++----- src/Symfony/Component/PropertyInfo/Type.php | 12 ++--- .../Dumper/CompiledUrlMatcherTrait.php | 6 +-- .../Component/Routing/Matcher/UrlMatcher.php | 2 +- .../Component/Routing/RouteCollection.php | 2 +- .../Runtime/Internal/ComposerPlugin.php | 13 ++--- .../Runtime/Resolver/ClosureResolver.php | 11 ++-- .../Runtime/Runner/ClosureRunner.php | 8 ++- .../Symfony/ConsoleApplicationRunner.php | 17 +++--- .../Runner/Symfony/HttpKernelRunner.php | 11 ++-- .../Runtime/Runner/Symfony/ResponseRunner.php | 8 ++- .../Component/Runtime/SymfonyRuntime.php | 12 ++--- .../Test/AccessDecisionStrategyTestCase.php | 2 +- .../Http/Authenticator/Passport/Passport.php | 10 ++-- src/Symfony/Component/Semaphore/Key.php | 10 ++-- src/Symfony/Component/Semaphore/Semaphore.php | 27 +++++----- .../Component/Semaphore/SemaphoreFactory.php | 14 +++-- .../Serializer/Encoder/JsonEncoder.php | 2 +- .../Normalizer/GetSetMethodNormalizer.php | 2 +- .../String/AbstractUnicodeString.php | 6 +-- .../Catalogue/AbstractOperation.php | 9 ++-- .../Translation/Formatter/IntlFormatter.php | 4 +- .../Translation/Loader/YamlFileLoader.php | 4 +- .../TranslationProviderCollection.php | 2 +- .../Validator/Constraints/CssColor.php | 2 +- .../Validator/Mapping/ClassMetadata.php | 26 ++++----- .../Validator/Mapping/GenericMetadata.php | 22 +++----- .../Mapping/Loader/XmlFileLoader.php | 4 +- .../Validator/Mapping/MemberMetadata.php | 6 +-- .../HttpClient/Test/TestHttpServer.php | 2 +- .../Translation/Test/TranslatorTest.php | 2 +- 139 files changed, 484 insertions(+), 739 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Messenger/AbstractDoctrineMiddleware.php b/src/Symfony/Bridge/Doctrine/Messenger/AbstractDoctrineMiddleware.php index 9fbf2deb963e3..95fcf21d210bb 100644 --- a/src/Symfony/Bridge/Doctrine/Messenger/AbstractDoctrineMiddleware.php +++ b/src/Symfony/Bridge/Doctrine/Messenger/AbstractDoctrineMiddleware.php @@ -25,8 +25,8 @@ */ abstract class AbstractDoctrineMiddleware implements MiddlewareInterface { - protected $managerRegistry; - protected $entityManagerName; + protected ManagerRegistry $managerRegistry; + protected ?string $entityManagerName; public function __construct(ManagerRegistry $managerRegistry, string $entityManagerName = null) { diff --git a/src/Symfony/Bridge/Doctrine/Messenger/DoctrineOpenTransactionLoggerMiddleware.php b/src/Symfony/Bridge/Doctrine/Messenger/DoctrineOpenTransactionLoggerMiddleware.php index 246f0090e58ef..31c83d8e2afc0 100644 --- a/src/Symfony/Bridge/Doctrine/Messenger/DoctrineOpenTransactionLoggerMiddleware.php +++ b/src/Symfony/Bridge/Doctrine/Messenger/DoctrineOpenTransactionLoggerMiddleware.php @@ -14,7 +14,6 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\Persistence\ManagerRegistry; use Psr\Log\LoggerInterface; -use Psr\Log\NullLogger; use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\Middleware\StackInterface; @@ -25,13 +24,13 @@ */ class DoctrineOpenTransactionLoggerMiddleware extends AbstractDoctrineMiddleware { - private $logger; + private ?LoggerInterface $logger; public function __construct(ManagerRegistry $managerRegistry, string $entityManagerName = null, LoggerInterface $logger = null) { parent::__construct($managerRegistry, $entityManagerName); - $this->logger = $logger ?? new NullLogger(); + $this->logger = $logger; } protected function handleForManager(EntityManagerInterface $entityManager, Envelope $envelope, StackInterface $stack): Envelope @@ -40,7 +39,7 @@ protected function handleForManager(EntityManagerInterface $entityManager, Envel return $stack->next()->handle($envelope, $stack); } finally { if ($entityManager->getConnection()->isTransactionActive()) { - $this->logger->error('A handler opened a transaction but did not close it.', [ + $this->logger?->error('A handler opened a transaction but did not close it.', [ 'message' => $envelope->getMessage(), ]); } diff --git a/src/Symfony/Bundle/DebugBundle/Command/ServerDumpPlaceholderCommand.php b/src/Symfony/Bundle/DebugBundle/Command/ServerDumpPlaceholderCommand.php index f0cffcd238ece..44023876fbf07 100644 --- a/src/Symfony/Bundle/DebugBundle/Command/ServerDumpPlaceholderCommand.php +++ b/src/Symfony/Bundle/DebugBundle/Command/ServerDumpPlaceholderCommand.php @@ -29,7 +29,7 @@ #[AsCommand(name: 'server:dump', description: 'Start a dump server that collects and displays dumps in a single place')] class ServerDumpPlaceholderCommand extends Command { - private $replacedCommand; + private ServerDumpCommand $replacedCommand; public function __construct(DumpServer $server = null, array $descriptors = []) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php index f4de2f09192da..260601908949a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php @@ -33,10 +33,7 @@ */ abstract class Descriptor implements DescriptorInterface { - /** - * @var OutputInterface - */ - protected $output; + protected OutputInterface $output; public function describe(OutputInterface $output, mixed $object, array $options = []): void { diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionPanelController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionPanelController.php index 4941208c88bc2..1e3168bafc44b 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionPanelController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionPanelController.php @@ -25,8 +25,8 @@ */ class ExceptionPanelController { - private $errorRenderer; - private $profiler; + private HtmlErrorRenderer $errorRenderer; + private ?Profiler $profiler; public function __construct(HtmlErrorRenderer $errorRenderer, Profiler $profiler = null) { diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index 4f0e052226c92..5431c239d0ec0 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -32,13 +32,13 @@ */ class ProfilerController { - private $templateManager; - private $generator; - private $profiler; - private $twig; - private $templates; - private $cspHandler; - private $baseDir; + private TemplateManager $templateManager; + private UrlGeneratorInterface $generator; + private ?Profiler $profiler; + private Environment $twig; + private array $templates; + private ?ContentSecurityPolicyHandler $cspHandler; + private ?string $baseDir; public function __construct(UrlGeneratorInterface $generator, Profiler $profiler = null, Environment $twig, array $templates, ContentSecurityPolicyHandler $cspHandler = null, string $baseDir = null) { @@ -174,7 +174,6 @@ public function searchBarAction(Request $request): Response $this->cspHandler?->disableCsp(); - $session = null; if ($request->attributes->getBoolean('_stateless') && $request->hasSession()) { $session = $request->getSession(); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php index 50560e0b3ffa1..29a239715a67c 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php @@ -30,15 +30,15 @@ */ class RouterController { - private $profiler; - private $twig; - private $matcher; - private $routes; + private ?Profiler $profiler; + private Environment $twig; + private ?UrlMatcherInterface $matcher; + private ?RouteCollection $routes; /** * @var ExpressionFunctionProviderInterface[] */ - private $expressionLanguageProviders = []; + private iterable $expressionLanguageProviders; public function __construct(Profiler $profiler = null, Environment $twig, UrlMatcherInterface $matcher = null, RouteCollection $routes = null, iterable $expressionLanguageProviders = []) { diff --git a/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php b/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php index 4cc0f8db1efe0..f7d8f5f1590b7 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php @@ -23,8 +23,8 @@ */ class ContentSecurityPolicyHandler { - private $nonceGenerator; - private $cspDisabled = false; + private NonceGenerator $nonceGenerator; + private bool $cspDisabled = false; public function __construct(NonceGenerator $nonceGenerator) { diff --git a/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php b/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php index 00b83866f9c8c..c75158c97388f 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php @@ -24,9 +24,9 @@ */ class TemplateManager { - protected $twig; - protected $templates; - protected $profiler; + protected Environment $twig; + protected array $templates; + protected Profiler $profiler; public function __construct(Profiler $profiler, Environment $twig, array $templates) { diff --git a/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php b/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php index 9d7ebfcfb91eb..60470b080acaf 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php @@ -27,20 +27,14 @@ */ class WebProfilerExtension extends ProfilerExtension { - /** - * @var HtmlDumper - */ - private $dumper; + private HtmlDumper $dumper; /** * @var resource */ private $output; - /** - * @var int - */ - private $stackLevel = 0; + private int $stackLevel = 0; public function __construct(HtmlDumper $dumper = null) { diff --git a/src/Symfony/Component/Asset/Exception/AssetNotFoundException.php b/src/Symfony/Component/Asset/Exception/AssetNotFoundException.php index f60ad306377af..ac3d2fa8f37bd 100644 --- a/src/Symfony/Component/Asset/Exception/AssetNotFoundException.php +++ b/src/Symfony/Component/Asset/Exception/AssetNotFoundException.php @@ -16,7 +16,7 @@ */ class AssetNotFoundException extends RuntimeException { - private $alternatives; + private array $alternatives; /** * @param string $message Exception message to throw diff --git a/src/Symfony/Component/AssetMapper/Compiler/CssAssetUrlCompiler.php b/src/Symfony/Component/AssetMapper/Compiler/CssAssetUrlCompiler.php index 535304841133c..e8d48e6306edf 100644 --- a/src/Symfony/Component/AssetMapper/Compiler/CssAssetUrlCompiler.php +++ b/src/Symfony/Component/AssetMapper/Compiler/CssAssetUrlCompiler.php @@ -12,7 +12,6 @@ namespace Symfony\Component\AssetMapper\Compiler; use Psr\Log\LoggerInterface; -use Psr\Log\NullLogger; use Symfony\Component\AssetMapper\AssetDependency; use Symfony\Component\AssetMapper\AssetMapperInterface; use Symfony\Component\AssetMapper\Exception\RuntimeException; @@ -29,16 +28,13 @@ final class CssAssetUrlCompiler implements AssetCompilerInterface { use AssetCompilerPathResolverTrait; - private readonly LoggerInterface $logger; - // https://regex101.com/r/BOJ3vG/1 public const ASSET_URL_PATTERN = '/url\(\s*["\']?(?!(?:\/|\#|%23|data|http|\/\/))([^"\'\s?#)]+)([#?][^"\')]+)?\s*["\']?\)/'; public function __construct( private readonly string $missingImportMode = self::MISSING_IMPORT_WARN, - LoggerInterface $logger = null, + private readonly ?LoggerInterface $logger = null, ) { - $this->logger = $logger ?? new NullLogger(); } public function compile(string $content, MappedAsset $asset, AssetMapperInterface $assetMapper): string @@ -76,7 +72,7 @@ private function handleMissingImport(string $message, \Throwable $e = null): voi { match ($this->missingImportMode) { AssetCompilerInterface::MISSING_IMPORT_IGNORE => null, - AssetCompilerInterface::MISSING_IMPORT_WARN => $this->logger->warning($message), + AssetCompilerInterface::MISSING_IMPORT_WARN => $this->logger?->warning($message), AssetCompilerInterface::MISSING_IMPORT_STRICT => throw new RuntimeException($message, 0, $e), }; } diff --git a/src/Symfony/Component/AssetMapper/Compiler/JavaScriptImportPathCompiler.php b/src/Symfony/Component/AssetMapper/Compiler/JavaScriptImportPathCompiler.php index 8ca018f0f13c4..d9cc0f7cda899 100644 --- a/src/Symfony/Component/AssetMapper/Compiler/JavaScriptImportPathCompiler.php +++ b/src/Symfony/Component/AssetMapper/Compiler/JavaScriptImportPathCompiler.php @@ -12,7 +12,6 @@ namespace Symfony\Component\AssetMapper\Compiler; use Psr\Log\LoggerInterface; -use Psr\Log\NullLogger; use Symfony\Component\AssetMapper\AssetDependency; use Symfony\Component\AssetMapper\AssetMapperInterface; use Symfony\Component\AssetMapper\Exception\RuntimeException; @@ -29,16 +28,13 @@ final class JavaScriptImportPathCompiler implements AssetCompilerInterface { use AssetCompilerPathResolverTrait; - private readonly LoggerInterface $logger; - // https://regex101.com/r/VFdR4H/1 private const IMPORT_PATTERN = '/(?:import\s+(?:(?:\*\s+as\s+\w+|[\w\s{},*]+)\s+from\s+)?|\bimport\()\s*[\'"`](\.\/[^\'"`]+|(\.\.\/)+[^\'"`]+)[\'"`]\s*[;\)]?/m'; public function __construct( private readonly string $missingImportMode = self::MISSING_IMPORT_WARN, - LoggerInterface $logger = null, + private readonly ?LoggerInterface $logger = null, ) { - $this->logger = $logger ?? new NullLogger(); } public function compile(string $content, MappedAsset $asset, AssetMapperInterface $assetMapper): string @@ -101,7 +97,7 @@ private function handleMissingImport(string $message, \Throwable $e = null): voi { match ($this->missingImportMode) { AssetCompilerInterface::MISSING_IMPORT_IGNORE => null, - AssetCompilerInterface::MISSING_IMPORT_WARN => $this->logger->warning($message), + AssetCompilerInterface::MISSING_IMPORT_WARN => $this->logger?->warning($message), AssetCompilerInterface::MISSING_IMPORT_STRICT => throw new RuntimeException($message, 0, $e), }; } diff --git a/src/Symfony/Component/BrowserKit/AbstractBrowser.php b/src/Symfony/Component/BrowserKit/AbstractBrowser.php index 5c263e6facc3b..4caedaf1e9123 100644 --- a/src/Symfony/Component/BrowserKit/AbstractBrowser.php +++ b/src/Symfony/Component/BrowserKit/AbstractBrowser.php @@ -204,11 +204,7 @@ public function getCookieJar(): CookieJar */ public function getCrawler(): Crawler { - if (null === $this->crawler) { - throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); - } - - return $this->crawler; + return $this->crawler ?? throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); } /** @@ -228,11 +224,7 @@ public function useHtml5Parser(bool $useHtml5Parser): static */ public function getInternalResponse(): Response { - if (null === $this->internalResponse) { - throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); - } - - return $this->internalResponse; + return $this->internalResponse ?? throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); } /** @@ -245,11 +237,7 @@ public function getInternalResponse(): Response */ public function getResponse(): object { - if (null === $this->response) { - throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); - } - - return $this->response; + return $this->response ?? throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); } /** @@ -257,11 +245,7 @@ public function getResponse(): object */ public function getInternalRequest(): Request { - if (null === $this->internalRequest) { - throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); - } - - return $this->internalRequest; + return $this->internalRequest ?? throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); } /** @@ -274,11 +258,7 @@ public function getInternalRequest(): Request */ public function getRequest(): object { - if (null === $this->request) { - throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); - } - - return $this->request; + return $this->request ?? throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); } /** @@ -300,11 +280,9 @@ public function click(Link $link): Crawler */ public function clickLink(string $linkText): Crawler { - if (null === $this->crawler) { - throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); - } + $crawler = $this->crawler ?? throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); - return $this->click($this->crawler->selectLink($linkText)->link()); + return $this->click($crawler->selectLink($linkText)->link()); } /** @@ -331,11 +309,8 @@ public function submit(Form $form, array $values = [], array $serverParameters = */ public function submitForm(string $button, array $fieldValues = [], string $method = 'POST', array $serverParameters = []): Crawler { - if (null === $this->crawler) { - throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); - } - - $buttonNode = $this->crawler->selectButton($button); + $crawler = $this->crawler ?? throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); + $buttonNode = $crawler->selectButton($button); if (0 === $buttonNode->count()) { throw new InvalidArgumentException(sprintf('There is no button with "%s" as its content, id, value or name.', $button)); diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index d887fdc7b3329..40eb4978b1b3c 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -33,8 +33,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg */ protected const NS_SEPARATOR = ':'; - private static $apcuSupported; - private static $phpFilesSupported; + private static bool $apcuSupported; protected function __construct(string $namespace = '', int $defaultLifetime = 0) { diff --git a/src/Symfony/Component/Cache/Adapter/NullAdapter.php b/src/Symfony/Component/Cache/Adapter/NullAdapter.php index 7809a71fec140..07c7af8162402 100644 --- a/src/Symfony/Component/Cache/Adapter/NullAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/NullAdapter.php @@ -20,7 +20,7 @@ */ class NullAdapter implements AdapterInterface, CacheInterface { - private static $createCacheItem; + private static \Closure $createCacheItem; public function __construct() { diff --git a/src/Symfony/Component/Cache/LockRegistry.php b/src/Symfony/Component/Cache/LockRegistry.php index 22d71839e3b57..f1fede641fb46 100644 --- a/src/Symfony/Component/Cache/LockRegistry.php +++ b/src/Symfony/Component/Cache/LockRegistry.php @@ -26,15 +26,15 @@ */ final class LockRegistry { - private static $openedFiles = []; - private static $lockedFiles; - private static $signalingException; - private static $signalingCallback; + private static array $openedFiles = []; + private static ?array $lockedFiles = null; + private static \Exception $signalingException; + private static \Closure $signalingCallback; /** * The number of items in this list controls the max number of concurrent processes. */ - private static $files = [ + private static array $files = [ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'AbstractAdapter.php', __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'AbstractTagAwareAdapter.php', __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'AdapterInterface.php', diff --git a/src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php b/src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php index 4f868f70319ab..621e2a07a1e42 100644 --- a/src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php @@ -44,11 +44,7 @@ public function getRootNode(): NodeDefinition|ArrayNodeDefinition */ public function buildTree(): NodeInterface { - if (null !== $this->tree) { - return $this->tree; - } - - return $this->tree = $this->root->getNode(true); + return $this->tree ??= $this->root->getNode(true); } /** diff --git a/src/Symfony/Component/Console/Command/CompleteCommand.php b/src/Symfony/Component/Console/Command/CompleteCommand.php index 058578d8b48d8..23be5577b21c6 100644 --- a/src/Symfony/Component/Console/Command/CompleteCommand.php +++ b/src/Symfony/Component/Console/Command/CompleteCommand.php @@ -44,9 +44,9 @@ final class CompleteCommand extends Command */ protected static $defaultDescription = 'Internal command to provide shell completion suggestions'; - private $completionOutputs; + private array $completionOutputs; - private $isDebug = false; + private bool $isDebug = false; /** * @param array> $completionOutputs A list of additional completion outputs, with shell name as key and FQCN as value diff --git a/src/Symfony/Component/Console/Completion/CompletionInput.php b/src/Symfony/Component/Console/Completion/CompletionInput.php index aa8dbfa18c41a..7ba41c0839da4 100644 --- a/src/Symfony/Component/Console/Completion/CompletionInput.php +++ b/src/Symfony/Component/Console/Completion/CompletionInput.php @@ -31,11 +31,11 @@ final class CompletionInput extends ArgvInput public const TYPE_OPTION_NAME = 'option_name'; public const TYPE_NONE = 'none'; - private $tokens; - private $currentIndex; - private $completionType; - private $completionName; - private $completionValue = ''; + private array $tokens; + private int $currentIndex; + private string $completionType; + private ?string $completionName = null; + private string $completionValue = ''; /** * Converts a terminal string into tokens. diff --git a/src/Symfony/Component/Console/Completion/CompletionSuggestions.php b/src/Symfony/Component/Console/Completion/CompletionSuggestions.php index 719118177f354..549bbafbda7e2 100644 --- a/src/Symfony/Component/Console/Completion/CompletionSuggestions.php +++ b/src/Symfony/Component/Console/Completion/CompletionSuggestions.php @@ -20,8 +20,8 @@ */ final class CompletionSuggestions { - private $valueSuggestions = []; - private $optionSuggestions = []; + private array $valueSuggestions = []; + private array $optionSuggestions = []; /** * Add a suggested value for an input option or argument. diff --git a/src/Symfony/Component/Console/Tester/CommandCompletionTester.php b/src/Symfony/Component/Console/Tester/CommandCompletionTester.php index ade7327529c32..a90fe52ef8de5 100644 --- a/src/Symfony/Component/Console/Tester/CommandCompletionTester.php +++ b/src/Symfony/Component/Console/Tester/CommandCompletionTester.php @@ -22,7 +22,7 @@ */ class CommandCompletionTester { - private $command; + private Command $command; public function __construct(Command $command) { diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AttributeAutoconfigurationPass.php b/src/Symfony/Component/DependencyInjection/Compiler/AttributeAutoconfigurationPass.php index b4c288e3c1dab..cb428565e37b1 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AttributeAutoconfigurationPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AttributeAutoconfigurationPass.php @@ -24,10 +24,10 @@ final class AttributeAutoconfigurationPass extends AbstractRecursivePass { protected bool $skipScalars = true; - private $classAttributeConfigurators = []; - private $methodAttributeConfigurators = []; - private $propertyAttributeConfigurators = []; - private $parameterAttributeConfigurators = []; + private array $classAttributeConfigurators = []; + private array $methodAttributeConfigurators = []; + private array $propertyAttributeConfigurators = []; + private array $parameterAttributeConfigurators = []; public function process(ContainerBuilder $container): void { diff --git a/src/Symfony/Component/DependencyInjection/Compiler/RegisterAutoconfigureAttributesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/RegisterAutoconfigureAttributesPass.php index b706a62471ba9..d479743ecd301 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/RegisterAutoconfigureAttributesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/RegisterAutoconfigureAttributesPass.php @@ -24,7 +24,7 @@ */ final class RegisterAutoconfigureAttributesPass implements CompilerPassInterface { - private static $registerForAutoconfiguration; + private static \Closure $registerForAutoconfiguration; public function process(ContainerBuilder $container): void { @@ -49,7 +49,7 @@ public function processClass(ContainerBuilder $container, \ReflectionClass $clas private static function registerForAutoconfiguration(ContainerBuilder $container, \ReflectionClass $class, \ReflectionAttribute $attribute): void { - if (self::$registerForAutoconfiguration) { + if (isset(self::$registerForAutoconfiguration)) { (self::$registerForAutoconfiguration)($container, $class, $attribute); return; diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 2b9eeb84cc44d..73eec07385e38 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -65,7 +65,7 @@ class Container implements ContainerInterface, ResetInterface private bool $compiled = false; private \Closure $getEnv; - private static $make; + private static \Closure $make; public function __construct(ParameterBagInterface $parameterBag = null) { diff --git a/src/Symfony/Component/Dotenv/Command/DebugCommand.php b/src/Symfony/Component/Dotenv/Command/DebugCommand.php index 85cca991ca760..47d05f5a9d154 100644 --- a/src/Symfony/Component/Dotenv/Command/DebugCommand.php +++ b/src/Symfony/Component/Dotenv/Command/DebugCommand.php @@ -39,8 +39,8 @@ final class DebugCommand extends Command */ protected static $defaultDescription = 'Lists all dotenv files with variables and values'; - private $kernelEnvironment; - private $projectDirectory; + private string $kernelEnvironment; + private string $projectDirectory; public function __construct(string $kernelEnvironment, string $projectDirectory) { diff --git a/src/Symfony/Component/ErrorHandler/ErrorHandler.php b/src/Symfony/Component/ErrorHandler/ErrorHandler.php index bda939a828073..479704021cd16 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/ErrorHandler.php @@ -96,6 +96,7 @@ class ErrorHandler private bool $isRecursive = false; private bool $isRoot = false; + /** @var callable|null */ private $exceptionHandler; private ?BufferingLogger $bootstrappingLogger = null; diff --git a/src/Symfony/Component/ExpressionLanguage/Node/ArrayNode.php b/src/Symfony/Component/ExpressionLanguage/Node/ArrayNode.php index e75de1af2aa69..993af3633d9a2 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/ArrayNode.php +++ b/src/Symfony/Component/ExpressionLanguage/Node/ArrayNode.php @@ -20,7 +20,7 @@ */ class ArrayNode extends Node { - protected $index; + protected int $index; public function __construct() { diff --git a/src/Symfony/Component/ExpressionLanguage/Token.php b/src/Symfony/Component/ExpressionLanguage/Token.php index c59fc7331d016..6eff31e9bc77f 100644 --- a/src/Symfony/Component/ExpressionLanguage/Token.php +++ b/src/Symfony/Component/ExpressionLanguage/Token.php @@ -30,8 +30,8 @@ class Token public const PUNCTUATION_TYPE = 'punctuation'; /** - * @param string $type The type of the token (self::*_TYPE) - * @param int|null $cursor The cursor position in the source + * @param self::*_TYPE $type + * @param int|null $cursor The cursor position in the source */ public function __construct(string $type, string|int|float|null $value, ?int $cursor) { diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index a379ce1863100..26534c80f01d6 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -22,7 +22,7 @@ */ class Filesystem { - private static $lastError; + private static ?string $lastError = null; /** * Copies a file. diff --git a/src/Symfony/Component/Filesystem/Path.php b/src/Symfony/Component/Filesystem/Path.php index 8ddbac8f4502f..6643962351feb 100644 --- a/src/Symfony/Component/Filesystem/Path.php +++ b/src/Symfony/Component/Filesystem/Path.php @@ -42,12 +42,9 @@ final class Path * * @var array */ - private static $buffer = []; + private static array $buffer = []; - /** - * @var int - */ - private static $bufferSize = 0; + private static int $bufferSize = 0; /** * Canonicalizes the given path. diff --git a/src/Symfony/Component/Finder/Iterator/VcsIgnoredFilterIterator.php b/src/Symfony/Component/Finder/Iterator/VcsIgnoredFilterIterator.php index 7e6051d38971a..ddd7007728a7f 100644 --- a/src/Symfony/Component/Finder/Iterator/VcsIgnoredFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/VcsIgnoredFilterIterator.php @@ -18,20 +18,17 @@ */ final class VcsIgnoredFilterIterator extends \FilterIterator { - /** - * @var string - */ - private $baseDir; + private string $baseDir; /** * @var array */ - private $gitignoreFilesCache = []; + private array $gitignoreFilesCache = []; /** * @var array */ - private $ignoredPathsCache = []; + private array $ignoredPathsCache = []; /** * @param \Iterator $iterator diff --git a/src/Symfony/Component/Form/ChoiceList/View/ChoiceListView.php b/src/Symfony/Component/Form/ChoiceList/View/ChoiceListView.php index 8f7a245916968..949174e3a7deb 100644 --- a/src/Symfony/Component/Form/ChoiceList/View/ChoiceListView.php +++ b/src/Symfony/Component/Form/ChoiceList/View/ChoiceListView.php @@ -28,8 +28,8 @@ class ChoiceListView /** * Creates a new choice list view. * - * @param ChoiceGroupView[]|ChoiceView[] $choices The choice views - * @param ChoiceGroupView[]|ChoiceView[] $preferredChoices the preferred choice views + * @param array $choices The choice views + * @param array $preferredChoices the preferred choice views */ public function __construct(array $choices = [], array $preferredChoices = []) { diff --git a/src/Symfony/Component/HttpClient/Internal/PushedResponse.php b/src/Symfony/Component/HttpClient/Internal/PushedResponse.php index f1e0ad687fd49..e77069d0cda9b 100644 --- a/src/Symfony/Component/HttpClient/Internal/PushedResponse.php +++ b/src/Symfony/Component/HttpClient/Internal/PushedResponse.php @@ -22,20 +22,11 @@ */ final class PushedResponse { - public CurlResponse $response; - - /** @var string[] */ - public array $requestHeaders; - - public array $parentOptions = []; - - public $handle; - - public function __construct(CurlResponse $response, array $requestHeaders, array $parentOptions, $handle) - { - $this->response = $response; - $this->requestHeaders = $requestHeaders; - $this->parentOptions = $parentOptions; - $this->handle = $handle; + public function __construct( + public CurlResponse $response, + public array $requestHeaders, + public array $parentOptions, + public \CurlHandle $handle, + ) { } } diff --git a/src/Symfony/Component/HttpClient/Response/AsyncResponse.php b/src/Symfony/Component/HttpClient/Response/AsyncResponse.php index e37278f79f711..2f538c99a5af6 100644 --- a/src/Symfony/Component/HttpClient/Response/AsyncResponse.php +++ b/src/Symfony/Component/HttpClient/Response/AsyncResponse.php @@ -38,8 +38,8 @@ class AsyncResponse implements ResponseInterface, StreamableInterface private ResponseInterface $response; private array $info = ['canceled' => false]; private $passthru; - private $stream; - private $yieldedState; + private ?\Iterator $stream = null; + private ?int $yieldedState = null; /** * @param ?callable(ChunkInterface, AsyncContext): ?\Iterator $passthru diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index efaa47d67ea3c..d472aca543554 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -242,7 +242,7 @@ public function __destruct() $this->doDestruct(); } finally { - if (\is_resource($this->handle) || $this->handle instanceof \CurlHandle) { + if ($this->handle instanceof \CurlHandle) { curl_setopt($this->handle, \CURLOPT_VERBOSE, false); } } diff --git a/src/Symfony/Component/HttpClient/Response/StreamWrapper.php b/src/Symfony/Component/HttpClient/Response/StreamWrapper.php index b5554a8ad2ced..e68eacbc0a2f5 100644 --- a/src/Symfony/Component/HttpClient/Response/StreamWrapper.php +++ b/src/Symfony/Component/HttpClient/Response/StreamWrapper.php @@ -30,7 +30,7 @@ class StreamWrapper private ResponseInterface $response; /** @var resource|string|null */ - private $content; + private $content = null; /** @var resource|callable|null */ private $handle; diff --git a/src/Symfony/Component/HttpClient/RetryableHttpClient.php b/src/Symfony/Component/HttpClient/RetryableHttpClient.php index bb0cab1b3ca6b..b506c9bccfa95 100644 --- a/src/Symfony/Component/HttpClient/RetryableHttpClient.php +++ b/src/Symfony/Component/HttpClient/RetryableHttpClient.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpClient; use Psr\Log\LoggerInterface; -use Psr\Log\NullLogger; use Symfony\Component\HttpClient\Response\AsyncContext; use Symfony\Component\HttpClient\Response\AsyncResponse; use Symfony\Component\HttpClient\Retry\GenericRetryStrategy; @@ -34,7 +33,7 @@ class RetryableHttpClient implements HttpClientInterface, ResetInterface private RetryStrategyInterface $strategy; private int $maxRetries; - private LoggerInterface $logger; + private ?LoggerInterface $logger; private array $baseUris = []; /** @@ -45,7 +44,7 @@ public function __construct(HttpClientInterface $client, RetryStrategyInterface $this->client = $client; $this->strategy = $strategy ?? new GenericRetryStrategy(); $this->maxRetries = $maxRetries; - $this->logger = $logger ?? new NullLogger(); + $this->logger = $logger; } public function withOptions(array $options): static @@ -149,7 +148,7 @@ public function request(string $method, string $url, array $options = []): Respo $content = ''; $firstChunk = null; - $this->logger->info('Try #{count} after {delay}ms'.($exception ? ': '.$exception->getMessage() : ', status code: '.$context->getStatusCode()), [ + $this->logger?->info('Try #{count} after {delay}ms'.($exception ? ': '.$exception->getMessage() : ', status code: '.$context->getStatusCode()), [ 'count' => $retryCount, 'delay' => $delay, ]); diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 0bef6f8d70796..776449c867309 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -766,7 +766,7 @@ public function setSession(SessionInterface $session) */ public function setSessionFactory(callable $factory): void { - $this->session = $factory; + $this->session = $factory(...); } /** diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index abb47583c3036..6acf11f0929ee 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -503,12 +503,6 @@ public function setStatusCode(int $code, string $text = null): static return $this; } - if (false === $text) { - $this->statusText = ''; - - return $this; - } - $this->statusText = $text; return $this; diff --git a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php index af21469b1ce8c..09a19c480c498 100644 --- a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php +++ b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php @@ -65,7 +65,7 @@ public function build(ContainerBuilder $container) */ public function getContainerExtension(): ?ExtensionInterface { - if (null === $this->extension) { + if (!isset($this->extension)) { $extension = $this->createContainerExtension(); if (null !== $extension) { @@ -101,7 +101,7 @@ public function getNamespace(): string public function getPath(): string { - if (null === $this->path) { + if (!isset($this->path)) { $reflected = new \ReflectionObject($this); $this->path = \dirname($reflected->getFileName()); } @@ -114,7 +114,7 @@ public function getPath(): string */ final public function getName(): string { - if (null === $this->name) { + if (!isset($this->name)) { $this->parseClassName(); } diff --git a/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php b/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php index ec27eaec122e5..2eb7c473ff028 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php @@ -42,13 +42,13 @@ abstract class AbstractSessionListener implements EventSubscriberInterface, Rese { public const NO_AUTO_CACHE_CONTROL_HEADER = 'Symfony-Session-NoAutoCacheControl'; - protected $container; + protected ?ContainerInterface $container; private bool $debug; /** * @var array */ - private $sessionOptions; + private array $sessionOptions; public function __construct(ContainerInterface $container = null, bool $debug = false, array $sessionOptions = []) { diff --git a/src/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php index 47027233a7220..6a8989081f16e 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php @@ -25,7 +25,7 @@ abstract class RoutableFragmentRenderer implements FragmentRendererInterface /** * @internal */ - protected $fragmentPath = '/_fragment'; + protected string $fragmentPath = '/_fragment'; /** * Sets the fragment path that triggers the fragment listener. diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php index 9a6af4a7a06c9..b5b35dbc04ced 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php @@ -37,9 +37,7 @@ class Connection extends AbstractConnection ]; private bool $bound = false; - - /** @var resource|LDAPConnection */ - private $connection; + private ?LDAPConnection $connection = null; public function __sleep(): array { @@ -92,11 +90,9 @@ public function bind(string $dn = null, #[\SensitiveParameter] string $password } /** - * @return resource|LDAPConnection - * * @internal */ - public function getResource() + public function getResource(): ?LDAPConnection { return $this->connection; } diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/EntryManager.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/EntryManager.php index 20f0922384024..97fd3004fad9a 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/EntryManager.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/EntryManager.php @@ -24,11 +24,9 @@ */ class EntryManager implements EntryManagerInterface { - private Connection $connection; - - public function __construct(Connection $connection) - { - $this->connection = $connection; + public function __construct( + private Connection $connection, + ) { } /** @@ -135,8 +133,8 @@ public function rename(Entry $entry, string $newRdn, bool $removeOldRdn = true) */ public function move(Entry $entry, string $newParent) { - $con = $this->getConnectionResource(); $rdn = $this->parseRdnFromEntry($entry); + $con = $this->getConnectionResource(); // deleteOldRdn does not matter here, since the Rdn will not be changing in the move. if (!@ldap_rename($con, $entry->getDn(), $rdn, $newParent, true)) { throw new LdapException(sprintf('Could not move entry "%s" to "%s": ', $entry->getDn(), $newParent).ldap_error($con), ldap_errno($con)); @@ -147,10 +145,8 @@ public function move(Entry $entry, string $newParent) /** * Get the connection resource, but first check if the connection is bound. - * - * @return resource|LDAPConnection */ - private function getConnectionResource() + private function getConnectionResource(): LDAPConnection { // If the connection is not bound, throw an exception. Users should use an explicit bind call first. if (!$this->connection->isBound()) { diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php index fe87e74234c63..e3c3a6d4592ae 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Ldap\Adapter\ExtLdap; -use LDAP\Connection as LDAPConnection; use LDAP\Result; use Symfony\Component\Ldap\Adapter\AbstractQuery; use Symfony\Component\Ldap\Adapter\CollectionInterface; @@ -26,7 +25,7 @@ class Query extends AbstractQuery { public const PAGINATION_OID = \LDAP_CONTROL_PAGEDRESULTS; - /** @var resource[]|Result[] */ + /** @var Result[] */ private array $results; private array $serverctrls = []; @@ -102,7 +101,7 @@ public function execute(): CollectionInterface if ($pageSize > 0 && $sizeLimit >= $pageSize) { $sizeLimit = 0; } - $search = $this->callSearchFunction($con, $func, $sizeLimit); + $search = @$func($con, $this->dn, $this->query, $this->options['filter'], $this->options['attrsOnly'], $sizeLimit, $this->options['timeout'], $this->options['deref'], $this->serverctrls); if (false === $search) { $ldapError = ''; @@ -123,7 +122,9 @@ public function execute(): CollectionInterface break; } if ($pageControl) { - $cookie = $this->controlPagedResultResponse($con, $search); + ldap_parse_result($con, $search, $errcode, $matcheddn, $errmsg, $referrals, $controls); + + $cookie = $controls[\LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'] ?? ''; } } while (null !== $cookie && '' !== $cookie); @@ -139,11 +140,9 @@ public function execute(): CollectionInterface * Returns an LDAP search resource. If this query resulted in multiple searches, only the first * page will be returned. * - * @return resource|Result|null - * * @internal */ - public function getResource(int $idx = 0) + public function getResource(int $idx = 0): ?Result { return $this->results[$idx] ?? null; } @@ -151,7 +150,7 @@ public function getResource(int $idx = 0) /** * Returns all LDAP search resources. * - * @return resource[]|Result[] + * @return Result[] * * @internal */ @@ -209,29 +208,4 @@ private function controlPagedResult(int $pageSize, bool $critical, string $cooki return true; } - - /** - * Retrieve LDAP pagination cookie. - * - * @param resource|LDAPConnection $con - * @param resource|Result $result - */ - private function controlPagedResultResponse($con, $result): string - { - ldap_parse_result($con, $result, $errcode, $matcheddn, $errmsg, $referrals, $controls); - - return $controls[\LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'] ?? ''; - } - - /** - * Calls actual LDAP search function with the prepared options and parameters. - * - * @param resource|LDAPConnection $con - * - * @return resource|Result|false - */ - private function callSearchFunction($con, callable $func, int $sizeLimit) - { - return @$func($con, $this->dn, $this->query, $this->options['filter'], $this->options['attrsOnly'], $sizeLimit, $this->options['timeout'], $this->options['deref'], $this->serverctrls); - } } diff --git a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/EntryManagerTest.php b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/EntryManagerTest.php index b34042cf1546a..e473bc831584e 100644 --- a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/EntryManagerTest.php +++ b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/EntryManagerTest.php @@ -25,9 +25,6 @@ public function testMove() $this->expectException(LdapException::class); $this->expectExceptionMessage('Entry "$$$$$$" malformed, could not parse RDN.'); $connection = $this->createMock(Connection::class); - $connection - ->expects($this->once()) - ->method('isBound')->willReturn(true); $entry = new Entry('$$$$$$'); $entryManager = new EntryManager($connection); diff --git a/src/Symfony/Component/Lock/Lock.php b/src/Symfony/Component/Lock/Lock.php index 1db5821114458..1d1f4c3aad5d4 100644 --- a/src/Symfony/Component/Lock/Lock.php +++ b/src/Symfony/Component/Lock/Lock.php @@ -13,7 +13,6 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; -use Psr\Log\NullLogger; use Symfony\Component\Lock\Exception\InvalidArgumentException; use Symfony\Component\Lock\Exception\LockAcquiringException; use Symfony\Component\Lock\Exception\LockConflictedException; @@ -29,24 +28,18 @@ final class Lock implements SharedLockInterface, LoggerAwareInterface { use LoggerAwareTrait; - private PersistingStoreInterface $store; - private Key $key; - private ?float $ttl; - private bool $autoRelease; private bool $dirty = false; /** * @param float|null $ttl Maximum expected lock duration in seconds * @param bool $autoRelease Whether to automatically release the lock or not when the lock instance is destroyed */ - public function __construct(Key $key, PersistingStoreInterface $store, float $ttl = null, bool $autoRelease = true) - { - $this->store = $store; - $this->key = $key; - $this->ttl = $ttl; - $this->autoRelease = $autoRelease; - - $this->logger = new NullLogger(); + public function __construct( + private Key $key, + private PersistingStoreInterface $store, + private ?float $ttl = null, + private bool $autoRelease = true, + ) { } public function __sleep(): array @@ -93,7 +86,7 @@ public function acquire(bool $blocking = false): bool } $this->dirty = true; - $this->logger->debug('Successfully acquired the "{resource}" lock.', ['resource' => $this->key]); + $this->logger?->debug('Successfully acquired the "{resource}" lock.', ['resource' => $this->key]); if ($this->ttl) { $this->refresh(); @@ -111,7 +104,7 @@ public function acquire(bool $blocking = false): bool return true; } catch (LockConflictedException $e) { $this->dirty = false; - $this->logger->info('Failed to acquire the "{resource}" lock. Someone else already acquired the lock.', ['resource' => $this->key]); + $this->logger?->info('Failed to acquire the "{resource}" lock. Someone else already acquired the lock.', ['resource' => $this->key]); if ($blocking) { throw $e; @@ -119,7 +112,7 @@ public function acquire(bool $blocking = false): bool return false; } catch (\Exception $e) { - $this->logger->notice('Failed to acquire the "{resource}" lock.', ['resource' => $this->key, 'exception' => $e]); + $this->logger?->notice('Failed to acquire the "{resource}" lock.', ['resource' => $this->key, 'exception' => $e]); throw new LockAcquiringException(sprintf('Failed to acquire the "%s" lock.', $this->key), 0, $e); } } @@ -129,7 +122,7 @@ public function acquireRead(bool $blocking = false): bool $this->key->resetLifetime(); try { if (!$this->store instanceof SharedLockStoreInterface) { - $this->logger->debug('Store does not support ReadLocks, fallback to WriteLock.', ['resource' => $this->key]); + $this->logger?->debug('Store does not support ReadLocks, fallback to WriteLock.', ['resource' => $this->key]); return $this->acquire($blocking); } @@ -151,7 +144,7 @@ public function acquireRead(bool $blocking = false): bool } $this->dirty = true; - $this->logger->debug('Successfully acquired the "{resource}" lock for reading.', ['resource' => $this->key]); + $this->logger?->debug('Successfully acquired the "{resource}" lock for reading.', ['resource' => $this->key]); if ($this->ttl) { $this->refresh(); @@ -169,7 +162,7 @@ public function acquireRead(bool $blocking = false): bool return true; } catch (LockConflictedException $e) { $this->dirty = false; - $this->logger->info('Failed to acquire the "{resource}" lock. Someone else already acquired the lock.', ['resource' => $this->key]); + $this->logger?->info('Failed to acquire the "{resource}" lock. Someone else already acquired the lock.', ['resource' => $this->key]); if ($blocking) { throw $e; @@ -177,7 +170,7 @@ public function acquireRead(bool $blocking = false): bool return false; } catch (\Exception $e) { - $this->logger->notice('Failed to acquire the "{resource}" lock.', ['resource' => $this->key, 'exception' => $e]); + $this->logger?->notice('Failed to acquire the "{resource}" lock.', ['resource' => $this->key, 'exception' => $e]); throw new LockAcquiringException(sprintf('Failed to acquire the "%s" lock.', $this->key), 0, $e); } } @@ -202,13 +195,13 @@ public function refresh(float $ttl = null): void throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $this->key)); } - $this->logger->debug('Expiration defined for "{resource}" lock for "{ttl}" seconds.', ['resource' => $this->key, 'ttl' => $ttl]); + $this->logger?->debug('Expiration defined for "{resource}" lock for "{ttl}" seconds.', ['resource' => $this->key, 'ttl' => $ttl]); } catch (LockConflictedException $e) { $this->dirty = false; - $this->logger->notice('Failed to define an expiration for the "{resource}" lock, someone else acquired the lock.', ['resource' => $this->key]); + $this->logger?->notice('Failed to define an expiration for the "{resource}" lock, someone else acquired the lock.', ['resource' => $this->key]); throw $e; } catch (\Exception $e) { - $this->logger->notice('Failed to define an expiration for the "{resource}" lock.', ['resource' => $this->key, 'exception' => $e]); + $this->logger?->notice('Failed to define an expiration for the "{resource}" lock.', ['resource' => $this->key, 'exception' => $e]); throw new LockAcquiringException(sprintf('Failed to define an expiration for the "%s" lock.', $this->key), 0, $e); } } @@ -234,9 +227,9 @@ public function release(): void throw new LockReleasingException(sprintf('Failed to release the "%s" lock, the resource is still locked.', $this->key)); } - $this->logger->debug('Successfully released the "{resource}" lock.', ['resource' => $this->key]); + $this->logger?->debug('Successfully released the "{resource}" lock.', ['resource' => $this->key]); } catch (LockReleasingException $e) { - $this->logger->notice('Failed to release the "{resource}" lock.', ['resource' => $this->key]); + $this->logger?->notice('Failed to release the "{resource}" lock.', ['resource' => $this->key]); throw $e; } } diff --git a/src/Symfony/Component/Lock/LockFactory.php b/src/Symfony/Component/Lock/LockFactory.php index 125b6eae50fbe..3ac3feeab1096 100644 --- a/src/Symfony/Component/Lock/LockFactory.php +++ b/src/Symfony/Component/Lock/LockFactory.php @@ -25,13 +25,9 @@ class LockFactory implements LoggerAwareInterface { use LoggerAwareTrait; - private PersistingStoreInterface $store; - - public function __construct(PersistingStoreInterface $store) - { - $this->store = $store; - - $this->logger = new NullLogger(); + public function __construct( + private PersistingStoreInterface $store, + ) { } /** @@ -60,7 +56,9 @@ public function createLock(string $resource, ?float $ttl = 300.0, bool $autoRele public function createLockFromKey(Key $key, ?float $ttl = 300.0, bool $autoRelease = true): LockInterface { $lock = new Lock($key, $this->store, $ttl, $autoRelease); - $lock->setLogger($this->logger); + if ($this->logger) { + $lock->setLogger($this->logger); + } return $lock; } diff --git a/src/Symfony/Component/Lock/Store/CombinedStore.php b/src/Symfony/Component/Lock/Store/CombinedStore.php index 9087874c29bf4..19cea4d735491 100644 --- a/src/Symfony/Component/Lock/Store/CombinedStore.php +++ b/src/Symfony/Component/Lock/Store/CombinedStore.php @@ -13,7 +13,6 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; -use Psr\Log\NullLogger; use Symfony\Component\Lock\Exception\InvalidArgumentException; use Symfony\Component\Lock\Exception\LockConflictedException; use Symfony\Component\Lock\Key; @@ -50,7 +49,6 @@ public function __construct(array $stores, StrategyInterface $strategy) $this->stores = $stores; $this->strategy = $strategy; - $this->logger = new NullLogger(); } /** @@ -67,7 +65,7 @@ public function save(Key $key) $store->save($key); ++$successCount; } catch (\Exception $e) { - $this->logger->debug('One store failed to save the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]); + $this->logger?->debug('One store failed to save the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]); ++$failureCount; } @@ -82,7 +80,7 @@ public function save(Key $key) return; } - $this->logger->info('Failed to store the "{resource}" lock. Quorum has not been met.', ['resource' => $key, 'success' => $successCount, 'failure' => $failureCount]); + $this->logger?->info('Failed to store the "{resource}" lock. Quorum has not been met.', ['resource' => $key, 'success' => $successCount, 'failure' => $failureCount]); // clean up potential locks $this->delete($key); @@ -108,7 +106,7 @@ public function saveRead(Key $key) } ++$successCount; } catch (\Exception $e) { - $this->logger->debug('One store failed to save the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]); + $this->logger?->debug('One store failed to save the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]); ++$failureCount; } @@ -123,7 +121,7 @@ public function saveRead(Key $key) return; } - $this->logger->info('Failed to store the "{resource}" lock. Quorum has not been met.', ['resource' => $key, 'success' => $successCount, 'failure' => $failureCount]); + $this->logger?->info('Failed to store the "{resource}" lock. Quorum has not been met.', ['resource' => $key, 'success' => $successCount, 'failure' => $failureCount]); // clean up potential locks $this->delete($key); @@ -144,7 +142,7 @@ public function putOffExpiration(Key $key, float $ttl) foreach ($this->stores as $store) { try { if (0.0 >= $adjustedTtl = $expireAt - microtime(true)) { - $this->logger->debug('Stores took to long to put off the expiration of the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'ttl' => $ttl]); + $this->logger?->debug('Stores took to long to put off the expiration of the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'ttl' => $ttl]); $key->reduceLifetime(0); break; } @@ -152,7 +150,7 @@ public function putOffExpiration(Key $key, float $ttl) $store->putOffExpiration($key, $adjustedTtl); ++$successCount; } catch (\Exception $e) { - $this->logger->debug('One store failed to put off the expiration of the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]); + $this->logger?->debug('One store failed to put off the expiration of the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]); ++$failureCount; } @@ -167,7 +165,7 @@ public function putOffExpiration(Key $key, float $ttl) return; } - $this->logger->notice('Failed to define the expiration for the "{resource}" lock. Quorum has not been met.', ['resource' => $key, 'success' => $successCount, 'failure' => $failureCount]); + $this->logger?->notice('Failed to define the expiration for the "{resource}" lock. Quorum has not been met.', ['resource' => $key, 'success' => $successCount, 'failure' => $failureCount]); // clean up potential locks $this->delete($key); @@ -184,7 +182,7 @@ public function delete(Key $key) try { $store->delete($key); } catch (\Exception $e) { - $this->logger->notice('One store failed to delete the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]); + $this->logger?->notice('One store failed to delete the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]); } } } @@ -203,7 +201,7 @@ public function exists(Key $key): bool ++$failureCount; } } catch (\Exception $e) { - $this->logger->debug('One store failed to check the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]); + $this->logger?->debug('One store failed to check the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]); ++$failureCount; } diff --git a/src/Symfony/Component/Lock/Store/DoctrineDbalPostgreSqlStore.php b/src/Symfony/Component/Lock/Store/DoctrineDbalPostgreSqlStore.php index d87a7d5667ba6..3f5651dde1820 100644 --- a/src/Symfony/Component/Lock/Store/DoctrineDbalPostgreSqlStore.php +++ b/src/Symfony/Component/Lock/Store/DoctrineDbalPostgreSqlStore.php @@ -33,7 +33,7 @@ class DoctrineDbalPostgreSqlStore implements BlockingSharedLockStoreInterface, BlockingStoreInterface { private Connection $conn; - private static $storeRegistry = []; + private static array $storeRegistry = []; /** * You can either pass an existing database connection a Doctrine DBAL Connection diff --git a/src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkApiTransport.php b/src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkApiTransport.php index d5964b9ab6087..22ed262924f6d 100644 --- a/src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkApiTransport.php +++ b/src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkApiTransport.php @@ -35,7 +35,7 @@ class PostmarkApiTransport extends AbstractApiTransport private string $key; - private $messageStream; + private ?string $messageStream = null; public function __construct(string $key, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null) { diff --git a/src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkSmtpTransport.php b/src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkSmtpTransport.php index 2eea1a5b85a29..83e0c9a6f845d 100644 --- a/src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkSmtpTransport.php +++ b/src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkSmtpTransport.php @@ -27,7 +27,7 @@ */ class PostmarkSmtpTransport extends EsmtpTransport { - private $messageStream; + private ?string $messageStream = null; public function __construct(string $id, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null) { diff --git a/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php index 85f95e088ffe5..fcc2ae890d3a1 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php @@ -61,9 +61,10 @@ class Connection implements ResetInterface * * redeliver_timeout: Timeout before redeliver messages still in handling state (i.e: delivered_at is not null and message is still in table). Default: 3600 * * auto_setup: Whether the table should be created automatically during send / get. Default: true */ - protected $configuration = []; - protected $driverConnection; - protected $queueEmptiedAt; + protected array $configuration; + protected DBALConnection $driverConnection; + protected ?float $queueEmptiedAt = null; + private ?SchemaSynchronizer $schemaSynchronizer; private bool $autoSetup; diff --git a/src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php b/src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php index 28aedeb1255c5..928443c97bd70 100644 --- a/src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php +++ b/src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php @@ -45,7 +45,7 @@ abstract class AbstractFailedMessagesCommand extends Command { protected const DEFAULT_TRANSPORT_OPTION = 'choose'; - protected $failureTransports; + protected ServiceProviderInterface $failureTransports; protected ?PhpSerializer $phpSerializer; private ?string $globalFailureReceiverName; diff --git a/src/Symfony/Component/Messenger/Middleware/HandleMessageMiddleware.php b/src/Symfony/Component/Messenger/Middleware/HandleMessageMiddleware.php index 6b84bd8cfd3ef..a8014a3e0c77c 100644 --- a/src/Symfony/Component/Messenger/Middleware/HandleMessageMiddleware.php +++ b/src/Symfony/Component/Messenger/Middleware/HandleMessageMiddleware.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Messenger\Middleware; use Psr\Log\LoggerAwareTrait; -use Psr\Log\NullLogger; use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\Exception\HandlerFailedException; use Symfony\Component\Messenger\Exception\LogicException; @@ -33,14 +32,10 @@ class HandleMessageMiddleware implements MiddlewareInterface { use LoggerAwareTrait; - private HandlersLocatorInterface $handlersLocator; - private bool $allowNoHandlers; - - public function __construct(HandlersLocatorInterface $handlersLocator, bool $allowNoHandlers = false) - { - $this->handlersLocator = $handlersLocator; - $this->allowNoHandlers = $allowNoHandlers; - $this->logger = new NullLogger(); + public function __construct( + private HandlersLocatorInterface $handlersLocator, + private bool $allowNoHandlers = false, + ) { } /** @@ -98,7 +93,7 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope $handledStamp = HandledStamp::fromDescriptor($handlerDescriptor, $result); $envelope = $envelope->with($handledStamp); - $this->logger->info('Message {class} handled by {handler}', $context + ['handler' => $handledStamp->getHandlerName()]); + $this->logger?->info('Message {class} handled by {handler}', $context + ['handler' => $handledStamp->getHandlerName()]); } catch (\Throwable $e) { $exceptions[] = $e; } @@ -122,7 +117,7 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope throw new NoHandlerForMessageException(sprintf('No handler for message "%s".', $context['class'])); } - $this->logger->info('No handler for message {class}', $context); + $this->logger?->info('No handler for message {class}', $context); } if (\count($exceptions)) { diff --git a/src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php b/src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php index c69022f1ef2bf..09571eaf8bfb0 100644 --- a/src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php +++ b/src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php @@ -13,7 +13,6 @@ use Psr\EventDispatcher\EventDispatcherInterface; use Psr\Log\LoggerAwareTrait; -use Psr\Log\NullLogger; use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\Event\SendMessageToTransportsEvent; use Symfony\Component\Messenger\Exception\NoSenderForMessageException; @@ -29,16 +28,11 @@ class SendMessageMiddleware implements MiddlewareInterface { use LoggerAwareTrait; - private SendersLocatorInterface $sendersLocator; - private ?EventDispatcherInterface $eventDispatcher; - private bool $allowNoSenders; - - public function __construct(SendersLocatorInterface $sendersLocator, EventDispatcherInterface $eventDispatcher = null, bool $allowNoSenders = true) - { - $this->sendersLocator = $sendersLocator; - $this->eventDispatcher = $eventDispatcher; - $this->allowNoSenders = $allowNoSenders; - $this->logger = new NullLogger(); + public function __construct( + private SendersLocatorInterface $sendersLocator, + private ?EventDispatcherInterface $eventDispatcher = null, + private bool $allowNoSenders = true, + ) { } public function handle(Envelope $envelope, StackInterface $stack): Envelope @@ -51,7 +45,7 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope if ($envelope->all(ReceivedStamp::class)) { // it's a received message, do not send it back - $this->logger->info('Received message {class}', $context); + $this->logger?->info('Received message {class}', $context); } else { $shouldDispatchEvent = true; $senders = $this->sendersLocator->getSenders($envelope); @@ -64,7 +58,7 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope $shouldDispatchEvent = false; } - $this->logger->info('Sending message {class} with {alias} sender using {sender}', $context + ['alias' => $alias, 'sender' => $sender::class]); + $this->logger?->info('Sending message {class} with {alias} sender using {sender}', $context + ['alias' => $alias, 'sender' => $sender::class]); $envelope = $sender->send($envelope->with(new SentStamp($sender::class, \is_string($alias) ? $alias : null))); } diff --git a/src/Symfony/Component/Messenger/Stamp/AckStamp.php b/src/Symfony/Component/Messenger/Stamp/AckStamp.php index b94c2c98e395c..6f5743e5d117b 100644 --- a/src/Symfony/Component/Messenger/Stamp/AckStamp.php +++ b/src/Symfony/Component/Messenger/Stamp/AckStamp.php @@ -18,14 +18,12 @@ */ final class AckStamp implements NonSendableStampInterface { - private $ack; - /** * @param \Closure(Envelope, \Throwable|null) $ack */ - public function __construct(\Closure $ack) - { - $this->ack = $ack; + public function __construct( + private readonly \Closure $ack, + ) { } public function ack(Envelope $envelope, \Throwable $e = null): void diff --git a/src/Symfony/Component/Messenger/Stamp/FlushBatchHandlersStamp.php b/src/Symfony/Component/Messenger/Stamp/FlushBatchHandlersStamp.php index 5dfbe2281efe3..99a0409cf5e13 100644 --- a/src/Symfony/Component/Messenger/Stamp/FlushBatchHandlersStamp.php +++ b/src/Symfony/Component/Messenger/Stamp/FlushBatchHandlersStamp.php @@ -16,7 +16,7 @@ */ final class FlushBatchHandlersStamp implements NonSendableStampInterface { - private $force; + private bool $force; public function __construct(bool $force) { diff --git a/src/Symfony/Component/Messenger/Stamp/NoAutoAckStamp.php b/src/Symfony/Component/Messenger/Stamp/NoAutoAckStamp.php index 15ba383b79c9c..6a293d4269505 100644 --- a/src/Symfony/Component/Messenger/Stamp/NoAutoAckStamp.php +++ b/src/Symfony/Component/Messenger/Stamp/NoAutoAckStamp.php @@ -18,7 +18,7 @@ */ final class NoAutoAckStamp implements NonSendableStampInterface { - private $handlerDescriptor; + private HandlerDescriptor $handlerDescriptor; public function __construct(HandlerDescriptor $handlerDescriptor) { diff --git a/src/Symfony/Component/Mime/Part/AbstractMultipartPart.php b/src/Symfony/Component/Mime/Part/AbstractMultipartPart.php index b7980ea0c25cf..1da0ddf33198c 100644 --- a/src/Symfony/Component/Mime/Part/AbstractMultipartPart.php +++ b/src/Symfony/Component/Mime/Part/AbstractMultipartPart.php @@ -18,8 +18,8 @@ */ abstract class AbstractMultipartPart extends AbstractPart { - private $boundary; - private $parts = []; + private ?string $boundary = null; + private array $parts = []; public function __construct(AbstractPart ...$parts) { diff --git a/src/Symfony/Component/Mime/Part/DataPart.php b/src/Symfony/Component/Mime/Part/DataPart.php index 4d5156d6e7cb2..2842267640642 100644 --- a/src/Symfony/Component/Mime/Part/DataPart.php +++ b/src/Symfony/Component/Mime/Part/DataPart.php @@ -20,19 +20,17 @@ class DataPart extends TextPart { /** @internal */ - protected $_parent; + protected array $_parent; - private $filename; - private $mediaType; - private $cid; + private ?string $filename = null; + private string $mediaType; + private ?string $cid = null; /** * @param resource|string|File $body Use a File instance to defer loading the file until rendering */ public function __construct($body, string $filename = null, string $contentType = null, string $encoding = null) { - unset($this->_parent); - if ($body instanceof File && !$filename) { $filename = $body->getFilename(); } diff --git a/src/Symfony/Component/Mime/Part/File.php b/src/Symfony/Component/Mime/Part/File.php index 0d75066ea4fdb..cd05a3deebcf4 100644 --- a/src/Symfony/Component/Mime/Part/File.php +++ b/src/Symfony/Component/Mime/Part/File.php @@ -18,7 +18,7 @@ */ class File { - private static $mimeTypes; + private static MimeTypes $mimeTypes; public function __construct( private string $path, diff --git a/src/Symfony/Component/Mime/Part/MessagePart.php b/src/Symfony/Component/Mime/Part/MessagePart.php index 520997aefd536..9d30544ae9f7a 100644 --- a/src/Symfony/Component/Mime/Part/MessagePart.php +++ b/src/Symfony/Component/Mime/Part/MessagePart.php @@ -21,7 +21,7 @@ */ class MessagePart extends DataPart { - private $message; + private RawMessage $message; public function __construct(RawMessage $message) { diff --git a/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php b/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php index e7dc3b17bb675..bd289f8ebe7fa 100644 --- a/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php +++ b/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php @@ -23,7 +23,7 @@ */ final class FormDataPart extends AbstractMultipartPart { - private $fields = []; + private array $fields = []; /** * @param array $fields diff --git a/src/Symfony/Component/Mime/Part/Multipart/RelatedPart.php b/src/Symfony/Component/Mime/Part/Multipart/RelatedPart.php index 08fdd5fa977ce..a0d6a1c2c0199 100644 --- a/src/Symfony/Component/Mime/Part/Multipart/RelatedPart.php +++ b/src/Symfony/Component/Mime/Part/Multipart/RelatedPart.php @@ -19,7 +19,7 @@ */ final class RelatedPart extends AbstractMultipartPart { - private $mainPart; + private AbstractPart $mainPart; public function __construct(AbstractPart $mainPart, AbstractPart $part, AbstractPart ...$parts) { diff --git a/src/Symfony/Component/Mime/Part/SMimePart.php b/src/Symfony/Component/Mime/Part/SMimePart.php index 7021819f6fd8c..57b9766b1faff 100644 --- a/src/Symfony/Component/Mime/Part/SMimePart.php +++ b/src/Symfony/Component/Mime/Part/SMimePart.php @@ -19,17 +19,15 @@ class SMimePart extends AbstractPart { /** @internal */ - protected $_headers; + protected Headers $_headers; - private $body; - private $type; - private $subtype; - private $parameters; + private iterable|string $body; + private string $type; + private string $subtype; + private array $parameters; public function __construct(iterable|string $body, string $type, string $subtype, array $parameters) { - unset($this->_headers); - parent::__construct(); $this->body = $body; diff --git a/src/Symfony/Component/Mime/Part/TextPart.php b/src/Symfony/Component/Mime/Part/TextPart.php index 01a684cca270a..576c64756c770 100644 --- a/src/Symfony/Component/Mime/Part/TextPart.php +++ b/src/Symfony/Component/Mime/Part/TextPart.php @@ -24,28 +24,23 @@ class TextPart extends AbstractPart { /** @internal */ - protected $_headers; + protected Headers $_headers; - private static $encoders = []; + private static array $encoders = []; private $body; - private $charset; - private $subtype; - /** - * @var ?string - */ - private $disposition; - private $name; - private $encoding; - private $seekable; + private ?string $charset; + private string $subtype; + private ?string $disposition = null; + private ?string $name = null; + private string $encoding; + private ?bool $seekable = null; /** * @param resource|string|File $body Use a File instance to defer loading the file until rendering */ public function __construct($body, ?string $charset = 'utf-8', string $subtype = 'plain', string $encoding = null) { - unset($this->_headers); - parent::__construct(); if (!\is_string($body) && !\is_resource($body) && !$body instanceof File) { diff --git a/src/Symfony/Component/Mime/RawMessage.php b/src/Symfony/Component/Mime/RawMessage.php index aec398c588098..de3fff38f635d 100644 --- a/src/Symfony/Component/Mime/RawMessage.php +++ b/src/Symfony/Component/Mime/RawMessage.php @@ -18,7 +18,7 @@ */ class RawMessage { - private $message; + private iterable|string|null $message = null; public function __construct(iterable|string $message) { diff --git a/src/Symfony/Component/Notifier/Bridge/Engagespot/EngagespotTransport.php b/src/Symfony/Component/Notifier/Bridge/Engagespot/EngagespotTransport.php index f60ac4231763a..efdae3a4cebff 100644 --- a/src/Symfony/Component/Notifier/Bridge/Engagespot/EngagespotTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Engagespot/EngagespotTransport.php @@ -29,8 +29,8 @@ final class EngagespotTransport extends AbstractTransport { protected const HOST = 'api.engagespot.co/2/campaigns'; - private $apiKey; - private $campaignName; + private string $apiKey; + private string $campaignName; public function __construct(#[\SensitiveParameter] string $apiKey, string $campaignName, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) { diff --git a/src/Symfony/Component/Notifier/Bridge/Expo/ExpoOptions.php b/src/Symfony/Component/Notifier/Bridge/Expo/ExpoOptions.php index fc780b56158ac..5f88192deea16 100644 --- a/src/Symfony/Component/Notifier/Bridge/Expo/ExpoOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/Expo/ExpoOptions.php @@ -20,14 +20,14 @@ */ final class ExpoOptions implements MessageOptionsInterface { - private $to; + private string $to; /** * @see https://docs.expo.dev/push-notifications/sending-notifications/#message-request-format */ - protected $options; + private array $options; - private $data; + private array $data; public function __construct(string $to, array $options = [], array $data = []) { diff --git a/src/Symfony/Component/Notifier/Bridge/Expo/ExpoTransport.php b/src/Symfony/Component/Notifier/Bridge/Expo/ExpoTransport.php index c8e0ab617dd5a..2eea64878f54f 100644 --- a/src/Symfony/Component/Notifier/Bridge/Expo/ExpoTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Expo/ExpoTransport.php @@ -29,8 +29,7 @@ final class ExpoTransport extends AbstractTransport { protected const HOST = 'exp.host/--/api/v2/push/send'; - /** @var string|null */ - private $token; + private ?string $token; public function __construct(#[\SensitiveParameter] string $token = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) { diff --git a/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostOptions.php b/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostOptions.php index 564199b1211f8..a7313f367cecf 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostOptions.php @@ -18,7 +18,7 @@ */ final class MattermostOptions implements MessageOptionsInterface { - private $options; + private array $options; public function __construct(array $options = []) { diff --git a/src/Symfony/Component/Notifier/Bridge/OneSignal/OneSignalOptions.php b/src/Symfony/Component/Notifier/Bridge/OneSignal/OneSignalOptions.php index 39e0778291b86..e4470af7f1ba1 100644 --- a/src/Symfony/Component/Notifier/Bridge/OneSignal/OneSignalOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/OneSignal/OneSignalOptions.php @@ -19,7 +19,7 @@ */ final class OneSignalOptions implements MessageOptionsInterface { - private $options; + private array $options; public function __construct(array $options = []) { diff --git a/src/Symfony/Component/Notifier/Bridge/OneSignal/OneSignalTransport.php b/src/Symfony/Component/Notifier/Bridge/OneSignal/OneSignalTransport.php index f146fca81b98f..89cd6195814ec 100644 --- a/src/Symfony/Component/Notifier/Bridge/OneSignal/OneSignalTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/OneSignal/OneSignalTransport.php @@ -29,9 +29,9 @@ final class OneSignalTransport extends AbstractTransport { protected const HOST = 'onesignal.com'; - private $appId; - private $apiKey; - private $defaultRecipientId; + private string $appId; + private string $apiKey; + private ?string $defaultRecipientId; public function __construct(string $appId, #[\SensitiveParameter] string $apiKey, string $defaultRecipientId = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) { diff --git a/src/Symfony/Component/Notifier/Bridge/Sms77/Sms77Transport.php b/src/Symfony/Component/Notifier/Bridge/Sms77/Sms77Transport.php index 6916daaebb33b..6761ec1f8dd58 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sms77/Sms77Transport.php +++ b/src/Symfony/Component/Notifier/Bridge/Sms77/Sms77Transport.php @@ -28,8 +28,8 @@ final class Sms77Transport extends AbstractTransport { protected const HOST = 'gateway.sms77.io'; - private $apiKey; - private $from; + private string $apiKey; + private ?string $from; public function __construct(#[\SensitiveParameter] string $apiKey, string $from = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) { diff --git a/src/Symfony/Component/Notifier/Bridge/Twitter/TwitterTransport.php b/src/Symfony/Component/Notifier/Bridge/Twitter/TwitterTransport.php index 9a5317ad0526f..72bfc07fb9b2f 100644 --- a/src/Symfony/Component/Notifier/Bridge/Twitter/TwitterTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Twitter/TwitterTransport.php @@ -34,7 +34,7 @@ final class TwitterTransport extends AbstractTransport { protected const HOST = 'api.twitter.com'; - private static $nonce; + private static string $nonce; private string $apiKey; private string $apiSecret; diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/VonageTransport.php b/src/Symfony/Component/Notifier/Bridge/Vonage/VonageTransport.php index 40ce9e650d72b..bdc910f14adf0 100644 --- a/src/Symfony/Component/Notifier/Bridge/Vonage/VonageTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/VonageTransport.php @@ -29,9 +29,9 @@ final class VonageTransport extends AbstractTransport // see https://developer.vonage.com/messaging/sms/overview protected const HOST = 'rest.nexmo.com'; - private $apiKey; - private $apiSecret; - private $from; + private string $apiKey; + private string $apiSecret; + private string $from; public function __construct(string $apiKey, #[\SensitiveParameter] string $apiSecret, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) { diff --git a/src/Symfony/Component/Notifier/Message/PushMessage.php b/src/Symfony/Component/Notifier/Message/PushMessage.php index 21f71b58bc266..41f71d6d7b6e0 100644 --- a/src/Symfony/Component/Notifier/Message/PushMessage.php +++ b/src/Symfony/Component/Notifier/Message/PushMessage.php @@ -18,11 +18,11 @@ */ class PushMessage implements MessageInterface, FromNotificationInterface { - private $transport; - private $subject; - private $content; - private $options; - private $notification; + private ?string $transport = null; + private string $subject; + private string $content; + private ?MessageOptionsInterface $options; + private ?Notification $notification = null; public function __construct(string $subject, string $content, MessageOptionsInterface $options = null) { diff --git a/src/Symfony/Component/Notifier/Test/Constraint/NotificationCount.php b/src/Symfony/Component/Notifier/Test/Constraint/NotificationCount.php index 01fc953735ff1..5850f8cc4edd7 100644 --- a/src/Symfony/Component/Notifier/Test/Constraint/NotificationCount.php +++ b/src/Symfony/Component/Notifier/Test/Constraint/NotificationCount.php @@ -19,9 +19,9 @@ */ final class NotificationCount extends Constraint { - private $expectedValue; - private $transport; - private $queued; + private int $expectedValue; + private ?string $transport; + private bool $queued; public function __construct(int $expectedValue, string $transport = null, bool $queued = false) { diff --git a/src/Symfony/Component/Notifier/Test/Constraint/NotificationSubjectContains.php b/src/Symfony/Component/Notifier/Test/Constraint/NotificationSubjectContains.php index 2d3fdb806334c..81cafd473a358 100644 --- a/src/Symfony/Component/Notifier/Test/Constraint/NotificationSubjectContains.php +++ b/src/Symfony/Component/Notifier/Test/Constraint/NotificationSubjectContains.php @@ -19,7 +19,7 @@ */ final class NotificationSubjectContains extends Constraint { - private $expectedText; + private string $expectedText; public function __construct(string $expectedText) { diff --git a/src/Symfony/Component/Notifier/Test/Constraint/NotificationTransportIsEqual.php b/src/Symfony/Component/Notifier/Test/Constraint/NotificationTransportIsEqual.php index 16b1c2b4e3134..cefa0cdc35dac 100644 --- a/src/Symfony/Component/Notifier/Test/Constraint/NotificationTransportIsEqual.php +++ b/src/Symfony/Component/Notifier/Test/Constraint/NotificationTransportIsEqual.php @@ -19,7 +19,7 @@ */ final class NotificationTransportIsEqual extends Constraint { - private $expectedText; + private string $expectedText; public function __construct(string $expectedText) { diff --git a/src/Symfony/Component/OptionsResolver/Debug/OptionsResolverIntrospector.php b/src/Symfony/Component/OptionsResolver/Debug/OptionsResolverIntrospector.php index 837fae0858886..f55ab147bb908 100644 --- a/src/Symfony/Component/OptionsResolver/Debug/OptionsResolverIntrospector.php +++ b/src/Symfony/Component/OptionsResolver/Debug/OptionsResolverIntrospector.php @@ -22,7 +22,7 @@ */ class OptionsResolverIntrospector { - private $get; + private \Closure $get; public function __construct(OptionsResolver $optionsResolver) { diff --git a/src/Symfony/Component/OptionsResolver/OptionConfigurator.php b/src/Symfony/Component/OptionsResolver/OptionConfigurator.php index de98db012b2f5..3aa37288aece3 100644 --- a/src/Symfony/Component/OptionsResolver/OptionConfigurator.php +++ b/src/Symfony/Component/OptionsResolver/OptionConfigurator.php @@ -15,8 +15,8 @@ final class OptionConfigurator { - private $name; - private $resolver; + private string $name; + private OptionsResolver $resolver; public function __construct(string $name, OptionsResolver $resolver) { diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index 724b121dd4075..dbeef8dc90846 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -50,73 +50,73 @@ class OptionsResolver implements Options /** * The names of all defined options. */ - private $defined = []; + private array $defined = []; /** * The default option values. */ - private $defaults = []; + private array $defaults = []; /** * A list of closure for nested options. * * @var \Closure[][] */ - private $nested = []; + private array $nested = []; /** * The names of required options. */ - private $required = []; + private array $required = []; /** * The resolved option values. */ - private $resolved = []; + private array $resolved = []; /** * A list of normalizer closures. * * @var \Closure[][] */ - private $normalizers = []; + private array $normalizers = []; /** * A list of accepted values for each option. */ - private $allowedValues = []; + private array $allowedValues = []; /** * A list of accepted types for each option. */ - private $allowedTypes = []; + private array $allowedTypes = []; /** * A list of info messages for each option. */ - private $info = []; + private array $info = []; /** * A list of closures for evaluating lazy options. */ - private $lazy = []; + private array $lazy = []; /** * A list of lazy options whose closure is currently being called. * * This list helps detecting circular dependencies between lazy options. */ - private $calling = []; + private array $calling = []; /** * A list of deprecated options. */ - private $deprecated = []; + private array $deprecated = []; /** * The list of options provided by the user. */ - private $given = []; + private array $given = []; /** * Whether the instance is locked for reading. @@ -126,19 +126,19 @@ class OptionsResolver implements Options * process. If any option is changed after being read, all evaluated * lazy options that depend on this option would become invalid. */ - private $locked = false; + private bool $locked = false; - private $parentsOptions = []; + private array $parentsOptions = []; /** * Whether the whole options definition is marked as array prototype. */ - private $prototype; + private ?bool $prototype = null; /** * The prototype array's index that is being read. */ - private $prototypeIndex; + private int|string|null $prototypeIndex = null; /** * Whether to ignore undefined options. diff --git a/src/Symfony/Component/Process/Exception/ProcessFailedException.php b/src/Symfony/Component/Process/Exception/ProcessFailedException.php index cf006daebfe61..19b40570c0857 100644 --- a/src/Symfony/Component/Process/Exception/ProcessFailedException.php +++ b/src/Symfony/Component/Process/Exception/ProcessFailedException.php @@ -20,7 +20,7 @@ */ class ProcessFailedException extends RuntimeException { - private $process; + private Process $process; public function __construct(Process $process) { diff --git a/src/Symfony/Component/Process/Exception/ProcessSignaledException.php b/src/Symfony/Component/Process/Exception/ProcessSignaledException.php index d4d322756f39b..0fed8ac30b7a0 100644 --- a/src/Symfony/Component/Process/Exception/ProcessSignaledException.php +++ b/src/Symfony/Component/Process/Exception/ProcessSignaledException.php @@ -20,7 +20,7 @@ */ final class ProcessSignaledException extends RuntimeException { - private $process; + private Process $process; public function __construct(Process $process) { diff --git a/src/Symfony/Component/Process/Exception/ProcessTimedOutException.php b/src/Symfony/Component/Process/Exception/ProcessTimedOutException.php index e507ca3099003..1cecdae75dbc9 100644 --- a/src/Symfony/Component/Process/Exception/ProcessTimedOutException.php +++ b/src/Symfony/Component/Process/Exception/ProcessTimedOutException.php @@ -23,8 +23,8 @@ class ProcessTimedOutException extends RuntimeException public const TYPE_GENERAL = 1; public const TYPE_IDLE = 2; - private $process; - private $timeoutType; + private Process $process; + private int $timeoutType; public function __construct(Process $process, int $timeoutType) { diff --git a/src/Symfony/Component/Process/ExecutableFinder.php b/src/Symfony/Component/Process/ExecutableFinder.php index e3387dfe15e75..b31f7530bcecd 100644 --- a/src/Symfony/Component/Process/ExecutableFinder.php +++ b/src/Symfony/Component/Process/ExecutableFinder.php @@ -19,7 +19,7 @@ */ class ExecutableFinder { - private $suffixes = ['.exe', '.bat', '.cmd', '.com']; + private array $suffixes = ['.exe', '.bat', '.cmd', '.com']; /** * Replaces default suffixes of executable. diff --git a/src/Symfony/Component/Process/InputStream.php b/src/Symfony/Component/Process/InputStream.php index 086f5a9edffc1..cf2773254ee5d 100644 --- a/src/Symfony/Component/Process/InputStream.php +++ b/src/Symfony/Component/Process/InputStream.php @@ -22,10 +22,9 @@ */ class InputStream implements \IteratorAggregate { - /** @var callable|null */ - private $onEmpty; - private $input = []; - private $open = true; + private ?\Closure $onEmpty = null; + private array $input = []; + private bool $open = true; /** * Sets a callback that is called when the write buffer becomes empty. @@ -34,7 +33,7 @@ class InputStream implements \IteratorAggregate */ public function onEmpty(callable $onEmpty = null) { - $this->onEmpty = $onEmpty; + $this->onEmpty = null !== $onEmpty ? $onEmpty(...) : null; } /** diff --git a/src/Symfony/Component/Process/PhpExecutableFinder.php b/src/Symfony/Component/Process/PhpExecutableFinder.php index 9ab8ac23fa29e..09f15008e59e3 100644 --- a/src/Symfony/Component/Process/PhpExecutableFinder.php +++ b/src/Symfony/Component/Process/PhpExecutableFinder.php @@ -19,7 +19,7 @@ */ class PhpExecutableFinder { - private $executableFinder; + private ExecutableFinder $executableFinder; public function __construct() { diff --git a/src/Symfony/Component/Process/Pipes/AbstractPipes.php b/src/Symfony/Component/Process/Pipes/AbstractPipes.php index ba3a97a3f6b1b..c54d4b436c313 100644 --- a/src/Symfony/Component/Process/Pipes/AbstractPipes.php +++ b/src/Symfony/Component/Process/Pipes/AbstractPipes.php @@ -22,10 +22,10 @@ abstract class AbstractPipes implements PipesInterface { public array $pipes = []; - private $inputBuffer = ''; + private string $inputBuffer = ''; private $input; - private $blocked = true; - private $lastError; + private bool $blocked = true; + private ?string $lastError = null; /** * @param resource|string|int|float|bool|\Iterator|null $input diff --git a/src/Symfony/Component/Process/Pipes/UnixPipes.php b/src/Symfony/Component/Process/Pipes/UnixPipes.php index d381d57b1c499..7bd0db0e94b45 100644 --- a/src/Symfony/Component/Process/Pipes/UnixPipes.php +++ b/src/Symfony/Component/Process/Pipes/UnixPipes.php @@ -22,9 +22,9 @@ */ class UnixPipes extends AbstractPipes { - private $ttyMode; - private $ptyMode; - private $haveReadSupport; + private ?bool $ttyMode; + private bool $ptyMode; + private bool $haveReadSupport; public function __construct(?bool $ttyMode, bool $ptyMode, mixed $input, bool $haveReadSupport) { diff --git a/src/Symfony/Component/Process/Pipes/WindowsPipes.php b/src/Symfony/Component/Process/Pipes/WindowsPipes.php index 793ccb15a01b1..637c8f3897636 100644 --- a/src/Symfony/Component/Process/Pipes/WindowsPipes.php +++ b/src/Symfony/Component/Process/Pipes/WindowsPipes.php @@ -26,14 +26,14 @@ */ class WindowsPipes extends AbstractPipes { - private $files = []; - private $fileHandles = []; - private $lockHandles = []; - private $readBytes = [ + private array $files = []; + private array $fileHandles = []; + private array $lockHandles = []; + private array $readBytes = [ Process::STDOUT => 0, Process::STDERR => 0, ]; - private $haveReadSupport; + private bool $haveReadSupport; public function __construct(mixed $input, bool $haveReadSupport) { diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index f330d405af0f0..1d30d27b6b64d 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -17,7 +17,6 @@ use Symfony\Component\Process\Exception\ProcessSignaledException; use Symfony\Component\Process\Exception\ProcessTimedOutException; use Symfony\Component\Process\Exception\RuntimeException; -use Symfony\Component\Process\Pipes\PipesInterface; use Symfony\Component\Process\Pipes\UnixPipes; use Symfony\Component\Process\Pipes\WindowsPipes; @@ -51,37 +50,35 @@ class Process implements \IteratorAggregate public const ITER_SKIP_OUT = 4; // Use this flag to skip STDOUT while iterating public const ITER_SKIP_ERR = 8; // Use this flag to skip STDERR while iterating - private $callback; - private $hasCallback = false; - private $commandline; - private $cwd; - private $env = []; + private ?\Closure $callback = null; + private array|string $commandline; + private ?string $cwd; + private array $env = []; private $input; - private $starttime; - private $lastOutputTime; - private $timeout; - private $idleTimeout; - private $exitcode; - private $fallbackStatus = []; - private $processInformation; - private $outputDisabled = false; + private ?float $starttime = null; + private ?float $lastOutputTime = null; + private ?float $timeout = null; + private ?float $idleTimeout = null; + private ?int $exitcode = null; + private array $fallbackStatus = []; + private array $processInformation; + private bool $outputDisabled = false; private $stdout; private $stderr; private $process; - private $status = self::STATUS_READY; - private $incrementalOutputOffset = 0; - private $incrementalErrorOutputOffset = 0; - private $tty = false; - private $pty; - private $options = ['suppress_errors' => true, 'bypass_shell' => true]; + private string $status = self::STATUS_READY; + private int $incrementalOutputOffset = 0; + private int $incrementalErrorOutputOffset = 0; + private bool $tty = false; + private bool $pty; + private array $options = ['suppress_errors' => true, 'bypass_shell' => true]; - private $useFileHandles = false; - /** @var PipesInterface */ - private $processPipes; + private bool $useFileHandles; + private WindowsPipes|UnixPipes $processPipes; - private $latestSignal; + private ?int $latestSignal = null; - private static $sigchild; + private static ?bool $sigchild = null; /** * Exit codes translation table. @@ -303,7 +300,6 @@ public function start(callable $callback = null, array $env = []) $this->resetProcessData(); $this->starttime = $this->lastOutputTime = microtime(true); $this->callback = $this->buildCallback($callback); - $this->hasCallback = null !== $callback; $descriptors = $this->getDescriptors(); if ($this->env) { @@ -1245,9 +1241,9 @@ private function getDescriptors(): array $this->input->rewind(); } if ('\\' === \DIRECTORY_SEPARATOR) { - $this->processPipes = new WindowsPipes($this->input, !$this->outputDisabled || $this->hasCallback); + $this->processPipes = new WindowsPipes($this->input, !$this->outputDisabled || $this->callback); } else { - $this->processPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $this->hasCallback); + $this->processPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $this->callback); } return $this->processPipes->getDescriptors(); @@ -1424,7 +1420,7 @@ private function resetProcessData(): void $this->callback = null; $this->exitcode = null; $this->fallbackStatus = []; - $this->processInformation = null; + $this->processInformation = []; $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+'); $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+'); $this->process = null; diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index 579b13452def2..774c2e989bae2 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -57,31 +57,18 @@ class PropertyAccessor implements PropertyAccessorInterface private const CACHE_PREFIX_READ = 'r'; private const CACHE_PREFIX_WRITE = 'w'; private const CACHE_PREFIX_PROPERTY_PATH = 'p'; - - private $magicMethodsFlags; - private $ignoreInvalidIndices; - private $ignoreInvalidProperty; - - /** - * @var CacheItemPoolInterface - */ - private $cacheItemPool; - - private $propertyPathCache = []; - - /** - * @var PropertyReadInfoExtractorInterface - */ - private $readInfoExtractor; - - /** - * @var PropertyWriteInfoExtractorInterface - */ - private $writeInfoExtractor; - private $readPropertyCache = []; - private $writePropertyCache = []; private const RESULT_PROTO = [self::VALUE => null]; + private int $magicMethodsFlags; + private bool $ignoreInvalidIndices; + private bool $ignoreInvalidProperty; + private ?CacheItemPoolInterface $cacheItemPool; + private array $propertyPathCache = []; + private PropertyReadInfoExtractorInterface $readInfoExtractor; + private PropertyWriteInfoExtractorInterface $writeInfoExtractor; + private array $readPropertyCache = []; + private array $writePropertyCache = []; + /** * Should not be used by application code. Use * {@link PropertyAccess::createPropertyAccessor()} instead. diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php b/src/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php index 51362afeb93a8..5593e31b05546 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php @@ -22,25 +22,12 @@ */ class PropertyAccessorBuilder { - /** @var int */ - private $magicMethods = PropertyAccessor::MAGIC_GET | PropertyAccessor::MAGIC_SET; - private $throwExceptionOnInvalidIndex = false; - private $throwExceptionOnInvalidPropertyPath = true; - - /** - * @var CacheItemPoolInterface|null - */ - private $cacheItemPool; - - /** - * @var PropertyReadInfoExtractorInterface|null - */ - private $readInfoExtractor; - - /** - * @var PropertyWriteInfoExtractorInterface|null - */ - private $writeInfoExtractor; + private int $magicMethods = PropertyAccessor::MAGIC_GET | PropertyAccessor::MAGIC_SET; + private bool $throwExceptionOnInvalidIndex = false; + private bool $throwExceptionOnInvalidPropertyPath = true; + private ?CacheItemPoolInterface $cacheItemPool = null; + private ?PropertyReadInfoExtractorInterface $readInfoExtractor = null; + private ?PropertyWriteInfoExtractorInterface $writeInfoExtractor = null; /** * Enables the use of all magic methods by the PropertyAccessor. diff --git a/src/Symfony/Component/PropertyAccess/PropertyPath.php b/src/Symfony/Component/PropertyAccess/PropertyPath.php index bf79bb307f105..a94e960ecd39d 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPath.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPath.php @@ -34,14 +34,12 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface * * @var list */ - private $elements = []; + private array $elements = []; /** * The number of elements in the property path. - * - * @var int */ - private $length; + private int $length; /** * Contains a Boolean for each property in $elements denoting whether this @@ -49,7 +47,7 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface * * @var array */ - private $isIndex = []; + private array $isIndex = []; /** * Contains a Boolean for each property in $elements denoting whether this @@ -57,14 +55,12 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface * * @var array */ - private $isNullSafe = []; + private array $isNullSafe = []; /** * String representation of the path. - * - * @var string */ - private $pathAsString; + private string $pathAsString; /** * Constructs a property path from a string. diff --git a/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php b/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php index a0154bd7ce483..7a87eec0e1a80 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php @@ -18,8 +18,8 @@ */ class PropertyPathBuilder { - private $elements = []; - private $isIndex = []; + private array $elements = []; + private array $isIndex = []; public function __construct(PropertyPathInterface|string $path = null) { diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ConstructorExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ConstructorExtractor.php index 9ee807111f4b8..18e563a71883d 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/ConstructorExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/ConstructorExtractor.php @@ -20,14 +20,12 @@ */ final class ConstructorExtractor implements PropertyTypeExtractorInterface { - private $extractors; - /** * @param iterable $extractors */ - public function __construct(iterable $extractors = []) - { - $this->extractors = $extractors; + public function __construct( + private readonly iterable $extractors = [], + ) { } public function getTypes(string $class, string $property, array $context = []): ?array diff --git a/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php index 75cae97b71afd..e329e9c0d2804 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php @@ -38,19 +38,19 @@ class PhpDocExtractor implements PropertyDescriptionExtractorInterface, Property /** * @var array */ - private $docBlocks = []; + private array $docBlocks = []; /** * @var Context[] */ - private $contexts = []; - - private $docBlockFactory; - private $contextFactory; - private $phpDocTypeHelper; - private $mutatorPrefixes; - private $accessorPrefixes; - private $arrayMutatorPrefixes; + private array $contexts = []; + + private DocBlockFactoryInterface $docBlockFactory; + private ContextFactory $contextFactory; + private PhpDocTypeHelper $phpDocTypeHelper; + private array $mutatorPrefixes; + private array $accessorPrefixes; + private array $arrayMutatorPrefixes; /** * @param string[]|null $mutatorPrefixes diff --git a/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php index 561dd2f2b44ad..d147d090b724a 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php @@ -37,21 +37,16 @@ final class PhpStanExtractor implements PropertyTypeExtractorInterface, Construc private const ACCESSOR = 1; private const MUTATOR = 2; - /** @var PhpDocParser */ - private $phpDocParser; - - /** @var Lexer */ - private $lexer; - - /** @var NameScopeFactory */ - private $nameScopeFactory; + private PhpDocParser $phpDocParser; + private Lexer $lexer; + private NameScopeFactory $nameScopeFactory; /** @var array */ - private $docBlocks = []; - private $phpStanTypeHelper; - private $mutatorPrefixes; - private $accessorPrefixes; - private $arrayMutatorPrefixes; + private array $docBlocks = []; + private PhpStanTypeHelper $phpStanTypeHelper; + private array $mutatorPrefixes; + private array $accessorPrefixes; + private array $arrayMutatorPrefixes; /** * @param list|null $mutatorPrefixes diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php index 6bd82147734d6..ddd073593104a 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php @@ -66,17 +66,16 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp 'double' => Type::BUILTIN_TYPE_FLOAT, ]; - private $mutatorPrefixes; - private $accessorPrefixes; - private $arrayMutatorPrefixes; - private $enableConstructorExtraction; - private $methodReflectionFlags; - private $magicMethodsFlags; - private $propertyReflectionFlags; - private $inflector; - - private $arrayMutatorPrefixesFirst; - private $arrayMutatorPrefixesLast; + private array $mutatorPrefixes; + private array $accessorPrefixes; + private array $arrayMutatorPrefixes; + private bool $enableConstructorExtraction; + private int $methodReflectionFlags; + private int $magicMethodsFlags; + private int $propertyReflectionFlags; + private InflectorInterface $inflector; + private array $arrayMutatorPrefixesFirst; + private array $arrayMutatorPrefixesLast; /** * @param string[]|null $mutatorPrefixes diff --git a/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php index 35253848b0a7a..0e6454206c895 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php @@ -23,11 +23,9 @@ */ class SerializerExtractor implements PropertyListExtractorInterface { - private $classMetadataFactory; - - public function __construct(ClassMetadataFactoryInterface $classMetadataFactory) - { - $this->classMetadataFactory = $classMetadataFactory; + public function __construct( + private readonly ClassMetadataFactoryInterface $classMetadataFactory, + ) { } public function getProperties(string $class, array $context = []): ?array diff --git a/src/Symfony/Component/PropertyInfo/PhpStan/NameScope.php b/src/Symfony/Component/PropertyInfo/PhpStan/NameScope.php index 6f971a243fbcf..91d91fa8ebc84 100644 --- a/src/Symfony/Component/PropertyInfo/PhpStan/NameScope.php +++ b/src/Symfony/Component/PropertyInfo/PhpStan/NameScope.php @@ -22,10 +22,10 @@ */ final class NameScope { - private $calledClassName; - private $namespace; + private string $calledClassName; + private string $namespace; /** @var array alias(string) => fullName(string) */ - private $uses; + private array $uses; public function __construct(string $calledClassName, string $namespace, array $uses = []) { diff --git a/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php b/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php index f096d2d8fabe6..b4543eace7d6e 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php +++ b/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php @@ -22,14 +22,12 @@ */ class PropertyInfoCacheExtractor implements PropertyInfoExtractorInterface, PropertyInitializableExtractorInterface { - private $propertyInfoExtractor; - private $cacheItemPool; - private $arrayCache = []; + private array $arrayCache = []; - public function __construct(PropertyInfoExtractorInterface $propertyInfoExtractor, CacheItemPoolInterface $cacheItemPool) - { - $this->propertyInfoExtractor = $propertyInfoExtractor; - $this->cacheItemPool = $cacheItemPool; + public function __construct( + private readonly PropertyInfoExtractorInterface $propertyInfoExtractor, + private readonly CacheItemPoolInterface $cacheItemPool, + ) { } public function isReadable(string $class, string $property, array $context = []): ?bool diff --git a/src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php b/src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php index c3ab15725a1c2..7416849a0a843 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php +++ b/src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php @@ -20,12 +20,6 @@ */ class PropertyInfoExtractor implements PropertyInfoExtractorInterface, PropertyInitializableExtractorInterface { - private $listExtractors; - private $typeExtractors; - private $descriptionExtractors; - private $accessExtractors; - private $initializableExtractors; - /** * @param iterable $listExtractors * @param iterable $typeExtractors @@ -33,13 +27,13 @@ class PropertyInfoExtractor implements PropertyInfoExtractorInterface, PropertyI * @param iterable $accessExtractors * @param iterable $initializableExtractors */ - public function __construct(iterable $listExtractors = [], iterable $typeExtractors = [], iterable $descriptionExtractors = [], iterable $accessExtractors = [], iterable $initializableExtractors = []) - { - $this->listExtractors = $listExtractors; - $this->typeExtractors = $typeExtractors; - $this->descriptionExtractors = $descriptionExtractors; - $this->accessExtractors = $accessExtractors; - $this->initializableExtractors = $initializableExtractors; + public function __construct( + private readonly iterable $listExtractors = [], + private readonly iterable $typeExtractors = [], + private readonly iterable $descriptionExtractors = [], + private readonly iterable $accessExtractors = [], + private readonly iterable $initializableExtractors = [], + ) { } public function getProperties(string $class, array $context = []): ?array diff --git a/src/Symfony/Component/PropertyInfo/PropertyReadInfo.php b/src/Symfony/Component/PropertyInfo/PropertyReadInfo.php index ae10352444793..8de070dc046c9 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyReadInfo.php +++ b/src/Symfony/Component/PropertyInfo/PropertyReadInfo.php @@ -27,23 +27,13 @@ final class PropertyReadInfo public const VISIBILITY_PROTECTED = 'protected'; public const VISIBILITY_PRIVATE = 'private'; - private $type; - - private $name; - - private $visibility; - - private $static; - - private $byRef; - - public function __construct(string $type, string $name, string $visibility, bool $static, bool $byRef) - { - $this->type = $type; - $this->name = $name; - $this->visibility = $visibility; - $this->static = $static; - $this->byRef = $byRef; + public function __construct( + private readonly string $type, + private readonly string $name, + private readonly string $visibility, + private readonly bool $static, + private readonly bool $byRef, + ) { } /** diff --git a/src/Symfony/Component/PropertyInfo/PropertyWriteInfo.php b/src/Symfony/Component/PropertyInfo/PropertyWriteInfo.php index b4e33b24084fa..6bc7abcdf849e 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyWriteInfo.php +++ b/src/Symfony/Component/PropertyInfo/PropertyWriteInfo.php @@ -30,20 +30,16 @@ final class PropertyWriteInfo public const VISIBILITY_PROTECTED = 'protected'; public const VISIBILITY_PRIVATE = 'private'; - private $type; - private $name; - private $visibility; - private $static; - private $adderInfo; - private $removerInfo; - private $errors = []; - - public function __construct(string $type = self::TYPE_NONE, string $name = null, string $visibility = null, bool $static = null) - { - $this->type = $type; - $this->name = $name; - $this->visibility = $visibility; - $this->static = $static; + private ?self $adderInfo = null; + private ?self $removerInfo = null; + private array $errors = []; + + public function __construct( + private readonly string $type = self::TYPE_NONE, + private readonly ?string $name = null, + private readonly ?string $visibility = null, + private readonly ?bool $static = null, + ) { } public function getType(): string diff --git a/src/Symfony/Component/PropertyInfo/Type.php b/src/Symfony/Component/PropertyInfo/Type.php index 2a33b14467276..a6fb90abf4a1e 100644 --- a/src/Symfony/Component/PropertyInfo/Type.php +++ b/src/Symfony/Component/PropertyInfo/Type.php @@ -63,12 +63,12 @@ class Type self::BUILTIN_TYPE_ITERABLE, ]; - private $builtinType; - private $nullable; - private $class; - private $collection; - private $collectionKeyType; - private $collectionValueType; + private string $builtinType; + private bool $nullable; + private ?string $class; + private bool $collection; + private array $collectionKeyType; + private array $collectionValueType; /** * @param Type[]|Type|null $collectionKeyType diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherTrait.php b/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherTrait.php index 207d054fb3ed5..50abf45878310 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherTrait.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherTrait.php @@ -30,11 +30,7 @@ trait CompiledUrlMatcherTrait private array $staticRoutes = []; private array $regexpList = []; private array $dynamicRoutes = []; - - /** - * @var callable|null - */ - private $checkCondition; + private ?\Closure $checkCondition; public function match(string $pathinfo): array { diff --git a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php index d1cee213778f3..778d154edbeb6 100644 --- a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php @@ -260,7 +260,7 @@ protected function mergeDefaults(array $params, array $defaults): array */ protected function getExpressionLanguage() { - if (null === $this->expressionLanguage) { + if (!isset($this->expressionLanguage)) { if (!class_exists(ExpressionLanguage::class)) { throw new \LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".'); } diff --git a/src/Symfony/Component/Routing/RouteCollection.php b/src/Symfony/Component/Routing/RouteCollection.php index f244e62bed344..0175e3abfeb19 100644 --- a/src/Symfony/Component/Routing/RouteCollection.php +++ b/src/Symfony/Component/Routing/RouteCollection.php @@ -37,7 +37,7 @@ class RouteCollection implements \IteratorAggregate, \Countable /** * @var array */ - private $aliases = []; + private array $aliases = []; /** * @var array diff --git a/src/Symfony/Component/Runtime/Internal/ComposerPlugin.php b/src/Symfony/Component/Runtime/Internal/ComposerPlugin.php index 1861676ad30ab..4f49e2bf2684d 100644 --- a/src/Symfony/Component/Runtime/Internal/ComposerPlugin.php +++ b/src/Symfony/Component/Runtime/Internal/ComposerPlugin.php @@ -27,17 +27,10 @@ */ class ComposerPlugin implements PluginInterface, EventSubscriberInterface { - /** - * @var Composer - */ - private $composer; + private Composer $composer; + private IOInterface $io; - /** - * @var IOInterface - */ - private $io; - - private static $activated = false; + private static bool $activated = false; public function activate(Composer $composer, IOInterface $io): void { diff --git a/src/Symfony/Component/Runtime/Resolver/ClosureResolver.php b/src/Symfony/Component/Runtime/Resolver/ClosureResolver.php index 183dcd6ad7777..c58cf2fbfb105 100644 --- a/src/Symfony/Component/Runtime/Resolver/ClosureResolver.php +++ b/src/Symfony/Component/Runtime/Resolver/ClosureResolver.php @@ -18,13 +18,10 @@ */ class ClosureResolver implements ResolverInterface { - private $closure; - private $arguments; - - public function __construct(\Closure $closure, \Closure $arguments) - { - $this->closure = $closure; - $this->arguments = $arguments; + public function __construct( + private readonly \Closure $closure, + private readonly \Closure $arguments, + ) { } public function resolve(): array diff --git a/src/Symfony/Component/Runtime/Runner/ClosureRunner.php b/src/Symfony/Component/Runtime/Runner/ClosureRunner.php index ab5207dfa4e1f..4b12ff1e3c88e 100644 --- a/src/Symfony/Component/Runtime/Runner/ClosureRunner.php +++ b/src/Symfony/Component/Runtime/Runner/ClosureRunner.php @@ -18,11 +18,9 @@ */ class ClosureRunner implements RunnerInterface { - private $closure; - - public function __construct(\Closure $closure) - { - $this->closure = $closure; + public function __construct( + private readonly \Closure $closure, + ) { } public function run(): int diff --git a/src/Symfony/Component/Runtime/Runner/Symfony/ConsoleApplicationRunner.php b/src/Symfony/Component/Runtime/Runner/Symfony/ConsoleApplicationRunner.php index 430ce57989ba4..d64bc1c77bf9f 100644 --- a/src/Symfony/Component/Runtime/Runner/Symfony/ConsoleApplicationRunner.php +++ b/src/Symfony/Component/Runtime/Runner/Symfony/ConsoleApplicationRunner.php @@ -22,17 +22,12 @@ */ class ConsoleApplicationRunner implements RunnerInterface { - private $application; - private $defaultEnv; - private $input; - private $output; - - public function __construct(Application $application, ?string $defaultEnv, InputInterface $input, OutputInterface $output = null) - { - $this->application = $application; - $this->defaultEnv = $defaultEnv; - $this->input = $input; - $this->output = $output; + public function __construct( + private readonly Application $application, + private readonly ?string $defaultEnv, + private readonly InputInterface $input, + private readonly ?OutputInterface $output = null, + ) { } public function run(): int diff --git a/src/Symfony/Component/Runtime/Runner/Symfony/HttpKernelRunner.php b/src/Symfony/Component/Runtime/Runner/Symfony/HttpKernelRunner.php index 691530d98bd27..e840623027492 100644 --- a/src/Symfony/Component/Runtime/Runner/Symfony/HttpKernelRunner.php +++ b/src/Symfony/Component/Runtime/Runner/Symfony/HttpKernelRunner.php @@ -21,13 +21,10 @@ */ class HttpKernelRunner implements RunnerInterface { - private $kernel; - private $request; - - public function __construct(HttpKernelInterface $kernel, Request $request) - { - $this->kernel = $kernel; - $this->request = $request; + public function __construct( + private readonly HttpKernelInterface $kernel, + private readonly Request $request, + ) { } public function run(): int diff --git a/src/Symfony/Component/Runtime/Runner/Symfony/ResponseRunner.php b/src/Symfony/Component/Runtime/Runner/Symfony/ResponseRunner.php index 05de474187a1d..04e5a3fa144f0 100644 --- a/src/Symfony/Component/Runtime/Runner/Symfony/ResponseRunner.php +++ b/src/Symfony/Component/Runtime/Runner/Symfony/ResponseRunner.php @@ -19,11 +19,9 @@ */ class ResponseRunner implements RunnerInterface { - private $response; - - public function __construct(Response $response) - { - $this->response = $response; + public function __construct( + private readonly Response $response, + ) { } public function run(): int diff --git a/src/Symfony/Component/Runtime/SymfonyRuntime.php b/src/Symfony/Component/Runtime/SymfonyRuntime.php index d74dfed71e513..a204b48067a7c 100644 --- a/src/Symfony/Component/Runtime/SymfonyRuntime.php +++ b/src/Symfony/Component/Runtime/SymfonyRuntime.php @@ -66,10 +66,10 @@ class_exists(MissingDotenv::class, false) || class_exists(Dotenv::class) || clas */ class SymfonyRuntime extends GenericRuntime { - private $input; - private $output; - private $console; - private $command; + private readonly ArgvInput $input; + private readonly ConsoleOutput $output; + private readonly Application $console; + private readonly Command $command; /** * @param array { @@ -165,7 +165,7 @@ public function getRunner(?object $application): RunnerInterface return new ConsoleApplicationRunner($application, $defaultEnv, $this->getInput(), $output); } - if ($this->command) { + if (isset($this->command)) { $this->getInput()->bind($this->command->getDefinition()); } @@ -203,7 +203,7 @@ protected static function register(GenericRuntime $runtime): GenericRuntime private function getInput(): ArgvInput { - if (null !== $this->input) { + if (isset($this->input)) { return $this->input; } diff --git a/src/Symfony/Component/Security/Core/Test/AccessDecisionStrategyTestCase.php b/src/Symfony/Component/Security/Core/Test/AccessDecisionStrategyTestCase.php index d542588fe9ff6..bf2a2b9a15ec3 100644 --- a/src/Symfony/Component/Security/Core/Test/AccessDecisionStrategyTestCase.php +++ b/src/Symfony/Component/Security/Core/Test/AccessDecisionStrategyTestCase.php @@ -64,7 +64,7 @@ final protected static function getVoters(int $grants, int $denies, int $abstain final protected static function getVoter(int $vote): VoterInterface { return new class($vote) implements VoterInterface { - private $vote; + private int $vote; public function __construct(int $vote) { diff --git a/src/Symfony/Component/Security/Http/Authenticator/Passport/Passport.php b/src/Symfony/Component/Security/Http/Authenticator/Passport/Passport.php index 0158ee5ba5e8b..9eb5fc42f05cb 100644 --- a/src/Symfony/Component/Security/Http/Authenticator/Passport/Passport.php +++ b/src/Symfony/Component/Security/Http/Authenticator/Passport/Passport.php @@ -33,7 +33,7 @@ class Passport private array $attributes = []; /** - * @param CredentialsInterface $credentials the credentials to check for this authentication, use + * @param CredentialsInterface $credentials The credentials to check for this authentication, use * SelfValidatingPassport if no credentials should be checked * @param BadgeInterface[] $badges */ @@ -48,7 +48,7 @@ public function __construct(UserBadge $userBadge, CredentialsInterface $credenti public function getUser(): UserInterface { - if (null === $this->user) { + if (!isset($this->user)) { if (!$this->hasBadge(UserBadge::class)) { throw new \LogicException('Cannot get the Security user, no username or UserBadge configured for this passport.'); } @@ -66,9 +66,9 @@ public function getUser(): UserInterface * This method replaces the current badge if it is already set on this * passport. * - * @param string|null $badgeFqcn A FQCN to which the badge should be mapped to. - * This allows replacing a built-in badge by a custom one using - *. e.g. addBadge(new MyCustomUserBadge(), UserBadge::class) + * @param string|null $badgeFqcn A FQCN to which the badge should be mapped to. + * This allows replacing a built-in badge by a custom one using + *. e.g. addBadge(new MyCustomUserBadge(), UserBadge::class) * * @return $this */ diff --git a/src/Symfony/Component/Semaphore/Key.php b/src/Symfony/Component/Semaphore/Key.php index deccee9c370b3..4e5a95c3143f2 100644 --- a/src/Symfony/Component/Semaphore/Key.php +++ b/src/Symfony/Component/Semaphore/Key.php @@ -21,11 +21,11 @@ */ final class Key { - private $resource; - private $limit; - private $weight; - private $expiringTime; - private $state = []; + private string $resource; + private int $limit; + private int $weight; + private ?float $expiringTime = null; + private array $state = []; public function __construct(string $resource, int $limit, int $weight = 1) { diff --git a/src/Symfony/Component/Semaphore/Semaphore.php b/src/Symfony/Component/Semaphore/Semaphore.php index 6fc110179aba3..b9494c5d7c03b 100644 --- a/src/Symfony/Component/Semaphore/Semaphore.php +++ b/src/Symfony/Component/Semaphore/Semaphore.php @@ -13,7 +13,6 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; -use Psr\Log\NullLogger; use Symfony\Component\Semaphore\Exception\InvalidArgumentException; use Symfony\Component\Semaphore\Exception\RuntimeException; use Symfony\Component\Semaphore\Exception\SemaphoreAcquiringException; @@ -30,11 +29,11 @@ final class Semaphore implements SemaphoreInterface, LoggerAwareInterface { use LoggerAwareTrait; - private $store; - private $key; - private $ttlInSecond; - private $autoRelease; - private $dirty = false; + private Key $key; + private PersistingStoreInterface $store; + private float $ttlInSecond; + private bool $autoRelease; + private bool $dirty = false; public function __construct(Key $key, PersistingStoreInterface $store, float $ttlInSecond = 300.0, bool $autoRelease = true) { @@ -42,8 +41,6 @@ public function __construct(Key $key, PersistingStoreInterface $store, float $tt $this->key = $key; $this->ttlInSecond = $ttlInSecond; $this->autoRelease = $autoRelease; - - $this->logger = new NullLogger(); } public function __sleep(): array @@ -76,15 +73,15 @@ public function acquire(): bool $this->key->reduceLifetime($this->ttlInSecond); $this->dirty = true; - $this->logger->debug('Successfully acquired the "{resource}" semaphore.', ['resource' => $this->key]); + $this->logger?->debug('Successfully acquired the "{resource}" semaphore.', ['resource' => $this->key]); return true; } catch (SemaphoreAcquiringException) { - $this->logger->notice('Failed to acquire the "{resource}" semaphore. Someone else already acquired the semaphore.', ['resource' => $this->key]); + $this->logger?->notice('Failed to acquire the "{resource}" semaphore. Someone else already acquired the semaphore.', ['resource' => $this->key]); return false; } catch (\Exception $e) { - $this->logger->notice('Failed to acquire the "{resource}" semaphore.', ['resource' => $this->key, 'exception' => $e]); + $this->logger?->notice('Failed to acquire the "{resource}" semaphore.', ['resource' => $this->key, 'exception' => $e]); throw new RuntimeException(sprintf('Failed to acquire the "%s" semaphore.', $this->key), 0, $e); } @@ -103,14 +100,14 @@ public function refresh(float $ttlInSecond = null): void $this->dirty = true; - $this->logger->debug('Expiration defined for "{resource}" semaphore for "{ttlInSecond}" seconds.', ['resource' => $this->key, 'ttlInSecond' => $ttlInSecond]); + $this->logger?->debug('Expiration defined for "{resource}" semaphore for "{ttlInSecond}" seconds.', ['resource' => $this->key, 'ttlInSecond' => $ttlInSecond]); } catch (SemaphoreExpiredException $e) { $this->dirty = false; - $this->logger->notice('Failed to define an expiration for the "{resource}" semaphore, the semaphore has expired.', ['resource' => $this->key]); + $this->logger?->notice('Failed to define an expiration for the "{resource}" semaphore, the semaphore has expired.', ['resource' => $this->key]); throw $e; } catch (\Exception $e) { - $this->logger->notice('Failed to define an expiration for the "{resource}" semaphore.', ['resource' => $this->key, 'exception' => $e]); + $this->logger?->notice('Failed to define an expiration for the "{resource}" semaphore.', ['resource' => $this->key, 'exception' => $e]); throw new RuntimeException(sprintf('Failed to define an expiration for the "%s" semaphore.', $this->key), 0, $e); } @@ -129,7 +126,7 @@ public function release(): void } catch (SemaphoreReleasingException $e) { throw $e; } catch (\Exception $e) { - $this->logger->notice('Failed to release the "{resource}" semaphore.', ['resource' => $this->key]); + $this->logger?->notice('Failed to release the "{resource}" semaphore.', ['resource' => $this->key]); throw new RuntimeException(sprintf('Failed to release the "%s" semaphore.', $this->key), 0, $e); } diff --git a/src/Symfony/Component/Semaphore/SemaphoreFactory.php b/src/Symfony/Component/Semaphore/SemaphoreFactory.php index 7daebce7701de..bbaf274e45e2e 100644 --- a/src/Symfony/Component/Semaphore/SemaphoreFactory.php +++ b/src/Symfony/Component/Semaphore/SemaphoreFactory.php @@ -13,7 +13,6 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; -use Psr\Log\NullLogger; /** * Factory provides method to create semaphores. @@ -26,12 +25,9 @@ class SemaphoreFactory implements LoggerAwareInterface { use LoggerAwareTrait; - private $store; - - public function __construct(PersistingStoreInterface $store) - { - $this->store = $store; - $this->logger = new NullLogger(); + public function __construct( + private PersistingStoreInterface $store, + ) { } /** @@ -50,7 +46,9 @@ public function createSemaphore(string $resource, int $limit, int $weight = 1, ? public function createSemaphoreFromKey(Key $key, ?float $ttlInSecond = 300.0, bool $autoRelease = true): SemaphoreInterface { $semaphore = new Semaphore($key, $this->store, $ttlInSecond, $autoRelease); - $semaphore->setLogger($this->logger); + if ($this->logger) { + $semaphore->setLogger($this->logger); + } return $semaphore; } diff --git a/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php b/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php index 0d8bf8d0951ac..f81386db33b03 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php @@ -23,7 +23,7 @@ class JsonEncoder implements EncoderInterface, DecoderInterface protected $encodingImpl; protected $decodingImpl; - private $defaultContext = [ + private array $defaultContext = [ JsonDecode::ASSOCIATIVE => true, ]; diff --git a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php index 063d34ea59177..2e0e80882b687 100644 --- a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php @@ -38,7 +38,7 @@ */ class GetSetMethodNormalizer extends AbstractObjectNormalizer { - private static $setterAccessibleCache = []; + private static array $setterAccessibleCache = []; public function getSupportedTypes(?string $format): array { diff --git a/src/Symfony/Component/String/AbstractUnicodeString.php b/src/Symfony/Component/String/AbstractUnicodeString.php index d19a61a9c6854..32842029dc3e3 100644 --- a/src/Symfony/Component/String/AbstractUnicodeString.php +++ b/src/Symfony/Component/String/AbstractUnicodeString.php @@ -44,9 +44,9 @@ abstract class AbstractUnicodeString extends AbstractString private const TRANSLIT_FROM = ['Æ', 'Ð', 'Ø', 'Þ', 'ß', 'æ', 'ð', 'ø', 'þ', 'Đ', 'đ', 'Ħ', 'ħ', 'ı', 'ĸ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'ʼn', 'Ŋ', 'ŋ', 'Œ', 'œ', 'Ŧ', 'ŧ', 'ƀ', 'Ɓ', 'Ƃ', 'ƃ', 'Ƈ', 'ƈ', 'Ɖ', 'Ɗ', 'Ƌ', 'ƌ', 'Ɛ', 'Ƒ', 'ƒ', 'Ɠ', 'ƕ', 'Ɩ', 'Ɨ', 'Ƙ', 'ƙ', 'ƚ', 'Ɲ', 'ƞ', 'Ƣ', 'ƣ', 'Ƥ', 'ƥ', 'ƫ', 'Ƭ', 'ƭ', 'Ʈ', 'Ʋ', 'Ƴ', 'ƴ', 'Ƶ', 'ƶ', 'DŽ', 'Dž', 'dž', 'Ǥ', 'ǥ', 'ȡ', 'Ȥ', 'ȥ', 'ȴ', 'ȵ', 'ȶ', 'ȷ', 'ȸ', 'ȹ', 'Ⱥ', 'Ȼ', 'ȼ', 'Ƚ', 'Ⱦ', 'ȿ', 'ɀ', 'Ƀ', 'Ʉ', 'Ɇ', 'ɇ', 'Ɉ', 'ɉ', 'Ɍ', 'ɍ', 'Ɏ', 'ɏ', 'ɓ', 'ɕ', 'ɖ', 'ɗ', 'ɛ', 'ɟ', 'ɠ', 'ɡ', 'ɢ', 'ɦ', 'ɧ', 'ɨ', 'ɪ', 'ɫ', 'ɬ', 'ɭ', 'ɱ', 'ɲ', 'ɳ', 'ɴ', 'ɶ', 'ɼ', 'ɽ', 'ɾ', 'ʀ', 'ʂ', 'ʈ', 'ʉ', 'ʋ', 'ʏ', 'ʐ', 'ʑ', 'ʙ', 'ʛ', 'ʜ', 'ʝ', 'ʟ', 'ʠ', 'ʣ', 'ʥ', 'ʦ', 'ʪ', 'ʫ', 'ᴀ', 'ᴁ', 'ᴃ', 'ᴄ', 'ᴅ', 'ᴆ', 'ᴇ', 'ᴊ', 'ᴋ', 'ᴌ', 'ᴍ', 'ᴏ', 'ᴘ', 'ᴛ', 'ᴜ', 'ᴠ', 'ᴡ', 'ᴢ', 'ᵫ', 'ᵬ', 'ᵭ', 'ᵮ', 'ᵯ', 'ᵰ', 'ᵱ', 'ᵲ', 'ᵳ', 'ᵴ', 'ᵵ', 'ᵶ', 'ᵺ', 'ᵻ', 'ᵽ', 'ᵾ', 'ᶀ', 'ᶁ', 'ᶂ', 'ᶃ', 'ᶄ', 'ᶅ', 'ᶆ', 'ᶇ', 'ᶈ', 'ᶉ', 'ᶊ', 'ᶌ', 'ᶍ', 'ᶎ', 'ᶏ', 'ᶑ', 'ᶒ', 'ᶓ', 'ᶖ', 'ᶙ', 'ẚ', 'ẜ', 'ẝ', 'ẞ', 'Ỻ', 'ỻ', 'Ỽ', 'ỽ', 'Ỿ', 'ỿ', '©', '®', '₠', '₢', '₣', '₤', '₧', '₺', '₹', 'ℌ', '℞', '㎧', '㎮', '㏆', '㏗', '㏞', '㏟', '¼', '½', '¾', '⅓', '⅔', '⅕', '⅖', '⅗', '⅘', '⅙', '⅚', '⅛', '⅜', '⅝', '⅞', '⅟', '〇', '‘', '’', '‚', '‛', '“', '”', '„', '‟', '′', '″', '〝', '〞', '«', '»', '‹', '›', '‐', '‑', '‒', '–', '—', '―', '︱', '︲', '﹘', '‖', '⁄', '⁅', '⁆', '⁎', '、', '。', '〈', '〉', '《', '》', '〔', '〕', '〘', '〙', '〚', '〛', '︑', '︒', '︹', '︺', '︽', '︾', '︿', '﹀', '﹑', '﹝', '﹞', '⦅', '⦆', '。', '、', '×', '÷', '−', '∕', '∖', '∣', '∥', '≪', '≫', '⦅', '⦆']; private const TRANSLIT_TO = ['AE', 'D', 'O', 'TH', 'ss', 'ae', 'd', 'o', 'th', 'D', 'd', 'H', 'h', 'i', 'q', 'L', 'l', 'L', 'l', '\'n', 'N', 'n', 'OE', 'oe', 'T', 't', 'b', 'B', 'B', 'b', 'C', 'c', 'D', 'D', 'D', 'd', 'E', 'F', 'f', 'G', 'hv', 'I', 'I', 'K', 'k', 'l', 'N', 'n', 'OI', 'oi', 'P', 'p', 't', 'T', 't', 'T', 'V', 'Y', 'y', 'Z', 'z', 'DZ', 'Dz', 'dz', 'G', 'g', 'd', 'Z', 'z', 'l', 'n', 't', 'j', 'db', 'qp', 'A', 'C', 'c', 'L', 'T', 's', 'z', 'B', 'U', 'E', 'e', 'J', 'j', 'R', 'r', 'Y', 'y', 'b', 'c', 'd', 'd', 'e', 'j', 'g', 'g', 'G', 'h', 'h', 'i', 'I', 'l', 'l', 'l', 'm', 'n', 'n', 'N', 'OE', 'r', 'r', 'r', 'R', 's', 't', 'u', 'v', 'Y', 'z', 'z', 'B', 'G', 'H', 'j', 'L', 'q', 'dz', 'dz', 'ts', 'ls', 'lz', 'A', 'AE', 'B', 'C', 'D', 'D', 'E', 'J', 'K', 'L', 'M', 'O', 'P', 'T', 'U', 'V', 'W', 'Z', 'ue', 'b', 'd', 'f', 'm', 'n', 'p', 'r', 'r', 's', 't', 'z', 'th', 'I', 'p', 'U', 'b', 'd', 'f', 'g', 'k', 'l', 'm', 'n', 'p', 'r', 's', 'v', 'x', 'z', 'a', 'd', 'e', 'e', 'i', 'u', 'a', 's', 's', 'SS', 'LL', 'll', 'V', 'v', 'Y', 'y', '(C)', '(R)', 'CE', 'Cr', 'Fr.', 'L.', 'Pts', 'TL', 'Rs', 'x', 'Rx', 'm/s', 'rad/s', 'C/kg', 'pH', 'V/m', 'A/m', ' 1/4', ' 1/2', ' 3/4', ' 1/3', ' 2/3', ' 1/5', ' 2/5', ' 3/5', ' 4/5', ' 1/6', ' 5/6', ' 1/8', ' 3/8', ' 5/8', ' 7/8', ' 1/', '0', '\'', '\'', ',', '\'', '"', '"', ',,', '"', '\'', '"', '"', '"', '<<', '>>', '<', '>', '-', '-', '-', '-', '-', '-', '-', '-', '-', '||', '/', '[', ']', '*', ',', '.', '<', '>', '<<', '>>', '[', ']', '[', ']', '[', ']', ',', '.', '[', ']', '<<', '>>', '<', '>', ',', '[', ']', '((', '))', '.', ',', '*', '/', '-', '/', '\\', '|', '||', '<<', '>>', '((', '))']; - private static $transliterators = []; - private static $tableZero; - private static $tableWide; + private static array $transliterators = []; + private static array $tableZero; + private static array $tableWide; public static function fromCodePoints(int ...$codes): static { diff --git a/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php b/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php index 65eea0bb9ba91..7dff58ff402e5 100644 --- a/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php +++ b/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php @@ -34,11 +34,6 @@ abstract class AbstractOperation implements OperationInterface protected $target; protected $result; - /** - * @var array|null The domains affected by this operation - */ - private $domains; - /** * This array stores 'all', 'new' and 'obsolete' messages for all valid domains. * @@ -62,6 +57,8 @@ abstract class AbstractOperation implements OperationInterface */ protected $messages; + private array $domains; + /** * @throws LogicException */ @@ -79,7 +76,7 @@ public function __construct(MessageCatalogueInterface $source, MessageCatalogueI public function getDomains(): array { - if (null === $this->domains) { + if (!isset($this->domains)) { $domains = []; foreach ([$this->source, $this->target] as $catalogue) { foreach ($catalogue->getDomains() as $domain) { diff --git a/src/Symfony/Component/Translation/Formatter/IntlFormatter.php b/src/Symfony/Component/Translation/Formatter/IntlFormatter.php index 30873cc584a9b..e62de253f8d25 100644 --- a/src/Symfony/Component/Translation/Formatter/IntlFormatter.php +++ b/src/Symfony/Component/Translation/Formatter/IntlFormatter.php @@ -20,8 +20,8 @@ */ class IntlFormatter implements IntlFormatterInterface { - private $hasMessageFormatter; - private $cache = []; + private bool $hasMessageFormatter; + private array $cache = []; public function formatIntl(string $message, string $locale, array $parameters = []): string { diff --git a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php index 598d98c647d1c..48e735d163da4 100644 --- a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php @@ -24,11 +24,11 @@ */ class YamlFileLoader extends FileLoader { - private $yamlParser; + private YamlParser $yamlParser; protected function loadResource(string $resource): array { - if (null === $this->yamlParser) { + if (!isset($this->yamlParser)) { if (!class_exists(\Symfony\Component\Yaml\Parser::class)) { throw new LogicException('Loading translations from the YAML format requires the Symfony Yaml component.'); } diff --git a/src/Symfony/Component/Translation/Provider/TranslationProviderCollection.php b/src/Symfony/Component/Translation/Provider/TranslationProviderCollection.php index 61ac641cd6eaa..b917415ba18a0 100644 --- a/src/Symfony/Component/Translation/Provider/TranslationProviderCollection.php +++ b/src/Symfony/Component/Translation/Provider/TranslationProviderCollection.php @@ -21,7 +21,7 @@ final class TranslationProviderCollection /** * @var array */ - private $providers; + private array $providers; /** * @param array $providers diff --git a/src/Symfony/Component/Validator/Constraints/CssColor.php b/src/Symfony/Component/Validator/Constraints/CssColor.php index d1e2e27834304..9e6643088709f 100644 --- a/src/Symfony/Component/Validator/Constraints/CssColor.php +++ b/src/Symfony/Component/Validator/Constraints/CssColor.php @@ -49,7 +49,7 @@ class CssColor extends Constraint /** * @var string[] */ - private static $validationModes = [ + private static array $validationModes = [ self::HEX_LONG, self::HEX_LONG_WITH_ALPHA, self::HEX_SHORT, diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php index 36d48675ca125..7450137b20abb 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -32,22 +32,18 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface { /** - * @var string - * * @internal This property is public in order to reduce the size of the * class' serialized representation. Do not access it. Use * {@link getClassName()} instead. */ - public $name; + public string $name; /** - * @var string - * * @internal This property is public in order to reduce the size of the * class' serialized representation. Do not access it. Use * {@link getDefaultGroup()} instead. */ - public $defaultGroup; + public string $defaultGroup; /** * @var MemberMetadata[][] @@ -56,7 +52,7 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface * class' serialized representation. Do not access it. Use * {@link getPropertyMetadata()} instead. */ - public $members = []; + public array $members = []; /** * @var PropertyMetadata[] @@ -65,7 +61,7 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface * class' serialized representation. Do not access it. Use * {@link getPropertyMetadata()} instead. */ - public $properties = []; + public array $properties = []; /** * @var GetterMetadata[] @@ -74,38 +70,34 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface * class' serialized representation. Do not access it. Use * {@link getPropertyMetadata()} instead. */ - public $getters = []; + public array $getters = []; /** - * @var GroupSequence - * * @internal This property is public in order to reduce the size of the * class' serialized representation. Do not access it. Use * {@link getGroupSequence()} instead. */ - public $groupSequence; + public ?GroupSequence $groupSequence = null; /** - * @var bool - * * @internal This property is public in order to reduce the size of the * class' serialized representation. Do not access it. Use * {@link isGroupSequenceProvider()} instead. */ - public $groupSequenceProvider = false; + public bool $groupSequenceProvider = false; /** * The strategy for traversing traversable objects. * * By default, only instances of {@link \Traversable} are traversed. * - * @var int + * @var TraversalStrategy::* * * @internal This property is public in order to reduce the size of the * class' serialized representation. Do not access it. Use * {@link getTraversalStrategy()} instead. */ - public $traversalStrategy = TraversalStrategy::IMPLICIT; + public int $traversalStrategy = TraversalStrategy::IMPLICIT; private \ReflectionClass $reflClass; diff --git a/src/Symfony/Component/Validator/Mapping/GenericMetadata.php b/src/Symfony/Component/Validator/Mapping/GenericMetadata.php index f05e402609d5d..6c1ba8b492203 100644 --- a/src/Symfony/Component/Validator/Mapping/GenericMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/GenericMetadata.php @@ -35,7 +35,7 @@ class GenericMetadata implements MetadataInterface * class' serialized representation. Do not access it. Use * {@link getConstraints()} and {@link findConstraints()} instead. */ - public $constraints = []; + public array $constraints = []; /** * @var array @@ -44,50 +44,44 @@ class GenericMetadata implements MetadataInterface * class' serialized representation. Do not access it. Use * {@link findConstraints()} instead. */ - public $constraintsByGroup = []; + public array $constraintsByGroup = []; /** * The strategy for cascading objects. * * By default, objects are not cascaded. * - * @var int - * - * @see CascadingStrategy + * @var CascadingStrategy::* * * @internal This property is public in order to reduce the size of the * class' serialized representation. Do not access it. Use * {@link getCascadingStrategy()} instead. */ - public $cascadingStrategy = CascadingStrategy::NONE; + public int $cascadingStrategy = CascadingStrategy::NONE; /** * The strategy for traversing traversable objects. * * By default, traversable objects are not traversed. * - * @var int - * - * @see TraversalStrategy + * @var TraversalStrategy::* * * @internal This property is public in order to reduce the size of the * class' serialized representation. Do not access it. Use * {@link getTraversalStrategy()} instead. */ - public $traversalStrategy = TraversalStrategy::NONE; + public int $traversalStrategy = TraversalStrategy::NONE; /** * Is auto-mapping enabled? * - * @var int - * - * @see AutoMappingStrategy + * @var AutoMappingStrategy::* * * @internal This property is public in order to reduce the size of the * class' serialized representation. Do not access it. Use * {@link getAutoMappingStrategy()} instead. */ - public $autoMappingStrategy = AutoMappingStrategy::NONE; + public int $autoMappingStrategy = AutoMappingStrategy::NONE; /** * Returns the names of the properties that should be serialized. diff --git a/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php index 2af7ec6f6c22b..bf36b15f3712f 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php @@ -37,7 +37,7 @@ public function __construct(string $file) public function loadClassMetadata(ClassMetadata $metadata): bool { - if (null === $this->classes) { + if (!isset($this->classes)) { $this->loadClassesFromXml(); } @@ -59,7 +59,7 @@ public function loadClassMetadata(ClassMetadata $metadata): bool */ public function getMappedClasses(): array { - if (null === $this->classes) { + if (!isset($this->classes)) { $this->loadClassesFromXml(); } diff --git a/src/Symfony/Component/Validator/Mapping/MemberMetadata.php b/src/Symfony/Component/Validator/Mapping/MemberMetadata.php index e7389f7b8e448..17b3400787ec7 100644 --- a/src/Symfony/Component/Validator/Mapping/MemberMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/MemberMetadata.php @@ -34,21 +34,21 @@ abstract class MemberMetadata extends GenericMetadata implements PropertyMetadat * class' serialized representation. Do not access it. Use * {@link getClassName()} instead. */ - public $class; + public string $class; /** * @internal This property is public in order to reduce the size of the * class' serialized representation. Do not access it. Use * {@link getName()} instead. */ - public $name; + public string $name; /** * @internal This property is public in order to reduce the size of the * class' serialized representation. Do not access it. Use * {@link getPropertyName()} instead. */ - public $property; + public string $property; /** * @var \ReflectionMethod[]|\ReflectionProperty[] diff --git a/src/Symfony/Contracts/HttpClient/Test/TestHttpServer.php b/src/Symfony/Contracts/HttpClient/Test/TestHttpServer.php index 2ec4aa5bb6ce7..86dfa7de90092 100644 --- a/src/Symfony/Contracts/HttpClient/Test/TestHttpServer.php +++ b/src/Symfony/Contracts/HttpClient/Test/TestHttpServer.php @@ -16,7 +16,7 @@ class TestHttpServer { - private static $process = []; + private static array $process = []; /** * @param string|null $workingDirectory diff --git a/src/Symfony/Contracts/Translation/Test/TranslatorTest.php b/src/Symfony/Contracts/Translation/Test/TranslatorTest.php index 674b78b3eae5b..18e669077713a 100644 --- a/src/Symfony/Contracts/Translation/Test/TranslatorTest.php +++ b/src/Symfony/Contracts/Translation/Test/TranslatorTest.php @@ -30,7 +30,7 @@ */ class TranslatorTest extends TestCase { - private $defaultLocale; + private string $defaultLocale; protected function setUp(): void { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy