8000 Add types to public and protected properties by nicolas-grekas · Pull Request #51069 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Add types to public and protected properties #51069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions .github/expected-missing-return-types.diff
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ diff --git a/src/Symfony/Component/BrowserKit/AbstractBrowser.php b/src/Symfony/
+ protected function filterResponse(object $response): Response
{
return $response;
diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
--- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
+++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
@@ -94,5 +94,5 @@ abstract class NodeDefinition implements NodeParentInterface
* @return NodeParentInterface|NodeBuilder|NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition
*/
- public function end(): NodeParentInterface
+ public function end(): NodeParentInterface|NodeBuilder|NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition
{
return $this->parent;
diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php
--- a/src/Symfony/Component/Console/Command/Command.php
+++ b/src/Symfony/Component/Console/Command/Command.php
Expand Down Expand Up @@ -72,14 +82,14 @@ diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Com
diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php
--- a/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php
@@ -41,5 +41,5 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
@@ -38,5 +38,5 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
* @return void
*/
- public function process(ContainerBuilder $container)
+ public function process(ContainerBuilder $container): void
{
$this->container = $container;
@@ -72,5 +72,5 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
@@ -69,5 +69,5 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
* @return mixed
*/
- protected function processValue(mixed $value, bool $isRoot = false)
Expand Down Expand Up @@ -278,28 +288,28 @@ diff --git a/src/Symfony/Component/Form/FormTypeInterface.php b/src/Symfony/Comp
diff --git a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php
--- a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php
+++ b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php
@@ -38,5 +38,5 @@ abstract class Bundle implements BundleInterface
@@ -35,5 +35,5 @@ abstract class Bundle implements BundleInterface
* @return void
*/
- public function boot()
+ public function boot(): void
{
}
@@ -45,5 +45,5 @@ abstract class Bundle implements BundleInterface
@@ -42,5 +42,5 @@ abstract class Bundle implements BundleInterface
* @return void
*/
- public function shutdown()
+ public function shutdown(): void
{
}
@@ -55,5 +55,5 @@ abstract class Bundle implements BundleInterface
@@ -52,5 +52,5 @@ abstract class Bundle implements BundleInterface
* @return void
*/
- public function build(ContainerBuilder $container)
+ public function build(ContainerBuilder $container): void
{
}
@@ -125,5 +125,5 @@ abstract class Bundle implements BundleInterface
@@ -122,5 +122,5 @@ abstract class Bundle implements BundleInterface
* @return void
*/
- public function registerCommands(Application $application)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ abstract class AbstractDoctrineExtension extends Extension
/**
* Used inside metadata driver method to simplify aggregation of data.
*/
protected $aliasMap = [];
protected array $aliasMap = [];

/**
* Used inside metadata driver method to simplify aggregation of data.
*/
protected $drivers = [];
protected array $drivers = [];

/**
* @param array $objectManager A configured object manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,15 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
/**
* DI object for the driver to use, either a service definition for a
* private service or a reference for a public service.
*
* @var Definition|Reference
*/
protected $driver;
protected Definition|Reference $driver;

/**
* List of namespaces handled by the driver.
*
* @var string[]
*/
protected $namespaces;
protected array $namespaces;

/**
* List of potential container parameters that hold the object manager name
Expand All @@ -54,24 +52,20 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
*
* @var string[]
*/
protected $managerParameters;
protected array $managerParameters;

/**
* Naming pattern of the metadata chain driver service ids, for example
* 'doctrine.orm.%s_metadata_driver'.
*
* @var string
*/
protected $driverPattern;
protected string $driverPattern;

/**
* A name for a parameter in the container. If set, this compiler pass will
* only do anything if the parameter is present. (But regardless of the
* value of that parameter.
*
* @var string|false
*/
protected $enabledParameter;
protected string|false $enabledParameter;

/**
* Naming pattern for the configuration service id, for example
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Doctrine/Form/DoctrineOrmExtension.php
10000
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class DoctrineOrmExtension extends AbstractExtension
{
protected $registry;
protected ManagerRegistry $registry;

public function __construct(ManagerRegistry $registry)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
{
protected $registry;
protected ManagerRegistry $registry;

private array $cache = [];

Expand Down
5 changes: 1 addition & 4 deletions src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@

abstract class DoctrineType extends AbstractType implements ResetInterface
{
/**
* @var ManagerRegistry
*/
protected $registry;
protected ManagerRegistry $registry;

/**
* @var IdReader[]
Expand Down
5 changes: 1 addition & 4 deletions src/Symfony/Bridge/Doctrine/ManagerRegistry.php
10000
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
*/
abstract class ManagerRegistry extends AbstractManagerRegistry
{
/**
* @var Container
*/
protected $container;
protected Container $container;

protected function getService($name): object
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ class UniqueEntity extends Constraint
self::NOT_UNIQUE_ERROR => 'NOT_UNIQUE_ERROR',
];

public $message = 'This value is already used.';
public $service = 'doctrine.orm.validator.unique';
public $em;
public $entityClass;
public $repositoryMethod = 'findBy';
public $fields = [];
public $errorPath;
public $ignoreNull = true;
public string $message = 'This value is already used.';
public string $service = 'doctrine.orm.validator.unique';
public ?string $em = null;
public ?string $entityClass = null;
public string $repositoryMethod = 'findBy';
public array|string $fields = [];
public ?string $errorPath = null;
public bool|array|string $ignoreNull = true;

/**
* @param array|string $fields The combination of fields that must contain unique values or a set of options
* @param bool|array|string $ignoreNull The combination of fields that ignore null values
*/
public function __construct(
$fields,
array|string $fields,
string $message = null,
string $service = null,
string $em = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
class DoctrineInitializer implements ObjectInitializerInterface
{
protected $registry;
protected ManagerRegistry $registry;

public function __construct(ManagerRegistry $registry)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@
*/
abstract class AbstractController implements ServiceSubscriberInterface
{
/**
* @var ContainerInterface
*/
protected $container;
protected ContainerInterface $container;

#[Required]
public function setContainer(ContainerInterface $container): ?ContainerInterface
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
*/
class HttpCache extends BaseHttpCache
{
protected $cacheDir;
protected $kernel;
protected ?string $cacheDir = null;
protected KernelInterface $kernel;

private ?StoreInterface $store = null;
private ?SurrogateInterface $surrogate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
abstract class AbstractVault
{
protected $lastMessage;
protected ?string $lastMessage = null;

public function getLastMessage(): ?string
{
Expand Down
11 changes: 3 additions & 8 deletions src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,9 @@ abstract class KernelTestCase extends TestCase
use MailerAssertionsTrait;
use NotificationAssertionsTrait;

protected static $class;

/**
* @var KernelInterface
*/
protected static $kernel;

protected static $booted = false;
protected static ?string $class = null;
protected static ?KernelInterface $kernel = null;
protected static bool $booted = false;

protected function tearDown(): void
{
Expand Down
7 changes: 3 additions & 4 deletions src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
*/
class Translator extends BaseTranslator implements WarmableInterface
{
protected $container;
protected $loaderIds;

protected $options = [
protected ContainerInterface $container;
protected array $loaderIds;
protected array $options = [
'cache_dir' => null,
'debug' => false,
'resource_files' => [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@
*/
abstract class AbstractFactory implements AuthenticatorFactoryInterface
{
protected $options = [
protected array $options = [
'check_path' => '/login_check',
'use_forward' => false,
'require_previous_session' => false,
'login_path' => '/login',
];

protected $defaultSuccessHandlerOptions = [
protected array $defaultSuccessHandlerOptions = [
'always_use_default_target_path' => false,
'default_target_path' => '/',
'login_path' => '/login',
'target_path_parameter' => '_target_path',
'use_referer' => false,
];

protected $defaultFailureHandlerOptions = [
protected array $defaultFailureHandlerOptions = [
'failure_path' => null,
'failure_forward' => false,
'login_path' => '/login',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class RememberMeFactory implements AuthenticatorFactoryInterface, PrependExtensi
{
public const PRIORITY = -50;

protected $options = [
protected array $options = [
'name' => 'REMEMBERME',
'lifetime' => 31536000,
'path' => '/',
Expand Down
24 changes: 12 additions & 12 deletions src/Symfony/Component/BrowserKit/AbstractBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@
*/
abstract class AbstractBrowser
{
protected $history;
protected $cookieJar;
protected $server = [];
protected $internalRequest;
protected $request;
protected $internalResponse;
protected $response;
protected $crawler;
protected History $history;
protected CookieJar $cookieJar;
protected array $server = [];
protected Request $internalRequest;
protected object $request;
protected Response $internalResponse;
protected object $response;
protected Crawler $crawler;
protected bool $useHtml5Parser = true;
protected $insulated = false;
protected $redirect;
protected $followRedirects = true;
protected $followMetaRefresh = false;
protected bool $insulated = false;
protected ?string $redirect;
protected bool $followRedirects = true;
protected bool $followMetaRefresh = false;

private int $maxRedirects = -1;
private int $redirectCount = 0;
Expand Down
16 changes: 8 additions & 8 deletions src/Symfony/Component/BrowserKit/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ class Cookie
'D M d H:i:s Y T',
];

protected $name;
protected $value;
protected $expires;
protected $path;
protected $domain;
protected $secure;
protected $httponly;
protected $rawValue;
protected string $name;
protected string $value;
protected ?string $expires = null;
protected string $path;
protected string $domain;
protected bool $secure;
protected bool $httponly;
protected string $rawValue;
private ?string $samesite;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/BrowserKit/CookieJar.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class CookieJar
{
protected $cookieJar = [];
protected array $cookieJar = [];

public function set(Cookie $cookie): void
{
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/BrowserKit/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/
class History
{
protected $stack = [];
protected $position = -1;
protected array $stack = [];
protected int $position = -1;

/**
* Clears the history.
Expand Down
Loading
0