8000 Add types to public and protected properties · symfony/symfony@bd629d9 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit bd629d9

Browse files
Add types to public and protected properties
1 parent d33c00b commit bd629d9

File tree

307 files changed

+944
-1349
lines changed

Some content is hidden

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

307 files changed

+944
-1349
lines changed

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ abstract class AbstractDoctrineExtension extends Extension
2828
/**
2929
* Used inside metadata driver method to simplify aggregation of data.
3030
*/
31-
protected $aliasMap = [];
31+
protected array $aliasMap = [];
3232

3333
/**
3434
* Used inside metadata driver method to simplify aggregation of data.
3535
*/
36-
protected $drivers = [];
36+
protected array $drivers = [];
3737

3838
/**
3939
* @param array $objectManager A configured object manager

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php

+5-11
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,15 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
3535
/**
3636
* DI object for the driver to use, either a service definition for a
3737
* private service or a reference for a public service.
38-
*
39-
* @var Definition|Reference
4038
*/
41-
protected $driver;
39+
protected Definition|Reference $driver;
4240

4341
/**
4442
* List of namespaces handled by the driver.
4543
*
4644
* @var string[]
4745
*/
48-
protected $namespaces;
46+
protected array $namespaces;
4947

5048
/**
5149
* List of potential container parameters that hold the object manager name
@@ -54,24 +52,20 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
5452
*
5553
* @var string[]
5654
*/
57-
protected $managerParameters;
55+
protected array $managerParameters;
5856

5957
/**
6058
* Naming pattern of the metadata chain driver service ids, for example
6159
* 'doctrine.orm.%s_metadata_driver'.
62-
*
63-
* @var string
6460
*/
65-
protected $driverPattern;
61+
protected string $driverPattern;
6662

6763
/**
6864
* A name for a parameter in the container. If set, this compiler pass will
6965
* only do anything if the parameter is present. (But regardless of the
7066
* value of that parameter.
71-
*
72-
* @var string|false
7367
*/
74-
protected $enabledParameter;
68+
protected string|false $enabledParameter;
7569

7670
/**
7771
* Naming pattern for the configuration service id, for example

src/Symfony/Bridge/Doctrine/Form/DoctrineOrmExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
class DoctrineOrmExtension extends AbstractExtension
2020
{
21-
protected $registry;
21+
protected ManagerRegistry $registry;
2222

2323
public function __construct(ManagerRegistry $registry)
2424
{

src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
3838
{
39-
protected $registry;
39+
protected ManagerRegistry $registry;
4040

4141
private array $cache = [];
4242

src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@
3131

3232
abstract class DoctrineType extends AbstractType implements ResetInterface
3333
{
34-
/**
35-
* @var ManagerRegistry
36-
*/
37-
protected $registry;
34+
protected ManagerRegistry $registry;
3835

