refactor: fix the latent LSP violations in HTTP - #10463
Open
paulbalandan wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Aligns HTTP PHPDoc contracts and runtime behavior for CodeIgniter 4.8.
Changes:
- Requires a non-null URI for outgoing requests.
- Changes uploaded-file moves to return the instance.
- Removes resolved PHPStan baseline entries and documents compatibility changes.
Validation: Source review only; focused tests and PHPStan remain for CI.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
utils/phpstan-baseline/property.phpDocType.neon |
Removes resolved URI property error. |
utils/phpstan-baseline/method.childReturnType.neon |
Removes resolved return-type baseline. |
utils/phpstan-baseline/loader.neon |
Drops the obsolete baseline include. |
user_guide_src/source/changelogs/v4.8.0.rst |
Documents HTTP compatibility changes. |
system/HTTP/OutgoingRequest.php |
Makes URI required and non-null. |
system/HTTP/IncomingRequest.php |
Inherits the parent URI documentation. |
system/HTTP/Files/UploadedFileInterface.php |
Changes the documented move return type. |
system/HTTP/Files/UploadedFile.php |
Returns the moved upload instance. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| $this->name = basename($destination); | ||
|
|
||
| return true; | ||
| return $this; |
| - **Cache:** ``CodeIgniter\Cache\CacheInterface::remember()`` now accepts a TTL callable. Custom implementations of ``CacheInterface`` must update the ``$ttl`` parameter type from ``int`` to ``callable|int``. | ||
| - **Database:** ``CodeIgniter\Database\ConnectionInterface`` now requires the ``afterCommit()``, ``afterRollback()``, ``inTransaction()``, and ``transaction()`` methods. | ||
| - **HTTP:** ``CodeIgniter\HTTP\ResponseInterface`` now requires the ``stream()`` and ``eventStream()`` methods, which create streaming and SSE responses. See :ref:`streaming-responses`. | ||
| - **HTTP:** ``CodeIgniter\HTTP\Files\UploadedFileInterface::move()`` now returns ``static`` instead of ``bool``. The previous ``bool`` return was incompatible with ``CodeIgniter\Files\File::move()``, which ``UploadedFile`` extends, so no implementation could satisfy both. |
| - **Config:** ``CodeIgniter\Config\Services::request()`` no longer accepts any parameter. | ||
| - **Database:** The following methods have had their signatures updated to remove deprecated parameters: | ||
| - ``CodeIgniter\Database\Forge::_createTable()`` no longer accepts the deprecated ``$ifNotExists`` parameter. The method signature is now ``_createTable(string $table, array $attributes)``. | ||
| - **HTTP:** ``CodeIgniter\HTTP\OutgoingRequest::__construct()`` now requires the ``$uri`` parameter, which was previously ``?URI $uri = null``. Omitting it never worked, as the constructor dereferences the URI to set the ``Host`` header. Consequently ``OutgoingRequest::getUri()`` now returns ``URI`` instead of ``URI|null``, matching ``OutgoingRequestInterface``. |
| public function __construct( | ||
| string $method, | ||
| ?URI $uri = null, | ||
| URI $uri, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Two changes that could break implementations:
UploadedFileInterface::move()andUploadedFile::move()now returnsstaticto be return-type compatible with the extendedFile::move()also returningstatic. The enforcement was in phpdocs only so phpstan only enforces this.OutgoingRequest::__construct()'s$uriparameter is now required (previously nullable) since (1) all concrete classes passes aURI, (2)OutgoingRequestInterface::getUri()should returnURIand never nullable, and (3) the constructor calls$this->uri->getHost()which doesn't use a null-coalesce so non-null is almost always intended.Checklist: