From 167111b8fbf47fe5d6b6b46149584e7f8fdb5da1 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Fri, 28 Aug 2026 14:43:01 +0800 Subject: [PATCH] refactor: fix remaining not found methods --- system/Images/Handlers/BaseHandler.php | 2 ++ tests/system/CodeIgniterTest.php | 6 ++-- tests/system/Images/GDHandlerTest.php | 15 +++++++-- tests/system/Models/FindModelTest.php | 2 +- tests/system/Models/GeneralModelTest.php | 3 +- .../system/RESTful/ResourceControllerTest.php | 1 + utils/phpstan-baseline/loader.neon | 1 - utils/phpstan-baseline/method.notFound.neon | 33 ------------------- 8 files changed, 20 insertions(+), 43 deletions(-) delete mode 100644 utils/phpstan-baseline/method.notFound.neon diff --git a/system/Images/Handlers/BaseHandler.php b/system/Images/Handlers/BaseHandler.php index 83535e1f8ad2..334075701465 100644 --- a/system/Images/Handlers/BaseHandler.php +++ b/system/Images/Handlers/BaseHandler.php @@ -23,6 +23,8 @@ * Base image handling implementation. * * @template T of object + * + * @method string getPathname() */ abstract class BaseHandler implements ImageHandlerInterface { diff --git a/tests/system/CodeIgniterTest.php b/tests/system/CodeIgniterTest.php index 0c7c8d2e64d0..bf6321d9d1fd 100644 --- a/tests/system/CodeIgniterTest.php +++ b/tests/system/CodeIgniterTest.php @@ -63,6 +63,7 @@ protected function setUp(): void $this->codeigniter = new MockCodeIgniter(new App()); $response = service('response'); + $this->assertInstanceOf(Response::class, $response); $response->pretend(); } @@ -985,10 +986,7 @@ public function testStartControllerPermitsInvoke(): void $startController = self::getPrivateMethodInvoker($this->codeigniter, 'startController'); $this->setPrivateProperty($this->codeigniter, 'method', '__invoke'); - $startController(); - - // No PageNotFoundException - $this->expectNotToPerformAssertions(); + $this->assertNull($startController()); } public function testRouteAttributeCacheIntegration(): void diff --git a/tests/system/Images/GDHandlerTest.php b/tests/system/Images/GDHandlerTest.php index 8d634d0912cd..a121b17ec899 100644 --- a/tests/system/Images/GDHandlerTest.php +++ b/tests/system/Images/GDHandlerTest.php @@ -346,9 +346,12 @@ public function testImageCopy(): void $this->handler->save($this->start . 'work/ci-logo.' . $type); $this->assertTrue($this->root->hasChild('work/ci-logo.' . $type)); + /** @var vfsStreamFile $child */ + $child = $this->root->getChild('work/ci-logo.' . $type); + $this->assertNotSame( file_get_contents($this->origin . 'ci-logo.' . $type), - $this->root->getChild('work/ci-logo.' . $type)->getContent(), + $child->getContent(), ); } } @@ -380,9 +383,12 @@ public function testImageCompressionGetResource(): void $this->handler->save($this->start . 'work/ci-logo.' . $type); $this->assertTrue($this->root->hasChild('work/ci-logo.' . $type)); + /** @var vfsStreamFile $child */ + $child = $this->root->getChild('work/ci-logo.' . $type); + $this->assertNotSame( file_get_contents($this->origin . 'ci-logo.' . $type), - $this->root->getChild('work/ci-logo.' . $type)->getContent(), + $child->getContent(), ); } } @@ -401,9 +407,12 @@ public function testImageCompressionWithResource(): void $this->assertTrue($this->root->hasChild('work/ci-logo.' . $type)); + /** @var vfsStreamFile $child */ + $child = $this->root->getChild('work/ci-logo.' . $type); + $this->assertNotSame( file_get_contents($this->origin . 'ci-logo.' . $type), - $this->root->getChild('work/ci-logo.' . $type)->getContent(), + $child->getContent(), ); } } diff --git a/tests/system/Models/FindModelTest.php b/tests/system/Models/FindModelTest.php index 41937bb22bf7..0f8481b78eac 100644 --- a/tests/system/Models/FindModelTest.php +++ b/tests/system/Models/FindModelTest.php @@ -133,7 +133,7 @@ public function testFindClearsBinds(): void $binds = $this->model->builder()->getBinds(); $this->assertCount(0, $binds); - $query = $this->model->getLastQuery(); + $query = $this->model->db->getLastQuery(); $this->assertCount(1, $this->getPrivateProperty($query, 'binds')); } diff --git a/tests/system/Models/GeneralModelTest.php b/tests/system/Models/GeneralModelTest.php index 9bc62c2d3501..bd9f2d14109e 100644 --- a/tests/system/Models/GeneralModelTest.php +++ b/tests/system/Models/GeneralModelTest.php @@ -83,7 +83,8 @@ public function testUndefinedModelMethod(): void { $this->expectException(BadMethodCallException::class); $this->expectExceptionMessage('Call to undefined method Tests\Support\Models\UserModel::undefinedMethodCall'); - $this->createModel(UserModel::class)->undefinedMethodCall(); + + $this->createModel(UserModel::class)->undefinedMethodCall(); // @phpstan-ignore method.notFound (Testing Model::__call() fallback) } public function testSetAllowedFields(): void diff --git a/tests/system/RESTful/ResourceControllerTest.php b/tests/system/RESTful/ResourceControllerTest.php index 2fe864736c05..05c3a3e02ffb 100644 --- a/tests/system/RESTful/ResourceControllerTest.php +++ b/tests/system/RESTful/ResourceControllerTest.php @@ -80,6 +80,7 @@ private function createCodeigniter(): void $this->codeigniter = new MockCodeIgniter($config); $response = service('response'); + $this->assertInstanceOf(Response::class, $response); $response->pretend(); } diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 999a75fe8d95..63afcc1d175c 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -8,7 +8,6 @@ includes: - function.resultUnused.neon - method.childParameterType.neon - method.childReturnType.neon - - method.notFound.neon - missingType.iterableValue.neon - property.defaultValue.neon - property.phpDocType.neon diff --git a/utils/phpstan-baseline/method.notFound.neon b/utils/phpstan-baseline/method.notFound.neon deleted file mode 100644 index 72d050dcc45c..000000000000 --- a/utils/phpstan-baseline/method.notFound.neon +++ /dev/null @@ -1,33 +0,0 @@ -# total 8 errors - -parameters: - ignoreErrors: - - - message: '#^Call to an undefined method CodeIgniter\\HTTP\\ResponseInterface\:\:pretend\(\)\.$#' - count: 1 - path: ../../tests/system/CodeIgniterTest.php - - - - message: '#^Call to an undefined method CodeIgniter\\Images\\Handlers\\BaseHandler\:\:getPathname\(\)\.$#' - count: 1 - path: ../../tests/system/Images/BaseHandlerTest.php - - - - message: '#^Call to an undefined method org\\bovigo\\vfs\\vfsStreamContent\:\:getContent\(\)\.$#' - count: 3 - path: ../../tests/system/Images/GDHandlerTest.php - - - - message: '#^Call to an undefined method CodeIgniter\\Model\:\:getLastQuery\(\)\.$#' - count: 1 - path: ../../tests/system/Models/FindModelTest.php - - - - message: '#^Call to an undefined method CodeIgniter\\Model\:\:undefinedMethodCall\(\)\.$#' - count: 1 - path: ../../tests/system/Models/GeneralModelTest.php - - - - message: '#^Call to an undefined method CodeIgniter\\HTTP\\ResponseInterface\:\:pretend\(\)\.$#' - count: 1 - path: ../../tests/system/RESTful/ResourceControllerTest.php