diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 2e6e8b31ec37..7c0fb2d51540 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -16429,12 +16429,6 @@ 'count' => 5, 'path' => __DIR__ . '/tests/system/Pager/PagerTest.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property CodeIgniter\\\\Publisher\\\\PublisherOutputTest\\:\\:\\$structure type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Publisher/PublisherOutputTest.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Publisher\\\\PublisherRestrictionsTest\\:\\:provideDefaultPublicRestrictions\\(\\) return type has no value type specified in iterable type iterable\\.$#', diff --git a/tests/system/CLI/ConsoleTest.php b/tests/system/CLI/ConsoleTest.php index cabe2152b684..c6773a07894f 100644 --- a/tests/system/CLI/ConsoleTest.php +++ b/tests/system/CLI/ConsoleTest.php @@ -30,14 +30,12 @@ final class ConsoleTest extends CIUnitTestCase { use StreamFilterTrait; - private DotEnv $env; - protected function setUp(): void { parent::setUp(); - $this->env = new DotEnv(ROOTPATH); - $this->env->load(); + $env = new DotEnv(ROOTPATH); + $env->load(); // Set environment values that would otherwise stop the framework from functioning during tests. if (! isset($_SERVER['app.baseURL'])) { diff --git a/tests/system/Cache/Handlers/MemcachedHandlerTest.php b/tests/system/Cache/Handlers/MemcachedHandlerTest.php index 4aad8288401c..45a44b64feff 100644 --- a/tests/system/Cache/Handlers/MemcachedHandlerTest.php +++ b/tests/system/Cache/Handlers/MemcachedHandlerTest.php @@ -25,8 +25,6 @@ #[Group('CacheLive')] final class MemcachedHandlerTest extends AbstractHandlerTestCase { - private Cache $config; - private static function getKeyArray() { return [ @@ -44,9 +42,9 @@ protected function setUp(): void $this->markTestSkipped('Memcached extension not loaded.'); } - $this->config = new Cache(); + $config = new Cache(); - $this->handler = new MemcachedHandler($this->config); + $this->handler = new MemcachedHandler($config); $this->handler->initialize(); } diff --git a/tests/system/CodeIgniterTest.php b/tests/system/CodeIgniterTest.php index d87d0d8661ba..2928777271fd 100644 --- a/tests/system/CodeIgniterTest.php +++ b/tests/system/CodeIgniterTest.php @@ -47,7 +47,6 @@ final class CodeIgniterTest extends CIUnitTestCase { private CodeIgniter $codeigniter; - protected $routes; #[WithoutErrorHandler] protected function setUp(): void diff --git a/tests/system/Config/DotEnvTest.php b/tests/system/Config/DotEnvTest.php index b2f8e8e947b7..6fd287be6ad5 100644 --- a/tests/system/Config/DotEnvTest.php +++ b/tests/system/Config/DotEnvTest.php @@ -32,7 +32,6 @@ final class DotEnvTest extends CIUnitTestCase { private ?vfsStreamDirectory $root; - private string $path; private string $fixturesFolder; #[WithoutErrorHandler] @@ -42,8 +41,8 @@ protected function setUp(): void $this->root = vfsStream::setup(); $this->fixturesFolder = $this->root->url(); - $this->path = TESTPATH . 'system/Config/fixtures'; - vfsStream::copyFromFileSystem($this->path, $this->root); + $path = TESTPATH . 'system/Config/fixtures'; + vfsStream::copyFromFileSystem($path, $this->root); $file = 'unreadable.env'; $path = rtrim($this->fixturesFolder, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file; diff --git a/tests/system/ControllerTest.php b/tests/system/ControllerTest.php index add07fc20dd4..ffdcd9589f8a 100644 --- a/tests/system/ControllerTest.php +++ b/tests/system/ControllerTest.php @@ -40,7 +40,6 @@ #[Group('Others')] final class ControllerTest extends CIUnitTestCase { - private App $config; private ?Controller $controller = null; /** @@ -59,9 +58,9 @@ protected function setUp(): void { parent::setUp(); - $this->config = new App(); - $this->request = new IncomingRequest($this->config, new SiteURI($this->config), null, new UserAgent()); - $this->response = new Response($this->config); + $config = new App(); + $this->request = new IncomingRequest($config, new SiteURI($config), null, new UserAgent()); + $this->response = new Response($config); $this->logger = Services::logger(); } diff --git a/tests/system/Files/FileWithVfsTest.php b/tests/system/Files/FileWithVfsTest.php index 9a1075ad9a1c..a6c26383d187 100644 --- a/tests/system/Files/FileWithVfsTest.php +++ b/tests/system/Files/FileWithVfsTest.php @@ -26,7 +26,6 @@ final class FileWithVfsTest extends CIUnitTestCase { // For VFS stuff private ?vfsStreamDirectory $root = null; - private string $path; private string $start; private File $file; @@ -35,8 +34,8 @@ protected function setUp(): void parent::setUp(); $this->root = vfsStream::setup(); - $this->path = '_support/Files/'; - vfsStream::copyFromFileSystem(TESTPATH . $this->path, $this->root); + $path = '_support/Files/'; + vfsStream::copyFromFileSystem(TESTPATH . $path, $this->root); $this->start = $this->root->url() . '/'; $this->file = new File($this->start . 'able/apple.php'); } diff --git a/tests/system/HTTP/Files/FileMovingTest.php b/tests/system/HTTP/Files/FileMovingTest.php index c07116970b5a..9624ecd78a06 100644 --- a/tests/system/HTTP/Files/FileMovingTest.php +++ b/tests/system/HTTP/Files/FileMovingTest.php @@ -26,8 +26,6 @@ final class FileMovingTest extends CIUnitTestCase { private ?vfsStreamDirectory $root; - private string $path; - private string $start; private string $destination; protected function setUp(): void @@ -35,11 +33,11 @@ protected function setUp(): void parent::setUp(); $this->root = vfsStream::setup(); - $this->path = '_support/Files/'; - vfsStream::copyFromFileSystem(TESTPATH . $this->path, $this->root); - $this->start = $this->root->url() . '/'; + $path = '_support/Files/'; + vfsStream::copyFromFileSystem(TESTPATH . $path, $this->root); + $start = $this->root->url() . '/'; - $this->destination = $this->start . 'destination'; + $this->destination = $start . 'destination'; if (is_dir($this->destination)) { rmdir($this->destination); } diff --git a/tests/system/Helpers/CookieHelperTest.php b/tests/system/Helpers/CookieHelperTest.php index 619a21717f86..b672e4da9104 100644 --- a/tests/system/Helpers/CookieHelperTest.php +++ b/tests/system/Helpers/CookieHelperTest.php @@ -33,7 +33,6 @@ #[Group('Others')] final class CookieHelperTest extends CIUnitTestCase { - private IncomingRequest $request; private string $name; private string $value; private int $expire; @@ -51,8 +50,8 @@ protected function setUp(): void Services::injectMock('response', new MockResponse(new App())); $this->response = Services::response(); - $this->request = new IncomingRequest(new App(), new SiteURI(new App()), null, new UserAgent()); - Services::injectMock('request', $this->request); + $request = new IncomingRequest(new App(), new SiteURI(new App()), null, new UserAgent()); + Services::injectMock('request', $request); helper('cookie'); } diff --git a/tests/system/Images/BaseHandlerTest.php b/tests/system/Images/BaseHandlerTest.php index 7332eba9031f..17bc3c00eb70 100644 --- a/tests/system/Images/BaseHandlerTest.php +++ b/tests/system/Images/BaseHandlerTest.php @@ -19,7 +19,6 @@ use CodeIgniter\Images\Handlers\BaseHandler; use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; -use org\bovigo\vfs\vfsStreamDirectory; use PHPUnit\Framework\Attributes\Group; /** @@ -35,7 +34,6 @@ #[Group('Others')] final class BaseHandlerTest extends CIUnitTestCase { - private vfsStreamDirectory $root; private string $origin; private string $start; private string $path; @@ -47,10 +45,10 @@ protected function setUp(): void } // create virtual file system - $this->root = vfsStream::setup(); + $root = vfsStream::setup(); // copy our support files $this->origin = SUPPORTPATH . 'Images/'; - vfsStream::copyFromFileSystem($this->origin, $this->root); + vfsStream::copyFromFileSystem($this->origin, $root); // make subfolders $structure = [ 'work' => [], @@ -58,10 +56,10 @@ protected function setUp(): void ]; vfsStream::create($structure); // with one of them read only - $this->root->getChild('wontwork')->chmod(0400); + $root->getChild('wontwork')->chmod(0400); // for VFS tests - $this->start = $this->root->url() . '/'; + $this->start = $root->url() . '/'; $this->path = $this->start . 'ci-logo.png'; } diff --git a/tests/system/Images/ImageTest.php b/tests/system/Images/ImageTest.php index c4411dd7dedb..622a34ad3cc2 100644 --- a/tests/system/Images/ImageTest.php +++ b/tests/system/Images/ImageTest.php @@ -26,7 +26,6 @@ final class ImageTest extends CIUnitTestCase { private vfsStreamDirectory $root; - private string $origin; private string $start; private Image $image; @@ -35,8 +34,8 @@ protected function setUp(): void // create virtual file system $this->root = vfsStream::setup(); // copy our support files - $this->origin = '_support/Images/'; - vfsStream::copyFromFileSystem(TESTPATH . $this->origin, $this->root); + $origin = '_support/Images/'; + vfsStream::copyFromFileSystem(TESTPATH . $origin, $this->root); // make subfolders $structure = [ 'work' => [], diff --git a/tests/system/Log/Handlers/FileHandlerTest.php b/tests/system/Log/Handlers/FileHandlerTest.php index 7cf11c1f3cf9..6647a42c8b43 100644 --- a/tests/system/Log/Handlers/FileHandlerTest.php +++ b/tests/system/Log/Handlers/FileHandlerTest.php @@ -17,7 +17,6 @@ use CodeIgniter\Test\Mock\MockFileLogger; use CodeIgniter\Test\Mock\MockLogger as LoggerConfig; use org\bovigo\vfs\vfsStream; -use org\bovigo\vfs\vfsStreamDirectory; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Log\Handlers\TestHandler; @@ -27,14 +26,13 @@ #[Group('Others')] final class FileHandlerTest extends CIUnitTestCase { - private vfsStreamDirectory $root; private string $start; protected function setUp(): void { parent::setUp(); - $this->root = vfsStream::setup('root'); - $this->start = $this->root->url() . '/'; + $root = vfsStream::setup('root'); + $this->start = $root->url() . '/'; } public function testHandle(): void diff --git a/tests/system/Publisher/PublisherOutputTest.php b/tests/system/Publisher/PublisherOutputTest.php index e03335e86fe6..0b9b744e01fd 100644 --- a/tests/system/Publisher/PublisherOutputTest.php +++ b/tests/system/Publisher/PublisherOutputTest.php @@ -24,11 +24,6 @@ #[Group('Others')] final class PublisherOutputTest extends CIUnitTestCase { - /** - * Files to seed to VFS - */ - private array $structure; - /** * Virtual destination */ @@ -60,7 +55,10 @@ protected function setUp(): void { parent::setUp(); - $this->structure = [ + /** + * Files to seed to VFS + */ + $structure = [ 'able' => [ 'apple.php' => 'Once upon a midnight dreary', 'bazam' => 'While I pondered weak and weary', @@ -74,7 +72,7 @@ protected function setUp(): void '.hidden' => 'There is no spoon', ]; - $this->root = vfsStream::setup('root', null, $this->structure); + $this->root = vfsStream::setup('root', null, $structure); // Add root to the list of allowed destinations config('Publisher')->restrictions[$this->root->url()] = '*'; diff --git a/tests/system/View/CellTest.php b/tests/system/View/CellTest.php index 27dd6512d174..64796d119c50 100644 --- a/tests/system/View/CellTest.php +++ b/tests/system/View/CellTest.php @@ -25,15 +25,14 @@ #[Group('Others')] final class CellTest extends CIUnitTestCase { - private MockCache $cache; private Cell $cell; protected function setUp(): void { parent::setUp(); - $this->cache = new MockCache(); - $this->cell = new Cell($this->cache); + $cache = new MockCache(); + $this->cell = new Cell($cache); } public function testPrepareParamsReturnsEmptyArrayWithInvalidParam(): void