3936
/**
4037
* @var IdReader[]

src/Symfony/Bridge/Doctrine/ManagerRegistry.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@
2424
*/
2525
abstract class ManagerRegistry extends AbstractManagerRegistry
2626
{
27-
/**
28-
* @var Container
29-
*/
30-
protected $container;
27+
protected Container $container;
3128

3229
protected function getService($name): object
3330
{

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ class UniqueEntity extends Constraint
2727
self::NOT_UNIQUE_ERROR => 'NOT_UNIQUE_ERROR',
2828
];
2929

30-
public $message = 'This value is already used.';
31-
public $service = 'doctrine.orm.validator.unique';
32-
public $em;
33-
public $entityClass;
34-
public $repositoryMethod = 'findBy';
35-
public $fields = [];
36-
public $errorPath;
37-
public $ignoreNull = true;
30+
public string $message = 'This value is already used.';
31+
public string $service = 'doctrine.orm.validator.unique';
32+
public ?string $em = null;
33+
public ?string $entityClass = null;
34+
public string $repositoryMethod = 'findBy';
35+
public array|string $fields = [];
36+
public ?string $errorPath = null;
37+
public bool|array|string $ignoreNull = true;
3838

3939
/**
4040
* @param array|string $fields The combination of fields that must contain unique values or a set of options
4141
* @param bool|array|string $ignoreNull The combination of fields that ignore null values
4242
*/
4343
public function __construct(
44-
$fields,
44+
array|string $fields,
4545
string $message = null,
4646
string $service = null,
4747
string $em = null,

src/Symfony/Bridge/Doctrine/Validator/DoctrineInitializer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
class DoctrineInitializer implements ObjectInitializerInterface
2323
{
24-
protected $registry;
24+
protected ManagerRegistry $registry;
2525

2626
public function __construct(ManagerRegistry $registry)
2727
{

src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
use Symfony\Component\WebLink\EventListener\AddLinkHeaderListener;
4545
use Symfony\Component\WebLink\GenericLinkProvider;
4646
use Symfony\Component\WebLink\HttpHeaderSerializer;
47-
use Symfony\Component\WebLink\Link;
4847
use Symfony\Contracts\Service\Attribute\Required;
4948
use Symfony\Contracts\Service\ServiceSubscriberInterface;
5049
use Twig\Environment;
@@ -56,15 +55,12 @@
5655
*/
5756
abstract class AbstractController implements ServiceSubscriberInterface
5857
{
59-
/**
60-
* @var ContainerInterface
61-
*/
62-
protected $container;
58+
protected ContainerInterface $container;
6359

6460
#[Required]
6561
public function setContainer(ContainerInterface $container): ?ContainerInterface
6662
{
67-
$previous = $this->container;
63+
$previous = $this->container ?? null;
6864
$this->container = $container;
6965

7066
return $previous;

src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
*/
2828
class HttpCache extends BaseHttpCache
2929
{
30-
protected $cacheDir;
31-
protected $kernel;
30+
protected ?string $cacheDir = null;
31+
protected KernelInterface $kernel;
3232

3333
private ?StoreInterface $store = null;
3434
private ?SurrogateInterface $surrogate;

src/Symfony/Bundle/FrameworkBundle/Routing/Router.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function __construct(ContainerInterface $container, mixed $resource, arra
6161

6262
public function getRouteCollection(): RouteCollection
6363
{
64-
if (null === $this->collection) {
64+
if (!isset($this->collection)) {
6565
$this->collection = $this->container->get('routing.loader')->load($this->resource, $this->options['resource_type']);
6666
$this->resolveParameters($this->collection);
6767
$this->collection->addResource(new ContainerParametersResource($this->collectedParameters));

src/Symfony/Bundle/FrameworkBundle/Secrets/AbstractVault.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
abstract class AbstractVault
1818
{
19-
protected $lastMessage;
19+
protected ?string $lastMessage = null;
2020

2121
public function getLastMessage(): ?string
2222
{

src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,9 @@ abstract class KernelTestCase extends TestCase
2727
use MailerAssertionsTrait;
2828
use NotificationAssertionsTrait;
2929

30-
protected static $class;
31-
32-
/**
33-
* @var KernelInterface
34-
*/
35-
protected static $kernel;
36-
37-
protected static $booted = false;
30+
protected static ?string $class = null;
31+
protected static ?KernelInterface $kernel = null;
32+
protected static bool $booted = false;
3833

3934
protected function tearDown(): void
4035
{

src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
*/
2525
class Translator extends BaseTranslator implements WarmableInterface
2626
{
27-
protected $container;
28-
protected $loaderIds;
29-
30-
protected $options = [
27+
protected ContainerInterface $container;
28+
protected array $loaderIds;
29+
protected array $options = [
3130
'cache_dir' => null,
3231
'debug' => false,
3332
'resource_files' => [],

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@
2525
*/
2626
abstract class AbstractFactory implements AuthenticatorFactoryInterface
2727
{
28-
protected $options = [
28+
protected array $options = [
2929
'check_path' => '/login_check',
3030
'use_forward' => false,
3131
'require_previous_session' => false,
3232
'login_path' => '/login',
3333
];
3434

35-
protected $defaultSuccessHandlerOptions = [
35+
protected array $defaultSuccessHandlerOptions = [
3636
'always_use_default_target_path' => false,
3737
'default_target_path' => '/',
3838
'login_path' => '/login',
3939
'target_path_parameter' => '_target_path',
4040
'use_referer' => false,
4141
];
4242

43-
protected $defaultFailureHandlerOptions = [
43+
protected array $defaultFailureHandlerOptions = [
4444
'failure_path' => null,
4545
'failure_forward' => false,
4646
'login_path' => '/login',

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class RememberMeFactory implements AuthenticatorFactoryInterface, PrependExtensi
3232
{
3333
public const PRIORITY = -50;
3434

35-
protected $options = [
35+
protected array $options = [
3636
'name' => 'REMEMBERME',
3737
'lifetime' => 31536000,
3838
'path' => '/',

src/Symfony/Component/BrowserKit/AbstractBrowser.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@
3232
*/
3333
abstract class AbstractBrowser
3434
{
35-
protected $history;
36-
protected $cookieJar;
37-
protected $server = [];
38-
protected $internalRequest;
39-
protected $request;
40-
protected $internalResponse;
41-
protected $response;
42-
protected $crawler;
35+
protected History $history;
36+
protected CookieJar $cookieJar;
37+
protected array $server = [];
38+
protected Request $internalRequest;
39+
protected object $request;
40+
protected Response $internalResponse;
41+
protected object $response;
42+
protected Crawler $crawler;
4343
protected bool $useHtml5Parser = true;
44-
protected $insulated = false;
45-
protected $redirect;
46-
protected $followRedirects = true;
47-
protected $followMetaRefresh = false;
44+
protected bool $insulated = false;
45+
protected ?string $redirect;
46+
protected bool $followRedirects = true;
47+
protected bool $followMetaRefresh = false;
4848

4949
private int $maxRedirects = -1;
5050
private int $redirectCount = 0;

src/Symfony/Component/BrowserKit/Cookie.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ class Cookie
3535
'D M d H:i:s Y T',
3636
];
3737

38-
protected $name;
39-
protected $value;
40-
protected $expires;
41-
protected $path;
42-
protected $domain;
43-
protected $secure;
44-
protected $httponly;
45-
protected $rawValue;
38+
protected string $name;
39+
protected string $value;
40+
protected ?string $expires = null;
41+
protected string $path;
42+
protected string $domain;
43+
protected bool $secure;
44+
protected bool $httponly;
45+
protected string $rawValue;
4646
private ?string $samesite;
4747

4848
/**
@@ -61,11 +61,11 @@ class Cookie
6161
public function __construct(string $name, ?string $value, string $expires = null, string $path = null, string $domain = '', bool $secure = false, bool $httponly = true, bool $encodedValue = false, string $samesite = null)
6262
{
6363
if ($encodedValue) {
64-
$this->value = urldecode($value);
65-
$this->rawValue = $value;
64+
$this->rawValue = $value ?? '';
65+
$this->value = urldecode($this->rawValue);
6666
} else {
67-
$this->value = $value;
68-
$this->rawValue = rawurlencode($value ?? '');
67+
$this->value = $value ?? '';
68+
$this->rawValue = rawurlencode($this->value);
6969
}
7070
$this->name = $name;
7171
$this->path = empty($path) ? '/' : $path;

src/Symfony/Component/BrowserKit/CookieJar.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class CookieJar
2222
{
23-
protected $cookieJar = [];
23+
protected array $cookieJar = [];
2424

2525
public function set(Cookie $cookie): void
2626
{

src/Symfony/Component/BrowserKit/History.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
*/
2121
class History
2222
{
23-
protected $stack = [];
24-
protected $position = -1;
23+
protected array $stack = [];
24+
protected int $position = -1;
2525

2626
/**
2727
* Clears the history.

src/Symfony/Component/BrowserKit/Request.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
*/
1717
class Request
1818
{
19-
protected $uri;
20-
protected $method;
21-
protected $parameters;
22-
protected $files;
23-
protected $cookies;
24-
protected $server;
25-
protected $content;
19+
protected string $uri;
20+
protected string $method;
21+
protected array $parameters;
22+
protected array $files;
23+
protected array $cookies;
24+
protected array $server;
25+
protected ?string $content;
2626

2727
/**
2828
* @param string $uri The request URI

src/Symfony/Component/Cache/Adapter/DoctrineDbalAdapter.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
class DoctrineDbalAdapter extends AbstractAdapter implements PruneableInterface
3131
{
32-
protected $maxIdLength = 255;
32+
private const MAX_KEY_LENGTH = 255;
3333

3434
private MarshallerInterface $marshaller;
3535
private Connection $conn;
@@ -88,6 +88,7 @@ public function __construct(Connection|string $connOrDsn, string $namespace = ''
8888
$this->conn = DriverManager::getConnection($params, $config);
8989
}
9090

91+
$this->maxIdLength = self::MAX_KEY_LENGTH;
9192
$this->table = $options['db_table'] ?? $this->table;
9293
$this->idCol = $options['db_id_col'] ?? $this->idCol;
9394
$this->dataCol = $options['db_data_col'] ?? $this->dataCol;

0 commit comments

Comments
 (0)
0