8000 Add types to private properties · symfony/symfony@d2bdeb0 · GitHub
[go: up one dir, main page]

Skip to content

Commit d2bdeb0

Browse files
Add types to private properties
1 parent 503a7b3 commit d2bdeb0

File tree

75 files changed

+223
-268
lines changed

Some content is hidden

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

75 files changed

+223
-268
lines changed

src/Symfony/Bridge/Doctrine/Messenger/AbstractDoctrineMiddleware.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
*/
2626
abstract class AbstractDoctrineMiddleware implements MiddlewareInterface
2727
{
28-
protected $managerRegistry;
29-
protected $entityManagerName;
28+
protected ManagerRegistry $managerRegistry;
29+
protected ?string $entityManagerName;
3030

3131
public function __construct(ManagerRegistry $managerRegistry, string $entityManagerName = null)
3232
{

src/Symfony/Bundle/DebugBundle/Command/ServerDumpPlaceholderCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#[AsCommand(name: 'server:dump', description: 'Start a dump server that collects and displays dumps in a single place')]
3030
class ServerDumpPlaceholderCommand extends Command
3131
{
32-
private $replacedCommand;
32+
private ServerDumpCommand $replacedCommand;
3333

3434
public function __construct(DumpServer $server = null, array $descriptors = [])
3535
{

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@
3333
*/
3434
abstract class Descriptor implements DescriptorInterface
3535
{
36-
/**
37-
* @var OutputInterface
38-
*/
39-
protected $output;
36+
protected OutputInterface $output;
4037

4138
public function describe(OutputInterface $output, mixed $object, array $options = []): void
4239
{

src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionPanelController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
*/
2626
class ExceptionPanelController
2727
{
28-
private $errorRenderer;
29-
private $profiler;
28+
private HtmlErrorRenderer $errorRenderer;
29+
private ?Profiler $profiler;
3030

3131
public function __construct(HtmlErrorRenderer $errorRenderer, Profiler $profiler = null)
3232
{

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
*/
3333
class ProfilerController
3434
{
35-
private $templateManager;
36-
private $generator;
37-
private $profiler;
38-
private $twig;
39-
private $templates;
40-
private $cspHandler;
41-
private $baseDir;
35+
private TemplateManager $templateManager;
36+
private UrlGeneratorInterface $generator;
37+
private ?Profiler $profiler;
38+
private Environment $twig;
39+
private array $templates;
40+
private ?ContentSecurityPolicyHandler $cspHandler;
41+
private ?string $baseDir;
4242

4343
public function __construct(UrlGeneratorInterface $generator, Profiler $profiler = null, Environment $twig, array $templates, ContentSecurityPolicyHandler $cspHandler = null, string $baseDir = null)
4444
{
@@ -174,7 +174,6 @@ public function searchBarAction(Request $request): Response
174174

175175
$this->cspHandler?->disableCsp();
176176

177-
178177
$session = null;
179178
if ($request->attributes->getBoolean('_stateless') && $request->hasSession()) {
180179
$session = $request->getSession();

src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
*/
3131
class RouterController
3232
{
33-
private $profiler;
34-
private $twig;
35-
private $matcher;
36-
private $routes;
33+
private ?Profiler $profiler;
34+
private Environment $twig;
35+
private ?UrlMatcherInterface $matcher;
36+
private ?RouteCollection $routes;
3737

3838
/**
3939
* @var ExpressionFunctionProviderInterface[]
4040
*/
41-
private $expressionLanguageProviders = [];
41+
private iterable $expressionLanguageProviders;
4242

4343
public function __construct(Profiler $profiler = null, Environment $twig, UrlMatcherInterface $matcher = null, RouteCollection $routes = null, iterable $expressionLanguageProviders = [])
4444
{

src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
*/
2424
class ContentSecurityPolicyHandler
2525
{
26-
private $nonceGenerator;
27-
private $cspDisabled = false;
26+
private NonceGenerator $nonceGenerator;
27+
private bool $cspDisabled = false;
2828

2929
public function __construct(NonceGenerator $nonceGenerator)
3030
{

src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
*/
2525
class TemplateManager
2626
{
27-
protected $twig;
28-
protected $templates;
29-
protected $profiler;
27+
protected Environment $twig;
28+
protected array $templates;
29+
protected Profiler $profiler;
3030

3131
public function __construct(Profiler $profiler, Environment $twig, array $templates)
3232
{

src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,14 @@
2727
*/
2828
class WebProfilerExtension extends ProfilerExtension
2929
{
30-
/**
31-
* @var HtmlDumper
32-
*/
33-
private $dumper;
30+
private HtmlDumper $dumper;
3431

3532
/**
3633
* @var resource
3734
*/
3835
private $output;
3936

40-
/**
41-
* @var int
42-
*/
43-
private $stackLevel = 0;
37+
private int $stackLevel = 0;
4438

4539
public function __construct(HtmlDumper $dumper = null)
4640
{

src/Symfony/Component/Asset/Exception/AssetNotFoundException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
class AssetNotFoundException extends RuntimeException
1818
{
19-
private $alternatives;
19+
private array $alternatives;
2020

2121
/**
2222
* @param string $message Exception message to throw

src/Symfony/Component/BrowserKit/AbstractBrowser.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public function getCookieJar(): CookieJar
204204
*/
205205
public function getCrawler(): Crawler
206206
{
207-
if (null === $this->crawler) {
207+
if (!isset($this->crawler)) {
208208
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
209209
}
210210

@@ -228,7 +228,7 @@ public function useHtml5Parser(bool $useHtml5Parser): static
228228
*/
229229
public function getInternalResponse(): Response
230230
{
231-
if (null === $this->internalResponse) {
231+
if (!isset($this->internalResponse)) {
232232
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
233233
}
234234

@@ -245,7 +245,7 @@ public function getInternalResponse(): Response
245245
*/
246246
public function getResponse(): object
247247
{
248-
if (null === $this->response) {
248+
if (!isset($this->response)) {
249249
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
250250
}
251251
97AE
@@ -257,7 +257,7 @@ public function getResponse(): object
257257
*/
258258
public function getInternalRequest(): Request
259259
{
260-
if (null === $this->internalRequest) {
260+
if (!isset($this->internalRequest)) {
261261
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
262262
}
263263

@@ -274,7 +274,7 @@ public function getInternalRequest(): Request
274274
*/
275275
public function getRequest(): object
276276
{
277-
if (null === $this->request) {
277+
if (!isset($this->request)) {
278278
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
279279
}
280280

@@ -300,7 +300,7 @@ public function click(Link $link): Crawler
300300
*/
301301
public function clickLink(string $linkText): Crawler
302302
{
303-
if (null === $this->crawler) {
303+
if (!isset($this->crawler)) {
304304
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
305305
}
306306

@@ -331,7 +331,7 @@ public function submit(Form $form, array $values = [], array $serverParameters =
331331
*/
332332
public function submitForm(string $button, array $fieldValues = [], string $method = 'POST', array $serverParameters = []): Crawler
333333
{
334-
if (null === $this->crawler) {
334+
if (!isset($this->crawler)) {
335335
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
336336
}
337337

src/Symfony/Component/Cache/LockRegistry.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
*/
2727
final class LockRegistry
2828
{
29-
private static $openedFiles = [];
30-
private static $lockedFiles;
31-
private static $signalingException;
32-
private static $signalingCallback;
29+
private static array $openedFiles = [];
30+
private static ?array $lockedFiles = null;
31+
private static \Exception $signalingException;
32+
private static \Closure $signalingCallback;
3333

3434
/**
3535
* The number of items in this list controls the max number of concurrent processes.
3636
*/
37-
private static $files = [
37+
private static array $files = [
3838
__DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'AbstractAdapter.php',
3939
__DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'AbstractTagAwareAdapter.php',
4040
__DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'AdapterInterface.php',

src/Symfony/Component/Console/Command/CompleteCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ final class CompleteCommand extends Command
4444
*/
4545
protected static $defaultDescription = 'Internal command to provide shell completion suggestions';
4646

47-
private $completionOutputs;
47+
private array $completionOutputs;
4848

49-
private $isDebug = false;
49+
private bool $isDebug = false;
5050

5151
/**
5252
* @param array<string, class-string<CompletionOutputInterface>> $completionOutputs A list of additional completion outputs, with shell name as key and FQCN as value

src/Symfony/Component/Console/Completion/CompletionInput.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ final class CompletionInput extends ArgvInput
3131
public const TYPE_OPTION_NAME = 'option_name';
3232
public const TYPE_NONE = 'none';
3333

34-
private $tokens;
35-
private $currentIndex;
36-
private $completionType;
37-
private $completionName;
38-
private $completionValue = '';
34+
private ?array $tokens = null;
35+
private ?int $currentIndex = null;
36+
private string $completionType;
37+
private ?string $completionName = null;
38+
private string $completionValue = '';
3939

4040
/**
4141
* Converts a terminal string into tokens.

src/Symfony/Component/Console/Completion/CompletionSuggestions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
*/
2121
final class CompletionSuggestions
2222
{
23-
private $valueSuggestions = [];
24-
private $optionSuggestions = [];
23+
private array $valueSuggestions = [];
24+
private array $optionSuggestions = [];
2525

2626
/**
2727
* Add a suggested value for an input option or argument.

src/Symfony/Component/Console/Tester/CommandCompletionTester.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class CommandCompletionTester
2424
{
25-
private $command;
25+
private Command $command;
2626

2727
public function __construct(Command $command)
2828
{

src/Symfony/Component/DependencyInjection/Compiler/AttributeAutoconfigurationPass.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ final class AttributeAutoconfigurationPass extends AbstractRecursivePass
2424
{
2525
protected bool $skipScalars = true;
2626

27-
private $classAttributeConfigurators = [];
28-
private $methodAttributeConfigurators = [];
29-
private $propertyAttributeConfigurators = [];
30-
private $parameterAttributeConfigurators = [];
27+
private array $classAttributeConfigurators = [];
28+
private array $methodAttributeConfigurators = [];
29+
private array $propertyAttributeConfigurators = [];
30+
private array $parameterAttributeConfigurators = [];
3131

3232
public function process(ContainerBuilder $container): void
3333
{

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Container implements ContainerInterface, ResetInterface
6565
private bool $compiled = false;
6666
private \Closure $getEnv;
6767

68-
private static $make;
68+
private static \Closure $make;
6969

7070
public function __construct(ParameterBagInterface $parameterBag = null)
7171
{

src/Symfony/Component/Dotenv/Command/DebugCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ final class DebugCommand extends Command
3939
*/
4040
protected static $defaultDescription = 'Lists all dotenv files with variables and values';
4141

42-
private $kernelEnvironment;
43-
private $projectDirectory;
42+
private string $kernelEnvironment;
43+
private string $projectDirectory;
4444

4545
public function __construct(string $kernelEnvironment, string $projectDirectory)
4646
{

src/Symfony/Component/ExpressionLanguage/Node/ArrayNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class ArrayNode extends Node
2222
{
23-
protected $index;
23+
protected int $index;
2424

2525
public function __construct()
2626
{

src/Symfony/Component/ExpressionLanguage/Token.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class Token
3030
public const PUNCTUATION_TYPE = 'punctuation';
3131

3232
/**
33-
* @param string $type The type of the token (self::*_TYPE)
34-
* @param int|null $cursor The cursor position in the source
33+
* @param self::*_TYPE $type
34+
* @param int|null $cursor The cursor position in the source
3535
*/
3636
public function __construct(string $type, string|int|float|null $value, ?int $cursor)
3737
{

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class Filesystem
2424
{
25-
private static $lastError;
25+
private static ?string $lastError = null;
2626

2727
/**
2828
* Copies a file.

src/Symfony/Component/Filesystem/Path.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,9 @@ final class Path
4242
*
4343
* @var array<string, string>
4444
*/
45-
private static $buffer = [];
45+
private static array $buffer = [];
4646

47-
/**
48-
* @var int
49-
*/
50-
private static $bufferSize = 0;
47+
private static int $bufferSize = 0;
5148

5249
/**
5350
* Canonicalizes the given path.

src/Symfony/Component/Finder/Iterator/VcsIgnoredFilterIterator.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,17 @@
1818
*/
1919
final class VcsIgnoredFilterIterator extends \FilterIterator
2020
{
21-
/**
22-
* @var string
23-
*/
24-
private $baseDir;
21+
private string $baseDir;
2522

2623
/**
2724
* @var array<string, array{0: string, 1: string}|null>
2825
*/
29-
private $gitignoreFilesCache = [];
26+
private array $gitignoreFilesCache = [];
3027

3128
/**
3229
* @var array<string, bool>
3330
*/
34-
private $ignoredPathsCache = [];
31+
private array $ignoredPathsCache = [];
3532

3633
/**
3734
* @param \Iterator<string, \SplFileInfo> $iterator

src/Symfony/Component/Form/ChoiceList/View/ChoiceListView.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class ChoiceListView
2828
/**
2929
* Creates a new choice list view.
3030
*
31-
* @param ChoiceGroupView[]|ChoiceView[] $choices The choice views
32-
* @param ChoiceGroupView[]|ChoiceView[] $preferredChoices the preferred choice views
31+
* @param array<ChoiceGroupView|ChoiceView> $choices The choice views
32+
* @param array<ChoiceGroupView|ChoiceView> $preferredChoices the preferred choice views
3333
*/
3434
public function __construct(array $choices = [], array $preferredChoices = [])
3535
{

0 commit comments

Comments
 (0)
0