Skip to content

refactor: fix uses of empty() calls - #10439

Open
paulbalandan wants to merge 1 commit into
codeigniter4:developfrom
paulbalandan:phpstan-empty-not-allowed
Open

refactor: fix uses of empty() calls#10439
paulbalandan wants to merge 1 commit into
codeigniter4:developfrom
paulbalandan:phpstan-empty-not-allowed

Conversation

@paulbalandan

Copy link
Copy Markdown
Member

Description
To fix the empty.notAllowed errors

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@paulbalandan paulbalandan added the refactor Pull requests that refactor code label Aug 8, 2026
@paulbalandan
paulbalandan requested a balanced review from Copilot August 8, 2026 05:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Replaces PHP empty() usage with explicit comparisons and removes the corresponding PHPStan baseline.

Changes:

  • Adds type-aware emptiness checks across framework components.
  • Initializes database error strings and strengthens a session assertion.
  • Removes 204 resolved PHPStan baseline errors.

Base branch was not provided; reviewed under develop compatibility rules. No tests were executed; CI validation remains required.

Reviewed changes

Copilot reviewed 65 out of 65 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
utils/phpstan-baseline/loader.neon Removes the resolved baseline include.
utils/phpstan-baseline/empty.notAllowed.neon Deletes 204 suppressions.
tests/system/Session/SessionTest.php Strengthens session regeneration assertions.
system/View/Filters.php Adds explicit default-value detection.
system/Validation/Rules.php Centralizes blank-value checks.
system/Test/FilterTestTrait.php Refines filter result handling.
system/Test/FeatureTestTrait.php Removes a redundant header guard.
system/Session/Handlers/RedisHandler.php Explicitly validates save paths.
system/Router/Router.php Validates the default controller type.
system/Router/RouteCollection.php Refactors route emptiness checks.
system/RESTful/BaseResource.php Refines model presence checks.
system/Pager/Pager.php Explicitly checks final-page state.
system/Images/Image.php Validates target filenames.
system/Images/Handlers/BaseHandler.php Validates source dimensions.
system/HTTP/Response.php Explicitly checks response status.
system/HTTP/RequestTrait.php Refines proxy configuration validation.
system/HTTP/Request.php Validates method and URI initialization.
system/HTTP/MessageTrait.php Refines header population checks.
system/HTTP/IncomingRequest.php Refactors forwarded HTTPS detection.
system/HTTP/CURLRequest.php Refines query, header, and body checks.
system/Honeypot/Honeypot.php Adds explicit content detection.
system/Helpers/url_helper.php Refines popup window-name handling.
system/Helpers/test_helper.php Validates mock metadata explicitly.
system/Helpers/form_helper.php Refines submitted-form detection.
system/Filters/Filters.php Refines before-filter result handling.
system/Files/File.php Explicitly checks file extensions.
system/Encryption/Handlers/SodiumHandler.php Validates key type and length.
system/Encryption/Handlers/OpenSSLHandler.php Validates encryption key strings.
system/Encryption/Encryption.php Refines driver and key validation.
system/Email/Email.php Refactors email value checks.
system/Debug/Toolbar.php Refines timeline child/query detection.
system/Debug/Timer.php Refines timer state checks.
system/Database/SQLSRV/Result.php Refines entity row detection.
system/Database/SQLSRV/Forge.php Refactors schema attribute checks.
system/Database/SQLSRV/Connection.php Refines credentials and connection checks.
system/Database/SQLSRV/Builder.php Refactors SQL Server builder checks.
system/Database/SQLite3/Table.php Refines prefix and foreign-key checks.
system/Database/SQLite3/Forge.php Refactors cache and increment checks.
system/Database/SQLite3/Connection.php Explicitly checks field results.
system/Database/SQLite3/Builder.php Refines upsert constraint checks.
system/Database/Query.php Initializes and checks query state.
system/Database/Postgre/Result.php Refines entity row detection.
system/Database/Postgre/Forge.php Refactors schema attribute checks.
system/Database/Postgre/Connection.php Refines DSN and schema checks.
system/Database/Postgre/Builder.php Refactors PostgreSQL builder checks.
system/Database/OCI8/Forge.php Refactors schema attribute checks.
system/Database/OCI8/Connection.php Refines database metadata checks.
system/Database/OCI8/Builder.php Refines ordering and constraints.
system/Database/MySQLi/Result.php Refines entity row detection.
system/Database/MySQLi/Forge.php Refactors column attribute checks.
system/Database/MySQLi/Connection.php Refines connection and SSL checks.
system/Database/MigrationRunner.php Refines path and query checks.
system/Database/Forge.php Refactors cache and field checks.
system/Database/Database.php Refines DSN and driver validation.
system/Database/BaseUtils.php Refines backup and result checks.
system/Database/BaseResult.php Refines row availability checks.
system/Database/BasePreparedQuery.php Initializes and checks error state.
system/Database/BaseConnection.php Refactors connection and identifier checks.
system/Database/BaseBuilder.php Refactors query-builder state checks.
system/Config/Services.php Refines email configuration selection.
system/Config/DotEnv.php Refines environment-variable checks.
system/Config/BaseService.php Uses explicit service-instance checks.
system/Commands/Database/Seed.php Refines missing seed-name detection.
system/Commands/Database/MigrateStatus.php Explicitly checks migration results.
system/Commands/Database/CreateDatabase.php Refines missing database-name detection.
Suppressed comments (1)

system/Router/RouteCollection.php:1487

  • An empty subdomain list previously imposed no restriction, but this condition treats ['subdomain' => []] as active. checkSubdomains([]) then always returns false, so routes built from an empty dynamic list disappear. Keep empty arrays equivalent to the old empty() check.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread system/Router/RouteCollection.php Outdated
Comment thread system/Database/BaseBuilder.php Outdated
Comment thread system/Database/BaseConnection.php Outdated
Comment thread system/Database/BaseBuilder.php
@paulbalandan
paulbalandan force-pushed the phpstan-empty-not-allowed branch from 993fa11 to 1150f6e Compare August 8, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Pull requests that refactor code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants