Skip to content

refactor: fix empty.property errors #9519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3407,7 +3407,7 @@ protected function resetSelect()
'QBUnion' => [],
]);

if (! empty($this->db)) {
if ($this->db instanceof BaseConnection) {
$this->db->setAliasedTables([]);
}

Expand Down
8 changes: 5 additions & 3 deletions system/Images/Handlers/BaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class BaseHandler implements ImageHandlerInterface
/**
* The image/file instance
*
* @var Image
* @var Image|null
*/
protected $image;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
*/
Expand All @@ -187,7 +189,7 @@ protected function image(): Image
}

// Verify withFile has been called
if (empty($this->image)) {
if ($this->image === null) {
throw ImageException::forMissingImage();
}

Expand Down
8 changes: 4 additions & 4 deletions system/Test/ControllerTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
Expand All @@ -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');
}
}
Expand Down
11 changes: 3 additions & 8 deletions utils/phpstan-baseline/empty.notAllowed.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 271 errors
# total 265 errors

parameters:
ignoreErrors:
Expand Down Expand Up @@ -39,7 +39,7 @@ parameters:

-
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
count: 29
count: 28
path: ../../system/Database/BaseBuilder.php

-
Expand Down Expand Up @@ -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

-
Expand Down Expand Up @@ -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
Expand Down
33 changes: 0 additions & 33 deletions utils/phpstan-baseline/empty.property.neon

This file was deleted.

3 changes: 1 addition & 2 deletions utils/phpstan-baseline/loader.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 3587 errors
# total 3575 errors
includes:
- argument.type.neon
- assign.propertyType.neon
Expand All @@ -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
Expand Down
Loading