8000 [Translation] add types to private properties · symfony/symfony@951c569 · GitHub
[go: up one dir, main page]

Skip to content

Commit 951c569

Browse files
rvanlaaknicolas-grekas
authored andcommitted
[Translation] add types to private properties
1 parent 0b001c5 commit 951c569

34 files changed

+125
-159
lines changed

src/Symfony/Component/Translation/Bridge/Crowdin/CrowdinProvider.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
*/
3434
final class CrowdinProvider implements ProviderInterface
3535
{
36-
private $client;
37-
private $loader;
38-
private $logger;
39-
private $xliffFileDumper;
40-
private $defaultLocale;
41-
private $endpoint;
36+
private HttpClientInterface $client;
37+
private LoaderInterface $loader;
38+
private LoggerInterface $logger;
39+
private XliffFileDumper $xliffFileDumper;
40+
private string $defaultLocale;
41+
private string $endpoint;
4242

4343
public function __construct(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, XliffFileDumper $xliffFileDumper, string $defaultLocale, string $endpoint)
4444
{

src/Symfony/Component/Translation/Bridge/Crowdin/CrowdinProviderFactory.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,11 @@ final class CrowdinProviderFactory extends AbstractProviderFactory
2929
{
3030
private const HOST = 'api.crowdin.com';
3131

32-
/** @var LoaderInterface */
33-
private $loader;
34-
35-
/** @var HttpClientInterface */
36-
private $client;
37-
38-
/** @var LoggerInterface */
39-
private $logger;
40-
41-
/** @var string */
42-
private $defaultLocale;
43-
44-
/** @var XliffFileDumper */
45-
private $xliffFileDumper;
32+
private LoaderInterface $loader;
33+
private HttpClientInterface $client;
34+
private LoggerInterface $logger;
35+
private string $defaultLocale;
36+
private XliffFileDumper $xliffFileDumper;
4637

4738
public function __construct(HttpClientInterface $client, LoggerInterface $logger, string $defaultLocale, LoaderInterface $loader, XliffFileDumper $xliffFileDumper)
4839
{

src/Symfony/Component/Translation/Bridge/Loco/LocoProvider.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
*/
3232
final class LocoProvider implements ProviderInterface
3333
{
34-
private $client;
35-
private $loader;
36-
private $logger;
37-
private $defaultLocale;
38-
private $endpoint;
34+
private HttpClientInterface $client;
35+
private LoaderInterface $loader;
36+
private LoggerInterface $logger;
37+
private string $defaultLocale;
38+
private string $endpoint;
3939

4040
public function __construct(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint)
4141
{

src/Symfony/Component/Translation/Bridge/Loco/LocoProviderFactory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ final class LocoProviderFactory extends AbstractProviderFactory
2727
{
2828
private const HOST = 'localise.biz';
2929

30-
private $client;
31-
private $logger;
32-
private $defaultLocale;
33-
private $loader;
30+
private HttpClientInterface $client;
31+
private LoggerInterface $logger;
32+
private string $defaultLocale;
33+
private LoaderInterface $loader;
3434

3535
public function __construct(HttpClientInterface $client, LoggerInterface $logger, string $defaultLocale, LoaderInterface $loader)
3636
{

src/Symfony/Component/Translation/Bridge/Lokalise/LokaliseProvider.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
*/
3333
final class LokaliseProvider implements ProviderInterface
3434
{
35-
private $client;
36-
private $loader;
37-
private $logger;
38-
private $defaultLocale;
39-
private $endpoint;
35+
private HttpClientInterface $client;
36+
private LoaderInterface $loader;
37+
private LoggerInterface $logger;
38+
private string $defaultLocale;
39+
private string $endpoint;
4040

4141
public function __construct(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint)
4242
{

src/Symfony/Component/Translation/Bridge/Lokalise/LokaliseProviderFactory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ final class LokaliseProviderFactory extends AbstractProviderFactory
2727
{
2828
private const HOST = 'api.lokalise.com';
2929

30-
private $client;
31-
private $logger;
32-
private $defaultLocale;
33-
private $loader;
30+
private HttpClientInterface $client;
31+
private LoggerInterface $logger;
32+
private string $defaultLocale;
33+
private LoaderInterface $loader;
3434

3535
public function __construct(HttpClientInterface $client, LoggerInterface $logger, string $defaultLocale, LoaderInterface $loader)
3636
{

src/Symfony/Component/Translation/Command/TranslationPullCommand.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ final class TranslationPullCommand extends Command
3535
protected static $defaultName = 'translation:pull';
3636
protected static $defaultDescription = 'Pull translations from a given provider.';
3737

38-
private $providerCollection;
39-
private $writer;
40-
private $reader;
41-
private $defaultLocale;
42-
private $transPaths;
43-
private $enabledLocales;
38+
private TranslationProviderCollection $providerCollection;
39+
private TranslationWriterInterface $writer;
40+
private TranslationReaderInterface $reader;
41+
private string $defaultLocale;
42+
private array $transPaths;
43+
private array $enabledLocales;
4444

4545
public function __construct(TranslationProviderCollection $providerCollection, TranslationWriterInterface $writer, TranslationReaderInterface $reader, string $defaultLocale, array $transPaths = [], array $enabledLocales = [])
4646
{

src/Symfony/Component/Translation/Command/TranslationPushCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ final class TranslationPushCommand extends Command
3434
protected static $defaultName = 'translation:push';
3535
protected static $defaultDescription = 'Push translations to a given provider.';
3636

37-
private $providers;
38-
private $reader;
39-
private $transPaths;
40-
private $enabledLocales;
37+
private TranslationProviderCollection $providers;
38+
private TranslationReaderInterface $reader;
39+
private array $transPaths;
40+
private array $enabledLocales;
4141

4242
public function __construct(TranslationProviderCollection $providers, TranslationReaderInterface $reader, array $transPaths = [], array $enabledLocales = [])
4343
{

src/Symfony/Component/Translation/Command/XliffLintCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ class XliffLintCommand extends Command
3434
protected static $defaultName = 'lint:xliff';
3535
protected static $defaultDescription = 'Lint an XLIFF file and outputs encountered errors';
3636

37-
private $format;
38-
private $displayCorrectFiles;
39-
private $directoryIteratorProvider;
40-
private $isReadableProvider;
41-
private $requireStrictFileNames;
37+
private string $format;
38+
private bool $displayCorrectFiles;
39+
private ?\Closure $directoryIteratorProvider;
40+
private ?\Closure $isReadableProvider;
41+
private bool $requireStrictFileNames;
4242

4343
public function __construct(string $name = null, callable $directoryIteratorProvider = null, callable $isReadableProvider = null, bool $requireStrictFileNames = true)
4444
{
4545
parent::__construct($name);
4646

47-
$this->directoryIteratorProvider = $directoryIteratorProvider;
48-
$this->isReadableProvider = $isReadableProvider;
47+
$this->directoryIteratorProvider = null === $directoryIteratorProvider || $directoryIteratorProvider instanceof \Closure ? $directoryIteratorProvider : \Closure::fromCallable($directoryIteratorProvider);
48+
$this->isReadableProvider = null === $isReadableProvider || $isReadableProvider instanceof \Closure ? $isReadableProvider : \Closure::fromCallable($isReadableProvider);
4949
$this->requireStrictFileNames = $requireStrictFileNames;
5050
}
5151

src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
class TranslationDataCollector extends DataCollector implements LateDataCollectorInterface
2727
{
28-
private $translator;
28+
private DataCollectorTranslator $translator;
2929

3030
public function __construct(DataCollectorTranslator $translator)
3131
{

src/Symfony/Component/Translation/DataCollectorTranslator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter
2525
public const MESSAGE_MISSING = 1;
2626
public const MESSAGE_EQUALS_FALLBACK = 2;
2727

28-
private $translator;
29-
private $messages = [];
28+
private TranslatorInterface $translator;
29+
private array $messages = [];
3030

3131
/**
3232
* @param TranslatorInterface&TranslatorBagInterface&LocaleAwareInterface $translator

src/Symfony/Component/Translation/DependencyInjection/TranslationDumperPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
*/
2121
class TranslationDumperPass implements CompilerPassInterface
2222
{
23-
private $writerServiceId;
24-
private $dumperTag;
23+
private string $writerServiceId;
24+
private string $dumperTag;
2525

2626
public function __construct(string $writerServiceId = 'translation.writer', string $dumperTag = 'translation.dumper')
2727
{

src/Symfony/Component/Translation/DependencyInjection/TranslationExtractorPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
*/
2222
class TranslationExtractorPass implements CompilerPassInterface
2323
{
24-
private $extractorServiceId;
25-
private $extractorTag;
24+
private string $extractorServiceId;
25+
private string $extractorTag;
2626

2727
public function __construct(string $extractorServiceId = 'translation.extractor', string $extractorTag = 'translation.extractor')
2828
{

src/Symfony/Component/Translation/DependencyInjection/TranslatorPass.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
class TranslatorPass implements CompilerPassInterface
2020
{
21-
private $translatorServiceId;
22-
private $readerServiceId;
23-
private $loaderTag;
24-
private $debugCommandServiceId;
25-
private $updateCommandServiceId;
21+
private string $translatorServiceId;
22+
private string $readerServiceId;
23+
private string $loaderTag;
24+
private string $debugCommandServiceId;
25+
private string $updateCommandServiceId;
2626

2727
public function __construct(string $translatorServiceId = 'translator.default', string $readerServiceId = 'translation.reader', string $loaderTag = 'translation.loader', string $debugCommandServiceId = 'console.command.translation_debug', string $updateCommandServiceId = 'console.command.translation_update')
2828
{

src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,26 @@
2222
*/
2323
class TranslatorPathsPass extends AbstractRecursivePass
2424
{
25-
private $translatorServiceId;
26-
private $debugCommandServiceId;
27-
private $updateCommandServiceId;
28-
private $resolverServiceId;
29-
private $level = 0;
25+
private string $translatorServiceId;
26+
private string $debugCommandServiceId;
27+
private string $updateCommandServiceId;
28+
private string $resolverServiceId;
29+
private int $level = 0;
3030

3131
/**
3232
* @var array<string, bool>
3333
*/
34-
private $paths = [];
34+
private array $paths = [];
3535

3636
/**
3737
* @var array<int, Definition>
3838
*/
39-
private $definitions = [];
39+
private array $definitions = [];
4040

4141
/**
4242
* @var array<string, array<string, bool>>
4343
*/
44-
private $controllers = [];
44+
private array $controllers = [];
4545

4646
public function __construct(string $translatorServiceId = 'translator', string $debugCommandServiceId = 'console.command.translation_debug', string $updateCommandServiceId = 'console.command.translation_update', string $resolverServiceId = 'argument_resolver.service')
4747
{

src/Symfony/Component/Translation/Dumper/CsvFileDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
*/
2121
class CsvFileDumper extends FileDumper
2222
{
23-
private $delimiter = ';';
24-
private $enclosure = '"';
23+
private string $delimiter = ';';
24+
private string $enclosure = '"';
2525

2626
/**
2727
* {@inheritdoc}

src/Symfony/Component/Translation/Dumper/YamlFileDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
class YamlFileDumper extends FileDumper
2525
{
26-
private $extension;
26+
private string $extension;
2727

2828
public function __construct(string $extension = 'yml')
2929
{

src/Symfony/Component/Translation/Exception/ProviderException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
*/
2121
class ProviderException extends RuntimeException implements ProviderExceptionInterface
2222
{
23-
private $response;
24-
private $debug;
23+
private ResponseInterface $response;
24+
private string $debug;
2525

2626
public function __construct(string $message, ResponseInterface $response, int $code = 0, \Exception $previous = null)
2727
{

src/Symfony/Component/Translation/Extractor/ChainExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ChainExtractor implements ExtractorInterface
2525
*
2626
* @var ExtractorInterface[]
2727
*/
28-
private $extractors = [];
28+
private array $extractors = [];
2929

3030
/**
3131
* Adds a loader to the translation extractor.
< 10000 /code>

src/Symfony/Component/Translation/Extractor/PhpExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
2828
/**
2929
* Prefix for new found message.
3030
*/
31-
private $prefix = '';
31+
private string $prefix = '';
3232

3333
/**
3434
* The sequence that captures translation messages.

src/Symfony/Component/Translation/Formatter/MessageFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class_exists(IntlFormatter::class);
2222
*/
2323
class MessageFormatter implements MessageFormatterInterface, IntlFormatterInterface
2424
{
25-
private $translator;
26-
private $intlFormatter;
25+
private TranslatorInterface $translator;
26+
private IntlFormatterInterface $intlFormatter;
2727

2828
/**
2929
* @param TranslatorInterface|null $translator An identity translator to use as selector for pluralization

src/Symfony/Component/Translation/Loader/CsvFileLoader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
*/
2121
class CsvFileLoader extends FileLoader
2222
{
23-
private $delimiter = ';';
24-
private $enclosure = '"';
25-
private $escape = '\\';
23+
private string $delimiter = ';';
24+
private string $enclosure = '"';
25+
private string $escape = '\\';
2626

2727
/**
2828
* {@inheritdoc}

src/Symfony/Component/Translation/Loader/PhpFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
class PhpFileLoader extends FileLoader
2020
{
21-
private static $cache = [];
21+
private static ?array $cache = [];
2222

2323
/**
2424
* {@inheritdoc}

src/Symfony/Component/Translation/LoggingTranslator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
*/
2222
class LoggingTranslator implements TranslatorInterface, TranslatorBagInterface, LocaleAwareInterface
2323
{
24-
private $translator;
25-
private $logger;
24+
private TranslatorInterface $translator;
25+
private LoggerInterface $logger;
2626

2727
/**
2828
* @param TranslatorInterface&TranslatorBagInterface&LocaleAwareInterface $translator The translator must implement TranslatorBagInterface

src/Symfony/Component/Translation/MessageCatalogue.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
*/
2020
class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterface
2121
{
22-
private $messages = [];
23-
private $metadata = [];
24-
private $resources = [];
25-
private $locale;
26-
private $fallbackCatalogue;
27-
private $parent;
22+
private array $messages = [];
23+
private array $metadata = [];
24+
private array $resources = [];
25+
private string $locale;
26+
private ?MessageCatalogueInterface $fallbackCatalogue = null;
27+
private ?self $parent = null;
2828

2929
/**
3030
* @param array $messages An array of messages classified by domain

src/Symfony/Component/Translation/Provider/Dsn.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
*/
2121
final class Dsn
2222
{
23-
private $scheme;
24-
private $host;
25-
private $user;
26-
private $password;
27-
private $port;
28-
private $path;
29-
private $options;
30-
private $originalDsn;
23+
private ?string $scheme;
24+
private ?string $host;
25+
private ?string $user;
26+
private ?string $password;
27+
private ?int $port;
28+
private ?string $path;
29+
private array $options = [];
30+
private string $originalDsn;
3131

3232
public function __construct(string $dsn)
3333
{

0 commit comments

Comments
 (0)
0