Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 143ecb3

Browse filesBrowse files
minor #43326 Add type to final/internal public/protected properties (nicolas-grekas)
This PR was merged into the 6.0 branch. Discussion ---------- Add type to final/internal public/protected properties | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Commits ------- 28f96ba Add type to final/internal public/protected properties
2 parents f3d199d + 28f96ba commit 143ecb3
Copy full SHA for 143ecb3

File tree

Expand file treeCollapse file tree

35 files changed

+111
-130
lines changed
Filter options
Expand file treeCollapse file tree

35 files changed

+111
-130
lines changed

‎.github/patch-types.php

Copy file name to clipboardExpand all lines: .github/patch-types.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/intersectiontype_classes.php'):
2727
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/MultipleArgumentsOptionalScalarNotReallyOptional.php'):
2828
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/CheckTypeDeclarationsPass/IntersectionConstructor.php'):
29+
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/NewInInitializer.php'):
2930
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php'):
3031
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/'):
3132
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'):

‎src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
final class StopwatchTokenParser extends AbstractTokenParser
2626
{
27-
protected $stopwatchIsAvailable;
27+
private bool $stopwatchIsAvailable;
2828

2929
public function __construct(bool $stopwatchIsAvailable)
3030
{

‎src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ class WebDebugToolbarListener implements EventSubscriberInterface
3939
public const DISABLED = 1;
4040
public const ENABLED = 2;
4141

42-
protected $twig;
43-
protected $urlGenerator;
44-
protected $interceptRedirects;
45-
protected $mode;
46-
protected $excludedAjaxPaths;
47-
private $cspHandler;
48-
private $dumpDataCollector;
42+
private Environment $twig;
43+
private ?UrlGeneratorInterface $urlGenerator;
44+
private bool $interceptRedirects;
45+
private int $mode;
46+
private string $excludedAjaxPaths;
47+
private ?ContentSecurityPolicyHandler $cspHandler;
48+
private ?DumpDataCollector $dumpDataCollector;
4949

5050
public function __construct(Environment $twig, bool $interceptRedirects = false, int $mode = self::ENABLED, UrlGeneratorInterface $urlGenerator = null, string $excludedAjaxPaths = '^/bundles|^/_wdt', ContentSecurityPolicyHandler $cspHandler = null, DumpDataCollector $dumpDataCollector = null)
5151
{

‎src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ private function getFileKey(string $file): string
318318
*/
319319
class LazyValue
320320
{
321-
public $file;
321+
public string $file;
322322

323323
public function __construct(string $file)
324324
{

‎src/Symfony/Component/Cache/Adapter/TraceableAdapter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/TraceableAdapter.php
+9-6Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,15 @@ protected function start(string $name)
270270
}
271271
}
272272

273+
/**
274+
* @internal
275+
*/
273276
class TraceableAdapterEvent
274277
{
275-
public $name;
276-
public $start;
277-
public $end;
278-
public $result;
279-
public $hits = 0;
280-
public $misses = 0;
278+
public string $name;
279+
public float $start;
280+
public float $end;
281+
public array|bool $result;
282+
public int $hits = 0;
283+
public int $misses = 0;
281284
}

‎src/Symfony/Component/Cache/CacheItem.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/CacheItem.php
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ final class CacheItem implements ItemInterface
2323
{
2424
private const METADATA_EXPIRY_OFFSET = 1527506807;
2525

26-
protected $key;
27-
protected $value;
28-
protected $isHit = false;
29-
protected $expiry;
30-
protected $metadata = [];
31-
protected $newMetadata = [];
32-
protected $innerItem;
33-
protected $poolHash;
34-
protected $isTaggable = false;
26+
protected string $key;
27+
protected mixed $value = null;
28+
protected bool $isHit = false;
29+
protected float|int|null $expiry = null;
30+
protected array $metadata = [];
31+
protected array $newMetadata = [];
32+
protected ?ItemInterface $innerItem = null;
33+
protected ?string $poolHash = null;
34+
protected bool $isTaggable = false;
3535

3636
/**
3737
* {@inheritdoc}

‎src/Symfony/Component/DependencyInjection/Attribute/Target.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Attribute/Target.php
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121
#[\Attribute(\Attribute::TARGET_PARAMETER)]
2222
final class Target
2323
{
24-
/**
25-
* @var string
26-
*/
27-
public $name;
24+
public string $name;
2825

2926
public function __construct(string $name)
3027
{

‎src/Symfony/Component/DependencyInjection/Definition.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Definition.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ class Definition
5252
*
5353
* Used to store the name of the inner id when using service decoration together with autowiring
5454
*/
55-
public $innerServiceId;
55+
public ?string $innerServiceId = null;
5656

5757
/**
5858
* @internal
5959
*
6060
* Used to store the behavior to follow when using service decoration and the decorated service is invalid
6161
*/
62-
public $decorationOnInvalid;
62+
public ?int $decorationOnInvalid = null;
6363

6464
public function __construct(string $class = null, array $arguments = [])
6565
{

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
1313

1414
use Symfony\Component\Config\Loader\ParamConfigurator;
15+
use Symfony\Component\DependencyInjection\Alias;
1516
use Symfony\Component\DependencyInjection\Argument\AbstractArgument;
1617
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
1718
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
@@ -31,7 +32,7 @@ abstract class AbstractConfigurator
3132
public static $valuePreProcessor;
3233

3334
/** @internal */
34-
protected $definition;
35+
protected Definition|Alias|null $definition = null;
3536

3637
public function __call(string $method, array $args)
3738
{

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/ReferenceConfigurator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/ReferenceConfigurator.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
class ReferenceConfigurator extends AbstractConfigurator
2020
{
2121
/** @internal */
22-
protected $id;
22+
protected string $id;
2323

2424
/** @internal */
25-
protected $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
25+
protected int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
2626

2727
public function __construct(string $id)
2828
{

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_new_in_initializer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_new_in_initializer.php
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,6 @@ public function isCompiled(): bool
3636
return true;
3737
}
3838

39-
public function getRemovedIds(): array
40-
{
41-
return [
42-
'Psr\\Container\\ContainerInterface' => true,
43-
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
44-
];
45-
}
46-
4739
/**
4840
* Gets the public 'foo' shared autowired service.
4941
*

‎src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ private function getEventFromTypeDeclaration(ContainerBuilder $container, string
186186
*/
187187
class ExtractingEventDispatcher extends EventDispatcher implements EventSubscriberInterface
188188
{
189-
public $listeners = [];
189+
public array $listeners = [];
190190

191-
public static $aliases = [];
192-
public static $subscriber;
191+
public static array $aliases = [];
192+
public static string $subscriber;
193193

194194
public function addListener(string $eventName, callable|array $listener, int $priority = 0)
195195
{

‎src/Symfony/Component/HttpClient/Internal/NativeClientState.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Internal/NativeClientState.php
+6-10Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,14 @@
2020
*/
2121
final class NativeClientState extends ClientState
2222
{
23-
/** @var int */
24-
public $id;
25-
/** @var int */
26-
public $maxHostConnections = \PHP_INT_MAX;
27-
/** @var int */
28-
public $responseCount = 0;
23+
public int $id;
24+
public int $maxHostConnections = \PHP_INT_MAX;
25+
public int $responseCount = 0;
2926
/** @var string[] */
30-
public $dnsCache = [];
31-
/** @var bool */
32-
public $sleep = false;
27+
public array $dnsCache = [];
28+
public bool $sleep = false;
3329
/** @var int[] */
34-
public $hosts = [];
30+
public array $hosts = [];
3531

3632
public function __construct()
3733
{

‎src/Symfony/Component/HttpClient/Response/StreamWrapper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Response/StreamWrapper.php
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ class StreamWrapper
2525
/** @var resource|string|null */
2626
public $context;
2727

28-
/** @var HttpClientInterface */
29-
private $client;
28+
private HttpClientInterface|ResponseInterface $client;
3029

3130
private ResponseInterface $response;
3231

@@ -37,7 +36,7 @@ class StreamWrapper
3736
private $handle;
3837

3938
private bool $blocking = true;
40-
private $timeout;
39+
private ?float $timeout = null;
4140
private bool $eof = false;
4241
private int $offset = 0;
4342

‎src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Component\HttpFoundation\Session\Session;
1818
use Symfony\Component\HttpFoundation\Session\SessionInterface;
1919
use Symfony\Component\HttpFoundation\Session\SessionUtils;
20-
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
2120
use Symfony\Component\HttpKernel\Event\RequestEvent;
2221
use Symfony\Component\HttpKernel\Event\ResponseEvent;
2322
use Symfony\Component\HttpKernel\Exception\UnexpectedSessionUsageException;
@@ -179,7 +178,7 @@ public function onKernelResponse(ResponseEvent $event)
179178
}
180179
}
181180

182-
if ($session instanceof Session ? $session->getUsageIndex() === 0 : !$session->isStarted()) {
181+
if ($session instanceof Session ? 0 === $session->getUsageIndex() : !$session->isStarted()) {
183182
return;
184183
}
185184

‎src/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
class AddRequestFormatsListener implements EventSubscriberInterface
2626
{
27-
protected $formats;
27+
private array $formats;
2828

2929
public function __construct(array $formats)
3030
{

‎src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
*/
3030
class ProfilerListener implements EventSubscriberInterface
3131
{
32-
protected $profiler;
33-
protected $matcher;
34-
protected $onlyException;
35-
protected $onlyMainRequests;
36-
protected $exception;
37-
protected $profiles;
38-
protected $requestStack;
39-
protected $parents;
32+
private Profiler $profiler;
33+
private ?RequestMatcherInterface $matcher;
34+
private bool $onlyException;
35+
private bool $onlyMainRequests;
36+
private ?\Throwable $exception = null;
37+
private \SplObjectStorage $profiles;
38+
private RequestStack $requestStack;
39+
private \SplObjectStorage $parents;
4040

4141
/**
4242
* @param bool $onlyException True if the profiler only collects data when an exception occurs, false otherwise

‎src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ class Connection implements ResetInterface
6060
protected $configuration = [];
6161
protected $driverConnection;
6262
protected $queueEmptiedAt;
63-
private $schemaSynchronizer;
64-
private $autoSetup;
63+
private ?SchemaSynchronizer $schemaSynchronizer;
64+
private bool $autoSetup;
6565

6666
public function __construct(array $configuration, DBALConnection $driverConnection, SchemaSynchronizer $schemaSynchronizer = null)
6767
{

‎src/Symfony/Component/Messenger/Middleware/StackMiddleware.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Middleware/StackMiddleware.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope
6565
*/
6666
class MiddlewareStack
6767
{
68-
public $iterator;
69-
public $stack = [];
68+
public ?\Iterator $iterator;
69+
public array $stack = [];
7070

7171
public function next(int $offset): ?MiddlewareInterface
7272
{
7373
if (isset($this->stack[$offset])) {
7474
return $this->stack[$offset];
7575
}
7676

77-
if (null === $this->iterator) {
77+
if (!isset($this->iterator)) {
7878
return null;
7979
}
8080

‎src/Symfony/Component/Mime/Encoder/QpEncoder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Encoder/QpEncoder.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class QpEncoder implements EncoderInterface
7676
255 => '=FF',
7777
];
7878

79-
private static $safeMapShare = [];
79+
private static array $safeMapShare = [];
8080

8181
/**
8282
* A map of non-encoded ascii characters.
@@ -85,7 +85,7 @@ class QpEncoder implements EncoderInterface
8585
*
8686
* @internal
8787
*/
88-
protected $safeMap = [];
88+
protected array $safeMap = [];
8989

9090
public function __construct()
9191
{

‎src/Symfony/Component/Notifier/Bridge/FakeChat/FakeChatTransportFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/FakeChat/FakeChatTransportFactory.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
*/
2424
final class FakeChatTransportFactory extends AbstractTransportFactory
2525
{
26-
protected $mailer;
27-
protected $logger;
26+
private MailerInterface $mailer;
27+
private LoggerInterface $logger;
2828

2929
public function __construct(MailerInterface $mailer, LoggerInterface $logger)
3030
{

‎src/Symfony/Component/Notifier/Bridge/FakeSms/FakeSmsTransportFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/FakeSms/FakeSmsTransportFactory.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
*/
2525
final class FakeSmsTransportFactory extends AbstractTransportFactory
2626
{
27-
protected $mailer;
28-
protected $logger;
27+
private MailerInterface $mailer;
28+
private LoggerInterface $logger;
2929

3030
public function __construct(MailerInterface $mailer, LoggerInterface $logger)
3131
{

‎src/Symfony/Component/Process/Pipes/AbstractPipes.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Pipes/AbstractPipes.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
abstract class AbstractPipes implements PipesInterface
2222
{
23-
public $pipes = [];
23+
public array $pipes = [];
2424

2525
private $inputBuffer = '';
2626
private $input;

‎src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
3535
/**
3636
* @internal
3737
*/
38-
public static $defaultMutatorPrefixes = ['add', 'remove', 'set'];
38+
public static array $defaultMutatorPrefixes = ['add', 'remove', 'set'];
3939

4040
/**
4141
* @internal
4242
*/
43-
public static $defaultAccessorPrefixes = ['get', 'is', 'has', 'can'];
43+
public static array $defaultAccessorPrefixes = ['get', 'is', 'has', 'can'];
4444

4545
/**
4646
* @internal
4747
*/
48-
public static $defaultArrayMutatorPrefixes = ['add', 'remove'];
48+
public static array $defaultArrayMutatorPrefixes = ['add', 'remove'];
4949

5050
public const ALLOW_PRIVATE = 1;
5151
public const ALLOW_PROTECTED = 2;

‎src/Symfony/Component/Routing/Matcher/UrlMatcher.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Matcher/UrlMatcher.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
4545
*
4646
* @internal
4747
*/
48-
protected $allowSchemes = [];
48+
protected array $allowSchemes = [];
4949

5050
protected $routes;
5151
protected $request;

‎src/Symfony/Component/Serializer/Encoder/ChainDecoder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/ChainDecoder.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
*/
2525
class ChainDecoder implements ContextAwareDecoderInterface
2626
{
27-
protected $decoders = [];
28-
protected $decoderByFormat = [];
27+
private array $decoders = [];
28+
private array $decoderByFormat = [];
2929

3030
public function __construct(array $decoders = [])
3131
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.