From 143b496dff4dfaec8acb7ef0d04a98beb3b6b687 Mon Sep 17 00:00:00 2001 From: michalsn Date: Sat, 13 Jun 2026 19:23:22 +0200 Subject: [PATCH] refactor: move ValidatedInput to the Input namespace --- structarmed.php | 6 +----- system/HTTP/FormRequest.php | 2 +- system/Input/InputDataFactory.php | 2 -- system/{Validation => Input}/ValidatedInput.php | 5 ++--- system/Validation/Validation.php | 1 + system/Validation/ValidationInterface.php | 1 + tests/system/HTTP/FormRequestTest.php | 2 +- tests/system/Input/InputDataFactoryTest.php | 1 - tests/system/{Validation => Input}/ValidatedInputTest.php | 3 +-- tests/system/Validation/ValidationTest.php | 1 + user_guide_src/source/changelogs/v4.8.0.rst | 4 ++-- user_guide_src/source/libraries/validation.rst | 2 +- 12 files changed, 12 insertions(+), 18 deletions(-) rename system/{Validation => Input}/ValidatedInput.php (97%) rename tests/system/{Validation => Input}/ValidatedInputTest.php (98%) diff --git a/structarmed.php b/structarmed.php index 3dba0faae009..7665bd34afd3 100644 --- a/structarmed.php +++ b/structarmed.php @@ -13,7 +13,6 @@ use CodeIgniter\Cache\ResponseCache; use CodeIgniter\HTTP\CLIRequest; -use CodeIgniter\HTTP\FormRequest; use CodeIgniter\HTTP\Header; use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\SSEResponse; @@ -27,7 +26,6 @@ use CodeIgniter\HTTP\URI; use CodeIgniter\Log\Handlers\ChromeLoggerHandler; use CodeIgniter\Security\CheckPhpIni; -use CodeIgniter\Validation\ValidatedInput; use CodeIgniter\View\Table; use CodeIgniter\Database\BaseResult; use CodeIgniter\View\Plugins; @@ -101,6 +99,7 @@ 'Filters' => ['HTTP'], 'Honeypot' => ['Filters', 'HTTP'], 'HTTP' => ['Cookie', 'Files', 'I18n', 'Input', 'Security', 'URI'], + 'Input' => ['I18n'], 'Images' => ['Files', 'I18n'], 'Lock' => ['Cache'], 'Model' => ['Database', 'DataCaster', 'DataConverter', 'Entity', 'I18n', 'Pager', 'Validation'], @@ -136,9 +135,6 @@ ->skipClassViolation(URICast::class, [ URI::class, ]) - ->skipClassViolation(FormRequest::class, [ - ValidatedInput::class, - ]) ->skipClassViolation(ChromeLoggerHandler::class, [ ResponseInterface::class, ]) diff --git a/system/HTTP/FormRequest.php b/system/HTTP/FormRequest.php index 28ad232c302d..881824e18acf 100644 --- a/system/HTTP/FormRequest.php +++ b/system/HTTP/FormRequest.php @@ -14,7 +14,7 @@ namespace CodeIgniter\HTTP; use CodeIgniter\Exceptions\RuntimeException; -use CodeIgniter\Validation\ValidatedInput; +use CodeIgniter\Input\ValidatedInput; use ReflectionNamedType; use ReflectionParameter; diff --git a/system/Input/InputDataFactory.php b/system/Input/InputDataFactory.php index 59c10be68bac..ae91d9c9511d 100644 --- a/system/Input/InputDataFactory.php +++ b/system/Input/InputDataFactory.php @@ -13,8 +13,6 @@ namespace CodeIgniter\Input; -use CodeIgniter\Validation\ValidatedInput; - /** * @see \CodeIgniter\Input\InputDataFactoryTest */ diff --git a/system/Validation/ValidatedInput.php b/system/Input/ValidatedInput.php similarity index 97% rename from system/Validation/ValidatedInput.php rename to system/Input/ValidatedInput.php index 2efc0abbdf7d..ddcd23e1b203 100644 --- a/system/Validation/ValidatedInput.php +++ b/system/Input/ValidatedInput.php @@ -11,11 +11,10 @@ * the LICENSE file that was distributed with this source code. */ -namespace CodeIgniter\Validation; +namespace CodeIgniter\Input; use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\I18n\Time; -use CodeIgniter\Input\InputData; use DateTimeZone; use Exception; use ReflectionEnum; @@ -27,7 +26,7 @@ * This class is stricter than InputData: missing values may use defaults and * null values remain null, but invalid present values throw. * - * @see \CodeIgniter\Validation\ValidatedInputTest + * @see \CodeIgniter\Input\ValidatedInputTest */ class ValidatedInput extends InputData { diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php index 31319c5d87ba..afd9dca27e6c 100644 --- a/system/Validation/Validation.php +++ b/system/Validation/Validation.php @@ -21,6 +21,7 @@ use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\Method; use CodeIgniter\HTTP\RequestInterface; +use CodeIgniter\Input\ValidatedInput; use CodeIgniter\Validation\Exceptions\ValidationException; use CodeIgniter\View\RendererInterface; diff --git a/system/Validation/ValidationInterface.php b/system/Validation/ValidationInterface.php index 1bf5c61a707e..ff263cda309b 100644 --- a/system/Validation/ValidationInterface.php +++ b/system/Validation/ValidationInterface.php @@ -15,6 +15,7 @@ use CodeIgniter\Database\BaseConnection; use CodeIgniter\HTTP\RequestInterface; +use CodeIgniter\Input\ValidatedInput; /** * Expected behavior of a validator diff --git a/tests/system/HTTP/FormRequestTest.php b/tests/system/HTTP/FormRequestTest.php index d517b4cbb2bf..e01c6ebb3509 100644 --- a/tests/system/HTTP/FormRequestTest.php +++ b/tests/system/HTTP/FormRequestTest.php @@ -15,10 +15,10 @@ use CodeIgniter\Config\Services; use CodeIgniter\Exceptions\RuntimeException; +use CodeIgniter\Input\ValidatedInput; use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockCodeIgniter; -use CodeIgniter\Validation\ValidatedInput; use Config\App; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; diff --git a/tests/system/Input/InputDataFactoryTest.php b/tests/system/Input/InputDataFactoryTest.php index b90da071f3f3..2736a708b8b3 100644 --- a/tests/system/Input/InputDataFactoryTest.php +++ b/tests/system/Input/InputDataFactoryTest.php @@ -14,7 +14,6 @@ namespace CodeIgniter\Input; use CodeIgniter\Test\CIUnitTestCase; -use CodeIgniter\Validation\ValidatedInput; use PHPUnit\Framework\Attributes\Group; /** diff --git a/tests/system/Validation/ValidatedInputTest.php b/tests/system/Input/ValidatedInputTest.php similarity index 98% rename from tests/system/Validation/ValidatedInputTest.php rename to tests/system/Input/ValidatedInputTest.php index e1f16bab566e..a7bba1ba8257 100644 --- a/tests/system/Validation/ValidatedInputTest.php +++ b/tests/system/Input/ValidatedInputTest.php @@ -11,11 +11,10 @@ * the LICENSE file that was distributed with this source code. */ -namespace CodeIgniter\Validation; +namespace CodeIgniter\Input; use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\I18n\Time; -use CodeIgniter\Input\InputData; use CodeIgniter\Test\CIUnitTestCase; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Enum\ColorEnum; diff --git a/tests/system/Validation/ValidationTest.php b/tests/system/Validation/ValidationTest.php index 0b7c7eaef766..41b926437efb 100644 --- a/tests/system/Validation/ValidationTest.php +++ b/tests/system/Validation/ValidationTest.php @@ -19,6 +19,7 @@ use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\SiteURI; use CodeIgniter\HTTP\UserAgent; +use CodeIgniter\Input\ValidatedInput; use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Validation\Exceptions\ValidationException; diff --git a/user_guide_src/source/changelogs/v4.8.0.rst b/user_guide_src/source/changelogs/v4.8.0.rst index 246ae053ec98..25b03cb154ec 100644 --- a/user_guide_src/source/changelogs/v4.8.0.rst +++ b/user_guide_src/source/changelogs/v4.8.0.rst @@ -54,7 +54,7 @@ update your implementations to include the new methods or method changes to ensu - **Database:** ``CodeIgniter\Database\ConnectionInterface`` now requires the ``afterCommit()``, ``afterRollback()``, ``inTransaction()``, and ``transaction()`` methods. - **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\Validation\ValidatedInput`` instance. +- **Validation:** ``CodeIgniter\Validation\ValidationInterface`` now requires the ``getValidatedInput()`` method, which returns a ``CodeIgniter\Input\ValidatedInput`` instance. Method Signature Changes ======================== @@ -333,7 +333,7 @@ Others ====== - **Float and Double Casting:** Added support for precision and rounding mode when casting to float or double in entities. -- Added ``CodeIgniter\Input\InputData`` and ``InputDataFactory`` for reusable typed input data objects. +- Added ``CodeIgniter\Input\InputData``, ``ValidatedInput``, and ``InputDataFactory`` for reusable typed input data objects. - Float and Double casting now throws ``CastException::forInvalidFloatRoundingMode()`` if an rounding mode other than up, down, even or odd is provided. - **Filters:** Added ``RequestId`` filter for request tracing and correlation logging. The filter stores the request ID in the request context and automatically adds the ``X-Request-ID`` response header. Incoming ``X-Request-ID`` headers are used when valid. See :ref:`requestid` for details. - **Environment:** Added ``CodeIgniter\EnvironmentDetector`` class and corresponding ``environment`` service as a mockable wrapper around the ``ENVIRONMENT`` constant. diff --git a/user_guide_src/source/libraries/validation.rst b/user_guide_src/source/libraries/validation.rst index 696ba5d64b1d..c7d76d1c0409 100644 --- a/user_guide_src/source/libraries/validation.rst +++ b/user_guide_src/source/libraries/validation.rst @@ -484,7 +484,7 @@ Typed Validated Input --------------------- ``getValidatedInput()`` returns the same validated data as a -``CodeIgniter\Validation\ValidatedInput`` object. Use it after validation +``CodeIgniter\Input\ValidatedInput`` object. Use it after validation succeeds when you want to read common controller values as strings, integers, floats, booleans, arrays, dates, or enums: