diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index e10dd557fda0..6aee36f14261 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -3407,7 +3407,7 @@ protected function resetSelect() 'QBUnion' => [], ]); - if (! empty($this->db)) { + if ($this->db instanceof BaseConnection) { $this->db->setAliasedTables([]); } diff --git a/system/Images/Handlers/BaseHandler.php b/system/Images/Handlers/BaseHandler.php index 9c263afb89d1..de3e15974a1b 100644 --- a/system/Images/Handlers/BaseHandler.php +++ b/system/Images/Handlers/BaseHandler.php @@ -34,7 +34,7 @@ abstract class BaseHandler implements ImageHandlerInterface /** * The image/file instance * - * @var Image + * @var Image|null */ protected $image; @@ -138,6 +138,8 @@ public function __construct($config = null) * Sets another image for this handler to work on. * Keeps us from needing to continually instantiate the handler. * + * @phpstan-assert Image $this->image + * * @return $this */ public function withFile(string $path) @@ -176,7 +178,7 @@ public function getFile() /** * Verifies that a file has been supplied and it is an image. * - * @return Image The image instance + * @phpstan-assert Image $this->image * * @throws ImageException */ @@ -187,7 +189,7 @@ protected function image(): Image } // Verify withFile has been called - if (empty($this->image)) { + if ($this->image === null) { throw ImageException::forMissingImage(); } diff --git a/system/Test/ControllerTestTrait.php b/system/Test/ControllerTestTrait.php index 2ac68938e251..2a7be526383d 100644 --- a/system/Test/ControllerTestTrait.php +++ b/system/Test/ControllerTestTrait.php @@ -95,7 +95,7 @@ protected function setUpControllerTestTrait(): void // The URL helper is always loaded by the system so ensure it is available. helper('url'); - if (empty($this->appConfig)) { + if (! $this->appConfig instanceof App) { $this->appConfig = config(App::class); } @@ -104,7 +104,7 @@ protected function setUpControllerTestTrait(): void $this->uri = $factory->createFromGlobals(); } - if (empty($this->request)) { + if (! $this->request instanceof IncomingRequest) { // Do some acrobatics, so we can use the Request service with our own URI $tempUri = service('uri'); Services::injectMock('uri', $this->uri); @@ -115,11 +115,11 @@ protected function setUpControllerTestTrait(): void Services::injectMock('uri', $tempUri); } - if (empty($this->response)) { + if (! $this->response instanceof ResponseInterface) { $this->response = service('response', $this->appConfig, false); } - if (empty($this->logger)) { + if (! $this->logger instanceof LoggerInterface) { $this->logger = service('logger'); } } diff --git a/utils/phpstan-baseline/empty.notAllowed.neon b/utils/phpstan-baseline/empty.notAllowed.neon index ad029ff92d04..c0e03d572785 100644 --- a/utils/phpstan-baseline/empty.notAllowed.neon +++ b/utils/phpstan-baseline/empty.notAllowed.neon @@ -1,4 +1,4 @@ -# total 271 errors +# total 265 errors parameters: ignoreErrors: @@ -39,7 +39,7 @@ parameters: - message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#' - count: 29 + count: 28 path: ../../system/Database/BaseBuilder.php - @@ -289,7 +289,7 @@ parameters: - message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#' - count: 3 + count: 2 path: ../../system/Images/Handlers/BaseHandler.php - @@ -367,11 +367,6 @@ parameters: count: 1 path: ../../tests/system/Session/SessionTest.php - - - message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#' - count: 4 - path: ../../tests/system/Test/ControllerTestTraitTest.php - - message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#' count: 1 diff --git a/utils/phpstan-baseline/empty.property.neon b/utils/phpstan-baseline/empty.property.neon deleted file mode 100644 index cbc2397dc84e..000000000000 --- a/utils/phpstan-baseline/empty.property.neon +++ /dev/null @@ -1,33 +0,0 @@ -# total 6 errors - -parameters: - ignoreErrors: - - - message: '#^Property CodeIgniter\\Database\\BaseBuilder\:\:\$db \(CodeIgniter\\Database\\BaseConnection\) in empty\(\) is not falsy\.$#' - count: 1 - path: ../../system/Database/BaseBuilder.php - - - - message: '#^Property CodeIgniter\\Images\\Handlers\\BaseHandler\:\:\$image \(CodeIgniter\\Images\\Image\) in empty\(\) is not falsy\.$#' - count: 1 - path: ../../system/Images/Handlers/BaseHandler.php - - - - message: '#^Property CodeIgniter\\Test\\ControllerTestTraitTest\:\:\$appConfig \(Config\\App\) in empty\(\) is not falsy\.$#' - count: 1 - path: ../../tests/system/Test/ControllerTestTraitTest.php - - - - message: '#^Property CodeIgniter\\Test\\ControllerTestTraitTest\:\:\$logger \(Psr\\Log\\LoggerInterface\) in empty\(\) is not falsy\.$#' - count: 1 - path: ../../tests/system/Test/ControllerTestTraitTest.php - - - - message: '#^Property CodeIgniter\\Test\\ControllerTestTraitTest\:\:\$request \(CodeIgniter\\HTTP\\IncomingRequest\) in empty\(\) is not falsy\.$#' - count: 1 - path: ../../tests/system/Test/ControllerTestTraitTest.php - - - - message: '#^Property CodeIgniter\\Test\\ControllerTestTraitTest\:\:\$response \(CodeIgniter\\HTTP\\ResponseInterface\) in empty\(\) is not falsy\.$#' - count: 1 - path: ../../tests/system/Test/ControllerTestTraitTest.php diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 575c7843ba98..89d0f88ce766 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 3587 errors +# total 3575 errors includes: - argument.type.neon - assign.propertyType.neon @@ -10,7 +10,6 @@ includes: - codeigniter.unknownServiceMethod.neon - deadCode.unreachable.neon - empty.notAllowed.neon - - empty.property.neon - generator.valueType.neon - isset.property.neon - method.alreadyNarrowedType.neon