diff --git a/rector.php b/rector.php index e83bfcc18c63..90c00508dfb6 100644 --- a/rector.php +++ b/rector.php @@ -10,6 +10,7 @@ */ use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector; +use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector; use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector; use Rector\CodeQuality\Rector\For_\ForToForeachRector; use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector; @@ -160,4 +161,5 @@ 'SQLite3', ]); $rectorConfig->rule(PrivatizeFinalClassPropertyRector::class); + $rectorConfig->rule(CompleteDynamicPropertiesRector::class); }; diff --git a/tests/system/CLI/ConsoleTest.php b/tests/system/CLI/ConsoleTest.php index 61905e71c613..1d24e1dd778c 100644 --- a/tests/system/CLI/ConsoleTest.php +++ b/tests/system/CLI/ConsoleTest.php @@ -24,6 +24,7 @@ */ final class ConsoleTest extends CIUnitTestCase { + private DotEnv $env; private $stream_filter; protected function setUp(): void diff --git a/tests/system/CommonFunctionsTest.php b/tests/system/CommonFunctionsTest.php index 4f27a8ab2f2c..c41952fd7554 100644 --- a/tests/system/CommonFunctionsTest.php +++ b/tests/system/CommonFunctionsTest.php @@ -12,6 +12,7 @@ namespace CodeIgniter; use CodeIgniter\Config\BaseService; +use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\Response; use CodeIgniter\HTTP\URI; @@ -43,6 +44,9 @@ */ final class CommonFunctionsTest extends CIUnitTestCase { + private ?App $config = null; + private IncomingRequest $request; + protected function setUp(): void { unset($_ENV['foo'], $_SERVER['foo']); diff --git a/tests/system/Config/DotEnvTest.php b/tests/system/Config/DotEnvTest.php index dbd296040117..aa718bd6dea6 100644 --- a/tests/system/Config/DotEnvTest.php +++ b/tests/system/Config/DotEnvTest.php @@ -13,6 +13,7 @@ use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; +use org\bovigo\vfs\vfsStreamDirectory; /** * @backupGlobals enabled @@ -23,6 +24,8 @@ */ final class DotEnvTest extends CIUnitTestCase { + private ?vfsStreamDirectory $root; + private string $path; private $fixturesFolder; protected function setUp(): void diff --git a/tests/system/ControllerTest.php b/tests/system/ControllerTest.php index 6a16ea7bb17f..cc77c7507b15 100644 --- a/tests/system/ControllerTest.php +++ b/tests/system/ControllerTest.php @@ -33,6 +33,8 @@ */ final class ControllerTest extends CIUnitTestCase { + private App $config; + /** * @var Controller */ diff --git a/tests/system/Database/Live/MetadataTest.php b/tests/system/Database/Live/MetadataTest.php index c72329d7bc71..40a16043c76a 100644 --- a/tests/system/Database/Live/MetadataTest.php +++ b/tests/system/Database/Live/MetadataTest.php @@ -11,6 +11,7 @@ namespace CodeIgniter\Database\Live; +use CodeIgniter\Database\Forge; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; @@ -25,8 +26,9 @@ final class MetadataTest extends CIUnitTestCase { use DatabaseTestTrait; - protected $refresh = true; - protected $seed = CITestSeeder::class; + private ?Forge $forge = null; + protected $refresh = true; + protected $seed = CITestSeeder::class; /** * Array of expected tables. diff --git a/tests/system/Events/EventsTest.php b/tests/system/Events/EventsTest.php index 77b233f9c1d5..9b69a219b929 100644 --- a/tests/system/Events/EventsTest.php +++ b/tests/system/Events/EventsTest.php @@ -25,7 +25,7 @@ final class EventsTest extends CIUnitTestCase /** * Accessible event manager instance */ - private MockEvents $manager; + private Events $manager; protected function setUp(): void { diff --git a/tests/system/HTTP/CURLRequestDoNotShareOptionsTest.php b/tests/system/HTTP/CURLRequestDoNotShareOptionsTest.php index e6e7449d2987..7a79ca3e354c 100644 --- a/tests/system/HTTP/CURLRequestDoNotShareOptionsTest.php +++ b/tests/system/HTTP/CURLRequestDoNotShareOptionsTest.php @@ -25,7 +25,7 @@ */ final class CURLRequestDoNotShareOptionsTest extends CIUnitTestCase { - private MockCURLRequest $request; + private CURLRequest $request; protected function setUp(): void { diff --git a/tests/system/HTTP/CURLRequestTest.php b/tests/system/HTTP/CURLRequestTest.php index 30ba8adcc102..e6d7072c09a0 100644 --- a/tests/system/HTTP/CURLRequestTest.php +++ b/tests/system/HTTP/CURLRequestTest.php @@ -25,7 +25,7 @@ */ final class CURLRequestTest extends CIUnitTestCase { - private MockCURLRequest $request; + private CURLRequest $request; protected function setUp(): void { diff --git a/tests/system/HTTP/ContentSecurityPolicyTest.php b/tests/system/HTTP/ContentSecurityPolicyTest.php index 4b51d9dbc46d..b685e0ac29e7 100644 --- a/tests/system/HTTP/ContentSecurityPolicyTest.php +++ b/tests/system/HTTP/ContentSecurityPolicyTest.php @@ -27,6 +27,9 @@ */ final class ContentSecurityPolicyTest extends CIUnitTestCase { + private ?Response $response = null; + private ?ContentSecurityPolicy $csp = null; + // Having this method as setUp() doesn't work - can't find Config\App !? protected function prepare(bool $CSPEnabled = true) { diff --git a/tests/system/HTTP/Files/FileMovingTest.php b/tests/system/HTTP/Files/FileMovingTest.php index 209e18b2a903..204579dd3da0 100644 --- a/tests/system/HTTP/Files/FileMovingTest.php +++ b/tests/system/HTTP/Files/FileMovingTest.php @@ -14,12 +14,18 @@ use CodeIgniter\HTTP\Exceptions\HTTPException; use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; +use org\bovigo\vfs\vfsStreamDirectory; /** * @internal */ final class FileMovingTest extends CIUnitTestCase { + private ?vfsStreamDirectory $root; + private string $path; + private string $start; + private string $destination; + protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Helpers/CookieHelperTest.php b/tests/system/Helpers/CookieHelperTest.php index 640a43cb3551..852b13361f70 100755 --- a/tests/system/Helpers/CookieHelperTest.php +++ b/tests/system/Helpers/CookieHelperTest.php @@ -28,6 +28,7 @@ */ final class CookieHelperTest extends CIUnitTestCase { + private IncomingRequest $request; private $name; private string $value; private int $expire; diff --git a/tests/system/Helpers/FilesystemHelperTest.php b/tests/system/Helpers/FilesystemHelperTest.php index c9f5789a9d4c..00acb804394d 100644 --- a/tests/system/Helpers/FilesystemHelperTest.php +++ b/tests/system/Helpers/FilesystemHelperTest.php @@ -20,6 +20,11 @@ */ final class FilesystemHelperTest extends CIUnitTestCase { + /** + * @var array>|array>|array|array|array|mixed + */ + private array $structure; + protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Images/BaseHandlerTest.php b/tests/system/Images/BaseHandlerTest.php index 8504779c44eb..a2cce0634e0a 100644 --- a/tests/system/Images/BaseHandlerTest.php +++ b/tests/system/Images/BaseHandlerTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Images\Handlers\BaseHandler; use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; +use org\bovigo\vfs\vfsStreamDirectory; /** * Test the common image processing functionality. @@ -30,6 +31,11 @@ */ final class BaseHandlerTest extends CIUnitTestCase { + private vfsStreamDirectory $root; + private string $origin; + private string $start; + private string $path; + protected function setUp(): void { if (! extension_loaded('gd')) { diff --git a/tests/system/Images/GDHandlerTest.php b/tests/system/Images/GDHandlerTest.php index 797724fe8a26..46db29f87118 100644 --- a/tests/system/Images/GDHandlerTest.php +++ b/tests/system/Images/GDHandlerTest.php @@ -13,8 +13,10 @@ use CodeIgniter\Config\Services; use CodeIgniter\Images\Exceptions\ImageException; +use CodeIgniter\Images\Handlers\BaseHandler; use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; +use org\bovigo\vfs\vfsStreamDirectory; /** * Unit testing for the GD image handler. @@ -29,6 +31,12 @@ */ final class GDHandlerTest extends CIUnitTestCase { + private vfsStreamDirectory $root; + private string $origin; + private string $start; + private string $path; + private BaseHandler $handler; + protected function setUp(): void { if (! extension_loaded('gd')) { diff --git a/tests/system/Images/ImageMagickHandlerTest.php b/tests/system/Images/ImageMagickHandlerTest.php index 012e782f6424..77fa8fee87b1 100644 --- a/tests/system/Images/ImageMagickHandlerTest.php +++ b/tests/system/Images/ImageMagickHandlerTest.php @@ -13,6 +13,7 @@ use CodeIgniter\Config\Services; use CodeIgniter\Images\Exceptions\ImageException; +use CodeIgniter\Images\Handlers\BaseHandler; use CodeIgniter\Test\CIUnitTestCase; use Config\Images; use Imagick; @@ -30,6 +31,11 @@ */ final class ImageMagickHandlerTest extends CIUnitTestCase { + private string $root; + private string $origin; + private string $path; + private BaseHandler $handler; + protected function setUp(): void { if (! extension_loaded('imagick')) { diff --git a/tests/system/Images/ImageTest.php b/tests/system/Images/ImageTest.php index 485da082f750..a85ed30c83fd 100644 --- a/tests/system/Images/ImageTest.php +++ b/tests/system/Images/ImageTest.php @@ -14,12 +14,18 @@ use CodeIgniter\Images\Exceptions\ImageException; use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; +use org\bovigo\vfs\vfsStreamDirectory; /** * @internal */ final class ImageTest extends CIUnitTestCase { + private vfsStreamDirectory $root; + private string $origin; + private string $start; + private Image $image; + protected function setUp(): void { // create virtual file system diff --git a/tests/system/Log/Handlers/FileHandlerTest.php b/tests/system/Log/Handlers/FileHandlerTest.php index 3739ad130197..050511a63465 100644 --- a/tests/system/Log/Handlers/FileHandlerTest.php +++ b/tests/system/Log/Handlers/FileHandlerTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\Mock\MockFileLogger; use CodeIgniter\Test\Mock\MockLogger as LoggerConfig; use org\bovigo\vfs\vfsStream; +use org\bovigo\vfs\vfsStreamDirectory; use Tests\Support\Log\Handlers\TestHandler; /** @@ -22,6 +23,9 @@ */ final class FileHandlerTest extends CIUnitTestCase { + private vfsStreamDirectory $root; + private string $start; + protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Pager/PagerRendererTest.php b/tests/system/Pager/PagerRendererTest.php index 6214c8ee5902..54f8019b4424 100644 --- a/tests/system/Pager/PagerRendererTest.php +++ b/tests/system/Pager/PagerRendererTest.php @@ -19,6 +19,7 @@ */ final class PagerRendererTest extends CIUnitTestCase { + private string $expect; private URI $uri; protected function setUp(): void diff --git a/tests/system/Test/TestCaseTest.php b/tests/system/Test/TestCaseTest.php index 5db2832fa12d..9657c65741d3 100644 --- a/tests/system/Test/TestCaseTest.php +++ b/tests/system/Test/TestCaseTest.php @@ -22,6 +22,11 @@ */ final class TestCaseTest extends CIUnitTestCase { + /** + * @var bool|resource + */ + private $stream_filter; + public function testGetPrivatePropertyWithObject() { $obj = new __TestForReflectionHelper(); diff --git a/tests/system/Throttle/ThrottleTest.php b/tests/system/Throttle/ThrottleTest.php index f38366a30595..a26723925e1f 100644 --- a/tests/system/Throttle/ThrottleTest.php +++ b/tests/system/Throttle/ThrottleTest.php @@ -11,6 +11,7 @@ namespace CodeIgniter\Throttle; +use CodeIgniter\Cache\CacheInterface; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockCache; @@ -19,6 +20,8 @@ */ final class ThrottleTest extends CIUnitTestCase { + private CacheInterface $cache; + protected function setUp(): void { parent::setUp(); diff --git a/tests/system/View/TableTest.php b/tests/system/View/TableTest.php index a96d03bf7657..261c89ca023d 100644 --- a/tests/system/View/TableTest.php +++ b/tests/system/View/TableTest.php @@ -21,6 +21,8 @@ */ final class TableTest extends CIUnitTestCase { + private Table $table; + protected function setUp(): void { $this->table = new MockTable();