From 22eba0488a680376608ac4bf15fcc001b833ab13 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 27 Jun 2022 18:24:07 +0900 Subject: [PATCH 1/4] chore: add CompleteDynamicPropertiesRector --- rector.php | 2 ++ 1 file changed, 2 insertions(+) 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); }; From 917597d5749f016744d19deab209ef353be470d0 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 27 Jun 2022 18:24:58 +0900 Subject: [PATCH 2/4] refactor: run rector --- tests/system/CLI/ConsoleTest.php | 5 ++++ tests/system/CommonFunctionsTest.php | 7 +++++ tests/system/Config/DotEnvTest.php | 7 +++++ tests/system/ControllerTest.php | 5 ++++ tests/system/Database/Live/MetadataTest.php | 6 +++++ .../system/HTTP/ContentSecurityPolicyTest.php | 10 +++++++ tests/system/HTTP/Files/FileMovingTest.php | 18 +++++++++++++ tests/system/Helpers/CookieHelperTest.php | 1 + tests/system/Helpers/FilesystemHelperTest.php | 5 ++++ tests/system/Images/BaseHandlerTest.php | 21 +++++++++++++++ tests/system/Images/GDHandlerTest.php | 27 +++++++++++++++++++ .../system/Images/ImageMagickHandlerTest.php | 21 +++++++++++++++ tests/system/Images/ImageTest.php | 18 +++++++++++++ tests/system/Log/Handlers/FileHandlerTest.php | 11 ++++++++ tests/system/Pager/PagerRendererTest.php | 5 ++++ tests/system/Test/TestCaseTest.php | 5 ++++ tests/system/Throttle/ThrottleTest.php | 5 ++++ tests/system/View/TableTest.php | 5 ++++ 18 files changed, 182 insertions(+) diff --git a/tests/system/CLI/ConsoleTest.php b/tests/system/CLI/ConsoleTest.php index 61905e71c613..660806c7c1ee 100644 --- a/tests/system/CLI/ConsoleTest.php +++ b/tests/system/CLI/ConsoleTest.php @@ -24,6 +24,11 @@ */ final class ConsoleTest extends CIUnitTestCase { + /** + * @var DotEnv|mixed + */ + public $env; + private $stream_filter; protected function setUp(): void diff --git a/tests/system/CommonFunctionsTest.php b/tests/system/CommonFunctionsTest.php index 4f27a8ab2f2c..cf01f4c403dc 100644 --- a/tests/system/CommonFunctionsTest.php +++ b/tests/system/CommonFunctionsTest.php @@ -43,6 +43,13 @@ */ final class CommonFunctionsTest extends CIUnitTestCase { + /** + * @var App|mixed + */ + public $config; + + public MockIncomingRequest $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..d5b2f1c69883 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,12 @@ */ final class DotEnvTest extends CIUnitTestCase { + /** + * @var mixed|vfsStreamDirectory|null + */ + public $root; + + public string $path; private $fixturesFolder; protected function setUp(): void diff --git a/tests/system/ControllerTest.php b/tests/system/ControllerTest.php index 6a16ea7bb17f..9a7e613b7808 100644 --- a/tests/system/ControllerTest.php +++ b/tests/system/ControllerTest.php @@ -33,6 +33,11 @@ */ final class ControllerTest extends CIUnitTestCase { + /** + * @var App|mixed + */ + public $config; + /** * @var Controller */ diff --git a/tests/system/Database/Live/MetadataTest.php b/tests/system/Database/Live/MetadataTest.php index c72329d7bc71..0c0a8a35365e 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,6 +26,11 @@ final class MetadataTest extends CIUnitTestCase { use DatabaseTestTrait; + /** + * @var Forge|mixed + */ + public $forge; + protected $refresh = true; protected $seed = CITestSeeder::class; diff --git a/tests/system/HTTP/ContentSecurityPolicyTest.php b/tests/system/HTTP/ContentSecurityPolicyTest.php index 4b51d9dbc46d..20acc61b4edd 100644 --- a/tests/system/HTTP/ContentSecurityPolicyTest.php +++ b/tests/system/HTTP/ContentSecurityPolicyTest.php @@ -27,6 +27,16 @@ */ final class ContentSecurityPolicyTest extends CIUnitTestCase { + /** + * @var mixed|Response + */ + public $response; + + /** + * @var \CodeIgniter\HTTP\ContentSecurityPolicy|mixed + */ + public $csp; + // 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..f48126571842 100644 --- a/tests/system/HTTP/Files/FileMovingTest.php +++ b/tests/system/HTTP/Files/FileMovingTest.php @@ -14,12 +14,30 @@ 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 { + /** + * @var mixed|vfsStreamDirectory|null + */ + public $root; + + public string $path; + + /** + * @var mixed|string + */ + public $start; + + /** + * @var mixed|string + */ + public $destination; + protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Helpers/CookieHelperTest.php b/tests/system/Helpers/CookieHelperTest.php index 640a43cb3551..90a5abc2cf2c 100755 --- a/tests/system/Helpers/CookieHelperTest.php +++ b/tests/system/Helpers/CookieHelperTest.php @@ -28,6 +28,7 @@ */ final class CookieHelperTest extends CIUnitTestCase { + public 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..775c23d9c68f 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 + */ + public $structure; + protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Images/BaseHandlerTest.php b/tests/system/Images/BaseHandlerTest.php index 8504779c44eb..1c89794cba8b 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,26 @@ */ final class BaseHandlerTest extends CIUnitTestCase { + /** + * @var mixed|vfsStreamDirectory + */ + public $root; + + /** + * @var mixed|string + */ + public $origin; + + /** + * @var mixed|string + */ + public $start; + + /** + * @var mixed|string + */ + public $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..bddcb90d0c5b 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,31 @@ */ final class GDHandlerTest extends CIUnitTestCase { + /** + * @var mixed|vfsStreamDirectory + */ + public $root; + + /** + * @var mixed|string + */ + public $origin; + + /** + * @var mixed|string + */ + public $start; + + /** + * @var mixed|string + */ + public $path; + + /** + * @var BaseHandler|mixed + */ + public $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..4e5bae197463 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,26 @@ */ final class ImageMagickHandlerTest extends CIUnitTestCase { + /** + * @var mixed|string + */ + public $root; + + /** + * @var mixed|string + */ + public $origin; + + /** + * @var mixed|string + */ + public $path; + + /** + * @var BaseHandler|mixed + */ + public $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..06c4e4cba7c2 100644 --- a/tests/system/Images/ImageTest.php +++ b/tests/system/Images/ImageTest.php @@ -14,12 +14,30 @@ 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 { + /** + * @var mixed|vfsStreamDirectory + */ + public $root; + + public string $origin; + + /** + * @var mixed|string + */ + public $start; + + /** + * @var Image|mixed + */ + public $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..13fc36a7bf7c 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,16 @@ */ final class FileHandlerTest extends CIUnitTestCase { + /** + * @var mixed|vfsStreamDirectory + */ + public $root; + + /** + * @var mixed|string + */ + public $start; + protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Pager/PagerRendererTest.php b/tests/system/Pager/PagerRendererTest.php index 6214c8ee5902..97a69b756f56 100644 --- a/tests/system/Pager/PagerRendererTest.php +++ b/tests/system/Pager/PagerRendererTest.php @@ -19,6 +19,11 @@ */ final class PagerRendererTest extends CIUnitTestCase { + /** + * @var mixed|string + */ + public $expect; + private URI $uri; protected function setUp(): void diff --git a/tests/system/Test/TestCaseTest.php b/tests/system/Test/TestCaseTest.php index 5db2832fa12d..b431b66687c7 100644 --- a/tests/system/Test/TestCaseTest.php +++ b/tests/system/Test/TestCaseTest.php @@ -22,6 +22,11 @@ */ final class TestCaseTest extends CIUnitTestCase { + /** + * @var bool|mixed|resource + */ + public $stream_filter; + public function testGetPrivatePropertyWithObject() { $obj = new __TestForReflectionHelper(); diff --git a/tests/system/Throttle/ThrottleTest.php b/tests/system/Throttle/ThrottleTest.php index f38366a30595..3a73e234c753 100644 --- a/tests/system/Throttle/ThrottleTest.php +++ b/tests/system/Throttle/ThrottleTest.php @@ -19,6 +19,11 @@ */ final class ThrottleTest extends CIUnitTestCase { + /** + * @var mixed|MockCache + */ + public $cache; + protected function setUp(): void { parent::setUp(); diff --git a/tests/system/View/TableTest.php b/tests/system/View/TableTest.php index a96d03bf7657..fca5845a9be5 100644 --- a/tests/system/View/TableTest.php +++ b/tests/system/View/TableTest.php @@ -21,6 +21,11 @@ */ final class TableTest extends CIUnitTestCase { + /** + * @var mixed|MockTable + */ + public $table; + protected function setUp(): void { $this->table = new MockTable(); From f211714cfd609d733b04720feb0fe8381e62a163 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 28 Jun 2022 07:08:19 +0900 Subject: [PATCH 3/4] test: replace public with private --- tests/system/CLI/ConsoleTest.php | 4 ++-- tests/system/CommonFunctionsTest.php | 4 ++-- tests/system/Config/DotEnvTest.php | 4 ++-- tests/system/ControllerTest.php | 4 ++-- tests/system/Database/Live/MetadataTest.php | 4 ++-- .../system/HTTP/ContentSecurityPolicyTest.php | 8 ++++---- tests/system/HTTP/Files/FileMovingTest.php | 12 +++++------ tests/system/Helpers/FilesystemHelperTest.php | 2 +- tests/system/Images/BaseHandlerTest.php | 16 +++++++-------- tests/system/Images/GDHandlerTest.php | 20 +++++++++---------- .../system/Images/ImageMagickHandlerTest.php | 16 +++++++-------- tests/system/Images/ImageTest.php | 12 +++++------ tests/system/Log/Handlers/FileHandlerTest.php | 8 ++++---- tests/system/Pager/PagerRendererTest.php | 4 ++-- tests/system/Test/TestCaseTest.php | 4 ++-- tests/system/Throttle/ThrottleTest.php | 4 ++-- tests/system/View/TableTest.php | 4 ++-- 17 files changed, 65 insertions(+), 65 deletions(-) diff --git a/tests/system/CLI/ConsoleTest.php b/tests/system/CLI/ConsoleTest.php index 660806c7c1ee..e45afff92b04 100644 --- a/tests/system/CLI/ConsoleTest.php +++ b/tests/system/CLI/ConsoleTest.php @@ -25,9 +25,9 @@ final class ConsoleTest extends CIUnitTestCase { /** - * @var DotEnv|mixed + * @var DotEnv */ - public $env; + private $env; private $stream_filter; diff --git a/tests/system/CommonFunctionsTest.php b/tests/system/CommonFunctionsTest.php index cf01f4c403dc..1fe8f3fec573 100644 --- a/tests/system/CommonFunctionsTest.php +++ b/tests/system/CommonFunctionsTest.php @@ -44,9 +44,9 @@ final class CommonFunctionsTest extends CIUnitTestCase { /** - * @var App|mixed + * @var App */ - public $config; + private $config; public MockIncomingRequest $request; diff --git a/tests/system/Config/DotEnvTest.php b/tests/system/Config/DotEnvTest.php index d5b2f1c69883..efcc4c5b5ef1 100644 --- a/tests/system/Config/DotEnvTest.php +++ b/tests/system/Config/DotEnvTest.php @@ -25,9 +25,9 @@ final class DotEnvTest extends CIUnitTestCase { /** - * @var mixed|vfsStreamDirectory|null + * @var vfsStreamDirectory|null */ - public $root; + private $root; public string $path; private $fixturesFolder; diff --git a/tests/system/ControllerTest.php b/tests/system/ControllerTest.php index 9a7e613b7808..ed98067f62ef 100644 --- a/tests/system/ControllerTest.php +++ b/tests/system/ControllerTest.php @@ -34,9 +34,9 @@ final class ControllerTest extends CIUnitTestCase { /** - * @var App|mixed + * @var App */ - public $config; + private $config; /** * @var Controller diff --git a/tests/system/Database/Live/MetadataTest.php b/tests/system/Database/Live/MetadataTest.php index 0c0a8a35365e..7f8df06ad708 100644 --- a/tests/system/Database/Live/MetadataTest.php +++ b/tests/system/Database/Live/MetadataTest.php @@ -27,9 +27,9 @@ final class MetadataTest extends CIUnitTestCase use DatabaseTestTrait; /** - * @var Forge|mixed + * @var Forge */ - public $forge; + private $forge; protected $refresh = true; protected $seed = CITestSeeder::class; diff --git a/tests/system/HTTP/ContentSecurityPolicyTest.php b/tests/system/HTTP/ContentSecurityPolicyTest.php index 20acc61b4edd..7dd221011542 100644 --- a/tests/system/HTTP/ContentSecurityPolicyTest.php +++ b/tests/system/HTTP/ContentSecurityPolicyTest.php @@ -28,14 +28,14 @@ final class ContentSecurityPolicyTest extends CIUnitTestCase { /** - * @var mixed|Response + * @var Response */ - public $response; + private $response; /** - * @var \CodeIgniter\HTTP\ContentSecurityPolicy|mixed + * @var \CodeIgniter\HTTP\ContentSecurityPolicy */ - public $csp; + private $csp; // 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 f48126571842..ef42ca3b314c 100644 --- a/tests/system/HTTP/Files/FileMovingTest.php +++ b/tests/system/HTTP/Files/FileMovingTest.php @@ -22,21 +22,21 @@ final class FileMovingTest extends CIUnitTestCase { /** - * @var mixed|vfsStreamDirectory|null + * @var vfsStreamDirectory|null */ - public $root; + private $root; public string $path; /** - * @var mixed|string + * @var string */ - public $start; + private $start; /** - * @var mixed|string + * @var string */ - public $destination; + private $destination; protected function setUp(): void { diff --git a/tests/system/Helpers/FilesystemHelperTest.php b/tests/system/Helpers/FilesystemHelperTest.php index 775c23d9c68f..7744bf82cf17 100644 --- a/tests/system/Helpers/FilesystemHelperTest.php +++ b/tests/system/Helpers/FilesystemHelperTest.php @@ -23,7 +23,7 @@ final class FilesystemHelperTest extends CIUnitTestCase /** * @var array>|array>|array|array|array|mixed */ - public $structure; + private $structure; protected function setUp(): void { diff --git a/tests/system/Images/BaseHandlerTest.php b/tests/system/Images/BaseHandlerTest.php index 1c89794cba8b..504459c48fe2 100644 --- a/tests/system/Images/BaseHandlerTest.php +++ b/tests/system/Images/BaseHandlerTest.php @@ -32,24 +32,24 @@ final class BaseHandlerTest extends CIUnitTestCase { /** - * @var mixed|vfsStreamDirectory + * @var vfsStreamDirectory */ - public $root; + private $root; /** - * @var mixed|string + * @var string */ - public $origin; + private $origin; /** - * @var mixed|string + * @var string */ - public $start; + private $start; /** - * @var mixed|string + * @var string */ - public $path; + private $path; protected function setUp(): void { diff --git a/tests/system/Images/GDHandlerTest.php b/tests/system/Images/GDHandlerTest.php index bddcb90d0c5b..b060c2b4be25 100644 --- a/tests/system/Images/GDHandlerTest.php +++ b/tests/system/Images/GDHandlerTest.php @@ -32,29 +32,29 @@ final class GDHandlerTest extends CIUnitTestCase { /** - * @var mixed|vfsStreamDirectory + * @var vfsStreamDirectory */ - public $root; + private $root; /** - * @var mixed|string + * @var string */ - public $origin; + private $origin; /** - * @var mixed|string + * @var string */ - public $start; + private $start; /** - * @var mixed|string + * @var string */ - public $path; + private $path; /** - * @var BaseHandler|mixed + * @var BaseHandler */ - public $handler; + private $handler; protected function setUp(): void { diff --git a/tests/system/Images/ImageMagickHandlerTest.php b/tests/system/Images/ImageMagickHandlerTest.php index 4e5bae197463..2efa53500817 100644 --- a/tests/system/Images/ImageMagickHandlerTest.php +++ b/tests/system/Images/ImageMagickHandlerTest.php @@ -32,24 +32,24 @@ final class ImageMagickHandlerTest extends CIUnitTestCase { /** - * @var mixed|string + * @var string */ - public $root; + private $root; /** - * @var mixed|string + * @var string */ - public $origin; + private $origin; /** - * @var mixed|string + * @var string */ - public $path; + private $path; /** - * @var BaseHandler|mixed + * @var BaseHandler */ - public $handler; + private $handler; protected function setUp(): void { diff --git a/tests/system/Images/ImageTest.php b/tests/system/Images/ImageTest.php index 06c4e4cba7c2..d751476548d2 100644 --- a/tests/system/Images/ImageTest.php +++ b/tests/system/Images/ImageTest.php @@ -22,21 +22,21 @@ final class ImageTest extends CIUnitTestCase { /** - * @var mixed|vfsStreamDirectory + * @var vfsStreamDirectory */ - public $root; + private $root; public string $origin; /** - * @var mixed|string + * @var string */ - public $start; + private $start; /** - * @var Image|mixed + * @var Image */ - public $image; + private $image; protected function setUp(): void { diff --git a/tests/system/Log/Handlers/FileHandlerTest.php b/tests/system/Log/Handlers/FileHandlerTest.php index 13fc36a7bf7c..f80412e5bea6 100644 --- a/tests/system/Log/Handlers/FileHandlerTest.php +++ b/tests/system/Log/Handlers/FileHandlerTest.php @@ -24,14 +24,14 @@ final class FileHandlerTest extends CIUnitTestCase { /** - * @var mixed|vfsStreamDirectory + * @var vfsStreamDirectory */ - public $root; + private $root; /** - * @var mixed|string + * @var string */ - public $start; + private $start; protected function setUp(): void { diff --git a/tests/system/Pager/PagerRendererTest.php b/tests/system/Pager/PagerRendererTest.php index 97a69b756f56..94951c02e29b 100644 --- a/tests/system/Pager/PagerRendererTest.php +++ b/tests/system/Pager/PagerRendererTest.php @@ -20,9 +20,9 @@ final class PagerRendererTest extends CIUnitTestCase { /** - * @var mixed|string + * @var string */ - public $expect; + private $expect; private URI $uri; diff --git a/tests/system/Test/TestCaseTest.php b/tests/system/Test/TestCaseTest.php index b431b66687c7..9657c65741d3 100644 --- a/tests/system/Test/TestCaseTest.php +++ b/tests/system/Test/TestCaseTest.php @@ -23,9 +23,9 @@ final class TestCaseTest extends CIUnitTestCase { /** - * @var bool|mixed|resource + * @var bool|resource */ - public $stream_filter; + private $stream_filter; public function testGetPrivatePropertyWithObject() { diff --git a/tests/system/Throttle/ThrottleTest.php b/tests/system/Throttle/ThrottleTest.php index 3a73e234c753..bb83e11b3cf9 100644 --- a/tests/system/Throttle/ThrottleTest.php +++ b/tests/system/Throttle/ThrottleTest.php @@ -20,9 +20,9 @@ final class ThrottleTest extends CIUnitTestCase { /** - * @var mixed|MockCache + * @var Cache */ - public $cache; + private $cache; protected function setUp(): void { diff --git a/tests/system/View/TableTest.php b/tests/system/View/TableTest.php index fca5845a9be5..cccaa4ced597 100644 --- a/tests/system/View/TableTest.php +++ b/tests/system/View/TableTest.php @@ -22,9 +22,9 @@ final class TableTest extends CIUnitTestCase { /** - * @var mixed|MockTable + * @var Table */ - public $table; + private $table; protected function setUp(): void { From e49c0bd41fbf7aee35c9aaa28b3c1dfaf69bd2ce Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 28 Jun 2022 07:10:48 +0900 Subject: [PATCH 4/4] refactor: run rector and fix types --- tests/system/CLI/ConsoleTest.php | 6 +--- tests/system/CommonFunctionsTest.php | 9 ++---- tests/system/Config/DotEnvTest.php | 8 ++--- tests/system/ControllerTest.php | 5 +--- tests/system/Database/Live/MetadataTest.php | 10 ++----- tests/system/Events/EventsTest.php | 2 +- .../HTTP/CURLRequestDoNotShareOptionsTest.php | 2 +- tests/system/HTTP/CURLRequestTest.php | 2 +- .../system/HTTP/ContentSecurityPolicyTest.php | 11 ++----- tests/system/HTTP/Files/FileMovingTest.php | 20 +++---------- tests/system/Helpers/CookieHelperTest.php | 2 +- tests/system/Helpers/FilesystemHelperTest.php | 2 +- tests/system/Images/BaseHandlerTest.php | 23 +++------------ tests/system/Images/GDHandlerTest.php | 29 ++++--------------- .../system/Images/ImageMagickHandlerTest.php | 23 +++------------ tests/system/Images/ImageTest.php | 20 +++---------- tests/system/Log/Handlers/FileHandlerTest.php | 11 ++----- tests/system/Pager/PagerRendererTest.php | 6 +--- tests/system/Throttle/ThrottleTest.php | 6 ++-- tests/system/View/TableTest.php | 5 +--- 20 files changed, 44 insertions(+), 158 deletions(-) diff --git a/tests/system/CLI/ConsoleTest.php b/tests/system/CLI/ConsoleTest.php index e45afff92b04..1d24e1dd778c 100644 --- a/tests/system/CLI/ConsoleTest.php +++ b/tests/system/CLI/ConsoleTest.php @@ -24,11 +24,7 @@ */ final class ConsoleTest extends CIUnitTestCase { - /** - * @var DotEnv - */ - private $env; - + private DotEnv $env; private $stream_filter; protected function setUp(): void diff --git a/tests/system/CommonFunctionsTest.php b/tests/system/CommonFunctionsTest.php index 1fe8f3fec573..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,12 +44,8 @@ */ final class CommonFunctionsTest extends CIUnitTestCase { - /** - * @var App - */ - private $config; - - public MockIncomingRequest $request; + private ?App $config = null; + private IncomingRequest $request; protected function setUp(): void { diff --git a/tests/system/Config/DotEnvTest.php b/tests/system/Config/DotEnvTest.php index efcc4c5b5ef1..aa718bd6dea6 100644 --- a/tests/system/Config/DotEnvTest.php +++ b/tests/system/Config/DotEnvTest.php @@ -24,12 +24,8 @@ */ final class DotEnvTest extends CIUnitTestCase { - /** - * @var vfsStreamDirectory|null - */ - private $root; - - public string $path; + 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 ed98067f62ef..cc77c7507b15 100644 --- a/tests/system/ControllerTest.php +++ b/tests/system/ControllerTest.php @@ -33,10 +33,7 @@ */ final class ControllerTest extends CIUnitTestCase { - /** - * @var App - */ - private $config; + private App $config; /** * @var Controller diff --git a/tests/system/Database/Live/MetadataTest.php b/tests/system/Database/Live/MetadataTest.php index 7f8df06ad708..40a16043c76a 100644 --- a/tests/system/Database/Live/MetadataTest.php +++ b/tests/system/Database/Live/MetadataTest.php @@ -26,13 +26,9 @@ final class MetadataTest extends CIUnitTestCase { use DatabaseTestTrait; - /** - * @var Forge - */ - private $forge; - - 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 7dd221011542..b685e0ac29e7 100644 --- a/tests/system/HTTP/ContentSecurityPolicyTest.php +++ b/tests/system/HTTP/ContentSecurityPolicyTest.php @@ -27,15 +27,8 @@ */ final class ContentSecurityPolicyTest extends CIUnitTestCase { - /** - * @var Response - */ - private $response; - - /** - * @var \CodeIgniter\HTTP\ContentSecurityPolicy - */ - private $csp; + 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 ef42ca3b314c..204579dd3da0 100644 --- a/tests/system/HTTP/Files/FileMovingTest.php +++ b/tests/system/HTTP/Files/FileMovingTest.php @@ -21,22 +21,10 @@ */ final class FileMovingTest extends CIUnitTestCase { - /** - * @var vfsStreamDirectory|null - */ - private $root; - - public string $path; - - /** - * @var string - */ - private $start; - - /** - * @var string - */ - private $destination; + private ?vfsStreamDirectory $root; + private string $path; + private string $start; + private string $destination; protected function setUp(): void { diff --git a/tests/system/Helpers/CookieHelperTest.php b/tests/system/Helpers/CookieHelperTest.php index 90a5abc2cf2c..852b13361f70 100755 --- a/tests/system/Helpers/CookieHelperTest.php +++ b/tests/system/Helpers/CookieHelperTest.php @@ -28,7 +28,7 @@ */ final class CookieHelperTest extends CIUnitTestCase { - public IncomingRequest $request; + 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 7744bf82cf17..00acb804394d 100644 --- a/tests/system/Helpers/FilesystemHelperTest.php +++ b/tests/system/Helpers/FilesystemHelperTest.php @@ -23,7 +23,7 @@ final class FilesystemHelperTest extends CIUnitTestCase /** * @var array>|array>|array|array|array|mixed */ - private $structure; + private array $structure; protected function setUp(): void { diff --git a/tests/system/Images/BaseHandlerTest.php b/tests/system/Images/BaseHandlerTest.php index 504459c48fe2..a2cce0634e0a 100644 --- a/tests/system/Images/BaseHandlerTest.php +++ b/tests/system/Images/BaseHandlerTest.php @@ -31,25 +31,10 @@ */ final class BaseHandlerTest extends CIUnitTestCase { - /** - * @var vfsStreamDirectory - */ - private $root; - - /** - * @var string - */ - private $origin; - - /** - * @var string - */ - private $start; - - /** - * @var string - */ - private $path; + private vfsStreamDirectory $root; + private string $origin; + private string $start; + private string $path; protected function setUp(): void { diff --git a/tests/system/Images/GDHandlerTest.php b/tests/system/Images/GDHandlerTest.php index b060c2b4be25..46db29f87118 100644 --- a/tests/system/Images/GDHandlerTest.php +++ b/tests/system/Images/GDHandlerTest.php @@ -31,30 +31,11 @@ */ final class GDHandlerTest extends CIUnitTestCase { - /** - * @var vfsStreamDirectory - */ - private $root; - - /** - * @var string - */ - private $origin; - - /** - * @var string - */ - private $start; - - /** - * @var string - */ - private $path; - - /** - * @var BaseHandler - */ - private $handler; + private vfsStreamDirectory $root; + private string $origin; + private string $start; + private string $path; + private BaseHandler $handler; protected function setUp(): void { diff --git a/tests/system/Images/ImageMagickHandlerTest.php b/tests/system/Images/ImageMagickHandlerTest.php index 2efa53500817..77fa8fee87b1 100644 --- a/tests/system/Images/ImageMagickHandlerTest.php +++ b/tests/system/Images/ImageMagickHandlerTest.php @@ -31,25 +31,10 @@ */ final class ImageMagickHandlerTest extends CIUnitTestCase { - /** - * @var string - */ - private $root; - - /** - * @var string - */ - private $origin; - - /** - * @var string - */ - private $path; - - /** - * @var BaseHandler - */ - private $handler; + private string $root; + private string $origin; + private string $path; + private BaseHandler $handler; protected function setUp(): void { diff --git a/tests/system/Images/ImageTest.php b/tests/system/Images/ImageTest.php index d751476548d2..a85ed30c83fd 100644 --- a/tests/system/Images/ImageTest.php +++ b/tests/system/Images/ImageTest.php @@ -21,22 +21,10 @@ */ final class ImageTest extends CIUnitTestCase { - /** - * @var vfsStreamDirectory - */ - private $root; - - public string $origin; - - /** - * @var string - */ - private $start; - - /** - * @var Image - */ - private $image; + private vfsStreamDirectory $root; + private string $origin; + private string $start; + private Image $image; protected function setUp(): void { diff --git a/tests/system/Log/Handlers/FileHandlerTest.php b/tests/system/Log/Handlers/FileHandlerTest.php index f80412e5bea6..050511a63465 100644 --- a/tests/system/Log/Handlers/FileHandlerTest.php +++ b/tests/system/Log/Handlers/FileHandlerTest.php @@ -23,15 +23,8 @@ */ final class FileHandlerTest extends CIUnitTestCase { - /** - * @var vfsStreamDirectory - */ - private $root; - - /** - * @var string - */ - private $start; + private vfsStreamDirectory $root; + private string $start; protected function setUp(): void { diff --git a/tests/system/Pager/PagerRendererTest.php b/tests/system/Pager/PagerRendererTest.php index 94951c02e29b..54f8019b4424 100644 --- a/tests/system/Pager/PagerRendererTest.php +++ b/tests/system/Pager/PagerRendererTest.php @@ -19,11 +19,7 @@ */ final class PagerRendererTest extends CIUnitTestCase { - /** - * @var string - */ - private $expect; - + private string $expect; private URI $uri; protected function setUp(): void diff --git a/tests/system/Throttle/ThrottleTest.php b/tests/system/Throttle/ThrottleTest.php index bb83e11b3cf9..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,10 +20,7 @@ */ final class ThrottleTest extends CIUnitTestCase { - /** - * @var Cache - */ - private $cache; + private CacheInterface $cache; protected function setUp(): void { diff --git a/tests/system/View/TableTest.php b/tests/system/View/TableTest.php index cccaa4ced597..261c89ca023d 100644 --- a/tests/system/View/TableTest.php +++ b/tests/system/View/TableTest.php @@ -21,10 +21,7 @@ */ final class TableTest extends CIUnitTestCase { - /** - * @var Table - */ - private $table; + private Table $table; protected function setUp(): void {