8000 Ensure all properties have a type by nicolas-grekas · Pull Request #51129 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
8000

Ensure all properties have a type #51129

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 27, 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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
{
Expand All @@ -42,11 +43,6 @@ public static function setUpBeforeClass(): void
}
}

public static function tearDownAfterClass(): void
{
self::$redis = null;
}

/**
* @runInSeparateProcess
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function testStoredFile()

class PhpArrayAdapterWrapper extends PhpArrayAdapter
{
protected $data = [];
protected array $data = [];

public function save(CacheItemInterface $item): bool
{
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/Console/Cursor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
final class Cursor
{
private OutputInterface $output;
/** @var resource */
private $input;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/Console/Input/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
abstract class Input implements InputInterface, StreamableInputInterface
{
protected $definition;
/** @var resource */
protected $stream;
protected $options = [];
protected $arguments = [];
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/Console/Output/StreamOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*/
class StreamOutput extends Output
{
/** @var resource */
private $stream;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Tests/CursorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

class CursorTest extends TestCase
{
/** @var resource */
protected $stream;

protected function setUp(): void
Expand All @@ -26,8 +27,7 @@ protected function setUp(): void

protected function tearDown(): void
{
fclose($this->stream);
$this->stream = null;
unset($this->stream);
}

public function testMoveUpOneLine()
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Tests/Helper/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

class TableTest extends TestCase
{
/** @var resource */
protected $stream;

protected function setUp(): void
Expand All @@ -34,8 +35,7 @@ protected function setUp(): void

protected function tearDown(): void
{
fclose($this->stream);
$this->stream = null;
unset($this->stream);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

class ConsoleSectionOutputTest extends TestCase
{
/** @var resource */
private $stream;

protected function setUp(): void
Expand All @@ -31,7 +32,7 @@ protected function setUp(): void

protected function tearDown(): void
{
$this->stream = null;
unset($this->stream);
}

public function testClearAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

class StreamOutputTest extends TestCase
{
/** @var resource */
protected $stream;

protected function setUp(): void
Expand All @@ -26,7 +27,7 @@ protected function setUp(): void

protected function tearDown(): void
{
$this->stream = null;
unset($this->stream);
}

public function testConstructor()
Expand Down
18 changes: 8 additions & 10 deletions src/Symfony/Component/Form/Console/Descriptor/Descriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/Symfony/Component/HttpClient/Internal/AmpClientState.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/HttpClient/Internal/AmpListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/HttpClient/Response/AsyncContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/Symfony/Component/HttpClient/Response/NativeResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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;

Expand Down Expand Up @@ -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'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

class ResponseFunctionalTest extends TestCase
{
/** @var resource|false */
private static $server;

public static function setUpBeforeClass(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

class AbstractSessionHandlerTest extends TestCase
{
/** @var resource|false */
private static $server;

public static function setUpBeforeClass(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Mime/Part/AbstractPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
abstract class AbstractPart
{
private $headers;
private Headers $headers;

public function __construct()
{
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/Mime/Part/TextPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class TextPart extends AbstractPart

private static array $encoders = [];

/** @var resource|string|File */
private $body;
private ?string $charset;
private string $subtype;
Expand Down
7 changes: 3 additions & 4 deletions src/Symfony/Component/Process/Pipes/AbstractPipes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading
0