8000 minor #43869 [FrameworkBundle] Add types to private properties (derra… · symfony/symfony@c3ba8a4 · GitHub
[go: up one dir, main page]

Skip to content

Commit c3ba8a4

Browse files
minor #43869 [FrameworkBundle] Add types to private properties (derrabus)
This PR was squashed before being merged into the 6.0 branch. Discussion ---------- [FrameworkBundle] Add types to private properties | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A Commits ------- 88220cf [FrameworkBundle] Add types to private properties
2 parents 60d12a9 + 88220cf commit c3ba8a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+149
-135
lines changed

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
abstract class AbstractPhpFileCacheWarmer implements CacheWarmerInterface
2121
{
22-
private $phpArrayFile;
22+
private string $phpArrayFile;
2323

2424
/**
2525
* @param string $phpArrayFile The PHP file where metadata are cached

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
*/
2626
class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer
2727
{
28-
private $annotationReader;
29-
private $excludeRegexp;
30-
private $debug;
28+
private Reader $annotationReader;
29+
private ?string $excludeRegexp;
30+
private bool $debug;
3131

3232
/**
3333
* @param string $phpArrayFile The PHP file where annotations are cached

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/CachePoolClearerCacheWarmer.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@
2525
*/
2626
final class CachePoolClearerCacheWarmer implements CacheWarmerInterface
2727
{
28-
private $poolClearer;
29-
private $pools;
28+
private Psr6CacheClearer $poolClearer;
29+
private array $pools;
3030

31+
/**
32+
* @param string[] $pools
33+
*/
3134
public function __construct(Psr6CacheClearer $poolClearer, array $pools = [])
3235
{
3336
$this->poolClearer = $poolClearer;

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
*/
2929
class ConfigBuilderCacheWarmer implements CacheWarmerInterface
3030
{
31-
private $kernel;
32-
private $logger;
31+
private KernelInterface $kernel;
32+
private ?LoggerInterface $logger;
3333

3434
public function __construct(KernelInterface $kernel, LoggerInterface $logger = null)
3535
{

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
class RouterCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface
2828
{
29-
private $container;
29+
private ContainerInterface $container;
3030

3131
public function __construct(ContainerInterface $container)
3232
{

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
class SerializerCacheWarmer extends AbstractPhpFileCacheWarmer
2929
{
30-
private $loaders;
30+
private array $loaders;
3131

3232
/**
3333
* @param LoaderInterface[] $loaders The serializer metadata loaders

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
*/
2525
class TranslationsCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface
2626
{
27-
private $container;
28-
private $translator;
27+
private ContainerInterface $container;
28+
private TranslatorInterface $translator;
2929

3030
public function __construct(ContainerInterface $container)
3131
{
@@ -40,9 +40,7 @@ public function __construct(ContainerInterface $container)
4040
*/
4141
public function warmUp(string $cacheDir): array
4242
{
43-
if (null === $this->translator) {
44-
$this->translator = $this->container->get('translator');
45-
}
43+
$this->translator ??= $this->container->get('translator');
4644

4745
if ($this->translator instanceof WarmableInterface) {
4846
return (array) $this->translator->warmUp($cacheDir);

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
class ValidatorCacheWarmer extends AbstractPhpFileCacheWarmer
3030
{
31-
private $validatorBuilder;
31+
private ValidatorBuilder $validatorBuilder;
3232

3333
/**
3434
* @param string $phpArrayFile The PHP file where metadata are cached

src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ class AssetsInstallCommand extends Command
4141
public const METHOD_ABSOLUTE_SYMLINK = 'absolute symlink';
4242
public const METHOD_RELATIVE_SYMLINK = 'relative symlink';
4343

44-
private $filesystem;
45-
private $projectDir;
44+
private Filesystem $filesystem;
45+
private string $projectDir;
4646

4747
public function __construct(Filesystem $filesystem, string $projectDir)
4848
{

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
#[AsCommand(name: 'cache:clear', description: 'Clear the cache')]
3838
class CacheClearCommand extends Command
3939
{
40-
private $cacheClearer;
41-
private $filesystem;
40+
private CacheClearerInterface $cacheClearer;
41+
private Filesystem $filesystem;
4242

4343
public function __construct(CacheClearerInterface $cacheClearer, Filesystem $filesystem = null)
4444
{

src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@
3131
#[AsCommand(name: 'cache:pool:clear', description: 'Clear cache pools')]
3232
final class CachePoolClearCommand extends Command
3333
{
34-
private $poolClearer;
35-
private $poolNames;
34+
private Psr6CacheClearer $poolClearer;
35+
private ?array $poolNames;
3636

37+
/**
38+
* @param string[]|null $poolNames
39+
*/
3740
public function __construct(Psr6CacheClearer $poolClearer, array $poolNames = null)
3841
{
3942
parent::__construct();

src/Symfony/Bundle/FrameworkBundle/Command/CachePoolDeleteCommand.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@
2929
#[AsCommand(name: 'cache:pool:delete', description: 'Delete an item from a cache pool')]
3030
final class CachePoolDeleteCommand extends Command
3131
{
32-
private $poolClearer;
33-
private $poolNames;
32+
private Psr6CacheClearer $poolClearer;
33+
private ?array $poolNames;
3434

35+
/**
36+
* @param string[]|null $poolNames
37+
*/
3538
public function __construct(Psr6CacheClearer $poolClearer, array $poolNames = null)
3639
{
3740
parent::__construct();

src/Symfony/Bundle/FrameworkBundle/Command/CachePoolListCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@
2525
#[AsCommand(name: 'cache:pool:list', description: 'List available cache pools')]
2626
final class CachePoolListCommand extends Command
2727
{
C2EE
28-
private $poolNames;
28+
private array $poolNames;
2929

30+
/**
31+
* @param string[] $poolNames
32+
*/
3033
public function __construct(array $poolNames)
3134
{
3235
parent::__construct();

src/Symfony/Bundle/FrameworkBundle/Command/CachePoolPruneCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
#[AsCommand(name: 'cache:pool:prune', description: 'Prune cache pools')]
2727
final class CachePoolPruneCommand extends Command
2828
{
29-
private $pools;
29+
private iterable $pools;
3030

3131
/**
32-
* @param iterable|PruneableInterface[] $pools
32+
* @param iterable<mixed, PruneableInterface> $pools
3333
*/
3434
public function __construct(iterable $pools)
3535
{

src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#[AsCommand(name: 'cache:warmup', description: 'Warm up an empty cache')]
3131
class CacheWarmupCommand extends Command
3232
{
33-
private $cacheWarmer;
33+
private CacheWarmerAggregate $cacheWarmer;
3434

3535
public function __construct(CacheWarmerAggregate $cacheWarmer)
3636
{

src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@
3131
#[AsCommand(name: 'lint:container', description: 'Ensure that arguments injected into services match type declarations')]
3232
final class ContainerLintCommand extends Command
3333
{
34-
/**
35-
* @var ContainerBuilder
36-
*/
37-
private $containerBuilder;
34+
private ContainerBuilder $containerBuilder;
3835

3936
/**
4037
* {@inheritdoc}
@@ -79,7 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7976

8077
private function getContainerBuilder(): ContainerBuilder
8178
{
82-
if ($this->containerBuilder) {
79+
if (isset($this->containerBuilder)) {
8380
return $this->containerBuilder;
8481
}
8582

src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
#[AsCommand(name: 'debug:autowiring', description: 'List classes/interfaces you can use for autowiring')]
3232
class DebugAutowiringCommand extends ContainerDebugCommand
3333
{
34-
private $supportsHref;
35-
private $fileLinkFormatter;
34+
private bool $supportsHref;
35+
private ?FileLinkFormatter $fileLinkFormatter;
3636

3737
public function __construct(string $name = null, FileLinkFormatter $fileLinkFormatter = null)
3838
{

src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class EventDispatcherDebugCommand extends Command
3434
{
3535
private const DEFAULT_DISPATCHER = 'event_dispatcher';
3636

37-
private $dispatchers;
37+
private ContainerInterface $dispatchers;
3838

3939
public function __construct(ContainerInterface $dispatchers)
4040
{

src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class RouterDebugCommand extends Command
3939
{
4040
use BuildDebugContainerTrait;
4141

42-
private $router;
43-
private $fileLinkFormatter;
42+
private RouterInterface $router;
43+
private ?FileLinkFormatter $fileLinkFormatter;
4444

4545
public function __construct(RouterInterface $router, FileLinkFormatter $fileLinkFormatter = null)
4646
{

src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Console\Input\InputOption;
2020
use Symfony\Component\Console\Output\OutputInterface;
2121
use Symfony\Component\Console\Style\SymfonyStyle;
22+
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
2223
use Symfony\Component\Routing\Matcher\TraceableUrlMatcher;
2324
use Symfony\Component\Routing\RouterInterface;
2425

@@ -32,9 +33,12 @@
3233
#[AsCommand(name: 'router:match', description: 'Help debug routes by simulating a path info match')]
3334
class RouterMatchCommand extends Command
3435
{
35-
private $router;
36-
private $expressionLanguageProviders;
36+
private RouterInterface $router;
37+
private iterable $expressionLanguageProviders;
3738

39+
/**
40+
* @param iterable<mixed, ExpressionFunctionProviderInterface> $expressionLanguageProviders
41+
*/
3842
public function __construct(RouterInterface $router, iterable $expressionLanguageProviders = [])
3943
{
4044
parent::__construct();

src/Symfony/Bundle/FrameworkBundle/Command/SecretsDecryptToLocalCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
#[AsCommand(name: 'secrets:decrypt-to-local', description: 'Decrypt all secrets and stores them in the local vault')]
2929
final class SecretsDecryptToLocalCommand extends Command
3030
{
31-
private $vault;
32-
private $localVault;
31+
private AbstractVault $vault;
32+
private ?AbstractVault $localVault;
3333

3434
public function __construct(AbstractVault $vault, AbstractVault $localVault = null)
3535
{

src/Symfony/Bundle/FrameworkBundle/Command/SecretsEncryptFromLocalCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#[AsCommand(name: 'secrets:encrypt-from-local', description: 'Encrypt all local secrets to the vault')]
2828
final class SecretsEncryptFromLocalCommand extends Command
2929
{
30-
private $vault;
31-
private $localVault;
30+
private AbstractVault $vault;
31+
private ?AbstractVault $localVault;
3232

3333
public function __construct(AbstractVault $vault, AbstractVault $localVault = null)
3434
{

src/Symfony/Bundle/FrameworkBundle/Command/SecretsGenerateKeysCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
#[AsCommand(name: 'secrets:generate-keys', description: 'Generate new encryption keys')]
3131
final class SecretsGenerateKeysCommand extends Command
3232
{
33-
private $vault;
34-
private $localVault;
33+
private AbstractVault $vault;
34+
private ?AbstractVault $localVault;
3535

3636
public function __construct(AbstractVault $vault, AbstractVault $localVault = null)
3737
{

src/Symfony/Bundle/FrameworkBundle/Command/SecretsListCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
#[AsCommand(name: 'secrets:list', description: 'List all secrets')]
3232
final class SecretsListCommand extends Command
3333
{
34-
private $vault;
35-
private $localVault;
34+
private AbstractVault $vault;
35+
private ?AbstractVault $localVault;
3636

3737
public function __construct(AbstractVault $vault, AbstractVault $localVault = null)
3838
{

src/Symfony/Bundle/FrameworkBundle/Command/SecretsRemoveCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
#[AsCommand(name: 'secrets:remove', description: 'Remove a secret from the vault')]
3333
final class SecretsRemoveCommand extends Command
3434
{
35-
private $vault;
36-
private $localVault;
35+
private AbstractVault $vault;
36+
private ?AbstractVault $localVault;
3737

3838
public function __construct(AbstractVault $vault, AbstractVault $localVault = null)
3939
{

src/Symfony/Bundle/FrameworkBundle/Command/SecretsSetCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
#[AsCommand(name: 'secrets:set', description: 'Set a secret in the vault')]
3434
final class SecretsSetCommand extends Command
3535
{
36-
private $vault;
37-
private $localVault;
36+
private AbstractVault $vault;
37+
private ?AbstractVault $localVault;
3838

3939
public function __construct(AbstractVault $vault, AbstractVault $localVault = null)
4040
{

src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ class TranslationDebugCommand extends Command
5050
public const MESSAGE_UNUSED = 1;
5151
public const MESSAGE_EQUALS_FALLBACK = 2;
5252

53-
private $translator;
54-
private $reader;
55-
private $extractor;
56-
private $defaultTransPath;
57-
private $defaultViewsPath;
58-
private $transPaths;
59-
private $codePaths;
60-
private $enabledLocales;
53+
private TranslatorInterface $translator;
54+
private TranslationReaderInterface $reader;
55+
private ExtractorInterface $extractor;
56+
private ?string $defaultTransPath;
57+
private ?string $defaultViewsPath;
58+
private array $transPaths;
59+
private array $codePaths;
60+
private array $enabledLocales;
6161

6262
public function __construct(TranslatorInterface $translator, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultTransPath = null, string $defaultViewsPath = null, array $transPaths = [], array $codePaths = [], array $enabledLocales = [])
6363
{

src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ class TranslationUpdateCommand extends Command
5050
'xlf20' => ['xlf', '2.0'],
5151
];
5252

53-
private $writer;
54-
private $reader;
55-
private $extractor;
56-
private $defaultLocale;
57-
private $defaultTransPath;
58-
private $defaultViewsPath;
59-
private $transPaths;
60-
private $codePaths;
61-
private $enabledLocales;
53+
private TranslationWriterInterface $writer;
54+
private TranslationReaderInterface $reader;
55+
private ExtractorInterface $extractor;
56+
private string $defaultLocale;
57+
private ?string $defaultTransPath;
58+
private ?string $defaultViewsPath;
59+
private array $transPaths;
60+
private array $codePaths;
61+
private array $enabledLocales;
6262

6363
public function __construct(TranslationWriterInterface $writer, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultLocale, string $defaultTransPath = null, string $defaultViewsPath = null, array $transPaths = [], array $codePaths = [], array $enabledLocales = [])
6464
{

src/Symfony/Bundle/FrameworkBundle/Console/Application.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
*/
3030
class Application extends BaseApplication
3131
{
32-
private $kernel;
33-
private $commandsRegistered = false;
34-
private $registrationErrors = [];
32+
private KernelInterface $kernel;
33+
private bool $commandsRegistered = false;
34+
private array $registrationErrors = [];
3535

3636
public function __construct(KernelInterface $kernel)
3737
{

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*/
3838
class TextDescriptor extends Descriptor
3939
{
40-
private $fileLinkFormatter;
40+
private ?FileLinkFormatter $fileLinkFormatter;
4141

4242
public function __construct(FileLinkFormatter $fileLinkFormatter = null)
4343
{

0 commit comments

Comments
 (0)
0