Skip to content
Open
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
4 changes: 2 additions & 2 deletions system/HTTP/Files/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function __construct(string $path, string $originalName, ?string $mimeTyp
* @param bool $overwrite State for indicating whether to overwrite the previously generated file with the same
* name or not.
*
* @return bool
* @return static
*/
public function move(string $targetPath, ?string $name = null, bool $overwrite = false)
{
Expand Down Expand Up @@ -172,7 +172,7 @@ public function move(string $targetPath, ?string $name = null, bool $overwrite =
$this->path = $targetPath;
$this->name = basename($destination);

return true;
return $this;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/Files/UploadedFileInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct(string $path, string $originalName, ?string $mimeTyp
* @param string $targetPath Path to which to move the uploaded file.
* @param string|null $name the name to rename the file to.
*
* @return bool
* @return static
*
* @throws InvalidArgumentException if the $path specified is invalid.
* @throws RuntimeException on the second or subsequent call to the method.
Expand Down
2 changes: 0 additions & 2 deletions system/HTTP/IncomingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ class IncomingRequest extends Request
* everything this cares about (and the router, etc) is the portion
* AFTER the baseURL. So, if hosted in a sub-folder this will
* appear different than actual URI path. If you need that use getPath().
*
* @var URI
*/
protected $uri;

Expand Down
6 changes: 3 additions & 3 deletions system/HTTP/OutgoingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class OutgoingRequest extends Message implements OutgoingRequestInterface
/**
* A URI instance.
*
* @var URI|null
* @var URI
*/
protected $uri;

Expand All @@ -40,7 +40,7 @@ class OutgoingRequest extends Message implements OutgoingRequestInterface
*/
public function __construct(
string $method,
?URI $uri = null,
URI $uri,
array $headers = [],
$body = null,
string $version = '1.1',
Expand Down Expand Up @@ -109,7 +109,7 @@ public function withMethod($method)
/**
* Retrieves the URI instance.
*
* @return URI|null
* @return URI
*/
public function getUri()
{
Expand Down
2 changes: 2 additions & 0 deletions user_guide_src/source/changelogs/v4.8.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ update your implementations to include the new methods or method changes to ensu
- **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. See :doc:`../installation/upgrade_480` for the migration.
- **Logging:** ``CodeIgniter\Log\Handlers\HandlerInterface::handle()`` now requires a third parameter ``array $context = []``. Any custom log handler that overrides ``handle()`` - whether implementing ``HandlerInterface`` directly or extending a built-in handler class - must add the parameter to its ``handle()`` method signature.
- **Security:** The ``SecurityInterface``'s ``verify()`` method now has a native return type of ``static``.
- **Validation:** ``CodeIgniter\Validation\ValidationInterface`` now requires the ``getValidatedInput()`` method, which returns a ``CodeIgniter\Input\ValidatedInput`` instance.
Expand All @@ -73,6 +74,7 @@ Method Signature Changes
- **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``. Passing ``null`` only worked when a ``Host`` header was supplied in the same call, since the constructor otherwise dereferences the URI to set that header. Consequently ``OutgoingRequest::getUri()`` now returns ``URI`` instead of ``URI|null``, matching ``OutgoingRequestInterface``. See :doc:`../installation/upgrade_480` for the migration.
- **Model:** ``CodeIgniter\BaseModel`` now requires the ``chunkRows()``, ``chunkById()``, and ``chunkRowsById()`` methods. Custom classes extending ``BaseModel`` directly must implement them.
- **Session:** The ``$max_lifetime`` parameter of the following ``gc()`` methods now has the native ``int`` type, matching ``SessionHandlerInterface``: ``ArrayHandler::gc()``, ``DatabaseHandler::gc()``, ``FileHandler::gc()``, ``MemcachedHandler::gc()``, ``PostgreHandler::gc()``, ``RedisHandler::gc()``.

Expand Down
55 changes: 55 additions & 0 deletions user_guide_src/source/installation/upgrade_480.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,61 @@ Previously, returning a non-integer value from a command run through ``spark`` w
Starting with v4.8.0, this behavior is still supported but will trigger a deprecation notice. Commands should now return an integer exit code
to ensure proper behavior across all platforms.

Uploaded File Move Return Type
==============================

``CodeIgniter\HTTP\Files\UploadedFileInterface::move()`` now returns ``static``
instead of ``bool``, matching ``CodeIgniter\Files\File::move()`` which
``UploadedFile`` extends.

If you have a custom implementation of ``UploadedFileInterface``, or a class
extending ``UploadedFile`` that overrides ``move()``, return the instance
instead of ``true``:

.. code-block:: php

// Before
public function move(string $targetPath, ?string $name = null, bool $overwrite = false)
{
// ...

return true;
}

// After
public function move(string $targetPath, ?string $name = null, bool $overwrite = false)
{
// ...

return $this;
}

Calling code that only tests the result, such as ``if ($file->move($path))``,
needs no change because the returned instance is truthy. Code comparing the
result strictly against ``true`` must be updated.

Outgoing Request Constructor
============================

``CodeIgniter\HTTP\OutgoingRequest::__construct()`` now requires the ``$uri``
parameter, which was previously ``?URI $uri = null``. Consequently
``OutgoingRequest::getUri()`` now returns ``URI`` instead of ``URI|null``.

Passing ``null`` only worked when a ``Host`` header was supplied in the same
call, because the constructor's host check short-circuits before dereferencing
the URI. Such calls must now pass a ``URI``:

.. code-block:: php

// Before
$request = new OutgoingRequest('GET', null, ['Host' => 'example.com']);

// After
$request = new OutgoingRequest('GET', new URI('http://example.com'), ['Host' => 'example.com']);

Any other call that omitted ``$uri`` or passed ``null`` already failed with
``Call to a member function getHost() on null``, so it needs no migration.

*********************
Breaking Enhancements
*********************
Expand Down
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 1492 errors
# total 1489 errors

includes:
- argument.type.neon
Expand All @@ -8,7 +8,6 @@ includes:
- deadCode.unreachable.neon
- function.resultUnused.neon
- method.childParameterType.neon
- method.childReturnType.neon
- method.notFound.neon
- missingType.callable.neon
- missingType.iterableValue.neon
Expand Down
13 changes: 0 additions & 13 deletions utils/phpstan-baseline/method.childReturnType.neon

This file was deleted.

7 changes: 1 addition & 6 deletions utils/phpstan-baseline/property.phpDocType.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 41 errors
# total 40 errors

parameters:
ignoreErrors:
Expand Down Expand Up @@ -147,11 +147,6 @@ parameters:
count: 1
path: ../../system/HTTP/Files/UploadedFile.php

-
message: '#^PHPDoc type CodeIgniter\\HTTP\\URI of property CodeIgniter\\HTTP\\IncomingRequest\:\:\$uri is not the same as PHPDoc type CodeIgniter\\HTTP\\URI\|null of overridden property CodeIgniter\\HTTP\\OutgoingRequest\:\:\$uri\.$#'
count: 1
path: ../../system/HTTP/IncomingRequest.php

-
message: '#^PHPDoc type string of property CodeIgniter\\Session\\Handlers\\FileHandler\:\:\$savePath is not the same as PHPDoc type array\<string, mixed\>\|string of overridden property CodeIgniter\\Session\\Handlers\\BaseHandler\:\:\$savePath\.$#'
count: 1
Expand Down
Loading