Skip to content

Commit 24f67ea

Browse files
authored
Merge pull request #6187 from kenjis/refactor-CompleteDynamicPropertiesRector
refactor: add CompleteDynamicPropertiesRector
2 parents adf2dc6 + e49c0bd commit 24f67ea

22 files changed

+75
-5
lines changed

rector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
13+
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
1314
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
1415
use Rector\CodeQuality\Rector\For_\ForToForeachRector;
1516
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
@@ -160,4 +161,5 @@
160161
'SQLite3',
161162
]);
162163
$rectorConfig->rule(PrivatizeFinalClassPropertyRector::class);
164+
$rectorConfig->rule(CompleteDynamicPropertiesRector::class);
163165
};

tests/system/CLI/ConsoleTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
final class ConsoleTest extends CIUnitTestCase
2626
{
27+
private DotEnv $env;
2728
private $stream_filter;
2829

2930
protected function setUp(): void

tests/system/CommonFunctionsTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace CodeIgniter;
1313

1414
use CodeIgniter\Config\BaseService;
15+
use CodeIgniter\HTTP\IncomingRequest;
1516
use CodeIgniter\HTTP\RedirectResponse;
1617
use CodeIgniter\HTTP\Response;
1718
use CodeIgniter\HTTP\URI;
@@ -43,6 +44,9 @@
4344
*/
4445
final class CommonFunctionsTest extends CIUnitTestCase
4546
{
47+
private ?App $config = null;
48+
private IncomingRequest $request;
49+
4650
protected function setUp(): void
4751
{
4852
unset($_ENV['foo'], $_SERVER['foo']);

tests/system/Config/DotEnvTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use CodeIgniter\Test\CIUnitTestCase;
1515
use org\bovigo\vfs\vfsStream;
16+
use org\bovigo\vfs\vfsStreamDirectory;
1617

1718
/**
1819
* @backupGlobals enabled
@@ -23,6 +24,8 @@
2324
*/
2425
final class DotEnvTest extends CIUnitTestCase
2526
{
27+
private ?vfsStreamDirectory $root;
28+
private string $path;
2629
private $fixturesFolder;
2730

2831
protected function setUp(): void

tests/system/ControllerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
*/
3434
final class ControllerTest extends CIUnitTestCase
3535
{
36+
private App $config;
37+
3638
/**
3739
* @var Controller
3840
*/

tests/system/Database/Live/MetadataTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace CodeIgniter\Database\Live;
1313

14+
use CodeIgniter\Database\Forge;
1415
use CodeIgniter\Test\CIUnitTestCase;
1516
use CodeIgniter\Test\DatabaseTestTrait;
1617
use Config\Database;
@@ -25,8 +26,9 @@ final class MetadataTest extends CIUnitTestCase
2526
{
2627
use DatabaseTestTrait;
2728

28-
protected $refresh = true;
29-
protected $seed = CITestSeeder::class;
29+
private ?Forge $forge = null;
30+
protected $refresh = true;
31+
protected $seed = CITestSeeder::class;
3032

3133
/**
3234
* Array of expected tables.

tests/system/Events/EventsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class EventsTest extends CIUnitTestCase
2525
/**
2626
* Accessible event manager instance
2727
*/
28-
private MockEvents $manager;
28+
private Events $manager;
2929

3030
protected function setUp(): void
3131
{

tests/system/HTTP/CURLRequestDoNotShareOptionsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
final class CURLRequestDoNotShareOptionsTest extends CIUnitTestCase
2727
{
28-
private MockCURLRequest $request;
28+
private CURLRequest $request;
2929

3030
protected function setUp(): void
3131
{

tests/system/HTTP/CURLRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
final class CURLRequestTest extends CIUnitTestCase
2727
{
28-
private MockCURLRequest $request;
28+
private CURLRequest $request;
2929

3030
protected function setUp(): void
3131
{

tests/system/HTTP/ContentSecurityPolicyTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
*/
2828
final class ContentSecurityPolicyTest extends CIUnitTestCase
2929
{
30+
private ?Response $response = null;
31+
private ?ContentSecurityPolicy $csp = null;
32+
3033
// Having this method as setUp() doesn't work - can't find Config\App !?
3134
protected function prepare(bool $CSPEnabled = true)
3235
{

tests/system/HTTP/Files/FileMovingTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@
1414
use CodeIgniter\HTTP\Exceptions\HTTPException;
1515
use CodeIgniter\Test\CIUnitTestCase;
1616
use org\bovigo\vfs\vfsStream;
17+
use org\bovigo\vfs\vfsStreamDirectory;
1718

1819
/**
1920
* @internal
2021
*/
2122
final class FileMovingTest extends CIUnitTestCase
2223
{
24+
private ?vfsStreamDirectory $root;
25+
private string $path;
26+
private string $start;
27+
private string $destination;
28+
2329
protected function setUp(): void
2430
{
2531
parent::setUp();

tests/system/Helpers/CookieHelperTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
*/
2929
final class CookieHelperTest extends CIUnitTestCase
3030
{
31+
private IncomingRequest $request;
3132
private $name;
3233
private string $value;
3334
private int $expire;

tests/system/Helpers/FilesystemHelperTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
*/
2121
final class FilesystemHelperTest extends CIUnitTestCase
2222
{
23+
/**
24+
* @var array<string, array<string, mixed[]>>|array<string, array<string, string>>|array<string, mixed>|array<string, mixed[]>|array<string, string>|mixed
25+
*/
26+
private array $structure;
27+
2328
protected function setUp(): void
2429
{
2530
parent::setUp();

tests/system/Images/BaseHandlerTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use CodeIgniter\Images\Handlers\BaseHandler;
1818
use CodeIgniter\Test\CIUnitTestCase;
1919
use org\bovigo\vfs\vfsStream;
20+
use org\bovigo\vfs\vfsStreamDirectory;
2021

2122
/**
2223
* Test the common image processing functionality.
@@ -30,6 +31,11 @@
3031
*/
3132
final class BaseHandlerTest extends CIUnitTestCase
3233
{
34+
private vfsStreamDirectory $root;
35+
private string $origin;
36+
private string $start;
37+
private string $path;
38+
3339
protected function setUp(): void
3440
{
3541
if (! extension_loaded('gd')) {

tests/system/Images/GDHandlerTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313

1414
use CodeIgniter\Config\Services;
1515
use CodeIgniter\Images\Exceptions\ImageException;
16+
use CodeIgniter\Images\Handlers\BaseHandler;
1617
use CodeIgniter\Test\CIUnitTestCase;
1718
use org\bovigo\vfs\vfsStream;
19+
use org\bovigo\vfs\vfsStreamDirectory;
1820

1921
/**
2022
* Unit testing for the GD image handler.
@@ -29,6 +31,12 @@
2931
*/
3032
final class GDHandlerTest extends CIUnitTestCase
3133
{
34+
private vfsStreamDirectory $root;
35+
private string $origin;
36+
private string $start;
37+
private string $path;
38+
private BaseHandler $handler;
39+
3240
protected function setUp(): void
3341
{
3442
if (! extension_loaded('gd')) {

tests/system/Images/ImageMagickHandlerTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use CodeIgniter\Config\Services;
1515
use CodeIgniter\Images\Exceptions\ImageException;
16+
use CodeIgniter\Images\Handlers\BaseHandler;
1617
use CodeIgniter\Test\CIUnitTestCase;
1718
use Config\Images;
1819
use Imagick;
@@ -30,6 +31,11 @@
3031
*/
3132
final class ImageMagickHandlerTest extends CIUnitTestCase
3233
{
34+
private string $root;
35+
private string $origin;
36+
private string $path;
37+
private BaseHandler $handler;
38+
3339
protected function setUp(): void
3440
{
3541
if (! extension_loaded('imagick')) {

tests/system/Images/ImageTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@
1414
use CodeIgniter\Images\Exceptions\ImageException;
1515
use CodeIgniter\Test\CIUnitTestCase;
1616
use org\bovigo\vfs\vfsStream;
17+
use org\bovigo\vfs\vfsStreamDirectory;
1718

1819
/**
1920
* @internal
2021
*/
2122
final class ImageTest extends CIUnitTestCase
2223
{
24+
private vfsStreamDirectory $root;
25+
private string $origin;
26+
private string $start;
27+
private Image $image;
28+
2329
protected function setUp(): void
2430
{
2531
// create virtual file system

tests/system/Log/Handlers/FileHandlerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@
1515
use CodeIgniter\Test\Mock\MockFileLogger;
1616
use CodeIgniter\Test\Mock\MockLogger as LoggerConfig;
1717
use org\bovigo\vfs\vfsStream;
18+
use org\bovigo\vfs\vfsStreamDirectory;
1819
use Tests\Support\Log\Handlers\TestHandler;
1920

2021
/**
2122
* @internal
2223
*/
2324
final class FileHandlerTest extends CIUnitTestCase
2425
{
26+
private vfsStreamDirectory $root;
27+
private string $start;
28+
2529
protected function setUp(): void
2630
{
2731
parent::setUp();

tests/system/Pager/PagerRendererTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
final class PagerRendererTest extends CIUnitTestCase
2121
{
22+
private string $expect;
2223
private URI $uri;
2324

2425
protected function setUp(): void

tests/system/Test/TestCaseTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
*/
2323
final class TestCaseTest extends CIUnitTestCase
2424
{
25+
/**
26+
* @var bool|resource
27+
*/
28+
private $stream_filter;
29+
2530
public function testGetPrivatePropertyWithObject()
2631
{
2732
$obj = new __TestForReflectionHelper();

tests/system/Throttle/ThrottleTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace CodeIgniter\Throttle;
1313

14+
use CodeIgniter\Cache\CacheInterface;
1415
use CodeIgniter\Test\CIUnitTestCase;
1516
use CodeIgniter\Test\Mock\MockCache;
1617

@@ -19,6 +20,8 @@
1920
*/
2021
final class ThrottleTest extends CIUnitTestCase
2122
{
23+
private CacheInterface $cache;
24+
2225
protected function setUp(): void
2326
{
2427
parent::setUp();

tests/system/View/TableTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
*/
2222
final class TableTest extends CIUnitTestCase
2323
{
24+
private Table $table;
25+
2426
protected function setUp(): void
2527
{
2628
$this->table = new MockTable();

0 commit comments

Comments
 (0)