From 25a861506001d86a92f63d9e7fd9bc138015d092 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 27 Jul 2023 11:02:28 +0200 Subject: [PATCH] Ensure all properties have a type --- .../Adapter/AbstractRedisAdapterTestCase.php | 8 ++------ .../Tests/Adapter/PhpArrayAdapterTest.php | 2 +- src/Symfony/Component/Console/Cursor.php | 1 + src/Symfony/Component/Console/Input/Input.php | 1 + .../Component/Console/Output/StreamOutput.php | 1 + .../Component/Console/Tests/CursorTest.php | 4 ++-- .../Console/Tests/Helper/TableTest.php | 4 ++-- .../Tests/Output/ConsoleSectionOutputTest.php | 3 ++- .../Console/Tests/Output/StreamOutputTest.php | 3 ++- .../Form/Console/Descriptor/Descriptor.php | 18 ++++++++---------- .../Tests/AbstractRequestHandlerTestCase.php | 2 +- .../HttpClient/Internal/AmpClientState.php | 7 ++++--- .../HttpClient/Internal/AmpListener.php | 1 + .../HttpClient/Response/AsyncContext.php | 2 ++ .../HttpClient/Response/AsyncResponse.php | 1 + .../Response/CommonResponseTrait.php | 2 ++ .../HttpClient/Response/NativeResponse.php | 10 +++++----- .../Response/TransportResponseTrait.php | 2 +- .../Tests/ResponseFunctionalTest.php | 1 + .../Handler/AbstractSessionHandlerTest.php | 1 + .../Tests/HttpCache/SubRequestHandlerTest.php | 8 +++----- .../Transport/Smtp/Stream/AbstractStream.php | 3 +++ .../Middleware/HandleMessageMiddlewareTest.php | 2 +- .../Component/Mime/Part/AbstractPart.php | 2 +- src/Symfony/Component/Mime/Part/TextPart.php | 1 + .../Component/Process/Pipes/AbstractPipes.php | 7 +++---- src/Symfony/Component/Process/Process.php | 11 ++++++++--- src/Symfony/Component/Process/ProcessUtils.php | 3 --- .../Tests/TestPluralAdderRemoverAndSetter.php | 2 +- ...erRemoverAndSetterSameSingularAndPlural.php | 2 +- .../Tests/LoginLink/LoginLinkHandlerTest.php | 2 +- .../Translation/Tests/TranslatorTest.php | 8 +++----- .../Component/Validator/Constraints/Choice.php | 1 + .../Component/Validator/Constraints/Email.php | 1 + .../Component/Validator/Constraints/Ip.php | 1 + .../Component/Validator/Constraints/Length.php | 1 + .../Validator/Constraints/NotBlank.php | 1 + .../Component/Validator/Constraints/Regex.php | 1 + .../Component/Validator/Constraints/Unique.php | 1 + .../Component/Validator/Constraints/Url.php | 1 + .../Component/Validator/Constraints/Uuid.php | 1 + .../VarDumper/Dumper/AbstractDumper.php | 7 +++++-- .../Component/VarDumper/Dumper/CliDumper.php | 3 ++- .../Component/VarDumper/Dumper/HtmlDumper.php | 1 + .../VarExporter/Internal/Hydrator.php | 6 +++--- .../Internal/LazyObjectRegistry.php | 10 +++++----- .../VarExporter/Internal/Reference.php | 12 +++++------- .../VarExporter/Internal/Registry.php | 10 +++++----- 48 files changed, 102 insertions(+), 81 deletions(-) diff --git a/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTestCase.php b/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTestCase.php index 10382178c837..793fa4838baf 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTestCase.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTestCase.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\SkippedTestSuiteError; use Psr\Cache\CacheItemPoolInterface; +use Relay\Relay; use Symfony\Component\Cache\Adapter\RedisAdapter; abstract class AbstractRedisAdapterTestCase extends AdapterTestCase @@ -23,7 +24,7 @@ abstract class AbstractRedisAdapterTestCase extends AdapterTestCase 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', ]; - protected static $redis; + protected static \Redis|Relay|\RedisArray|\RedisCluster|\Predis\ClientInterface $redis; public function createCachePool(int $defaultLifetime = 0, string $testMethod = null): CacheItemPoolInterface { @@ -42,11 +43,6 @@ public static function setUpBeforeClass(): void } } - public static function tearDownAfterClass(): void - { - self::$redis = null; - } - /** * @runInSeparateProcess */ diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php index 1762aca5b94a..440352c9b63f 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php @@ -148,7 +148,7 @@ public function testStoredFile() class PhpArrayAdapterWrapper extends PhpArrayAdapter { - protected $data = []; + protected array $data = []; public function save(CacheItemInterface $item): bool { diff --git a/src/Symfony/Component/Console/Cursor.php b/src/Symfony/Component/Console/Cursor.php index b7f5a17e0dfa..69fd3821cdd0 100644 --- a/src/Symfony/Component/Console/Cursor.php +++ b/src/Symfony/Component/Console/Cursor.php @@ -19,6 +19,7 @@ final class Cursor { private OutputInterface $output; + /** @var resource */ private $input; /** diff --git a/src/Symfony/Component/Console/Input/Input.php b/src/Symfony/Component/Console/Input/Input.php index 0f5617cd17a9..c7959a6ce023 100644 --- a/src/Symfony/Component/Console/Input/Input.php +++ b/src/Symfony/Component/Console/Input/Input.php @@ -28,6 +28,7 @@ abstract class Input implements InputInterface, StreamableInputInterface { protected $definition; + /** @var resource */ protected $stream; protected $options = []; protected $arguments = []; diff --git a/src/Symfony/Component/Console/Output/StreamOutput.php b/src/Symfony/Component/Console/Output/StreamOutput.php index 155066ea0e1e..da5eefb6ff25 100644 --- a/src/Symfony/Component/Console/Output/StreamOutput.php +++ b/src/Symfony/Component/Console/Output/StreamOutput.php @@ -29,6 +29,7 @@ */ class StreamOutput extends Output { + /** @var resource */ private $stream; /** diff --git a/src/Symfony/Component/Console/Tests/CursorTest.php b/src/Symfony/Component/Console/Tests/CursorTest.php index 7237f8dde98d..d8ae705ea888 100644 --- a/src/Symfony/Component/Console/Tests/CursorTest.php +++ b/src/Symfony/Component/Console/Tests/CursorTest.php @@ -17,6 +17,7 @@ class CursorTest extends TestCase { + /** @var resource */ protected $stream; protected function setUp(): void @@ -26,8 +27,7 @@ protected function setUp(): void protected function tearDown(): void { - fclose($this->stream); - $this->stream = null; + unset($this->stream); } public function testMoveUpOneLine() diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index ddda3382f82f..d6b1e7a420ef 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -25,6 +25,7 @@ class TableTest extends TestCase { + /** @var resource */ protected $stream; protected function setUp(): void @@ -34,8 +35,7 @@ protected function setUp(): void protected function tearDown(): void { - fclose($this->stream); - $this->stream = null; + unset($this->stream); } /** diff --git a/src/Symfony/Component/Console/Tests/Output/ConsoleSectionOutputTest.php b/src/Symfony/Component/Console/Tests/Output/ConsoleSectionOutputTest.php index 984ade26608a..ed1f9ff16883 100644 --- a/src/Symfony/Component/Console/Tests/Output/ConsoleSectionOutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/ConsoleSectionOutputTest.php @@ -22,6 +22,7 @@ class ConsoleSectionOutputTest extends TestCase { + /** @var resource */ private $stream; protected function setUp(): void @@ -31,7 +32,7 @@ protected function setUp(): void protected function tearDown(): void { - $this->stream = null; + unset($this->stream); } public function testClearAll() diff --git a/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php b/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php index 89debf40c692..f8c9913bc8cd 100644 --- a/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php @@ -17,6 +17,7 @@ class StreamOutputTest extends TestCase { + /** @var resource */ protected $stream; protected function setUp(): void @@ -26,7 +27,7 @@ protected function setUp(): void protected function tearDown(): void { - $this->stream = null; + unset($this->stream); } public function testConstructor() diff --git a/src/Symfony/Component/Form/Console/Descriptor/Descriptor.php b/src/Symfony/Component/Form/Console/Descriptor/Descriptor.php index 3c54545cf12a..b8d0399ee172 100644 --- a/src/Symfony/Component/Form/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Component/Form/Console/Descriptor/Descriptor.php @@ -29,16 +29,14 @@ */ abstract class Descriptor implements DescriptorInterface { - /** @var OutputStyle */ - protected $output; - protected $type; - protected $ownOptions = []; - protected $overriddenOptions = []; - protected $parentOptions = []; - protected $extensionOptions = []; - protected $requiredOptions = []; - protected $parents = []; - protected $extensions = []; + protected OutputStyle $output; + protected array $ownOptions = []; + protected array $overriddenOptions = []; + protected array $parentOptions = []; + protected array $extensionOptions = []; + protected array $requiredOptions = []; + protected array $parents = []; + protected array $extensions = []; public function describe(OutputInterface $output, ?object $object, array $options = []): void { diff --git a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTestCase.php b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTestCase.php index 3367d58047ef..c21dcd6a2fd9 100644 --- a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTestCase.php +++ b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTestCase.php @@ -31,7 +31,7 @@ abstract class AbstractRequestHandlerTestCase extends TestCase { protected RequestHandlerInterface $requestHandler; protected FormFactory $factory; - protected $request; + protected mixed $request = null; protected ServerParams $serverParams; protected function setUp(): void diff --git a/src/Symfony/Component/HttpClient/Internal/AmpClientState.php b/src/Symfony/Component/HttpClient/Internal/AmpClientState.php index 539bde252a42..90a002fe1a65 100644 --- a/src/Symfony/Component/HttpClient/Internal/AmpClientState.php +++ b/src/Symfony/Component/HttpClient/Internal/AmpClientState.php @@ -145,15 +145,16 @@ private function getClient(array $options): array $options['crypto_method'] && $context = $context->withMinimumVersion($options['crypto_method']); $connector = $handleConnector = new class() implements Connector { - public $connector; - public $uri; + public DnsConnector $connector; + public string $uri; + /** @var resource|null */ public $handle; public function connect(string $uri, ConnectContext $context = null, CancellationToken $token = null): Promise { $result = $this->connector->connect($this->uri ?? $uri, $context, $token); $result->onResolve(function ($e, $socket) { - $this->handle = null !== $socket ? $socket->getResource() : false; + $this->handle = $socket?->getResource(); }); return $result; diff --git a/src/Symfony/Component/HttpClient/Internal/AmpListener.php b/src/Symfony/Component/HttpClient/Internal/AmpListener.php index 206c44982b66..95c3bb0ed68f 100644 --- a/src/Symfony/Component/HttpClient/Internal/AmpListener.php +++ b/src/Symfony/Component/HttpClient/Internal/AmpListener.php @@ -28,6 +28,7 @@ class AmpListener implements EventListener private array $info; private array $pinSha256; private \Closure $onProgress; + /** @var resource|null */ private $handle; public function __construct(array &$info, array $pinSha256, \Closure $onProgress, &$handle) diff --git a/src/Symfony/Component/HttpClient/Response/AsyncContext.php b/src/Symfony/Component/HttpClient/Response/AsyncContext.php index 55903463ae43..6307cd43593a 100644 --- a/src/Symfony/Component/HttpClient/Response/AsyncContext.php +++ b/src/Symfony/Component/HttpClient/Response/AsyncContext.php @@ -25,10 +25,12 @@ */ final class AsyncContext { + /** @var callable|null */ private $passthru; private HttpClientInterface $client; private ResponseInterface $response; private array $info = []; + /** @var resource|null */ private $content; private int $offset; diff --git a/src/Symfony/Component/HttpClient/Response/AsyncResponse.php b/src/Symfony/Component/HttpClient/Response/AsyncResponse.php index 2f538c99a5af..6f9791546d30 100644 --- a/src/Symfony/Component/HttpClient/Response/AsyncResponse.php +++ b/src/Symfony/Component/HttpClient/Response/AsyncResponse.php @@ -37,6 +37,7 @@ class AsyncResponse implements ResponseInterface, StreamableInterface private ?HttpClientInterface $client; private ResponseInterface $response; private array $info = ['canceled' => false]; + /** @var callable|null */ private $passthru; private ?\Iterator $stream = null; private ?int $yieldedState = null; diff --git a/src/Symfony/Component/HttpClient/Response/CommonResponseTrait.php b/src/Symfony/Component/HttpClient/Response/CommonResponseTrait.php index c3e2b0aa9bd9..96944c2fc3af 100644 --- a/src/Symfony/Component/HttpClient/Response/CommonResponseTrait.php +++ b/src/Symfony/Component/HttpClient/Response/CommonResponseTrait.php @@ -30,7 +30,9 @@ trait CommonResponseTrait * @var callable|null A callback that tells whether we're waiting for response headers */ private $initializer; + /** @var bool|\Closure|resource|null */ private $shouldBuffer; + /** @var resource|null */ private $content; private int $offset = 0; private ?array $jsonData = null; diff --git a/src/Symfony/Component/HttpClient/Response/NativeResponse.php b/src/Symfony/Component/HttpClient/Response/NativeResponse.php index 6fd71a4a4069..4d9e3e2176d8 100644 --- a/src/Symfony/Component/HttpClient/Response/NativeResponse.php +++ b/src/Symfony/Component/HttpClient/Response/NativeResponse.php @@ -34,8 +34,8 @@ final class NativeResponse implements ResponseInterface, StreamableInterface */ private $context; private string $url; - private $resolver; - private $onProgress; + private \Closure $resolver; + private ?\Closure $onProgress; private ?int $remaining = null; /** @@ -58,8 +58,8 @@ public function __construct(NativeClientState $multi, $context, string $url, arr $this->logger = $logger; $this->timeout = $options['timeout']; $this->info = &$info; - $this->resolver = $resolver; - $this->onProgress = $onProgress; + $this->resolver = $resolver(...); + $this->onProgress = $onProgress ? $onProgress(...) : null; $this->inflate = !isset($options['normalized_headers']['accept-encoding']); $this->shouldBuffer = $options['buffer'] ?? true; @@ -177,7 +177,7 @@ private function open(): void } stream_set_blocking($h, false); - $this->context = $this->resolver = null; + unset($this->context, $this->resolver); // Create dechunk buffers if (isset($this->headers['content-length'])) { diff --git a/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php b/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php index fd37ff0d83fd..084221b19e75 100644 --- a/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php +++ b/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php @@ -38,7 +38,7 @@ trait TransportResponseTrait 'canceled' => false, ]; - /** @var object|resource */ + /** @var object|resource|null */ private $handle; private int|string $id; private ?float $timeout = 0; diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php index 841b7a50fa3c..c89adcd3cd4b 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php @@ -16,6 +16,7 @@ class ResponseFunctionalTest extends TestCase { + /** @var resource|false */ private static $server; public static function setUpBeforeClass(): void diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php index fa5119cf3b8c..aabeba9009bd 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php @@ -16,6 +16,7 @@ class AbstractSessionHandlerTest extends TestCase { + /** @var resource|false */ private static $server; public static function setUpBeforeClass(): void diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SubRequestHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SubRequestHandlerTest.php index 97b8b461d20e..98387d3b4880 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SubRequestHandlerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SubRequestHandlerTest.php @@ -142,11 +142,9 @@ private function getGlobalState(): array class TestSubRequestHandlerKernel implements HttpKernelInterface { - private $assertCallback; - - public function __construct(\Closure $assertCallback) - { - $this->assertCallback = $assertCallback; + public function __construct( + private \Closure $assertCallback, + ) { } public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = true): Response diff --git a/src/Symfony/Component/Mailer/Transport/Smtp/Stream/AbstractStream.php b/src/Symfony/Component/Mailer/Transport/Smtp/Stream/AbstractStream.php index ecfb21994946..db84fb0247a1 100644 --- a/src/Symfony/Component/Mailer/Transport/Smtp/Stream/AbstractStream.php +++ b/src/Symfony/Component/Mailer/Transport/Smtp/Stream/AbstractStream.php @@ -24,8 +24,11 @@ */ abstract class AbstractStream { + /** @var resource|null */ protected $stream; + /** @var resource|null */ protected $in; + /** @var resource|null */ protected $out; private string $debug = ''; diff --git a/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php b/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php index 0829765319c9..d05cf7360df9 100644 --- a/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php +++ b/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php @@ -261,7 +261,7 @@ private function process(array $jobs): void public function testBatchHandlerNoBatch() { $handler = new class() implements BatchHandlerInterface { - public $processedMessages; + public array $processedMessages; use BatchHandlerTrait; diff --git a/src/Symfony/Component/Mime/Part/AbstractPart.php b/src/Symfony/Component/Mime/Part/AbstractPart.php index 93892d9df6ee..130106d68c0c 100644 --- a/src/Symfony/Component/Mime/Part/AbstractPart.php +++ b/src/Symfony/Component/Mime/Part/AbstractPart.php @@ -18,7 +18,7 @@ */ abstract class AbstractPart { - private $headers; + private Headers $headers; public function __construct() { diff --git a/src/Symfony/Component/Mime/Part/TextPart.php b/src/Symfony/Component/Mime/Part/TextPart.php index 576c64756c77..bae1e4ffd6e2 100644 --- a/src/Symfony/Component/Mime/Part/TextPart.php +++ b/src/Symfony/Component/Mime/Part/TextPart.php @@ -28,6 +28,7 @@ class TextPart extends AbstractPart private static array $encoders = []; + /** @var resource|string|File */ private $body; private ?string $charset; private string $subtype; diff --git a/src/Symfony/Component/Process/Pipes/AbstractPipes.php b/src/Symfony/Component/Process/Pipes/AbstractPipes.php index c54d4b436c31..cbbb7277093e 100644 --- a/src/Symfony/Component/Process/Pipes/AbstractPipes.php +++ b/src/Symfony/Component/Process/Pipes/AbstractPipes.php @@ -23,19 +23,18 @@ abstract class AbstractPipes implements PipesInterface public array $pipes = []; private string $inputBuffer = ''; + /** @var resource|string|\Iterator */ private $input; private bool $blocked = true; private ?string $lastError = null; /** - * @param resource|string|int|float|bool|\Iterator|null $input + * @param resource|string|\Iterator $input */ - public function __construct(mixed $input) + public function __construct($input) { if (\is_resource($input) || $input instanceof \Iterator) { $this->input = $input; - } elseif (\is_string($input)) { - $this->inputBuffer = $input; } else { $this->inputBuffer = (string) $input; } diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 1d30d27b6b64..8e520d04e7d5 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -54,6 +54,7 @@ class Process implements \IteratorAggregate private array|string $commandline; private ?string $cwd; private array $env = []; + /** @var resource|string|\Iterator|null */ private $input; private ?float $starttime = null; private ?float $lastOutputTime = null; @@ -63,8 +64,11 @@ class Process implements \IteratorAggregate private array $fallbackStatus = []; private array $processInformation; private bool $outputDisabled = false; + /** @var resource */ private $stdout; + /** @var resource */ private $stderr; + /** @var resource|null */ private $process; private string $status = self::STATUS_READY; private int $incrementalOutputOffset = 0; @@ -345,11 +349,12 @@ public function start(callable $callback = null, array $env = []) throw new RuntimeException(sprintf('The provided cwd "%s" does not exist.', $this->cwd)); } - $this->process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options); + $process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options); - if (!\is_resource($this->process)) { + if (!\is_resource($process)) { throw new RuntimeException('Unable to launch a new process.'); } + $this->process = $process; $this->status = self::STATUS_STARTED; if (isset($descriptors[3])) { @@ -1118,7 +1123,7 @@ public function getInput() * * This content will be passed to the underlying process standard input. * - * @param string|int|float|bool|resource|\Traversable|null $input The content + * @param string|resource|\Traversable|self|null $input The content * * @return $this * diff --git a/src/Symfony/Component/Process/ProcessUtils.php b/src/Symfony/Component/Process/ProcessUtils.php index 744399d98f61..092c5ccf75b0 100644 --- a/src/Symfony/Component/Process/ProcessUtils.php +++ b/src/Symfony/Component/Process/ProcessUtils.php @@ -43,9 +43,6 @@ public static function validateInput(string $caller, mixed $input): mixed if (\is_resource($input)) { return $input; } - if (\is_string($input)) { - return $input; - } if (\is_scalar($input)) { return (string) $input; } diff --git a/src/Symfony/Component/PropertyAccess/Tests/TestPluralAdderRemoverAndSetter.php b/src/Symfony/Component/PropertyAccess/Tests/TestPluralAdderRemoverAndSetter.php index 300e48e0d406..68fa86a629ce 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/TestPluralAdderRemoverAndSetter.php +++ b/src/Symfony/Component/PropertyAccess/Tests/TestPluralAdderRemoverAndSetter.php @@ -13,7 +13,7 @@ class TestPluralAdderRemoverAndSetter { - private $emails = []; + private array $emails = []; public function getEmails() { diff --git a/src/Symfony/Component/PropertyAccess/Tests/TestPluralAdderRemoverAndSetterSameSingularAndPlural.php b/src/Symfony/Component/PropertyAccess/Tests/TestPluralAdderRemoverAndSetterSameSingularAndPlural.php index 656d78528d78..367e929b5e3b 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/TestPluralAdderRemoverAndSetterSameSingularAndPlural.php +++ b/src/Symfony/Component/PropertyAccess/Tests/TestPluralAdderRemoverAndSetterSameSingularAndPlural.php @@ -13,7 +13,7 @@ class TestPluralAdderRemoverAndSetterSameSingularAndPlural { - private $aircraft = []; + private array $aircraft = []; public function getAircraft() { diff --git a/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php index b7cc25f36c24..94c32ba8b342 100644 --- a/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php @@ -306,7 +306,7 @@ public function eraseCredentials(): void class TestLoginLinkHandlerUserProvider implements UserProviderInterface { - private $users = []; + private array $users = []; public function createUser(TestLoginLinkHandlerUser $user): void { diff --git a/src/Symfony/Component/Translation/Tests/TranslatorTest.php b/src/Symfony/Component/Translation/Tests/TranslatorTest.php index e86d1bcb6e29..d6dee409fb6e 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorTest.php @@ -598,11 +598,9 @@ public function testMissingLoaderForResourceError() class StringClass { - protected $str; - - public function __construct($str) - { - $this->str = $str; + public function __construct( + protected string $str, + ) { } public function __toString(): string diff --git a/src/Symfony/Component/Validator/Constraints/Choice.php b/src/Symfony/Component/Validator/Constraints/Choice.php index 5544688d0baf..2980ae760589 100644 --- a/src/Symfony/Component/Validator/Constraints/Choice.php +++ b/src/Symfony/Component/Validator/Constraints/Choice.php @@ -38,6 +38,7 @@ class Choice extends Constraint protected static $errorNames = self::ERROR_NAMES; public $choices; + /** @var callable|string|null */ public $callback; public $multiple = false; public $strict = true; diff --git a/src/Symfony/Component/Validator/Constraints/Email.php b/src/Symfony/Component/Validator/Constraints/Email.php index 46928894f3b8..9d11eb3edafe 100644 --- a/src/Symfony/Component/Validator/Constraints/Email.php +++ b/src/Symfony/Component/Validator/Constraints/Email.php @@ -53,6 +53,7 @@ class Email extends Constraint public $message = 'This value is not a valid email address.'; public $mode; + /** @var callable|null */ public $normalizer; public function __construct( diff --git a/src/Symfony/Component/Validator/Constraints/Ip.php b/src/Symfony/Component/Validator/Constraints/Ip.php index 94c4ca484766..955a898f898f 100644 --- a/src/Symfony/Component/Validator/Constraints/Ip.php +++ b/src/Symfony/Component/Validator/Constraints/Ip.php @@ -84,6 +84,7 @@ class Ip extends Constraint public $message = 'This is not a valid IP address.'; + /** @var callable|null */ public $normalizer; public function __construct( diff --git a/src/Symfony/Component/Validator/Constraints/Length.php b/src/Symfony/Component/Validator/Constraints/Length.php index 7f91cdd8c2fe..820ae66dffbc 100644 --- a/src/Symfony/Component/Validator/Constraints/Length.php +++ b/src/Symfony/Component/Validator/Constraints/Length.php @@ -58,6 +58,7 @@ class Length extends Constraint public $max; public $min; public $charset = 'UTF-8'; + /** @var callable|null */ public $normalizer; /** @var self::COUNT_* */ public string $countUnit = self::COUNT_CODEPOINTS; diff --git a/src/Symfony/Component/Validator/Constraints/NotBlank.php b/src/Symfony/Component/Validator/Constraints/NotBlank.php index 38637ad20260..c16d1c1294da 100644 --- a/src/Symfony/Component/Validator/Constraints/NotBlank.php +++ b/src/Symfony/Component/Validator/Constraints/NotBlank.php @@ -37,6 +37,7 @@ class NotBlank extends Constraint public $message = 'This value should not be blank.'; public $allowNull = false; + /** @var callable|null */ public $normalizer; public function __construct(array $options = null, string $message = null, bool $allowNull = null, callable $normalizer = null, array $groups = null, mixed $payload = null) diff --git a/src/Symfony/Component/Validator/Constraints/Regex.php b/src/Symfony/Component/Validator/Constraints/Regex.php index 67dc8b37c67f..19c934f59653 100644 --- a/src/Symfony/Component/Validator/Constraints/Regex.php +++ b/src/Symfony/Component/Validator/Constraints/Regex.php @@ -38,6 +38,7 @@ class Regex extends Constraint public $pattern; public $htmlPattern; public $match = true; + /** @var callable|null */ public $normalizer; public function __construct( diff --git a/src/Symfony/Component/Validator/Constraints/Unique.php b/src/Symfony/Component/Validator/Constraints/Unique.php index 6db31c0e4123..8fb234b7ee69 100644 --- a/src/Symfony/Component/Validator/Constraints/Unique.php +++ b/src/Symfony/Component/Validator/Constraints/Unique.php @@ -37,6 +37,7 @@ class Unique extends Constraint protected static $errorNames = self::ERROR_NAMES; public $message = 'This collection should contain only unique elements.'; + /** @var callable|null */ public $normalizer; /** diff --git a/src/Symfony/Component/Validator/Constraints/Url.php b/src/Symfony/Component/Validator/Constraints/Url.php index e3bea2e1b3d6..8d0663b7fffb 100644 --- a/src/Symfony/Component/Validator/Constraints/Url.php +++ b/src/Symfony/Component/Validator/Constraints/Url.php @@ -37,6 +37,7 @@ class Url extends Constraint public $message = 'This value is not a valid URL.'; public $protocols = ['http', 'https']; public $relativeProtocol = false; + /** @var callable|null */ public $normalizer; public function __construct( diff --git a/src/Symfony/Component/Validator/Constraints/Uuid.php b/src/Symfony/Component/Validator/Constraints/Uuid.php index a96d2ceb936c..2afbe4105ff1 100644 --- a/src/Symfony/Component/Validator/Constraints/Uuid.php +++ b/src/Symfony/Component/Validator/Constraints/Uuid.php @@ -97,6 +97,7 @@ class Uuid extends Constraint */ public $versions = self::ALL_VERSIONS; + /** @var callable|null */ public $normalizer; /** diff --git a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php index 053a90972bc0..18f43d3160de 100644 --- a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php @@ -26,10 +26,13 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface public const DUMP_COMMA_SEPARATOR = 4; public const DUMP_TRAILING_COMMA = 8; + /** @var callable|resource|string|null */ public static $defaultOutput = 'php://output'; protected $line = ''; + /** @var callable|null */ protected $lineDumper; + /** @var resource|null */ protected $outputStream; protected $decimalPoint = '.'; protected $indentPad = ' '; @@ -55,9 +58,9 @@ public function __construct($output = null, string $charset = null, int $flags = /** * Sets the output destination of the dumps. * - * @param callable|resource|string $output A line dumper callable, an opened stream or an output path + * @param callable|resource|string|null $output A line dumper callable, an opened stream or an output path * - * @return callable|resource|string The previous output destination + * @return callable|resource|string|null The previous output destination */ public function setOutput($output) { diff --git a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php index c155d4c79a7c..cc73f4a42809 100644 --- a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php @@ -22,6 +22,7 @@ class CliDumper extends AbstractDumper { public static $defaultColors; + /** @var callable|resource|string|null */ public static $defaultOutput = 'php://stdout'; protected $colors; @@ -534,7 +535,7 @@ protected function supportsColors(): bool if ($this->outputStream !== static::$defaultOutput) { return $this->hasColorSupport($this->outputStream); } - if (null !== static::$defaultColors) { + if (isset(static::$defaultColors)) { return static::$defaultColors; } if (isset($_SERVER['argv'][1])) { diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index 8a2570b2c4fb..f93b220eff96 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -21,6 +21,7 @@ */ class HtmlDumper extends CliDumper { + /** @var callable|resource|string|null */ public static $defaultOutput = 'php://output'; protected static $themes = [ diff --git a/src/Symfony/Component/VarExporter/Internal/Hydrator.php b/src/Symfony/Component/VarExporter/Internal/Hydrator.php index f665f6ee15c6..b8068fdc21eb 100644 --- a/src/Symfony/Component/VarExporter/Internal/Hydrator.php +++ b/src/Symfony/Component/VarExporter/Internal/Hydrator.php @@ -20,9 +20,9 @@ */ class Hydrator { - public static $hydrators = []; - public static $simpleHydrators = []; - public static $propertyScopes = []; + public static array $hydrators = []; + public static array $simpleHydrators = []; + public static array $propertyScopes = []; public $registry; public $values; diff --git a/src/Symfony/Component/VarExporter/Internal/LazyObjectRegistry.php b/src/Symfony/Component/VarExporter/Internal/LazyObjectRegistry.php index d9d992557fbc..fddc6fb3b966 100644 --- a/src/Symfony/Component/VarExporter/Internal/LazyObjectRegistry.php +++ b/src/Symfony/Component/VarExporter/Internal/LazyObjectRegistry.php @@ -23,27 +23,27 @@ class LazyObjectRegistry /** * @var array */ - public static $classReflectors = []; + public static array $classReflectors = []; /** * @var array> */ - public static $defaultProperties = []; + public static array $defaultProperties = []; /** * @var array> */ - public static $classResetters = []; + public static array $classResetters = []; /** * @var array */ - public static $classAccessors = []; + public static array $classAccessors = []; /** * @var array */ - public static $parentMethods = []; + public static array $parentMethods = []; public static ?\Closure $noInitializerState = null; diff --git a/src/Symfony/Component/VarExporter/Internal/Reference.php b/src/Symfony/Component/VarExporter/Internal/Reference.php index e371c07b8834..2c7bd7b82b0e 100644 --- a/src/Symfony/Component/VarExporter/Internal/Reference.php +++ b/src/Symfony/Component/VarExporter/Internal/Reference.php @@ -18,13 +18,11 @@ */ class Reference { - public $id; - public $value; - public $count = 0; + public int $count = 0; - public function __construct(int $id, $value = null) - { - $this->id = $id; - $this->value = $value; + public function __construct( + public readonly int $id, + public readonly mixed $value = null, + ) { } } diff --git a/src/Symfony/Component/VarExporter/Internal/Registry.php b/src/Symfony/Component/VarExporter/Internal/Registry.php index 09d2de2a05ab..db05bbb85256 100644 --- a/src/Symfony/Component/VarExporter/Internal/Registry.php +++ b/src/Symfony/Component/VarExporter/Internal/Registry.php @@ -21,11 +21,11 @@ */ class Registry { - public static $reflectors = []; - public static $prototypes = []; - public static $factories = []; - public static $cloneable = []; - public static $instantiableWithoutConstructor = []; + public static array $reflectors = []; + public static array $prototypes = []; + public static array $factories = []; + public static array $cloneable = []; + public static array $instantiableWithoutConstructor = []; public $classes = [];