mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Merge remote-tracking branch 'upstream/develop' into 4.6
# Conflicts: # system/Autoloader/Autoloader.php # system/BaseModel.php # system/CLI/CLI.php # system/Database/MigrationRunner.php # system/Exceptions/PageNotFoundException.php # system/Router/RouteCollection.php # system/Validation/FileRules.php # tests/system/Autoloader/AutoloaderTest.php # tests/system/Filters/FiltersTest.php # tests/system/Test/ControllerTestTraitTest.php # tests/system/Test/FeatureTestTraitTest.php # tests/system/Validation/CreditCardRulesTest.php # tests/system/Validation/FileRulesTest.php # tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php # tests/system/Validation/StrictRules/FileRulesTest.php # tests/system/View/ViewTest.php
This commit is contained in:
commit
c32dcd4329
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@ -10,7 +9,7 @@ final class ExampleSessionTest extends CIUnitTestCase
|
||||
{
|
||||
public function testSessionSimple(): void
|
||||
{
|
||||
$session = Services::session();
|
||||
$session = service('session');
|
||||
|
||||
$session->set('logged_in', 123);
|
||||
$this->assertSame(123, $session->get('logged_in'));
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use Config\App;
|
||||
use Config\Services;
|
||||
use Tests\Support\Libraries\ConfigReader;
|
||||
|
||||
/**
|
||||
@ -17,7 +16,7 @@ final class HealthTest extends CIUnitTestCase
|
||||
|
||||
public function testBaseUrlHasBeenSet(): void
|
||||
{
|
||||
$validation = Services::validation();
|
||||
$validation = service('validation');
|
||||
|
||||
$env = false;
|
||||
|
||||
|
@ -44,10 +44,10 @@ Events::on('pre_system', static function (): void {
|
||||
*/
|
||||
if (CI_DEBUG && ! is_cli()) {
|
||||
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
|
||||
Services::toolbar()->respond();
|
||||
service('toolbar')->respond();
|
||||
// Hot Reload route - for framework use on the hot reloader.
|
||||
if (ENVIRONMENT === 'development') {
|
||||
Services::routes()->get('__hot-reload', static function (): void {
|
||||
service('routes')->get('__hot-reload', static function (): void {
|
||||
(new HotReloader())->run();
|
||||
});
|
||||
}
|
||||
|
@ -72,6 +72,6 @@ class Format extends BaseConfig
|
||||
*/
|
||||
public function getFormatter(string $mime)
|
||||
{
|
||||
return Services::format()->getFormatter($mime);
|
||||
return service('format')->getFormatter($mime);
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,6 @@ abstract class BaseController extends Controller
|
||||
|
||||
// Preload any models, libraries, etc, here.
|
||||
|
||||
// E.g.: $this->session = \Config\Services::session();
|
||||
// E.g.: $this->session = service('session');
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
use CodeIgniter\HTTP\Header;
|
||||
use Config\Services;
|
||||
use CodeIgniter\CodeIgniter;
|
||||
|
||||
$errorId = uniqid('error', true);
|
||||
@ -225,7 +224,7 @@ $errorId = uniqid('error', true);
|
||||
|
||||
<!-- Request -->
|
||||
<div class="content" id="request">
|
||||
<?php $request = Services::request(); ?>
|
||||
<?php $request = service('request'); ?>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
@ -343,7 +342,7 @@ $errorId = uniqid('error', true);
|
||||
|
||||
<!-- Response -->
|
||||
<?php
|
||||
$response = Services::response();
|
||||
$response = service('response');
|
||||
$response->setStatusCode(http_response_code());
|
||||
?>
|
||||
<div class="content" id="response">
|
||||
|
@ -28,7 +28,7 @@
|
||||
"phpunit/phpcov": "^9.0.2 || ^10.0",
|
||||
"phpunit/phpunit": "^10.5.16 || ^11.2",
|
||||
"predis/predis": "^1.1 || ^2.0",
|
||||
"rector/rector": "1.2.8"
|
||||
"rector/rector": "1.2.10"
|
||||
},
|
||||
"replace": {
|
||||
"codeigniter4/framework": "self.version"
|
||||
|
@ -7,54 +7,12 @@ $ignoreErrors[] = [
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/app/Config/Filters.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: function.alreadyNarrowedType
|
||||
'message' => '#^Call to function method_exists\\(\\) with \'Composer\\\\\\\\InstalledVersions\' and \'getAllRawData\' will always evaluate to true\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/system/Autoloader/Autoloader.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.iterableValue
|
||||
'message' => '#^Method CodeIgniter\\\\Autoloader\\\\Autoloader\\:\\:loadComposerNamespaces\\(\\) has parameter \\$composerPackages with no value type specified in iterable type array\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/system/Autoloader/Autoloader.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: isset.property
|
||||
'message' => '#^Property Config\\\\Autoload\\:\\:\\$helpers \\(array\\<int, string\\>\\) in isset\\(\\) is not nullable\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/system/Autoloader/Autoloader.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: ternary.condNotBoolean
|
||||
'message' => '#^Only booleans are allowed in a ternary operator condition, int\\|string given\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/system/Autoloader/FileLocator.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: ternary.shortNotAllowed
|
||||
'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#',
|
||||
'count' => 6,
|
||||
'path' => __DIR__ . '/system/Autoloader/FileLocator.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.iterableValue
|
||||
'message' => '#^Method CodeIgniter\\\\Autoloader\\\\FileLocatorCached\\:\\:search\\(\\) return type has no value type specified in iterable type array\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/system/Autoloader/FileLocatorCached.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.iterableValue
|
||||
'message' => '#^Property CodeIgniter\\\\Autoloader\\\\FileLocatorCached\\:\\:\\$cache type has no value type specified in iterable type array\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/system/Autoloader/FileLocatorCached.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.iterableValue
|
||||
'message' => '#^Method CodeIgniter\\\\Autoloader\\\\FileLocatorInterface\\:\\:search\\(\\) return type has no value type specified in iterable type array\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/system/Autoloader/FileLocatorInterface.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.iterableValue
|
||||
'message' => '#^Method CodeIgniter\\\\BaseModel\\:\\:__call\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#',
|
||||
@ -1009,12 +967,6 @@ $ignoreErrors[] = [
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/system/Common.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: empty.notAllowed
|
||||
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
|
||||
'count' => 4,
|
||||
'path' => __DIR__ . '/system/Common.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.iterableValue
|
||||
'message' => '#^Function cache\\(\\) return type has no value type specified in iterable type array\\.$#',
|
||||
@ -1285,18 +1237,6 @@ $ignoreErrors[] = [
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/system/Config/Factories.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: booleanNot.exprNotBoolean
|
||||
'message' => '#^Only booleans are allowed in a negated boolean, array given\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/system/Config/Factories.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: booleanNot.exprNotBoolean
|
||||
'message' => '#^Only booleans are allowed in a negated boolean, string\\|null given\\.$#',
|
||||
'count' => 2,
|
||||
'path' => __DIR__ . '/system/Config/Factories.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.iterableValue
|
||||
'message' => '#^Property CodeIgniter\\\\Config\\\\Factory\\:\\:\\$default type has no value type specified in iterable type array\\.$#',
|
||||
@ -2500,7 +2440,7 @@ $ignoreErrors[] = [
|
||||
$ignoreErrors[] = [
|
||||
// identifier: empty.notAllowed
|
||||
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
|
||||
'count' => 13,
|
||||
'count' => 12,
|
||||
'path' => __DIR__ . '/system/Database/Forge.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
@ -5863,12 +5803,6 @@ $ignoreErrors[] = [
|
||||
'count' => 2,
|
||||
'path' => __DIR__ . '/system/HTTP/DownloadResponse.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.iterableValue
|
||||
'message' => '#^Method CodeIgniter\\\\HTTP\\\\DownloadResponse\\:\\:setCache\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/system/HTTP/DownloadResponse.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: method.childReturnType
|
||||
'message' => '#^Return type \\(CodeIgniter\\\\HTTP\\\\DownloadResponse\\) of method CodeIgniter\\\\HTTP\\\\DownloadResponse\\:\\:sendBody\\(\\) should be covariant with return type \\(\\$this\\(CodeIgniter\\\\HTTP\\\\Response\\)\\) of method CodeIgniter\\\\HTTP\\\\Response\\:\\:sendBody\\(\\)$#',
|
||||
@ -9115,12 +9049,6 @@ $ignoreErrors[] = [
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/system/Test/CIUnitTestCase.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.callable
|
||||
'message' => '#^Method CodeIgniter\\\\Test\\\\CIUnitTestCase\\:\\:getPrivateMethodInvoker\\(\\) return type has no signature specified for Closure\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/system/Test/CIUnitTestCase.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.return
|
||||
'message' => '#^Method CodeIgniter\\\\Test\\\\CIUnitTestCase\\:\\:mockCache\\(\\) has no return type specified\\.$#',
|
||||
@ -9151,12 +9079,6 @@ $ignoreErrors[] = [
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/system/Test/CIUnitTestCase.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.return
|
||||
'message' => '#^Method CodeIgniter\\\\Test\\\\CIUnitTestCase\\:\\:setPrivateProperty\\(\\) has no return type specified\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/system/Test/CIUnitTestCase.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: booleanNot.exprNotBoolean
|
||||
'message' => '#^Only booleans are allowed in a negated boolean, CodeIgniter\\\\CodeIgniter given\\.$#',
|
||||
@ -11689,36 +11611,6 @@ $ignoreErrors[] = [
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/AutoReview/FrameworkCodeTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.callable
|
||||
'message' => '#^Method CodeIgniter\\\\Autoloader\\\\AutoloaderTest\\:\\:getPrivateMethodInvoker\\(\\) return type has no signature specified for Closure\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Autoloader/AutoloaderTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.return
|
||||
'message' => '#^Method CodeIgniter\\\\Autoloader\\\\AutoloaderTest\\:\\:setPrivateProperty\\(\\) has no return type specified\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Autoloader/AutoloaderTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: ternary.shortNotAllowed
|
||||
'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#',
|
||||
'count' => 2,
|
||||
'path' => __DIR__ . '/tests/system/Autoloader/AutoloaderTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: method.notFound
|
||||
'message' => '#^Call to an undefined method CodeIgniter\\\\Autoloader\\\\FileLocatorInterface\\:\\:__destruct\\(\\)\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Autoloader/FileLocatorCachedTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: method.notFound
|
||||
'message' => '#^Call to an undefined method CodeIgniter\\\\Autoloader\\\\FileLocatorInterface\\:\\:deleteCache\\(\\)\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Autoloader/FileLocatorCachedTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: codeigniter.superglobalAccessAssign
|
||||
'message' => '#^Assigning 3 directly on offset \'argc\' of \\$_SERVER is discouraged\\.$#',
|
||||
@ -13009,24 +12901,12 @@ $ignoreErrors[] = [
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Database/Builder/WhereTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.callable
|
||||
'message' => '#^Method CodeIgniter\\\\Database\\\\ConfigTest\\:\\:getPrivateMethodInvoker\\(\\) return type has no signature specified for Closure\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Database/ConfigTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.iterableValue
|
||||
'message' => '#^Method CodeIgniter\\\\Database\\\\ConfigTest\\:\\:provideConvertDSN\\(\\) return type has no value type specified in iterable type iterable\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Database/ConfigTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.return
|
||||
'message' => '#^Method CodeIgniter\\\\Database\\\\ConfigTest\\:\\:setPrivateProperty\\(\\) has no return type specified\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Database/ConfigTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.iterableValue
|
||||
'message' => '#^Property CodeIgniter\\\\Database\\\\ConfigTest\\:\\:\\$dsnGroup type has no value type specified in iterable type array\\.$#',
|
||||
@ -13375,18 +13255,6 @@ $ignoreErrors[] = [
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Debug/ExceptionsTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.callable
|
||||
'message' => '#^Method CodeIgniter\\\\Debug\\\\ExceptionsTest\\:\\:getPrivateMethodInvoker\\(\\) return type has no signature specified for Closure\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Debug/ExceptionsTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.return
|
||||
'message' => '#^Method CodeIgniter\\\\Debug\\\\ExceptionsTest\\:\\:setPrivateProperty\\(\\) has no return type specified\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Debug/ExceptionsTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: argument.type
|
||||
'message' => '#^Parameter \\#2 \\$callable of method CodeIgniter\\\\Debug\\\\Timer\\:\\:record\\(\\) expects callable\\(\\)\\: mixed, \'strlen\' given\\.$#',
|
||||
@ -13525,12 +13393,6 @@ $ignoreErrors[] = [
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.callable
|
||||
'message' => '#^Method CodeIgniter\\\\Entity\\\\EntityTest\\:\\:getPrivateMethodInvoker\\(\\) return type has no signature specified for Closure\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.return
|
||||
'message' => '#^Method CodeIgniter\\\\Entity\\\\EntityTest\\:\\:getSimpleSwappedEntity\\(\\) has no return type specified\\.$#',
|
||||
@ -13543,12 +13405,6 @@ $ignoreErrors[] = [
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.return
|
||||
'message' => '#^Method CodeIgniter\\\\Entity\\\\EntityTest\\:\\:setPrivateProperty\\(\\) has no return type specified\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: codeigniter.configArgumentInstanceof
|
||||
'message' => '#^Argument \\#1 \\$name \\(\'Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#',
|
||||
@ -15651,13 +15507,13 @@ $ignoreErrors[] = [
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: argument.type
|
||||
'message' => '#^Parameter \\#1 \\$row of method CodeIgniter\\\\BaseModel\\:\\:save\\(\\) expects array\\<int\\|string, float\\|int\\|object\\|string\\|null\\>\\|object, array\\<string, array\\<int, string\\>\\> given\\.$#',
|
||||
'message' => '#^Parameter \\#1 \\$row of method CodeIgniter\\\\BaseModel\\:\\:save\\(\\) expects array<int\\|string, bool\\|float\\|int\\|object\\|string\\|null>\\|object, array<string, array<int, string>> given\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Models/DataConverterModelTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: argument.type
|
||||
'message' => '#^Parameter \\#2 \\$row of method CodeIgniter\\\\Model\\:\\:update\\(\\) expects array\\<int\\|string, float\\|int\\|object\\|string\\|null\\>\\|object\\|null, array\\<string, array\\<int, string\\>\\> given\\.$#',
|
||||
'message' => '#^Parameter \\#2 \\$row of method CodeIgniter\\\\Model\\:\\:update\\(\\) expects array<int\\|string, bool\\|float\\|int\\|object\\|string\\|null>\\|object\\|null, array<string, array<int, string>> given\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Models/DataConverterModelTest.php',
|
||||
];
|
||||
@ -15853,18 +15709,6 @@ $ignoreErrors[] = [
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Models/InsertModelTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.callable
|
||||
'message' => '#^Method CodeIgniter\\\\Models\\\\LiveModelTestCase\\:\\:getPrivateMethodInvoker\\(\\) return type has no signature specified for Closure\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Models/LiveModelTestCase.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.return
|
||||
'message' => '#^Method CodeIgniter\\\\Models\\\\LiveModelTestCase\\:\\:setPrivateProperty\\(\\) has no return type specified\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Models/LiveModelTestCase.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: property.nonObject
|
||||
'message' => '#^Cannot access property \\$created_at on array\\.$#',
|
||||
@ -16059,7 +15903,7 @@ $ignoreErrors[] = [
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: argument.type
|
||||
'message' => '#^Parameter \\#1 \\$row of method CodeIgniter\\\\BaseModel\\:\\:save\\(\\) expects array\\<int\\|string, float\\|int\\|object\\|string\\|null\\>\\|object, array\\<int, array\\>\\|null given\\.$#',
|
||||
'message' => '#^Parameter \\#1 \\$row of method CodeIgniter\\\\BaseModel\\:\\:save\\(\\) expects array<int\\|string, bool\\|float\\|int\\|object\\|string\\|null>\\|object, array<int, array>\\|null given\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php',
|
||||
];
|
||||
@ -16303,12 +16147,6 @@ $ignoreErrors[] = [
|
||||
'count' => 5,
|
||||
'path' => __DIR__ . '/tests/system/Pager/PagerTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.iterableValue
|
||||
'message' => '#^Property CodeIgniter\\\\Publisher\\\\PublisherOutputTest\\:\\:\\$structure type has no value type specified in iterable type array\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Publisher/PublisherOutputTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.iterableValue
|
||||
'message' => '#^Method CodeIgniter\\\\Publisher\\\\PublisherRestrictionsTest\\:\\:provideDefaultPublicRestrictions\\(\\) return type has no value type specified in iterable type iterable\\.$#',
|
||||
@ -16921,18 +16759,6 @@ $ignoreErrors[] = [
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Session/Handlers/Database/AbstractHandlerTestCase.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.callable
|
||||
'message' => '#^Method CodeIgniter\\\\Session\\\\Handlers\\\\Database\\\\AbstractHandlerTestCase\\:\\:getPrivateMethodInvoker\\(\\) return type has no signature specified for Closure\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Session/Handlers/Database/AbstractHandlerTestCase.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.return
|
||||
'message' => '#^Method CodeIgniter\\\\Session\\\\Handlers\\\\Database\\\\AbstractHandlerTestCase\\:\\:setPrivateProperty\\(\\) has no return type specified\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Session/Handlers/Database/AbstractHandlerTestCase.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.return
|
||||
'message' => '#^Method CodeIgniter\\\\Session\\\\Handlers\\\\Database\\\\MySQLiHandlerTest\\:\\:getInstance\\(\\) has no return type specified\\.$#',
|
||||
@ -18181,18 +18007,6 @@ $ignoreErrors[] = [
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/Validation/ValidationTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: assign.propertyType
|
||||
'message' => '#^Property CodeIgniter\\\\View\\\\DecoratorsTest\\:\\:\\$loader \\(CodeIgniter\\\\Autoloader\\\\FileLocator\\) does not accept CodeIgniter\\\\Autoloader\\\\FileLocatorInterface\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/View/DecoratorsTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: assign.propertyType
|
||||
'message' => '#^Property CodeIgniter\\\\View\\\\ParserFilterTest\\:\\:\\$loader \\(CodeIgniter\\\\Autoloader\\\\FileLocator\\) does not accept CodeIgniter\\\\Autoloader\\\\FileLocatorInterface\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/View/ParserFilterTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.return
|
||||
'message' => '#^Method CodeIgniter\\\\View\\\\ParserPluginTest\\:\\:setHints\\(\\) has no return type specified\\.$#',
|
||||
@ -18217,36 +18031,12 @@ $ignoreErrors[] = [
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/View/ParserTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.iterableValue
|
||||
'message' => '#^Method class@anonymous/tests/system/View/ParserTest\\.php\\:340\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/View/ParserTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: argument.type
|
||||
'message' => '#^Parameter \\#2 \\$context of method CodeIgniter\\\\View\\\\Parser\\:\\:setData\\(\\) expects \'attr\'\\|\'css\'\\|\'html\'\\|\'js\'\\|\'raw\'\\|\'url\'\\|null, \'unknown\' given\\.$#',
|
||||
'count' => 3,
|
||||
'path' => __DIR__ . '/tests/system/View/ParserTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: assign.propertyType
|
||||
'message' => '#^Property CodeIgniter\\\\View\\\\ParserTest\\:\\:\\$loader \\(CodeIgniter\\\\Autoloader\\\\FileLocator\\) does not accept CodeIgniter\\\\Autoloader\\\\FileLocatorInterface\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/View/ParserTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.property
|
||||
'message' => '#^Property class@anonymous/tests/system/View/ParserTest\\.php\\:340\\:\\:\\$bar has no type specified\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/View/ParserTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: missingType.property
|
||||
'message' => '#^Property class@anonymous/tests/system/View/ParserTest\\.php\\:340\\:\\:\\$foo has no type specified\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/View/ParserTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: method.notFound
|
||||
'message' => '#^Call to an undefined method CodeIgniter\\\\View\\\\Table\\:\\:compileTemplate\\(\\)\\.$#',
|
||||
@ -18337,11 +18127,5 @@ $ignoreErrors[] = [
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/View/TableTest.php',
|
||||
];
|
||||
$ignoreErrors[] = [
|
||||
// identifier: assign.propertyType
|
||||
'message' => '#^Property CodeIgniter\\\\View\\\\ViewTest\\:\\:\\$loader \\(CodeIgniter\\\\Autoloader\\\\FileLocator\\) does not accept CodeIgniter\\\\Autoloader\\\\FileLocatorInterface\\.$#',
|
||||
'count' => 1,
|
||||
'path' => __DIR__ . '/tests/system/View/ViewTest.php',
|
||||
];
|
||||
|
||||
return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
|
||||
|
14
rector.php
14
rector.php
@ -17,13 +17,9 @@ use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
|
||||
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
|
||||
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector;
|
||||
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
|
||||
use Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector;
|
||||
use Rector\CodeQuality\Rector\If_\CombineIfRector;
|
||||
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
|
||||
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
|
||||
use Rector\CodeQuality\Rector\If_\ShortenElseIfRector;
|
||||
use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector;
|
||||
use Rector\CodeQuality\Rector\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector;
|
||||
use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector;
|
||||
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
|
||||
@ -187,11 +183,9 @@ return RectorConfig::configure()
|
||||
CountArrayToEmptyArrayComparisonRector::class,
|
||||
ChangeNestedForeachIfsToEarlyContinueRector::class,
|
||||
ChangeIfElseValueAssignToEarlyReturnRector::class,
|
||||
CombineIfRector::class,
|
||||
InlineIfToExplicitIfRector::class,
|
||||
PreparedValueToEarlyReturnRector::class,
|
||||
ShortenElseIfRector::class,
|
||||
SimplifyIfElseToTernaryRector::class,
|
||||
UnusedForeachValueToArrayKeysRector::class,
|
||||
ChangeArrayPushToArrayAssignRector::class,
|
||||
RemoveErrorSuppressInTryCatchStmtsRector::class,
|
||||
@ -204,18 +198,16 @@ return RectorConfig::configure()
|
||||
PrivatizeFinalClassPropertyRector::class,
|
||||
CompleteDynamicPropertiesRector::class,
|
||||
BooleanInIfConditionRuleFixerRector::class,
|
||||
SingleInArrayToCompareRector::class,
|
||||
VersionCompareFuncCallToConstantRector::class,
|
||||
ExplicitBoolCompareRector::class,
|
||||
AddClosureVoidReturnTypeWhereNoReturnRector::class,
|
||||
AddFunctionVoidReturnTypeWhereNoReturnRector::class,
|
||||
AddMethodCallBasedStrictParamTypeRector::class,
|
||||
TypedPropertyFromAssignsRector::class,
|
||||
ClosureReturnTypeRector::class,
|
||||
SimplifyBoolIdenticalTrueRector::class,
|
||||
FlipTypeControlToUseExclusiveTypeRector::class,
|
||||
])
|
||||
->withConfiguredRule(StringClassNameToClassConstantRector::class, [
|
||||
// keep '\\' prefix string on string '\Foo\Bar'
|
||||
StringClassNameToClassConstantRector::SHOULD_KEEP_PRE_SLASH => true,
|
||||
])
|
||||
->withCodeQualityLevel(15);
|
||||
->withCodeQualityLevel(24);
|
||||
|
@ -21,7 +21,6 @@ use Composer\InstalledVersions;
|
||||
use Config\Autoload;
|
||||
use Config\Kint as KintConfig;
|
||||
use Config\Modules;
|
||||
use Config\Services;
|
||||
use Kint;
|
||||
use Kint\Renderer\CliRenderer;
|
||||
use Kint\Renderer\RichRenderer;
|
||||
@ -367,6 +366,9 @@ class Autoloader
|
||||
return $cleanFilename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{only?: list<string>, exclude?: list<string>} $composerPackages
|
||||
*/
|
||||
private function loadComposerNamespaces(ClassLoader $composer, array $composerPackages): void
|
||||
{
|
||||
$namespacePaths = $composer->getPrefixesPsr4();
|
||||
@ -380,7 +382,7 @@ class Autoloader
|
||||
}
|
||||
}
|
||||
|
||||
if (! method_exists(InstalledVersions::class, 'getAllRawData')) {
|
||||
if (! method_exists(InstalledVersions::class, 'getAllRawData')) { // @phpstan-ignore function.alreadyNarrowedType
|
||||
throw new RuntimeException(
|
||||
'Your Composer version is too old.'
|
||||
. ' Please update Composer (run `composer self-update`) to v2.0.14 or later'
|
||||
@ -537,7 +539,7 @@ class Autoloader
|
||||
Kint::$plugins = $config->plugins;
|
||||
}
|
||||
|
||||
$csp = Services::csp();
|
||||
$csp = service('csp');
|
||||
if ($csp->enabled()) {
|
||||
RichRenderer::$js_nonce = $csp->getScriptNonce();
|
||||
RichRenderer::$css_nonce = $csp->getStyleNonce();
|
||||
|
@ -145,10 +145,11 @@ class FileLocator implements FileLocatorInterface
|
||||
|
||||
if ((isset($tokens[$i - 2][1]) && ($tokens[$i - 2][1] === 'phpnamespace' || $tokens[$i - 2][1] === 'namespace')) || ($dlm && $tokens[$i - 1][0] === T_NS_SEPARATOR && $token[0] === T_STRING)) {
|
||||
if (! $dlm) {
|
||||
$namespace = 0;
|
||||
$namespace = '';
|
||||
}
|
||||
|
||||
if (isset($token[1])) {
|
||||
$namespace = $namespace ? $namespace . '\\' . $token[1] : $token[1];
|
||||
$namespace = $namespace !== '' ? $namespace . '\\' . $token[1] : $token[1];
|
||||
$dlm = true;
|
||||
}
|
||||
} elseif ($dlm && ($token[0] !== T_NS_SEPARATOR) && ($token[0] !== T_STRING)) {
|
||||
@ -194,8 +195,9 @@ class FileLocator implements FileLocatorInterface
|
||||
|
||||
foreach ($this->getNamespaces() as $namespace) {
|
||||
if (isset($namespace['path']) && is_file($namespace['path'] . $path)) {
|
||||
$fullPath = $namespace['path'] . $path;
|
||||
$fullPath = realpath($fullPath) ?: $fullPath;
|
||||
$fullPath = $namespace['path'] . $path;
|
||||
$resolvedPath = realpath($fullPath);
|
||||
$fullPath = $resolvedPath !== false ? $resolvedPath : $fullPath;
|
||||
|
||||
if ($prioritizeApp) {
|
||||
$foundPaths[] = $fullPath;
|
||||
@ -272,14 +274,16 @@ class FileLocator implements FileLocatorInterface
|
||||
*/
|
||||
public function findQualifiedNameFromPath(string $path)
|
||||
{
|
||||
$path = realpath($path) ?: $path;
|
||||
$resolvedPath = realpath($path);
|
||||
$path = $resolvedPath !== false ? $resolvedPath : $path;
|
||||
|
||||
if (! is_file($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($this->getNamespaces() as $namespace) {
|
||||
$namespace['path'] = realpath($namespace['path']) ?: $namespace['path'];
|
||||
$resolvedNamespacePath = realpath($namespace['path']);
|
||||
$namespace['path'] = $resolvedNamespacePath !== false ? $resolvedNamespacePath : $namespace['path'];
|
||||
|
||||
if ($namespace['path'] === '') {
|
||||
continue;
|
||||
@ -331,8 +335,9 @@ class FileLocator implements FileLocatorInterface
|
||||
helper('filesystem');
|
||||
|
||||
foreach ($this->getNamespaces() as $namespace) {
|
||||
$fullPath = $namespace['path'] . $path;
|
||||
$fullPath = realpath($fullPath) ?: $fullPath;
|
||||
$fullPath = $namespace['path'] . $path;
|
||||
$resolvedPath = realpath($fullPath);
|
||||
$fullPath = $resolvedPath !== false ? $resolvedPath : $fullPath;
|
||||
|
||||
if (! is_dir($fullPath)) {
|
||||
continue;
|
||||
@ -365,8 +370,9 @@ class FileLocator implements FileLocatorInterface
|
||||
|
||||
// autoloader->getNamespace($prefix) returns an array of paths for that namespace
|
||||
foreach ($this->autoloader->getNamespace($prefix) as $namespacePath) {
|
||||
$fullPath = rtrim($namespacePath, '/') . '/' . $path;
|
||||
$fullPath = realpath($fullPath) ?: $fullPath;
|
||||
$fullPath = rtrim($namespacePath, '/') . '/' . $path;
|
||||
$resolvedPath = realpath($fullPath);
|
||||
$fullPath = $resolvedPath !== false ? $resolvedPath : $fullPath;
|
||||
|
||||
if (! is_dir($fullPath)) {
|
||||
continue;
|
||||
@ -392,8 +398,9 @@ class FileLocator implements FileLocatorInterface
|
||||
*/
|
||||
protected function legacyLocate(string $file, ?string $folder = null)
|
||||
{
|
||||
$path = APPPATH . ($folder === null ? $file : $folder . '/' . $file);
|
||||
$path = realpath($path) ?: $path;
|
||||
$path = APPPATH . ($folder === null ? $file : $folder . '/' . $file);
|
||||
$resolvedPath = realpath($path);
|
||||
$path = $resolvedPath !== false ? $resolvedPath : $path;
|
||||
|
||||
if (is_file($path)) {
|
||||
return $path;
|
||||
|
@ -36,6 +36,8 @@ final class FileLocatorCached implements FileLocatorInterface
|
||||
* [
|
||||
* 'search' => [$path => $foundPaths],
|
||||
* ]
|
||||
*
|
||||
* @var array<string, array<string, mixed>>
|
||||
*/
|
||||
private array $cache = [];
|
||||
|
||||
@ -114,6 +116,9 @@ final class FileLocatorCached implements FileLocatorInterface
|
||||
return $classname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public function search(string $path, string $ext = 'php', bool $prioritizeApp = true): array
|
||||
{
|
||||
if (isset($this->cache['search'][$path][$ext][$prioritizeApp])) {
|
||||
|
@ -53,6 +53,8 @@ interface FileLocatorInterface
|
||||
* 'app/Modules/foo/Config/Routes.php',
|
||||
* 'app/Modules/bar/Config/Routes.php',
|
||||
* ]
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function search(string $path, string $ext = 'php', bool $prioritizeApp = true): array;
|
||||
|
||||
|
@ -27,7 +27,6 @@ use CodeIgniter\I18n\Time;
|
||||
use CodeIgniter\Pager\Pager;
|
||||
use CodeIgniter\Validation\ValidationInterface;
|
||||
use Config\Feature;
|
||||
use Config\Services;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
use ReflectionProperty;
|
||||
@ -47,7 +46,7 @@ use stdClass;
|
||||
* - process various callbacks
|
||||
* - allow intermingling calls to the db connection
|
||||
*
|
||||
* @phpstan-type row_array array<int|string, float|int|null|object|string>
|
||||
* @phpstan-type row_array array<int|string, float|int|null|object|string|bool>
|
||||
* @phpstan-type event_data_beforeinsert array{data: row_array}
|
||||
* @phpstan-type event_data_afterinsert array{id: int|string, data: row_array, result: bool}
|
||||
* @phpstan-type event_data_beforefind array{id?: int|string, method: string, singleton: bool, limit?: int, offset?: int}
|
||||
@ -1609,7 +1608,7 @@ abstract class BaseModel
|
||||
protected function ensureValidation(): void
|
||||
{
|
||||
if ($this->validation === null) {
|
||||
$this->validation = Services::validation(null, false);
|
||||
$this->validation = service('validation', null, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -246,12 +246,12 @@ class Boot
|
||||
|
||||
protected static function autoloadHelpers(): void
|
||||
{
|
||||
Services::autoloader()->loadHelpers();
|
||||
service('autoloader')->loadHelpers();
|
||||
}
|
||||
|
||||
protected static function setExceptionHandler(): void
|
||||
{
|
||||
Services::exceptions()->initialize();
|
||||
service('exceptions')->initialize();
|
||||
}
|
||||
|
||||
protected static function checkMissingExtensions(): void
|
||||
@ -290,7 +290,7 @@ class Boot
|
||||
|
||||
protected static function initializeKint(): void
|
||||
{
|
||||
Services::autoloader()->initializeKint(CI_DEBUG);
|
||||
service('autoloader')->initializeKint(CI_DEBUG);
|
||||
}
|
||||
|
||||
protected static function loadConfigCache(): FactoriesCache
|
||||
@ -308,7 +308,7 @@ class Boot
|
||||
*/
|
||||
protected static function initializeCodeIgniter(): CodeIgniter
|
||||
{
|
||||
$app = Config\Services::codeigniter();
|
||||
$app = service('codeigniter');
|
||||
$app->initialize();
|
||||
$context = is_cli() ? 'php-cli' : 'web';
|
||||
$app->setContext($context);
|
||||
|
@ -15,7 +15,6 @@ namespace CodeIgniter\CLI;
|
||||
|
||||
use CodeIgniter\CLI\Exceptions\CLIException;
|
||||
use CodeIgniter\Exceptions\InvalidArgumentException;
|
||||
use Config\Services;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
@ -416,7 +415,7 @@ class CLI
|
||||
{
|
||||
$label = $field;
|
||||
$field = 'temp';
|
||||
$validation = Services::validation(null, false);
|
||||
$validation = service('validation', null, false);
|
||||
$validation->setRules([
|
||||
$field => [
|
||||
'label' => $label,
|
||||
|
@ -819,7 +819,7 @@ class CodeIgniter
|
||||
{
|
||||
$this->benchmark->start('routing');
|
||||
|
||||
if ($routes === null) {
|
||||
if (! $routes instanceof RouteCollectionInterface) {
|
||||
$routes = service('routes')->loadRoutes();
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CodeIgniter\Commands\Utilities\Routes;
|
||||
|
||||
use CodeIgniter\Config\Services;
|
||||
use CodeIgniter\Filters\Filters;
|
||||
use CodeIgniter\HTTP\Method;
|
||||
use CodeIgniter\HTTP\Request;
|
||||
@ -68,7 +67,7 @@ final class FilterCollector
|
||||
];
|
||||
}
|
||||
|
||||
$request = Services::incomingrequest(null, false);
|
||||
$request = service('incomingrequest', null, false);
|
||||
$request->setMethod($method);
|
||||
|
||||
$router = $this->createRouter($request);
|
||||
@ -128,7 +127,7 @@ final class FilterCollector
|
||||
*/
|
||||
public function getRequiredFilters(): array
|
||||
{
|
||||
$request = Services::incomingrequest(null, false);
|
||||
$request = service('incomingrequest', null, false);
|
||||
$request->setMethod(Method::GET);
|
||||
|
||||
$router = $this->createRouter($request);
|
||||
|
@ -582,8 +582,8 @@ if (! function_exists('helper')) {
|
||||
foreach ($filenames as $filename) {
|
||||
// Store our system and application helper
|
||||
// versions so that we can control the load ordering.
|
||||
$systemHelper = null;
|
||||
$appHelper = null;
|
||||
$systemHelper = '';
|
||||
$appHelper = '';
|
||||
$localIncludes = [];
|
||||
|
||||
if (! str_contains($filename, '_helper')) {
|
||||
@ -600,7 +600,7 @@ if (! function_exists('helper')) {
|
||||
if (str_contains($filename, '\\')) {
|
||||
$path = $loader->locateFile($filename, 'Helpers');
|
||||
|
||||
if (empty($path)) {
|
||||
if ($path !== '') {
|
||||
throw FileNotFoundException::forFileNotFound($filename);
|
||||
}
|
||||
|
||||
@ -622,7 +622,7 @@ if (! function_exists('helper')) {
|
||||
}
|
||||
|
||||
// App-level helpers should override all others
|
||||
if (! empty($appHelper)) {
|
||||
if ($appHelper !== '') {
|
||||
$includes[] = $appHelper;
|
||||
$loaded[] = $filename;
|
||||
}
|
||||
@ -631,7 +631,7 @@ if (! function_exists('helper')) {
|
||||
$includes = [...$includes, ...$localIncludes];
|
||||
|
||||
// And the system default one should be added in last.
|
||||
if (! empty($systemHelper)) {
|
||||
if ($systemHelper !== '') {
|
||||
$includes[] = $systemHelper;
|
||||
$loaded[] = $filename;
|
||||
}
|
||||
@ -871,7 +871,7 @@ if (! function_exists('_solidus')) {
|
||||
{
|
||||
static $docTypes = null;
|
||||
|
||||
if ($docTypesConfig !== null) {
|
||||
if ($docTypesConfig instanceof DocTypes) {
|
||||
$docTypes = $docTypesConfig;
|
||||
}
|
||||
|
||||
@ -1094,7 +1094,7 @@ if (! function_exists('stringify_attributes')) {
|
||||
{
|
||||
$atts = '';
|
||||
|
||||
if (empty($attributes)) {
|
||||
if ($attributes === '' || $attributes === [] || $attributes === null) {
|
||||
return $atts;
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ final class Factories
|
||||
}
|
||||
|
||||
// Try to locate the class
|
||||
if (! $class = self::locateClass($options, $alias)) {
|
||||
if (($class = self::locateClass($options, $alias)) === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ final class Factories
|
||||
}
|
||||
|
||||
// Try to locate the class
|
||||
if (! $class = self::locateClass($options, $alias)) {
|
||||
if (($class = self::locateClass($options, $alias)) === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -310,7 +310,7 @@ final class Factories
|
||||
}
|
||||
// No namespace? Search for it
|
||||
// Check all namespaces, prioritizing App and modules
|
||||
elseif (! $files = $locator->search($options['path'] . DIRECTORY_SEPARATOR . $alias)) {
|
||||
elseif (($files = $locator->search($options['path'] . DIRECTORY_SEPARATOR . $alias)) === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -705,7 +705,7 @@ class Services extends BaseService
|
||||
// See https://www.php.net/manual/en/function.session-cache-limiter.php.
|
||||
// The headers are not managed by CI's Response class.
|
||||
// So, we remove CI's default Cache-Control header.
|
||||
AppServices::response()->removeHeader('Cache-Control');
|
||||
AppServices::get('response')->removeHeader('Cache-Control');
|
||||
|
||||
$session->start();
|
||||
}
|
||||
|
@ -688,7 +688,7 @@ abstract class BaseConnection implements ConnectionInterface
|
||||
// Let others do something with this query.
|
||||
Events::trigger('DBQuery', $query);
|
||||
|
||||
if ($exception !== null) {
|
||||
if ($exception instanceof DatabaseException) {
|
||||
throw new DatabaseException(
|
||||
$exception->getMessage(),
|
||||
$exception->getCode(),
|
||||
|
@ -573,7 +573,7 @@ class Forge
|
||||
}
|
||||
|
||||
// Most databases don't support creating indexes from within the CREATE TABLE statement
|
||||
if (! empty($this->keys)) {
|
||||
if ($this->keys !== []) {
|
||||
for ($i = 0, $sqls = $this->_processIndexes($table), $c = count($sqls); $i < $c; $i++) {
|
||||
$this->db->query($sqls[$i]);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ abstract class Migration
|
||||
{
|
||||
if (isset($this->DBGroup)) {
|
||||
$this->forge = Database::forge($this->DBGroup);
|
||||
} elseif ($forge !== null) {
|
||||
} elseif ($forge instanceof Forge) {
|
||||
$this->forge = $forge;
|
||||
} else {
|
||||
$this->forge = Database::forge(config(Database::class)->defaultGroup);
|
||||
|
@ -20,7 +20,6 @@ use CodeIgniter\Exceptions\RuntimeException;
|
||||
use CodeIgniter\I18n\Time;
|
||||
use Config\Database;
|
||||
use Config\Migrations as MigrationsConfig;
|
||||
use Config\Services;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
@ -390,7 +389,7 @@ class MigrationRunner
|
||||
*/
|
||||
public function findMigrations(): array
|
||||
{
|
||||
$namespaces = $this->namespace ? [$this->namespace] : array_keys(Services::autoloader()->getNamespace());
|
||||
$namespaces = $this->namespace ? [$this->namespace] : array_keys(service('autoloader')->getNamespace());
|
||||
$migrations = [];
|
||||
|
||||
foreach ($namespaces as $namespace) {
|
||||
@ -415,7 +414,7 @@ class MigrationRunner
|
||||
public function findNamespaceMigrations(string $namespace): array
|
||||
{
|
||||
$migrations = [];
|
||||
$locator = Services::locator(true);
|
||||
$locator = service('locator', true);
|
||||
|
||||
if (! empty($this->path)) {
|
||||
helper('filesystem');
|
||||
@ -455,7 +454,7 @@ class MigrationRunner
|
||||
return false;
|
||||
}
|
||||
|
||||
$locator = Services::locator(true);
|
||||
$locator = service('locator', true);
|
||||
|
||||
$migration = new stdClass();
|
||||
|
||||
|
@ -105,7 +105,7 @@ class Seeder
|
||||
*/
|
||||
public static function faker(): ?Generator
|
||||
{
|
||||
if (self::$faker === null && class_exists(Factory::class)) {
|
||||
if (! self::$faker instanceof Generator && class_exists(Factory::class)) {
|
||||
self::$faker = Factory::create();
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@ use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Config\Exceptions as ExceptionsConfig;
|
||||
use Config\Paths;
|
||||
use Config\Services;
|
||||
use ErrorException;
|
||||
use Psr\Log\LogLevel;
|
||||
use Throwable;
|
||||
@ -126,7 +125,7 @@ class Exceptions
|
||||
|
||||
[$statusCode, $exitCode] = $this->determineCodes($exception);
|
||||
|
||||
$this->request = Services::request();
|
||||
$this->request = service('request');
|
||||
|
||||
if ($this->config->log === true && ! in_array($statusCode, $this->config->ignoreCodes, true)) {
|
||||
$uri = $this->request->getPath() === '' ? '/' : $this->request->getPath();
|
||||
@ -155,7 +154,7 @@ class Exceptions
|
||||
}
|
||||
}
|
||||
|
||||
$this->response = Services::response();
|
||||
$this->response = service('response');
|
||||
|
||||
if (method_exists($this->config, 'handler')) {
|
||||
// Use new ExceptionHandler
|
||||
|
@ -25,7 +25,6 @@ use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\I18n\Time;
|
||||
use Config\Services;
|
||||
use Config\Toolbar as ToolbarConfig;
|
||||
use Kint\Kint;
|
||||
|
||||
@ -386,7 +385,7 @@ class Toolbar
|
||||
return;
|
||||
}
|
||||
|
||||
$toolbar = Services::toolbar(config(ToolbarConfig::class));
|
||||
$toolbar = service('toolbar', config(ToolbarConfig::class));
|
||||
$stats = $app->getPerformanceStats();
|
||||
$data = $toolbar->run(
|
||||
$stats['startTime'],
|
||||
@ -529,7 +528,7 @@ class Toolbar
|
||||
case 'html':
|
||||
$data['styles'] = [];
|
||||
extract($data);
|
||||
$parser = Services::parser($this->config->viewsPath, null, false);
|
||||
$parser = service('parser', $this->config->viewsPath, null, false);
|
||||
ob_start();
|
||||
include $this->config->viewsPath . 'toolbar.tpl.php';
|
||||
$output = ob_get_clean();
|
||||
|
@ -13,8 +13,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CodeIgniter\Debug\Toolbar\Collectors;
|
||||
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
* Loags collector
|
||||
*/
|
||||
@ -92,6 +90,6 @@ class Logs extends BaseCollector
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
return $this->data = Services::logger(true)->logCache ?? [];
|
||||
return $this->data = service('logger', true)->logCache ?? [];
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ declare(strict_types=1);
|
||||
namespace CodeIgniter\Debug\Toolbar\Collectors;
|
||||
|
||||
use CodeIgniter\Router\DefinedRouteCollector;
|
||||
use Config\Services;
|
||||
use ReflectionException;
|
||||
use ReflectionFunction;
|
||||
use ReflectionMethod;
|
||||
@ -74,8 +73,8 @@ class Routes extends BaseCollector
|
||||
*/
|
||||
public function display(): array
|
||||
{
|
||||
$rawRoutes = Services::routes(true);
|
||||
$router = Services::router(null, null, true);
|
||||
$rawRoutes = service('routes', true);
|
||||
$router = service('router', null, null, true);
|
||||
|
||||
// Get our parameters
|
||||
// Closure routes
|
||||
@ -153,7 +152,7 @@ class Routes extends BaseCollector
|
||||
*/
|
||||
public function getBadgeValue(): int
|
||||
{
|
||||
$rawRoutes = Services::routes(true);
|
||||
$rawRoutes = service('routes', true);
|
||||
|
||||
return count($rawRoutes->getRoutes());
|
||||
}
|
||||
|
@ -13,8 +13,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CodeIgniter\Debug\Toolbar\Collectors;
|
||||
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
* Timers collector
|
||||
*/
|
||||
@ -52,7 +50,7 @@ class Timers extends BaseCollector
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$benchmark = Services::timer(true);
|
||||
$benchmark = service('timer', true);
|
||||
$rows = $benchmark->getTimers(6);
|
||||
|
||||
foreach ($rows as $name => $info) {
|
||||
|
@ -45,6 +45,8 @@ class DownloadException extends RuntimeException
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Since v4.5.6
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function forCannotSetCache()
|
||||
|
@ -13,8 +13,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CodeIgniter\Exceptions;
|
||||
|
||||
use Config\Services;
|
||||
|
||||
class PageNotFoundException extends RuntimeException implements HTTPExceptionInterface
|
||||
{
|
||||
use DebugTraceableTrait;
|
||||
@ -77,7 +75,7 @@ class PageNotFoundException extends RuntimeException implements HTTPExceptionInt
|
||||
*/
|
||||
private static function lang(string $line, array $args = []): string
|
||||
{
|
||||
$lang = Services::language(null, false);
|
||||
$lang = service('language', null, false);
|
||||
|
||||
return $lang->getLine($line, $args);
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ use CodeIgniter\Honeypot\Exceptions\HoneypotException;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
* Honeypot filter
|
||||
@ -40,7 +39,7 @@ class Honeypot implements FilterInterface
|
||||
return;
|
||||
}
|
||||
|
||||
if (Services::honeypot()->hasContent($request)) {
|
||||
if (service('honeypot')->hasContent($request)) {
|
||||
throw HoneypotException::isBot();
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class DownloadResponse extends Response
|
||||
*/
|
||||
public function setBinary(string $binary)
|
||||
{
|
||||
if ($this->file !== null) {
|
||||
if ($this->file instanceof File) {
|
||||
throw DownloadException::forCannotSetBinary();
|
||||
}
|
||||
|
||||
@ -242,16 +242,6 @@ class DownloadResponse extends Response
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables cache configuration.
|
||||
*
|
||||
* @throws DownloadException
|
||||
*/
|
||||
public function setCache(array $options = [])
|
||||
{
|
||||
throw DownloadException::forCannotSetCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
@ -290,10 +280,8 @@ class DownloadResponse extends Response
|
||||
$this->setHeader('Content-Disposition', $this->getContentDisposition());
|
||||
}
|
||||
|
||||
$this->setHeader('Expires-Disposition', '0');
|
||||
$this->setHeader('Content-Transfer-Encoding', 'binary');
|
||||
$this->setHeader('Content-Length', (string) $this->getContentLength());
|
||||
$this->noCache();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -309,7 +297,7 @@ class DownloadResponse extends Response
|
||||
return $this->sendBodyByBinary();
|
||||
}
|
||||
|
||||
if ($this->file !== null) {
|
||||
if ($this->file instanceof File) {
|
||||
return $this->sendBodyByFilePath();
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ class RedirectException extends RuntimeException implements ExceptionInterface,
|
||||
|
||||
public function getResponse(): ResponseInterface
|
||||
{
|
||||
if (null === $this->response) {
|
||||
if (! $this->response instanceof ResponseInterface) {
|
||||
$this->response = service('response')
|
||||
->redirect(base_url($this->getMessage()), 'auto', $this->getCode());
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class Negotiate
|
||||
*/
|
||||
public function __construct(?RequestInterface $request = null)
|
||||
{
|
||||
if ($request !== null) {
|
||||
if ($request instanceof RequestInterface) {
|
||||
assert($request instanceof IncomingRequest);
|
||||
|
||||
$this->request = $request;
|
||||
|
@ -15,7 +15,6 @@ namespace CodeIgniter\HTTP;
|
||||
|
||||
use CodeIgniter\Cookie\CookieStore;
|
||||
use CodeIgniter\HTTP\Exceptions\HTTPException;
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
* Handle a redirect response
|
||||
@ -148,7 +147,7 @@ class RedirectResponse extends Response
|
||||
*/
|
||||
public function withCookies()
|
||||
{
|
||||
$this->cookieStore = new CookieStore(Services::response()->getCookies());
|
||||
$this->cookieStore = new CookieStore(service('response')->getCookies());
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -163,7 +162,7 @@ class RedirectResponse extends Response
|
||||
*/
|
||||
public function withHeaders()
|
||||
{
|
||||
foreach (Services::response()->headers() as $name => $value) {
|
||||
foreach (service('response')->headers() as $name => $value) {
|
||||
if ($value instanceof Header) {
|
||||
$this->setHeader($name, $value->getValue());
|
||||
} else {
|
||||
|
@ -249,7 +249,7 @@ trait RequestTrait
|
||||
*
|
||||
* @param string $name Supergrlobal name (lowercase)
|
||||
* @phpstan-param 'get'|'post'|'request'|'cookie'|'server' $name
|
||||
* @param array|string|null $index
|
||||
* @param array|int|string|null $index
|
||||
* @param int|null $filter Filter constant
|
||||
* @param array|int|null $flags Options
|
||||
*
|
||||
@ -290,7 +290,7 @@ trait RequestTrait
|
||||
}
|
||||
|
||||
// Does the index contain array notation?
|
||||
if (($count = preg_match_all('/(?:^[^\[]+)|\[[^]]*\]/', $index, $matches)) > 1) {
|
||||
if (is_string($index) && ($count = preg_match_all('/(?:^[^\[]+)|\[[^]]*\]/', $index, $matches)) > 1) {
|
||||
$value = $this->globals[$name];
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
|
@ -18,7 +18,6 @@ use CodeIgniter\Cookie\CookieStore;
|
||||
use CodeIgniter\HTTP\Exceptions\HTTPException;
|
||||
use Config\App;
|
||||
use Config\Cookie as CookieConfig;
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
* Representation of an outgoing, server-side response.
|
||||
@ -158,7 +157,7 @@ class Response extends Message implements ResponseInterface
|
||||
$this->noCache();
|
||||
|
||||
// We need CSP object even if not enabled to avoid calls to non existing methods
|
||||
$this->CSP = Services::csp();
|
||||
$this->CSP = service('csp');
|
||||
|
||||
$this->cookieStore = new CookieStore([]);
|
||||
|
||||
|
@ -421,7 +421,7 @@ class SiteURI extends URI
|
||||
$relativePath = $this->stringifyRelativePath($relativePath);
|
||||
|
||||
// Check current host.
|
||||
$host = $config === null ? $this->getHost() : null;
|
||||
$host = ! $config instanceof App ? $this->getHost() : null;
|
||||
|
||||
$config ??= config(App::class);
|
||||
|
||||
|
@ -1177,7 +1177,8 @@ class URI implements Stringable
|
||||
parse_str($params, $result);
|
||||
|
||||
foreach ($result as $key => $value) {
|
||||
$return[hex2bin($key)] = $value;
|
||||
// Array key might be int
|
||||
$return[hex2bin((string) $key)] = $value;
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
@ -14,7 +14,6 @@ declare(strict_types=1);
|
||||
namespace CodeIgniter\Log\Handlers;
|
||||
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
* Class ChromeLoggerHandler
|
||||
@ -156,8 +155,8 @@ class ChromeLoggerHandler extends BaseHandler
|
||||
*/
|
||||
public function sendLogs(?ResponseInterface &$response = null)
|
||||
{
|
||||
if ($response === null) {
|
||||
$response = Services::response(null, true);
|
||||
if (! $response instanceof ResponseInterface) {
|
||||
$response = service('response', null, true);
|
||||
}
|
||||
|
||||
$data = base64_encode(
|
||||
|
@ -22,7 +22,6 @@ use CodeIgniter\Router\Exceptions\RouterException;
|
||||
use Config\App;
|
||||
use Config\Modules;
|
||||
use Config\Routing;
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
* @todo Implement nested resource routing (See CakePHP)
|
||||
@ -283,7 +282,7 @@ class RouteCollection implements RouteCollectionInterface
|
||||
$this->fileLocator = $locator;
|
||||
$this->moduleConfig = $moduleConfig;
|
||||
|
||||
$this->httpHost = Services::request()->getServer('HTTP_HOST');
|
||||
$this->httpHost = service('request')->getServer('HTTP_HOST');
|
||||
|
||||
// Setup based on config file. Let routes file override.
|
||||
$this->defaultNamespace = rtrim($routing->defaultNamespace, '\\') . '\\';
|
||||
|
@ -109,14 +109,14 @@ trait ControllerTestTrait
|
||||
$tempUri = service('uri');
|
||||
Services::injectMock('uri', $this->uri);
|
||||
|
||||
$this->withRequest(Services::incomingrequest($this->appConfig, false));
|
||||
$this->withRequest(service('incomingrequest', $this->appConfig, false));
|
||||
|
||||
// Restore the URI service
|
||||
Services::injectMock('uri', $tempUri);
|
||||
}
|
||||
|
||||
if (empty($this->response)) {
|
||||
$this->response = Services::response($this->appConfig, false);
|
||||
$this->response = service('response', $this->appConfig, false);
|
||||
}
|
||||
|
||||
if (empty($this->logger)) {
|
||||
@ -285,7 +285,7 @@ trait ControllerTestTrait
|
||||
Services::injectMock('uri', $this->uri);
|
||||
|
||||
// Update the Request instance, because Request has the SiteURI instance.
|
||||
$this->request = Services::incomingrequest(null, false);
|
||||
$this->request = service('incomingrequest', null, false);
|
||||
Services::injectMock('request', $this->request);
|
||||
|
||||
return $this;
|
||||
|
@ -200,10 +200,10 @@ trait FeatureTestTrait
|
||||
Services::injectMock('request', $request);
|
||||
|
||||
// Make sure filters are reset between tests
|
||||
Services::injectMock('filters', Services::filters(null, false));
|
||||
Services::injectMock('filters', service('filters', null, false));
|
||||
|
||||
// Make sure validation is reset between tests
|
||||
Services::injectMock('validation', Services::validation(null, false));
|
||||
Services::injectMock('validation', service('validation', null, false));
|
||||
|
||||
$response = $this->app
|
||||
->setContext('web')
|
||||
@ -321,7 +321,7 @@ trait FeatureTestTrait
|
||||
|
||||
Services::injectMock('uri', $uri);
|
||||
|
||||
$request = Services::incomingrequest($config, false);
|
||||
$request = service('incomingrequest', $config, false);
|
||||
|
||||
$request->setMethod($method);
|
||||
$request->setProtocolVersion('1.1');
|
||||
|
@ -31,7 +31,8 @@ trait ReflectionHelper
|
||||
* @param object|string $obj object or class name
|
||||
* @param string $method method name
|
||||
*
|
||||
* @return Closure
|
||||
* @return Closure
|
||||
* @phpstan-return Closure(mixed ...$args): mixed
|
||||
*
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
@ -73,7 +74,7 @@ trait ReflectionHelper
|
||||
*
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public static function setPrivateProperty($obj, $property, $value)
|
||||
public static function setPrivateProperty($obj, $property, $value): void
|
||||
{
|
||||
$refProperty = self::getAccessibleRefProperty($obj, $property);
|
||||
|
||||
@ -90,7 +91,7 @@ trait ReflectionHelper
|
||||
* @param object|string $obj object or class name
|
||||
* @param string $property property name
|
||||
*
|
||||
* @return mixed value
|
||||
* @return mixed
|
||||
*
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
|
@ -13,7 +13,6 @@ declare(strict_types=1);
|
||||
|
||||
use CodeIgniter\Boot;
|
||||
use Config\Paths;
|
||||
use Config\Services;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', '1');
|
||||
@ -88,4 +87,4 @@ Boot::bootTest($paths);
|
||||
* ---------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Services::routes()->loadRoutes();
|
||||
service('routes')->loadRoutes();
|
||||
|
@ -23,7 +23,6 @@ use CodeIgniter\HTTP\Method;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\Validation\Exceptions\ValidationException;
|
||||
use CodeIgniter\View\RendererInterface;
|
||||
use Config\Services;
|
||||
use Config\Validation as ValidationConfig;
|
||||
|
||||
/**
|
||||
@ -795,7 +794,7 @@ class Validation implements ValidationInterface
|
||||
$placeholderFields = $this->retrievePlaceholders($row, $data);
|
||||
|
||||
foreach ($placeholderFields as $field) {
|
||||
$validator ??= Services::validation(null, false);
|
||||
$validator ??= service('validation', null, false);
|
||||
assert($validator instanceof Validation);
|
||||
|
||||
$placeholderRules = $rules[$field]['rules'] ?? null;
|
||||
@ -918,26 +917,24 @@ class Validation implements ValidationInterface
|
||||
): string {
|
||||
$param ??= '';
|
||||
|
||||
$args = [
|
||||
'field' => ($label === null || $label === '') ? $field : lang($label),
|
||||
'param' => (! isset($this->rules[$param]['label'])) ? $param : lang($this->rules[$param]['label']),
|
||||
'value' => $value ?? '',
|
||||
];
|
||||
|
||||
// Check if custom message has been defined by user
|
||||
if (isset($this->customErrors[$field][$rule])) {
|
||||
$message = lang($this->customErrors[$field][$rule]);
|
||||
} elseif (null !== $originalField && isset($this->customErrors[$originalField][$rule])) {
|
||||
$message = lang($this->customErrors[$originalField][$rule]);
|
||||
} else {
|
||||
// Try to grab a localized version of the message...
|
||||
// lang() will return the rule name back if not found,
|
||||
// so there will always be a string being returned.
|
||||
$message = lang('Validation.' . $rule);
|
||||
return lang($this->customErrors[$field][$rule], $args);
|
||||
}
|
||||
if (null !== $originalField && isset($this->customErrors[$originalField][$rule])) {
|
||||
return lang($this->customErrors[$originalField][$rule], $args);
|
||||
}
|
||||
|
||||
$message = str_replace('{field}', ($label === null || $label === '') ? $field : lang($label), $message);
|
||||
$message = str_replace(
|
||||
'{param}',
|
||||
(! isset($this->rules[$param]['label'])) ? $param : lang($this->rules[$param]['label']),
|
||||
$message
|
||||
);
|
||||
|
||||
return str_replace('{value}', $value ?? '', $message);
|
||||
// Try to grab a localized version of the message...
|
||||
// lang() will return the rule name back if not found,
|
||||
// so there will always be a string being returned.
|
||||
return lang('Validation.' . $rule, $args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,6 @@ use CodeIgniter\Cache\CacheInterface;
|
||||
use CodeIgniter\Config\Factories;
|
||||
use CodeIgniter\View\Cells\Cell as BaseCell;
|
||||
use CodeIgniter\View\Exceptions\ViewException;
|
||||
use Config\Services;
|
||||
use ReflectionException;
|
||||
use ReflectionMethod;
|
||||
|
||||
@ -93,7 +92,7 @@ class Cell
|
||||
}
|
||||
|
||||
if (method_exists($instance, 'initController')) {
|
||||
$instance->initController(Services::request(), service('response'), service('logger'));
|
||||
$instance->initController(service('request'), service('response'), service('logger'));
|
||||
}
|
||||
|
||||
if (! method_exists($instance, $method)) {
|
||||
|
@ -87,7 +87,7 @@ final class ResponseTraitTest extends CIUnitTestCase
|
||||
$config = $this->createAppConfig();
|
||||
$this->createCookieConfig();
|
||||
|
||||
if ($this->request === null) {
|
||||
if (! $this->request instanceof MockIncomingRequest) {
|
||||
$this->request = new MockIncomingRequest(
|
||||
$config,
|
||||
new SiteURI($config, $routePath),
|
||||
|
@ -22,7 +22,6 @@ use CodeIgniter\Test\CIUnitTestCase;
|
||||
use CodeIgniter\Test\ReflectionHelper;
|
||||
use Config\Autoload;
|
||||
use Config\Modules;
|
||||
use Config\Services;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\PreserveGlobalState;
|
||||
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
|
||||
@ -112,17 +111,21 @@ final class AutoloaderTest extends CIUnitTestCase
|
||||
|
||||
public function testServiceAutoLoaderFromShareInstances(): void
|
||||
{
|
||||
$classLoader = $this->getPrivateMethodInvoker(Services::autoloader(), 'loadInNamespace');
|
||||
$classLoader = $this->getPrivateMethodInvoker(service('autoloader'), 'loadInNamespace');
|
||||
|
||||
// look for Home controller, as that should be in base repo
|
||||
$actual = $classLoader(Home::class);
|
||||
$expected = APPPATH . 'Controllers' . DIRECTORY_SEPARATOR . 'Home.php';
|
||||
$this->assertSame($expected, realpath($actual) ?: $actual);
|
||||
|
||||
$resolvedPath = realpath($actual);
|
||||
$actual = $resolvedPath !== false ? $resolvedPath : $actual;
|
||||
|
||||
$this->assertSame($expected, $actual);
|
||||
}
|
||||
|
||||
public function testServiceAutoLoader(): void
|
||||
{
|
||||
$autoloader = Services::autoloader(false);
|
||||
$autoloader = service('autoloader', false);
|
||||
$autoloader->initialize(new Autoload(), new Modules());
|
||||
$autoloader->register();
|
||||
|
||||
@ -131,7 +134,11 @@ final class AutoloaderTest extends CIUnitTestCase
|
||||
// look for Home controller, as that should be in base repo
|
||||
$actual = $classLoader(Home::class);
|
||||
$expected = APPPATH . 'Controllers' . DIRECTORY_SEPARATOR . 'Home.php';
|
||||
$this->assertSame($expected, realpath($actual) ?: $actual);
|
||||
|
||||
$resolvedPath = realpath($actual);
|
||||
$actual = $resolvedPath !== false ? $resolvedPath : $actual;
|
||||
|
||||
$this->assertSame($expected, $actual);
|
||||
|
||||
$autoloader->unregister();
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ use PHPUnit\Framework\Attributes\Group;
|
||||
final class FileLocatorCachedTest extends FileLocatorTest
|
||||
{
|
||||
private FileVarExportHandler $handler;
|
||||
protected FileLocatorInterface $locator;
|
||||
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
|
@ -27,6 +27,9 @@ use PHPUnit\Framework\Attributes\Group;
|
||||
#[Group('Others')]
|
||||
class FileLocatorTest extends CIUnitTestCase
|
||||
{
|
||||
/**
|
||||
* @var FileLocator|FileLocatorCached
|
||||
*/
|
||||
protected FileLocatorInterface $locator;
|
||||
|
||||
protected function setUp(): void
|
||||
|
@ -30,14 +30,12 @@ final class ConsoleTest extends CIUnitTestCase
|
||||
{
|
||||
use StreamFilterTrait;
|
||||
|
||||
private DotEnv $env;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->env = new DotEnv(ROOTPATH);
|
||||
$this->env->load();
|
||||
$env = new DotEnv(ROOTPATH);
|
||||
$env->load();
|
||||
|
||||
// Set environment values that would otherwise stop the framework from functioning during tests.
|
||||
if (! isset($_SERVER['app.baseURL'])) {
|
||||
|
@ -25,8 +25,6 @@ use PHPUnit\Framework\Attributes\Group;
|
||||
#[Group('CacheLive')]
|
||||
final class MemcachedHandlerTest extends AbstractHandlerTestCase
|
||||
{
|
||||
private Cache $config;
|
||||
|
||||
private static function getKeyArray()
|
||||
{
|
||||
return [
|
||||
@ -44,9 +42,9 @@ final class MemcachedHandlerTest extends AbstractHandlerTestCase
|
||||
$this->markTestSkipped('Memcached extension not loaded.');
|
||||
}
|
||||
|
||||
$this->config = new Cache();
|
||||
$config = new Cache();
|
||||
|
||||
$this->handler = new MemcachedHandler($this->config);
|
||||
$this->handler = new MemcachedHandler($config);
|
||||
|
||||
$this->handler->initialize();
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ use Tests\Support\Filters\RedirectFilter;
|
||||
final class CodeIgniterTest extends CIUnitTestCase
|
||||
{
|
||||
private CodeIgniter $codeigniter;
|
||||
protected $routes;
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
protected function setUp(): void
|
||||
@ -58,7 +57,7 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
|
||||
$this->codeigniter = new MockCodeIgniter(new App());
|
||||
|
||||
$response = Services::response();
|
||||
$response = service('response');
|
||||
$response->pretend();
|
||||
}
|
||||
|
||||
@ -110,11 +109,11 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->add('pages/(:segment)', static function ($segment): void {
|
||||
echo 'You want to see "' . esc($segment) . '" page.';
|
||||
});
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -134,10 +133,10 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->setAutoRoute(false);
|
||||
$routes->set404Override('Tests\Support\Errors::show404');
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -154,10 +153,10 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['argc'] = 2;
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->setAutoRoute(false);
|
||||
$routes->set404Override('Tests\Support\Controllers\Popcorn::pop');
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
$response = $this->codeigniter->run($routes, true);
|
||||
@ -172,10 +171,10 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['argc'] = 2;
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->setAutoRoute(false);
|
||||
$routes->set404Override('Tests\Support\Controllers\Popcorn::pop');
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
$response = $this->codeigniter->run($routes, true);
|
||||
@ -189,12 +188,12 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['argc'] = 2;
|
||||
|
||||
// Inject mock router.
|
||||
$routes = new RouteCollection(Services::locator(), new Modules(), new Routing());
|
||||
$routes = new RouteCollection(service('locator'), new Modules(), new Routing());
|
||||
$routes->setAutoRoute(false);
|
||||
$routes->set404Override(static function (): void {
|
||||
echo '404 Override by Closure.';
|
||||
});
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -214,12 +213,12 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->add(
|
||||
'pages/(:segment)',
|
||||
static fn ($segment) => 'You want to see "' . esc($segment) . '" page.'
|
||||
);
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -238,14 +237,14 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->add('pages/(:segment)', static function ($segment) {
|
||||
$response = Services::response();
|
||||
$response = service('response');
|
||||
$string = "You want to see 'about' page.";
|
||||
|
||||
return $response->setBody($string);
|
||||
});
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -267,13 +266,13 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->add('pages/(:segment)', static function ($segment) {
|
||||
$response = Services::response();
|
||||
$response = service('response');
|
||||
|
||||
return $response->download('some.txt', 'some text', true);
|
||||
});
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -292,14 +291,14 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->add(
|
||||
'pages/about',
|
||||
static fn () => Services::incomingrequest()->getBody(),
|
||||
static fn () => service('incomingrequest')->getBody(),
|
||||
['filter' => Customfilter::class]
|
||||
);
|
||||
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -319,15 +318,15 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['REQUEST_URI'] = '/pages/about';
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->add(
|
||||
'pages/about',
|
||||
static fn () => Services::incomingrequest()->getBody(),
|
||||
static fn () => service('incomingrequest')->getBody(),
|
||||
// Set filter with no argument.
|
||||
['filter' => 'test-customfilter']
|
||||
);
|
||||
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
/** @var FiltersConfig $filterConfig */
|
||||
@ -338,7 +337,7 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
'before' => ['pages/*'],
|
||||
],
|
||||
];
|
||||
Services::filters($filterConfig);
|
||||
service('filters', $filterConfig);
|
||||
|
||||
ob_start();
|
||||
$this->codeigniter->run();
|
||||
@ -358,13 +357,13 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->add(
|
||||
'pages/about',
|
||||
static fn () => Services::incomingrequest()->getBody(),
|
||||
static fn () => service('incomingrequest')->getBody(),
|
||||
['filter' => Customfilter::class]
|
||||
);
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -382,7 +381,7 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['argv'] = ['index.php', '/'];
|
||||
$_SERVER['argc'] = 2;
|
||||
|
||||
$response = Services::response(null, false);
|
||||
$response = service('response', null, false);
|
||||
|
||||
$this->assertInstanceOf(Response::class, $response);
|
||||
}
|
||||
@ -393,7 +392,7 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['argc'] = 2;
|
||||
|
||||
// Inject mock router.
|
||||
$router = Services::router(null, Services::incomingrequest(), false);
|
||||
$router = service('router', null, service('incomingrequest'), false);
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -482,12 +481,12 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->add('pages/named', static function (): void {
|
||||
}, ['as' => 'name']);
|
||||
$routes->addRedirect('example', 'name');
|
||||
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -506,12 +505,12 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->add('pages/uri', static function (): void {
|
||||
});
|
||||
$routes->addRedirect('example', 'pages/uri');
|
||||
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -535,11 +534,11 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
// addRedirect() sets status code 302 by default.
|
||||
$routes->addRedirect('example', 'pages/notset');
|
||||
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -562,10 +561,10 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->addRedirect('example', 'pages/notset', 301);
|
||||
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -587,10 +586,10 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->addRedirect('example', 'pages/notset', 301);
|
||||
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -610,12 +609,12 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['argc'] = 2;
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->get('/', static function (): never {
|
||||
throw new RedirectException('redirect-exception', 503);
|
||||
});
|
||||
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
$response = $this->codeigniter->run($routes, true);
|
||||
@ -630,7 +629,7 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['argc'] = 2;
|
||||
|
||||
// Inject mock router.
|
||||
$router = Services::router(null, Services::incomingrequest(), false);
|
||||
$router = service('router', null, service('incomingrequest'), false);
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -652,10 +651,10 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->addRedirect('example', 'pages/notset', 301);
|
||||
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -674,13 +673,13 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->add('image', static function () {
|
||||
$response = Services::response();
|
||||
$response = service('response');
|
||||
|
||||
return $response->setContentType('image/jpeg', '');
|
||||
});
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
ob_start();
|
||||
@ -717,7 +716,7 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'CLI';
|
||||
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->cli('cli', '\Tests\Support\Controllers\Popcorn::index');
|
||||
|
||||
ob_start();
|
||||
@ -739,7 +738,7 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
|
||||
$_POST['_method'] = Method::PUT;
|
||||
|
||||
$routes = \Config\Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->setDefaultNamespace('App\Controllers');
|
||||
$routes->resetRoutes();
|
||||
$routes->post('/', 'Home::index');
|
||||
@ -749,7 +748,7 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$this->codeigniter->run();
|
||||
ob_get_clean();
|
||||
|
||||
$this->assertSame(Method::PUT, Services::incomingrequest()->getMethod());
|
||||
$this->assertSame(Method::PUT, service('incomingrequest')->getMethod());
|
||||
}
|
||||
|
||||
public function testSpoofRequestMethodCannotUseGET(): void
|
||||
@ -764,7 +763,7 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
|
||||
$_POST['_method'] = 'GET';
|
||||
|
||||
$routes = \Config\Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->setDefaultNamespace('App\Controllers');
|
||||
$routes->resetRoutes();
|
||||
$routes->post('/', 'Home::index');
|
||||
@ -774,7 +773,7 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$this->codeigniter->run();
|
||||
ob_get_clean();
|
||||
|
||||
$this->assertSame('POST', Services::incomingrequest()->getMethod());
|
||||
$this->assertSame('POST', service('incomingrequest')->getMethod());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -793,22 +792,22 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['REQUEST_URI'] = '/test';
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->add('test', static function () {
|
||||
CodeIgniter::cache(3600);
|
||||
|
||||
$response = Services::response();
|
||||
$response = service('response');
|
||||
$string = 'This is a test page. Elapsed time: {elapsed_time}';
|
||||
|
||||
return $response->setBody($string);
|
||||
});
|
||||
$router = Services::router($routes, Services::incomingrequest());
|
||||
$router = service('router', $routes, service('incomingrequest'));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
/** @var FiltersConfig $filterConfig */
|
||||
$filterConfig = config('Filters');
|
||||
$filterConfig->globals['after'] = ['secureheaders'];
|
||||
Services::filters($filterConfig);
|
||||
service('filters', $filterConfig);
|
||||
|
||||
// The first response to be cached.
|
||||
ob_start();
|
||||
@ -816,7 +815,7 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$output = ob_get_clean();
|
||||
|
||||
$this->assertStringContainsString('This is a test page', $output);
|
||||
$response = Services::response();
|
||||
$response = service('response');
|
||||
$headers = $response->headers();
|
||||
$this->assertArrayHasKey('X-Frame-Options', $headers);
|
||||
|
||||
@ -826,7 +825,7 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$output = ob_get_clean();
|
||||
|
||||
$this->assertStringContainsString('This is a test page', $output);
|
||||
$response = Services::response();
|
||||
$response = service('response');
|
||||
$headers = $response->headers();
|
||||
$this->assertArrayHasKey('X-Frame-Options', $headers);
|
||||
|
||||
@ -872,18 +871,18 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
$this->codeigniter = new MockCodeIgniter(new App());
|
||||
|
||||
$routes = Services::routes(true);
|
||||
$routes = service('routes', true);
|
||||
$routePath = explode('?', $testingUrl)[0];
|
||||
$string = 'This is a test page, to check cache configuration';
|
||||
$routes->add($routePath, static function () use ($string) {
|
||||
Services::responsecache()->setTtl(60);
|
||||
$response = Services::response();
|
||||
service('responsecache')->setTtl(60);
|
||||
$response = service('response');
|
||||
|
||||
return $response->setBody($string);
|
||||
});
|
||||
|
||||
// Inject router
|
||||
$router = Services::router($routes, Services::incomingrequest(null, false));
|
||||
$router = service('router', $routes, service('incomingrequest', null, false));
|
||||
Services::injectMock('router', $router);
|
||||
|
||||
// Cache the page output using default caching function and $cacheConfig
|
||||
@ -956,14 +955,14 @@ final class CodeIgniterTest extends CIUnitTestCase
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
// Inject mock router.
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->setAutoRoute(true);
|
||||
|
||||
// Inject the before filter.
|
||||
$filterConfig = config('Filters');
|
||||
$filterConfig->aliases['redirectFilter'] = RedirectFilter::class;
|
||||
$filterConfig->globals['before'] = ['redirectFilter'];
|
||||
Services::filters($filterConfig);
|
||||
service('filters', $filterConfig);
|
||||
|
||||
$this->expectException(PageNotFoundException::class);
|
||||
|
||||
|
@ -15,7 +15,6 @@ namespace CodeIgniter\Commands;
|
||||
|
||||
use CodeIgniter\Log\Logger;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use Config\Services;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Tests\Support\Commands\AppInfo;
|
||||
|
||||
@ -30,7 +29,7 @@ final class BaseCommandTest extends CIUnitTestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->logger = Services::logger();
|
||||
$this->logger = service('logger');
|
||||
}
|
||||
|
||||
public function testMagicIssetTrue(): void
|
||||
|
@ -17,7 +17,6 @@ use CodeIgniter\CLI\Commands;
|
||||
use CodeIgniter\Log\Logger;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use CodeIgniter\Test\StreamFilterTrait;
|
||||
use Config\Services;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Tests\Support\Commands\ParamsReveal;
|
||||
@ -39,8 +38,8 @@ final class CommandTest extends CIUnitTestCase
|
||||
|
||||
parent::setUp();
|
||||
|
||||
$this->logger = Services::logger();
|
||||
$this->commands = Services::commands();
|
||||
$this->logger = service('logger');
|
||||
$this->commands = service('commands');
|
||||
}
|
||||
|
||||
protected function getBuffer(): string
|
||||
|
@ -47,7 +47,7 @@ final class RoutesTest extends CIUnitTestCase
|
||||
|
||||
private function getCleanRoutes(): RouteCollection
|
||||
{
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->resetRoutes();
|
||||
$routes->loadRoutes();
|
||||
|
||||
@ -246,7 +246,7 @@ final class RoutesTest extends CIUnitTestCase
|
||||
|
||||
public function testRoutesCommandRouteWithRegexp(): void
|
||||
{
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->resetRoutes();
|
||||
$routes->options('picker/(.+)', 'Options::index');
|
||||
|
||||
|
@ -17,7 +17,6 @@ use CodeIgniter\Test\CIUnitTestCase;
|
||||
use CodeIgniter\Test\StreamFilterTrait;
|
||||
use Config\Autoload;
|
||||
use Config\Modules;
|
||||
use Config\Services;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
|
||||
/**
|
||||
@ -31,7 +30,7 @@ final class ScaffoldGeneratorTest extends CIUnitTestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->resetServices();
|
||||
Services::autoloader()->initialize(new Autoload(), new Modules());
|
||||
service('autoloader')->initialize(new Autoload(), new Modules());
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ namespace CodeIgniter\Commands\Translation;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use CodeIgniter\Test\StreamFilterTrait;
|
||||
use Config\App;
|
||||
use Config\Services;
|
||||
use Locale;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
|
||||
@ -68,7 +67,7 @@ final class LocalizationFinderTest extends CIUnitTestCase
|
||||
self::$locale = 'test_locale_incorrect';
|
||||
$this->makeLocaleDirectory();
|
||||
|
||||
$status = Services::commands()->run('lang:find', [
|
||||
$status = service('commands')->run('lang:find', [
|
||||
'dir' => 'Translation',
|
||||
'locale' => self::$locale,
|
||||
]);
|
||||
@ -89,7 +88,7 @@ final class LocalizationFinderTest extends CIUnitTestCase
|
||||
{
|
||||
$this->makeLocaleDirectory();
|
||||
|
||||
$status = Services::commands()->run('lang:find', [
|
||||
$status = service('commands')->run('lang:find', [
|
||||
'dir' => 'Translation/NotExistFolder',
|
||||
]);
|
||||
|
||||
|
@ -16,7 +16,6 @@ namespace CodeIgniter\Commands\Utilities;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use CodeIgniter\Test\StreamFilterTrait;
|
||||
use Config\App;
|
||||
use Config\Services;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
|
||||
/**
|
||||
@ -74,7 +73,7 @@ final class ConfigCheckTest extends CIUnitTestCase
|
||||
|
||||
public function testGetKintD(): void
|
||||
{
|
||||
$command = new ConfigCheck(Services::logger(), Services::commands());
|
||||
$command = new ConfigCheck(service('logger'), service('commands'));
|
||||
$getKintD = $this->getPrivateMethodInvoker($command, 'getKintD');
|
||||
|
||||
$output = $getKintD(new App());
|
||||
@ -114,7 +113,7 @@ final class ConfigCheckTest extends CIUnitTestCase
|
||||
|
||||
public function testGetVarDump(): void
|
||||
{
|
||||
$command = new ConfigCheck(Services::logger(), Services::commands());
|
||||
$command = new ConfigCheck(service('logger'), service('commands'));
|
||||
$getVarDump = $this->getPrivateMethodInvoker($command, 'getVarDump');
|
||||
|
||||
$output = $getVarDump(new App());
|
||||
|
@ -16,7 +16,6 @@ namespace CodeIgniter\Commands\Utilities\Routes\AutoRouterImproved;
|
||||
use CodeIgniter\HTTP\Method;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use Config\Filters;
|
||||
use Config\Services;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
|
||||
/**
|
||||
@ -34,7 +33,7 @@ final class AutoRouteCollectorTest extends CIUnitTestCase
|
||||
|
||||
private function createAutoRouteCollector(array $filterConfigFilters): AutoRouteCollector
|
||||
{
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->resetRoutes();
|
||||
$routes->setAutoRoute(true);
|
||||
config('Feature')->autoRoutesImproved = true;
|
||||
@ -44,7 +43,7 @@ final class AutoRouteCollectorTest extends CIUnitTestCase
|
||||
/** @var Filters $filterConfig */
|
||||
$filterConfig = config('Filters');
|
||||
$filterConfig->filters = $filterConfigFilters;
|
||||
Services::filters($filterConfig);
|
||||
service('filters', $filterConfig);
|
||||
|
||||
return new AutoRouteCollector(
|
||||
$namespace,
|
||||
|
@ -15,7 +15,6 @@ namespace CodeIgniter\Commands\Utilities\Routes;
|
||||
|
||||
use CodeIgniter\HTTP\Method;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use Config\Services;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
|
||||
/**
|
||||
@ -26,7 +25,7 @@ final class FilterCollectorTest extends CIUnitTestCase
|
||||
{
|
||||
public function testGet(): void
|
||||
{
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->resetRoutes();
|
||||
$routes->setDefaultNamespace('App\Controllers');
|
||||
$routes->get('/', 'Home::index');
|
||||
|
@ -13,7 +13,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CodeIgniter\Commands\Utilities\Routes;
|
||||
|
||||
use CodeIgniter\Config\Services;
|
||||
use CodeIgniter\Filters\CSRF;
|
||||
use CodeIgniter\Filters\DebugToolbar;
|
||||
use CodeIgniter\Filters\Filters;
|
||||
@ -47,8 +46,8 @@ final class FilterFinderTest extends CIUnitTestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->request = Services::request();
|
||||
$this->response = Services::response();
|
||||
$this->request = service('request');
|
||||
$this->response = service('response');
|
||||
|
||||
$this->moduleConfig = new Modules();
|
||||
$this->moduleConfig->enabled = false;
|
||||
@ -56,7 +55,7 @@ final class FilterFinderTest extends CIUnitTestCase
|
||||
|
||||
private function createRouteCollection(array $routes = []): RouteCollection
|
||||
{
|
||||
$collection = new RouteCollection(Services::locator(), $this->moduleConfig, new Routing());
|
||||
$collection = new RouteCollection(service('locator'), $this->moduleConfig, new Routing());
|
||||
|
||||
$routes = ($routes !== []) ? $routes : [
|
||||
'users' => 'Users::index',
|
||||
|
@ -13,7 +13,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CodeIgniter\Commands\Utilities\Routes;
|
||||
|
||||
use CodeIgniter\Config\Services;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
@ -49,7 +48,7 @@ final class SampleURIGeneratorTest extends CIUnitTestCase
|
||||
|
||||
public function testGetFromPlaceholderCustomPlaceholder(): void
|
||||
{
|
||||
$routes = Services::routes();
|
||||
$routes = service('routes');
|
||||
$routes->addPlaceholder(
|
||||
'uuid',
|
||||
'[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
|
||||
|
@ -630,11 +630,11 @@ final class CommonFunctionsTest extends CIUnitTestCase
|
||||
#[WithoutErrorHandler]
|
||||
public function testForceHttpsNullRequestAndResponse(): void
|
||||
{
|
||||
$this->assertNull(Services::response()->header('Location'));
|
||||
$this->assertNull(service('response')->header('Location'));
|
||||
|
||||
Services::response()->setCookie('force', 'cookie');
|
||||
Services::response()->setHeader('Force', 'header');
|
||||
Services::response()->setBody('default body');
|
||||
service('response')->setCookie('force', 'cookie');
|
||||
service('response')->setHeader('Force', 'header');
|
||||
service('response')->setBody('default body');
|
||||
|
||||
try {
|
||||
force_https();
|
||||
@ -726,7 +726,7 @@ final class CommonFunctionsTest extends CIUnitTestCase
|
||||
$config->CSPEnabled = true;
|
||||
|
||||
// Initialize Kint
|
||||
Services::autoloader()->initializeKint(CI_DEBUG);
|
||||
service('autoloader')->initializeKint(CI_DEBUG);
|
||||
|
||||
$cliDetection = Kint::$cli_detection;
|
||||
Kint::$cli_detection = false;
|
||||
@ -750,7 +750,7 @@ final class CommonFunctionsTest extends CIUnitTestCase
|
||||
$config->CSPEnabled = true;
|
||||
|
||||
// Initialize Kint
|
||||
Services::autoloader()->initializeKint(CI_DEBUG);
|
||||
service('autoloader')->initializeKint(CI_DEBUG);
|
||||
|
||||
Kint::$cli_detection = false;
|
||||
|
||||
|
@ -82,7 +82,7 @@ final class CommonHelperTest extends CIUnitTestCase
|
||||
private function getMockLocator()
|
||||
{
|
||||
return $this->getMockBuilder(FileLocator::class)
|
||||
->setConstructorArgs([Services::autoloader()])
|
||||
->setConstructorArgs([service('autoloader')])
|
||||
->onlyMethods(['search'])
|
||||
->getMock();
|
||||
}
|
||||
@ -90,7 +90,7 @@ final class CommonHelperTest extends CIUnitTestCase
|
||||
public function testHelperWithFatalLocatorThrowsException(): void
|
||||
{
|
||||
// Replace the locator with one that will fail if it is called
|
||||
$locator = new FatalLocator(Services::autoloader());
|
||||
$locator = new FatalLocator(service('autoloader'));
|
||||
Services::injectMock('locator', $locator);
|
||||
|
||||
try {
|
||||
@ -109,7 +109,7 @@ final class CommonHelperTest extends CIUnitTestCase
|
||||
helper('baguette');
|
||||
|
||||
// Replace the locator with one that will fail if it is called
|
||||
$locator = new FatalLocator(Services::autoloader());
|
||||
$locator = new FatalLocator(service('autoloader'));
|
||||
Services::injectMock('locator', $locator);
|
||||
|
||||
try {
|
||||
|
@ -48,7 +48,7 @@ final class CommonSingleServiceTest extends CIUnitTestCase
|
||||
{
|
||||
if ($service === 'commands') {
|
||||
$locator = $this->getMockBuilder(FileLocator::class)
|
||||
->setConstructorArgs([Services::autoloader()])
|
||||
->setConstructorArgs([service('autoloader')])
|
||||
->onlyMethods(['listFiles'])
|
||||
->getMock();
|
||||
|
||||
|
@ -32,7 +32,6 @@ use TypeError;
|
||||
final class DotEnvTest extends CIUnitTestCase
|
||||
{
|
||||
private ?vfsStreamDirectory $root;
|
||||
private string $path;
|
||||
private string $fixturesFolder;
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
@ -42,8 +41,8 @@ final class DotEnvTest extends CIUnitTestCase
|
||||
|
||||
$this->root = vfsStream::setup();
|
||||
$this->fixturesFolder = $this->root->url();
|
||||
$this->path = TESTPATH . 'system/Config/fixtures';
|
||||
vfsStream::copyFromFileSystem($this->path, $this->root);
|
||||
$path = TESTPATH . 'system/Config/fixtures';
|
||||
vfsStream::copyFromFileSystem($path, $this->root);
|
||||
|
||||
$file = 'unreadable.env';
|
||||
$path = rtrim($this->fixturesFolder, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file;
|
||||
|
@ -217,7 +217,7 @@ final class ServicesTest extends CIUnitTestCase
|
||||
|
||||
public function testNewToolbar(): void
|
||||
{
|
||||
$actual = Services::toolbar(null);
|
||||
$actual = service('toolbar', null);
|
||||
$this->assertInstanceOf(Toolbar::class, $actual);
|
||||
}
|
||||
|
||||
@ -409,7 +409,7 @@ final class ServicesTest extends CIUnitTestCase
|
||||
|
||||
public function testFormat(): void
|
||||
{
|
||||
$this->assertInstanceOf(Format::class, Services::format());
|
||||
$this->assertInstanceOf(Format::class, service('format'));
|
||||
}
|
||||
|
||||
public function testUnsharedFormat(): void
|
||||
|
@ -23,7 +23,6 @@ use CodeIgniter\HTTP\UserAgent;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use CodeIgniter\Validation\Exceptions\ValidationException;
|
||||
use Config\App;
|
||||
use Config\Services;
|
||||
use Config\Validation as ValidationConfig;
|
||||
use PHPUnit\Framework\Attributes\BackupGlobals;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
@ -40,7 +39,6 @@ use Psr\Log\LoggerInterface;
|
||||
#[Group('Others')]
|
||||
final class ControllerTest extends CIUnitTestCase
|
||||
{
|
||||
private App $config;
|
||||
private ?Controller $controller = null;
|
||||
|
||||
/**
|
||||
@ -59,10 +57,10 @@ final class ControllerTest extends CIUnitTestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->config = new App();
|
||||
$this->request = new IncomingRequest($this->config, new SiteURI($this->config), null, new UserAgent());
|
||||
$this->response = new Response($this->config);
|
||||
$this->logger = Services::logger();
|
||||
$config = new App();
|
||||
$this->request = new IncomingRequest($config, new SiteURI($config), null, new UserAgent());
|
||||
$this->response = new Response($config);
|
||||
$this->logger = service('logger');
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
@ -150,7 +148,7 @@ final class ControllerTest extends CIUnitTestCase
|
||||
|
||||
$method = $this->getPrivateMethodInvoker($this->controller, 'validate');
|
||||
$this->assertFalse($method('signup'));
|
||||
$this->assertSame('You must choose a username.', Services::validation()->getError('username'));
|
||||
$this->assertSame('You must choose a username.', service('validation')->getError('username'));
|
||||
}
|
||||
|
||||
public function testValidateWithStringRulesFoundUseMessagesParameter(): void
|
||||
@ -175,7 +173,7 @@ final class ControllerTest extends CIUnitTestCase
|
||||
'required' => 'You must choose a username.',
|
||||
],
|
||||
]));
|
||||
$this->assertSame('You must choose a username.', Services::validation()->getError('username'));
|
||||
$this->assertSame('You must choose a username.', service('validation')->getError('username'));
|
||||
}
|
||||
|
||||
public function testValidateData(): void
|
||||
@ -197,7 +195,7 @@ final class ControllerTest extends CIUnitTestCase
|
||||
$this->assertFalse($method($data, $rule));
|
||||
$this->assertSame(
|
||||
'The password field must be at least 10 characters in length.',
|
||||
Services::validation()->getError('password')
|
||||
service('validation')->getError('password')
|
||||
);
|
||||
}
|
||||
|
||||
@ -226,11 +224,11 @@ final class ControllerTest extends CIUnitTestCase
|
||||
$this->assertFalse($method($data, $rules, $errors));
|
||||
$this->assertSame(
|
||||
'"username" must be 3 letters or longer.',
|
||||
Services::validation()->getError('username')
|
||||
service('validation')->getError('username')
|
||||
);
|
||||
$this->assertSame(
|
||||
'The password field must be at least 10 characters in length.',
|
||||
Services::validation()->getError('password')
|
||||
service('validation')->getError('password')
|
||||
);
|
||||
}
|
||||
|
||||
@ -264,11 +262,11 @@ final class ControllerTest extends CIUnitTestCase
|
||||
$this->assertFalse($method($data, $rules));
|
||||
$this->assertSame(
|
||||
'"Username" must be 3 letters or longer.',
|
||||
Services::validation()->getError('username')
|
||||
service('validation')->getError('username')
|
||||
);
|
||||
$this->assertSame(
|
||||
'The Password field must be at least 10 characters in length.',
|
||||
Services::validation()->getError('password')
|
||||
service('validation')->getError('password')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ namespace CodeIgniter\Database\DatabaseTestCase;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use CodeIgniter\Test\DatabaseTestTrait;
|
||||
use Config\Database;
|
||||
use Config\Services;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
|
||||
/**
|
||||
@ -68,7 +67,7 @@ final class DatabaseTestCaseMigrationOnce1Test extends CIUnitTestCase
|
||||
|
||||
protected function setUpAddNamespace(): void
|
||||
{
|
||||
Services::autoloader()->addNamespace(
|
||||
service('autoloader')->addNamespace(
|
||||
'Tests\Support\MigrationTestMigrations',
|
||||
SUPPORTPATH . 'MigrationTestMigrations'
|
||||
);
|
||||
|
@ -16,7 +16,6 @@ namespace CodeIgniter\Database\DatabaseTestCase;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use CodeIgniter\Test\DatabaseTestTrait;
|
||||
use Config\Database;
|
||||
use Config\Services;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
|
||||
/**
|
||||
@ -68,7 +67,7 @@ final class DatabaseTestCaseMigrationOnce2Test extends CIUnitTestCase
|
||||
|
||||
protected function setUpAddNamespace(): void
|
||||
{
|
||||
Services::autoloader()->addNamespace(
|
||||
service('autoloader')->addNamespace(
|
||||
'Tests\Support\MigrationTestMigrations',
|
||||
SUPPORTPATH . 'MigrationTestMigrations'
|
||||
);
|
||||
|
@ -16,7 +16,6 @@ namespace CodeIgniter\Database;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use CodeIgniter\Test\DatabaseTestTrait;
|
||||
use Config\Database;
|
||||
use Config\Services;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Tests\Support\Database\Seeds\AnotherSeeder;
|
||||
use Tests\Support\Database\Seeds\CITestSeeder;
|
||||
@ -73,7 +72,7 @@ final class DatabaseTestCaseTest extends CIUnitTestCase
|
||||
|
||||
protected function setUpAddNamespace(): void
|
||||
{
|
||||
Services::autoloader()->addNamespace(
|
||||
service('autoloader')->addNamespace(
|
||||
'Tests\Support\MigrationTestMigrations',
|
||||
SUPPORTPATH . 'MigrationTestMigrations'
|
||||
);
|
||||
|
@ -278,15 +278,15 @@ final class ForgeTest extends CIUnitTestCase
|
||||
|
||||
$fieldsData = $this->db->getFieldData('forge_test_table');
|
||||
if ($this->db->DBDriver === 'MySQLi') {
|
||||
$this->assertSame(strtolower($fieldsData[0]->type), 'bigint');
|
||||
$this->assertSame('bigint', strtolower($fieldsData[0]->type));
|
||||
} elseif ($this->db->DBDriver === 'Postgre') {
|
||||
$this->assertSame(strtolower($fieldsData[0]->type), 'bigint');
|
||||
$this->assertSame('bigint', strtolower($fieldsData[0]->type));
|
||||
} elseif ($this->db->DBDriver === 'SQLite3') {
|
||||
$this->assertSame(strtolower($fieldsData[0]->type), 'integer');
|
||||
$this->assertSame('integer', strtolower($fieldsData[0]->type));
|
||||
} elseif ($this->db->DBDriver === 'OCI8') {
|
||||
$this->assertSame(strtolower($fieldsData[0]->type), 'number');
|
||||
$this->assertSame('number', strtolower($fieldsData[0]->type));
|
||||
} elseif ($this->db->DBDriver === 'SQLSRV') {
|
||||
$this->assertSame(strtolower($fieldsData[0]->type), 'bigint');
|
||||
$this->assertSame('bigint', strtolower($fieldsData[0]->type));
|
||||
}
|
||||
|
||||
$this->forge->dropTable('forge_test_table', true);
|
||||
@ -1166,65 +1166,65 @@ final class ForgeTest extends CIUnitTestCase
|
||||
$keys = $this->db->getIndexData('forge_test_1');
|
||||
|
||||
if ($this->db->DBDriver === 'MySQLi') {
|
||||
$this->assertSame($keys['PRIMARY']->name, 'PRIMARY');
|
||||
$this->assertSame('PRIMARY', $keys['PRIMARY']->name);
|
||||
$this->assertSame($keys['PRIMARY']->fields, ['id']);
|
||||
$this->assertSame($keys['PRIMARY']->type, 'PRIMARY');
|
||||
$this->assertSame('PRIMARY', $keys['PRIMARY']->type);
|
||||
|
||||
$this->assertSame($keys['code_company']->name, 'code_company');
|
||||
$this->assertSame('code_company', $keys['code_company']->name);
|
||||
$this->assertSame($keys['code_company']->fields, ['code', 'company']);
|
||||
$this->assertSame($keys['code_company']->type, 'INDEX');
|
||||
$this->assertSame('INDEX', $keys['code_company']->type);
|
||||
|
||||
$this->assertSame($keys['code_active']->name, 'code_active');
|
||||
$this->assertSame('code_active', $keys['code_active']->name);
|
||||
$this->assertSame($keys['code_active']->fields, ['code', 'active']);
|
||||
$this->assertSame($keys['code_active']->type, 'UNIQUE');
|
||||
$this->assertSame('UNIQUE', $keys['code_active']->type);
|
||||
} elseif ($this->db->DBDriver === 'Postgre') {
|
||||
$this->assertSame($keys['pk_db_forge_test_1']->name, 'pk_db_forge_test_1');
|
||||
$this->assertSame('pk_db_forge_test_1', $keys['pk_db_forge_test_1']->name);
|
||||
$this->assertSame($keys['pk_db_forge_test_1']->fields, ['id']);
|
||||
$this->assertSame($keys['pk_db_forge_test_1']->type, 'PRIMARY');
|
||||
$this->assertSame('PRIMARY', $keys['pk_db_forge_test_1']->type);
|
||||
|
||||
$this->assertSame($keys['db_forge_test_1_code_company']->name, 'db_forge_test_1_code_company');
|
||||
$this->assertSame('db_forge_test_1_code_company', $keys['db_forge_test_1_code_company']->name);
|
||||
$this->assertSame($keys['db_forge_test_1_code_company']->fields, ['code', 'company']);
|
||||
$this->assertSame($keys['db_forge_test_1_code_company']->type, 'INDEX');
|
||||
$this->assertSame('INDEX', $keys['db_forge_test_1_code_company']->type);
|
||||
|
||||
$this->assertSame($keys['db_forge_test_1_code_active']->name, 'db_forge_test_1_code_active');
|
||||
$this->assertSame('db_forge_test_1_code_active', $keys['db_forge_test_1_code_active']->name);
|
||||
$this->assertSame($keys['db_forge_test_1_code_active']->fields, ['code', 'active']);
|
||||
$this->assertSame($keys['db_forge_test_1_code_active']->type, 'UNIQUE');
|
||||
$this->assertSame('UNIQUE', $keys['db_forge_test_1_code_active']->type);
|
||||
} elseif ($this->db->DBDriver === 'SQLite3') {
|
||||
$this->assertSame($keys['PRIMARY']->name, 'PRIMARY');
|
||||
$this->assertSame('PRIMARY', $keys['PRIMARY']->name);
|
||||
$this->assertSame($keys['PRIMARY']->fields, ['id']);
|
||||
$this->assertSame($keys['PRIMARY']->type, 'PRIMARY');
|
||||
$this->assertSame('PRIMARY', $keys['PRIMARY']->type);
|
||||
|
||||
$this->assertSame($keys['db_forge_test_1_code_company']->name, 'db_forge_test_1_code_company');
|
||||
$this->assertSame('db_forge_test_1_code_company', $keys['db_forge_test_1_code_company']->name);
|
||||
$this->assertSame($keys['db_forge_test_1_code_company']->fields, ['code', 'company']);
|
||||
$this->assertSame($keys['db_forge_test_1_code_company']->type, 'INDEX');
|
||||
$this->assertSame('INDEX', $keys['db_forge_test_1_code_company']->type);
|
||||
|
||||
$this->assertSame($keys['db_forge_test_1_code_active']->name, 'db_forge_test_1_code_active');
|
||||
$this->assertSame('db_forge_test_1_code_active', $keys['db_forge_test_1_code_active']->name);
|
||||
$this->assertSame($keys['db_forge_test_1_code_active']->fields, ['code', 'active']);
|
||||
$this->assertSame($keys['db_forge_test_1_code_active']->type, 'UNIQUE');
|
||||
$this->assertSame('UNIQUE', $keys['db_forge_test_1_code_active']->type);
|
||||
} elseif ($this->db->DBDriver === 'SQLSRV') {
|
||||
$this->assertSame($keys['pk_db_forge_test_1']->name, 'pk_db_forge_test_1');
|
||||
$this->assertSame('pk_db_forge_test_1', $keys['pk_db_forge_test_1']->name);
|
||||
$this->assertSame($keys['pk_db_forge_test_1']->fields, ['id']);
|
||||
$this->assertSame($keys['pk_db_forge_test_1']->type, 'PRIMARY');
|
||||
$this->assertSame('PRIMARY', $keys['pk_db_forge_test_1']->type);
|
||||
|
||||
$this->assertSame($keys['db_forge_test_1_code_company']->name, 'db_forge_test_1_code_company');
|
||||
$this->assertSame('db_forge_test_1_code_company', $keys['db_forge_test_1_code_company']->name);
|
||||
$this->assertSame($keys['db_forge_test_1_code_company']->fields, ['code', 'company']);
|
||||
$this->assertSame($keys['db_forge_test_1_code_company']->type, 'INDEX');
|
||||
$this->assertSame('INDEX', $keys['db_forge_test_1_code_company']->type);
|
||||
|
||||
$this->assertSame($keys['db_forge_test_1_code_active']->name, 'db_forge_test_1_code_active');
|
||||
$this->assertSame('db_forge_test_1_code_active', $keys['db_forge_test_1_code_active']->name);
|
||||
$this->assertSame($keys['db_forge_test_1_code_active']->fields, ['code', 'active']);
|
||||
$this->assertSame($keys['db_forge_test_1_code_active']->type, 'UNIQUE');
|
||||
$this->assertSame('UNIQUE', $keys['db_forge_test_1_code_active']->type);
|
||||
} elseif ($this->db->DBDriver === 'OCI8') {
|
||||
$this->assertSame($keys['pk_db_forge_test_1']->name, 'pk_db_forge_test_1');
|
||||
$this->assertSame('pk_db_forge_test_1', $keys['pk_db_forge_test_1']->name);
|
||||
$this->assertSame($keys['pk_db_forge_test_1']->fields, ['id']);
|
||||
$this->assertSame($keys['pk_db_forge_test_1']->type, 'PRIMARY');
|
||||
$this->assertSame('PRIMARY', $keys['pk_db_forge_test_1']->type);
|
||||
|
||||
$this->assertSame($keys['db_forge_test_1_code_company']->name, 'db_forge_test_1_code_company');
|
||||
$this->assertSame('db_forge_test_1_code_company', $keys['db_forge_test_1_code_company']->name);
|
||||
$this->assertSame($keys['db_forge_test_1_code_company']->fields, ['code', 'company']);
|
||||
$this->assertSame($keys['db_forge_test_1_code_company']->type, 'INDEX');
|
||||
$this->assertSame('INDEX', $keys['db_forge_test_1_code_company']->type);
|
||||
|
||||
$this->assertSame($keys['db_forge_test_1_code_active']->name, 'db_forge_test_1_code_active');
|
||||
$this->assertSame('db_forge_test_1_code_active', $keys['db_forge_test_1_code_active']->name);
|
||||
$this->assertSame($keys['db_forge_test_1_code_active']->fields, ['code', 'active']);
|
||||
$this->assertSame($keys['db_forge_test_1_code_active']->type, 'UNIQUE');
|
||||
$this->assertSame('UNIQUE', $keys['db_forge_test_1_code_active']->type);
|
||||
}
|
||||
|
||||
$this->forge->dropTable('forge_test_1', true);
|
||||
|
@ -55,7 +55,7 @@ final class CallStoredProcedureTest extends CIUnitTestCase
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertSame($result, '7');
|
||||
$this->assertSame('7', $result);
|
||||
}
|
||||
|
||||
public function testCallStoredProcedure(): void
|
||||
@ -77,7 +77,7 @@ final class CallStoredProcedureTest extends CIUnitTestCase
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertSame($result, '7');
|
||||
$this->assertSame('7', $result);
|
||||
}
|
||||
|
||||
public function testCallStoredProcedureForCursor(): void
|
||||
|
@ -58,7 +58,7 @@ final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase
|
||||
$fields = $this->db->getFieldData($this->table);
|
||||
|
||||
$idDefault = $this->getFieldMetaData('id', $this->table)->default;
|
||||
$this->assertMatchesRegularExpression('/"ORACLE"."ISEQ\$\$_[0-9]+".nextval/', $idDefault);
|
||||
$this->assertMatchesRegularExpression('/"ORACLE"."ISEQ\$\$_\d+".nextval/', $idDefault);
|
||||
|
||||
$expected = [
|
||||
(object) [
|
||||
|
@ -49,7 +49,7 @@ final class LastInsertIDTest extends CIUnitTestCase
|
||||
$this->db->table('job')->insert($jobData);
|
||||
$actual = $this->db->insertID();
|
||||
|
||||
$this->assertSame($actual, 5);
|
||||
$this->assertSame(5, $actual);
|
||||
}
|
||||
|
||||
public function testGetInsertIDWithQuery(): void
|
||||
@ -57,7 +57,7 @@ final class LastInsertIDTest extends CIUnitTestCase
|
||||
$this->db->query('INSERT INTO "db_job" ("name", "description") VALUES (?, ?)', ['Grocery Sales', 'Discount!']);
|
||||
$actual = $this->db->insertID();
|
||||
|
||||
$this->assertSame($actual, 5);
|
||||
$this->assertSame(5, $actual);
|
||||
}
|
||||
|
||||
public function testGetInsertIDWithHasCommentQuery(): void
|
||||
@ -73,7 +73,7 @@ final class LastInsertIDTest extends CIUnitTestCase
|
||||
$this->db->query($sql, ['Discount!']);
|
||||
$actual = $this->db->insertID();
|
||||
|
||||
$this->assertSame($actual, 5);
|
||||
$this->assertSame(5, $actual);
|
||||
}
|
||||
|
||||
public function testGetInsertIDWithPreparedQuery(): void
|
||||
@ -87,6 +87,6 @@ final class LastInsertIDTest extends CIUnitTestCase
|
||||
$query->execute('foo', 'bar');
|
||||
$actual = $this->db->insertID();
|
||||
|
||||
$this->assertSame($actual, 5);
|
||||
$this->assertSame(5, $actual);
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ use CodeIgniter\Test\CIUnitTestCase;
|
||||
use CodeIgniter\Test\DatabaseTestTrait;
|
||||
use Config\Database;
|
||||
use Config\Migrations;
|
||||
use Config\Services;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use org\bovigo\vfs\vfsStreamDirectory;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
@ -60,7 +59,7 @@ final class MigrationRunnerTest extends CIUnitTestCase
|
||||
|
||||
protected function setUpAddNamespace(): void
|
||||
{
|
||||
Services::autoloader()->addNamespace(
|
||||
service('autoloader')->addNamespace(
|
||||
'Tests\Support\MigrationTestMigrations',
|
||||
SUPPORTPATH . 'MigrationTestMigrations'
|
||||
);
|
||||
|
@ -49,6 +49,6 @@ final class RawSqlTest extends CIUnitTestCase
|
||||
|
||||
$key = $rawSql->getBindingKey();
|
||||
|
||||
$this->assertMatchesRegularExpression('/\ARawSql[0-9]+\z/', $key);
|
||||
$this->assertMatchesRegularExpression('/\ARawSql\d+\z/', $key);
|
||||
}
|
||||
}
|
||||
|
@ -107,8 +107,8 @@ final class ExceptionHandlerTest extends CIUnitTestCase
|
||||
{
|
||||
$exception = PageNotFoundException::forControllerNotFound('Foo', 'bar');
|
||||
|
||||
$request = Services::incomingrequest(null, false);
|
||||
$response = Services::response(null, false);
|
||||
$request = service('incomingrequest', null, false);
|
||||
$response = service('response', null, false);
|
||||
$response->pretend();
|
||||
|
||||
ob_start();
|
||||
@ -126,9 +126,9 @@ final class ExceptionHandlerTest extends CIUnitTestCase
|
||||
{
|
||||
$exception = PageNotFoundException::forControllerNotFound('Foo', 'bar');
|
||||
|
||||
$request = Services::incomingrequest(null, false);
|
||||
$request = service('incomingrequest', null, false);
|
||||
$request->setHeader('accept', 'text/html');
|
||||
$response = Services::response(null, false);
|
||||
$response = service('response', null, false);
|
||||
$response->pretend();
|
||||
|
||||
ob_start();
|
||||
@ -144,7 +144,7 @@ final class ExceptionHandlerTest extends CIUnitTestCase
|
||||
|
||||
$request = Services::clirequest(null, false);
|
||||
$request->setHeader('accept', 'text/html');
|
||||
$response = Services::response(null, false);
|
||||
$response = service('response', null, false);
|
||||
$response->pretend();
|
||||
|
||||
$this->handler->handle($exception, $request, $response, 404, EXIT_ERROR);
|
||||
|
@ -647,6 +647,6 @@ final class FileCollectionTest extends CIUnitTestCase
|
||||
$count++;
|
||||
}
|
||||
|
||||
$this->assertSame($count, 5);
|
||||
$this->assertSame(5, $count);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ final class FileWithVfsTest extends CIUnitTestCase
|
||||
{
|
||||
// For VFS stuff
|
||||
private ?vfsStreamDirectory $root = null;
|
||||
private string $path;
|
||||
private string $start;
|
||||
private File $file;
|
||||
|
||||
@ -35,8 +34,8 @@ final class FileWithVfsTest extends CIUnitTestCase
|
||||
parent::setUp();
|
||||
|
||||
$this->root = vfsStream::setup();
|
||||
$this->path = '_support/Files/';
|
||||
vfsStream::copyFromFileSystem(TESTPATH . $this->path, $this->root);
|
||||
$path = '_support/Files/';
|
||||
vfsStream::copyFromFileSystem(TESTPATH . $path, $this->root);
|
||||
$this->start = $this->root->url() . '/';
|
||||
$this->file = new File($this->start . 'able/apple.php');
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ final class CSRFTest extends CIUnitTestCase
|
||||
];
|
||||
|
||||
$this->request = Services::clirequest(null, false);
|
||||
$this->response = Services::response();
|
||||
$this->response = service('response');
|
||||
|
||||
$filters = new Filters($this->config, $this->request, $this->response);
|
||||
$uri = 'admin/foo/bar';
|
||||
@ -68,8 +68,8 @@ final class CSRFTest extends CIUnitTestCase
|
||||
'after' => [],
|
||||
];
|
||||
|
||||
$this->request = Services::incomingrequest(null, false);
|
||||
$this->response = Services::response();
|
||||
$this->request = service('incomingrequest', null, false);
|
||||
$this->response = service('response');
|
||||
|
||||
$filters = new Filters($this->config, $this->request, $this->response);
|
||||
$uri = 'admin/foo/bar';
|
||||
|
@ -22,7 +22,6 @@ use CodeIgniter\HTTP\SiteURI;
|
||||
use CodeIgniter\HTTP\UserAgent;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use CodeIgniter\Test\Mock\MockAppConfig;
|
||||
use Config\Services;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
|
||||
/**
|
||||
@ -145,10 +144,10 @@ final class CorsTest extends CIUnitTestCase
|
||||
return $response;
|
||||
}
|
||||
|
||||
$response ??= Services::response();
|
||||
$response ??= service('response');
|
||||
|
||||
$response = $this->cors->after($request, $response);
|
||||
$response ??= Services::response();
|
||||
$response ??= service('response');
|
||||
|
||||
$this->response = $response;
|
||||
|
||||
|
@ -13,9 +13,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace CodeIgniter\Filters;
|
||||
|
||||
use CodeIgniter\Config\Services;
|
||||
use CodeIgniter\HTTP\CLIRequest;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\Response;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use Config\Filters as FilterConfig;
|
||||
@ -32,7 +32,7 @@ final class DebugToolbarTest extends CIUnitTestCase
|
||||
/**
|
||||
* @var CLIRequest|IncomingRequest
|
||||
*/
|
||||
private $request;
|
||||
private RequestInterface $request;
|
||||
|
||||
private Response $response;
|
||||
|
||||
@ -40,8 +40,8 @@ final class DebugToolbarTest extends CIUnitTestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->request = Services::request();
|
||||
$this->response = Services::response();
|
||||
$this->request = service('request');
|
||||
$this->response = service('response');
|
||||
}
|
||||
|
||||
public function testDebugToolbarFilter(): void
|
||||
|
@ -13,7 +13,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CodeIgniter\Filters;
|
||||
|
||||
use CodeIgniter\Config\Services;
|
||||
use CodeIgniter\Filters\Exceptions\FilterException;
|
||||
use CodeIgniter\Filters\fixtures\GoogleCurious;
|
||||
use CodeIgniter\Filters\fixtures\GoogleEmpty;
|
||||
@ -65,16 +64,16 @@ final class FiltersTest extends CIUnitTestCase
|
||||
'App' => APPPATH,
|
||||
'Tests\Support' => TESTPATH . '_support',
|
||||
];
|
||||
Services::autoloader()->addNamespace($defaults);
|
||||
service('autoloader')->addNamespace($defaults);
|
||||
|
||||
$_SERVER = [];
|
||||
|
||||
$this->response = Services::response();
|
||||
$this->response = service('response');
|
||||
}
|
||||
|
||||
private function createFilters(FiltersConfig $config, $request = null): Filters
|
||||
{
|
||||
$request ??= Services::incomingrequest();
|
||||
$request ??= service('request');
|
||||
|
||||
return new Filters($config, $request, $this->response);
|
||||
}
|
||||
|
@ -13,10 +13,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace CodeIgniter\Filters;
|
||||
|
||||
use CodeIgniter\Config\Services;
|
||||
use CodeIgniter\Honeypot\Exceptions\HoneypotException;
|
||||
use CodeIgniter\HTTP\CLIRequest;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\Response;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use Config\Honeypot;
|
||||
@ -37,9 +37,9 @@ final class HoneypotTest extends CIUnitTestCase
|
||||
private Honeypot $honey;
|
||||
|
||||
/**
|
||||
* @var CLIRequest|IncomingRequest|null
|
||||
* @var CLIRequest|IncomingRequest
|
||||
*/
|
||||
private $request;
|
||||
private RequestInterface $request;
|
||||
|
||||
private ?Response $response = null;
|
||||
|
||||
@ -62,8 +62,8 @@ final class HoneypotTest extends CIUnitTestCase
|
||||
'after' => [],
|
||||
];
|
||||
|
||||
$this->request = Services::request(null, false);
|
||||
$this->response = Services::response();
|
||||
$this->request = service('request', null, false);
|
||||
$this->response = service('response');
|
||||
|
||||
$filters = new Filters($this->config, $this->request, $this->response);
|
||||
$uri = 'admin/foo/bar';
|
||||
@ -80,8 +80,8 @@ final class HoneypotTest extends CIUnitTestCase
|
||||
];
|
||||
|
||||
unset($_POST[$this->honey->name]);
|
||||
$this->request = Services::request(null, false);
|
||||
$this->response = Services::response();
|
||||
$this->request = service('request', null, false);
|
||||
$this->response = service('response');
|
||||
|
||||
$expected = $this->request;
|
||||
|
||||
@ -101,8 +101,8 @@ final class HoneypotTest extends CIUnitTestCase
|
||||
'after' => ['honeypot'],
|
||||
];
|
||||
|
||||
$this->request = Services::request(null, false);
|
||||
$this->response = Services::response();
|
||||
$this->request = service('request', null, false);
|
||||
$this->response = service('response');
|
||||
|
||||
$filters = new Filters($this->config, $this->request, $this->response);
|
||||
$uri = 'admin/foo/bar';
|
||||
@ -121,8 +121,8 @@ final class HoneypotTest extends CIUnitTestCase
|
||||
'after' => ['honeypot'],
|
||||
];
|
||||
|
||||
$this->request = Services::request(null, false);
|
||||
$this->response = Services::response();
|
||||
$this->request = service('request', null, false);
|
||||
$this->response = service('response');
|
||||
|
||||
$filters = new Filters($this->config, $this->request, $this->response);
|
||||
$uri = 'admin/foo/bar';
|
||||
|
@ -13,7 +13,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CodeIgniter\Filters;
|
||||
|
||||
use CodeIgniter\Config\Services;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
|
||||
@ -26,8 +25,8 @@ final class SecureHeadersTest extends CIUnitTestCase
|
||||
public function testAfter(): void
|
||||
{
|
||||
$filter = new SecureHeaders();
|
||||
$request = Services::request(null, false);
|
||||
$response = Services::response(null, false);
|
||||
$request = service('request', null, false);
|
||||
$response = service('response', null, false);
|
||||
|
||||
$filter->after($request, $response);
|
||||
|
||||
|
@ -13,7 +13,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CodeIgniter\Filters\fixtures;
|
||||
|
||||
use CodeIgniter\Config\Services;
|
||||
use CodeIgniter\Filters\FilterInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
@ -22,7 +21,7 @@ class GoogleYou implements FilterInterface
|
||||
{
|
||||
public function before(RequestInterface $request, $arguments = null)
|
||||
{
|
||||
$response = Services::response();
|
||||
$response = service('response');
|
||||
$response->setBody('http://google.com');
|
||||
|
||||
return $response;
|
||||
|
@ -14,7 +14,6 @@ declare(strict_types=1);
|
||||
namespace CodeIgniter\HTTP;
|
||||
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use Config\Services;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
|
||||
/**
|
||||
@ -41,7 +40,7 @@ final class CorsTest extends CIUnitTestCase
|
||||
|
||||
private function createRequest(): IncomingRequest
|
||||
{
|
||||
return Services::incomingrequest(null, false);
|
||||
return service('incomingrequest', null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,7 +102,7 @@ final class CorsTest extends CIUnitTestCase
|
||||
->setHeader('Access-Control-Request-Method', 'PUT')
|
||||
->setHeader('Origin', 'http://localhost:8080');
|
||||
|
||||
$response = Services::response(null, false);
|
||||
$response = service('response', null, false);
|
||||
|
||||
$response = $cors->handlePreflightRequest($request, $response);
|
||||
|
||||
@ -138,7 +137,7 @@ final class CorsTest extends CIUnitTestCase
|
||||
->setHeader('Access-Control-Request-Method', 'PUT')
|
||||
->setHeader('Origin', 'https://api.example.com');
|
||||
|
||||
$response = Services::response(null, false);
|
||||
$response = service('response', null, false);
|
||||
|
||||
$response = $cors->handlePreflightRequest($request, $response);
|
||||
|
||||
@ -175,7 +174,7 @@ final class CorsTest extends CIUnitTestCase
|
||||
->setHeader('Access-Control-Request-Method', 'PUT')
|
||||
->setHeader('Origin', 'https://api.example.com');
|
||||
|
||||
$response = Services::response(null, false)
|
||||
$response = service('response', null, false)
|
||||
->setHeader('Vary', 'Accept-Language');
|
||||
|
||||
$response = $cors->handlePreflightRequest($request, $response);
|
||||
@ -213,7 +212,7 @@ final class CorsTest extends CIUnitTestCase
|
||||
->setHeader('Access-Control-Request-Method', 'PUT')
|
||||
->setHeader('Origin', 'https://bad.site.com');
|
||||
|
||||
$response = Services::response(null, false);
|
||||
$response = service('response', null, false);
|
||||
|
||||
$response = $cors->handlePreflightRequest($request, $response);
|
||||
|
||||
@ -239,7 +238,7 @@ final class CorsTest extends CIUnitTestCase
|
||||
->setHeader('Access-Control-Request-Method', 'PUT')
|
||||
->setHeader('Origin', 'https://api.example.com');
|
||||
|
||||
$response = Services::response(null, false);
|
||||
$response = service('response', null, false);
|
||||
|
||||
$response = $cors->handlePreflightRequest($request, $response);
|
||||
|
||||
@ -276,7 +275,7 @@ final class CorsTest extends CIUnitTestCase
|
||||
->setHeader('Access-Control-Request-Method', 'PUT')
|
||||
->setHeader('Origin', 'https://bad.site.com');
|
||||
|
||||
$response = Services::response(null, false);
|
||||
$response = service('response', null, false);
|
||||
|
||||
$response = $cors->handlePreflightRequest($request, $response);
|
||||
|
||||
@ -303,7 +302,7 @@ final class CorsTest extends CIUnitTestCase
|
||||
->setHeader('Access-Control-Request-Method', 'PUT')
|
||||
->setHeader('Origin', 'http://localhost:8080');
|
||||
|
||||
$response = Services::response(null, false);
|
||||
$response = service('response', null, false);
|
||||
|
||||
$response = $cors->handlePreflightRequest($request, $response);
|
||||
|
||||
@ -340,7 +339,7 @@ final class CorsTest extends CIUnitTestCase
|
||||
->withMethod('GET')
|
||||
->setHeader('Origin', 'http://localhost:8080');
|
||||
|
||||
$response = Services::response(null, false);
|
||||
$response = service('response', null, false);
|
||||
|
||||
$response = $cors->addResponseHeaders($request, $response);
|
||||
|
||||
@ -371,7 +370,7 @@ final class CorsTest extends CIUnitTestCase
|
||||
->withMethod('POST')
|
||||
->setHeader('Origin', 'http://localhost:8080');
|
||||
|
||||
$response = Services::response(null, false);
|
||||
$response = service('response', null, false);
|
||||
|
||||
$response = $cors->addResponseHeaders($request, $response);
|
||||
|
||||
@ -395,7 +394,7 @@ final class CorsTest extends CIUnitTestCase
|
||||
->setHeader('Cookie', 'pageAccess=2')
|
||||
->setHeader('Origin', 'http://localhost:8080');
|
||||
|
||||
$response = Services::response(null, false);
|
||||
$response = service('response', null, false);
|
||||
|
||||
$response = $cors->addResponseHeaders($request, $response);
|
||||
|
||||
@ -423,7 +422,7 @@ final class CorsTest extends CIUnitTestCase
|
||||
->withMethod('GET')
|
||||
->setHeader('Origin', 'http://localhost:8080');
|
||||
|
||||
$response = Services::response(null, false);
|
||||
$response = service('response', null, false);
|
||||
|
||||
$response = $cors->addResponseHeaders($request, $response);
|
||||
|
||||
@ -449,7 +448,7 @@ final class CorsTest extends CIUnitTestCase
|
||||
->withMethod('PUT')
|
||||
->setHeader('Origin', 'https://api.example.com');
|
||||
|
||||
$response = Services::response(null, false);
|
||||
$response = service('response', null, false);
|
||||
|
||||
$response = $cors->addResponseHeaders($request, $response);
|
||||
|
||||
@ -481,7 +480,7 @@ final class CorsTest extends CIUnitTestCase
|
||||
->withMethod('PUT')
|
||||
->setHeader('Origin', 'https://api.example.com');
|
||||
|
||||
$response = Services::response(null, false)
|
||||
$response = service('response', null, false)
|
||||
->setHeader('Vary', 'Accept-Language');
|
||||
|
||||
$response = $cors->addResponseHeaders($request, $response);
|
||||
@ -508,7 +507,7 @@ final class CorsTest extends CIUnitTestCase
|
||||
->withMethod('PUT')
|
||||
->setHeader('Origin', 'https://bad.site.com');
|
||||
|
||||
$response = Services::response(null, false);
|
||||
$response = service('response', null, false);
|
||||
|
||||
$response = $cors->addResponseHeaders($request, $response);
|
||||
|
||||
|
@ -148,12 +148,25 @@ final class DownloadResponseTest extends CIUnitTestCase
|
||||
$this->assertSame('private, no-transform, no-store, must-revalidate', $response->getHeaderLine('Cache-control'));
|
||||
}
|
||||
|
||||
public function testCantSetCache(): void
|
||||
public function testSetCache(): void
|
||||
{
|
||||
$response = new DownloadResponse('unit-test.txt', true);
|
||||
|
||||
$this->expectException(DownloadException::class);
|
||||
$response->setCache();
|
||||
$date = date('r');
|
||||
|
||||
$options = [
|
||||
'etag' => '12345678',
|
||||
'last-modified' => $date,
|
||||
'max-age' => 300,
|
||||
'must-revalidate',
|
||||
];
|
||||
|
||||
$response->setCache($options);
|
||||
$response->buildHeaders();
|
||||
|
||||
$this->assertSame('12345678', $response->getHeaderLine('ETag'));
|
||||
$this->assertSame($date, $response->getHeaderLine('Last-Modified'));
|
||||
$this->assertSame('max-age=300, must-revalidate', $response->getHeaderLine('Cache-Control'));
|
||||
}
|
||||
|
||||
public function testWhenFilepathIsSetBinaryCanNotBeSet(): void
|
||||
@ -200,30 +213,53 @@ final class DownloadResponseTest extends CIUnitTestCase
|
||||
$this->assertSame($size, $response->getContentLength());
|
||||
}
|
||||
|
||||
public function testIsSetDownloadableHeadlersFromBinary(): void
|
||||
public function testIsSetDownloadableHeadersFromBinary(): void
|
||||
{
|
||||
$response = new DownloadResponse('unit test.txt', false);
|
||||
|
||||
$response->setBinary('test');
|
||||
$response->buildHeaders();
|
||||
|
||||
$this->assertSame('private, no-transform, no-store, must-revalidate', $response->getHeaderLine('Cache-Control'));
|
||||
$this->assertSame('application/octet-stream', $response->getHeaderLine('Content-Type'));
|
||||
$this->assertSame('attachment; filename="unit test.txt"; filename*=UTF-8\'\'unit%20test.txt', $response->getHeaderLine('Content-Disposition'));
|
||||
$this->assertSame('0', $response->getHeaderLine('Expires-Disposition'));
|
||||
$this->assertSame('binary', $response->getHeaderLine('Content-Transfer-Encoding'));
|
||||
$this->assertSame('4', $response->getHeaderLine('Content-Length'));
|
||||
}
|
||||
|
||||
public function testIsSetDownloadableHeadlersFromFile(): void
|
||||
public function testIsSetDownloadableHeadersFromFile(): void
|
||||
{
|
||||
$response = new DownloadResponse('unit-test.php', false);
|
||||
|
||||
$response->setFilePath(__FILE__);
|
||||
$response->buildHeaders();
|
||||
|
||||
$this->assertSame('private, no-transform, no-store, must-revalidate', $response->getHeaderLine('Cache-Control'));
|
||||
$this->assertSame('application/octet-stream', $response->getHeaderLine('Content-Type'));
|
||||
$this->assertSame('attachment; filename="unit-test.php"; filename*=UTF-8\'\'unit-test.php', $response->getHeaderLine('Content-Disposition'));
|
||||
$this->assertSame('binary', $response->getHeaderLine('Content-Transfer-Encoding'));
|
||||
$this->assertSame(filesize(__FILE__), (int) $response->getHeaderLine('Content-Length'));
|
||||
}
|
||||
|
||||
public function testCustomHeaders(): void
|
||||
{
|
||||
$response = new DownloadResponse('unit-test.php', false);
|
||||
|
||||
$response->setFilePath(__FILE__);
|
||||
|
||||
$response->setHeader('Last-Modified', 'Fri, 18 Oct 2024 13:17:37 GMT');
|
||||
$response->setHeader('Expires', 'Sun, 17 Nov 2024 14:17:37 GMT');
|
||||
$response->setHeader('Pragma', 'public');
|
||||
$response->removeHeader('Cache-Control');
|
||||
$response->setHeader('Cache-Control', 'public');
|
||||
$response->buildHeaders();
|
||||
|
||||
$this->assertSame('Fri, 18 Oct 2024 13:17:37 GMT', $response->getHeaderLine('Last-Modified'));
|
||||
$this->assertSame('Sun, 17 Nov 2024 14:17:37 GMT', $response->getHeaderLine('Expires'));
|
||||
$this->assertSame('public', $response->getHeaderLine('Pragma'));
|
||||
$this->assertSame('public', $response->getHeaderLine('Cache-Control'));
|
||||
$this->assertSame('application/octet-stream', $response->getHeaderLine('Content-Type'));
|
||||
$this->assertSame('attachment; filename="unit-test.php"; filename*=UTF-8\'\'unit-test.php', $response->getHeaderLine('Content-Disposition'));
|
||||
$this->assertSame('0', $response->getHeaderLine('Expires-Disposition'));
|
||||
$this->assertSame('binary', $response->getHeaderLine('Content-Transfer-Encoding'));
|
||||
$this->assertSame(filesize(__FILE__), (int) $response->getHeaderLine('Content-Length'));
|
||||
}
|
||||
|
@ -26,8 +26,6 @@ use PHPUnit\Framework\Attributes\Group;
|
||||
final class FileMovingTest extends CIUnitTestCase
|
||||
{
|
||||
private ?vfsStreamDirectory $root;
|
||||
private string $path;
|
||||
private string $start;
|
||||
private string $destination;
|
||||
|
||||
protected function setUp(): void
|
||||
@ -35,11 +33,11 @@ final class FileMovingTest extends CIUnitTestCase
|
||||
parent::setUp();
|
||||
|
||||
$this->root = vfsStream::setup();
|
||||
$this->path = '_support/Files/';
|
||||
vfsStream::copyFromFileSystem(TESTPATH . $this->path, $this->root);
|
||||
$this->start = $this->root->url() . '/';
|
||||
$path = '_support/Files/';
|
||||
vfsStream::copyFromFileSystem(TESTPATH . $path, $this->root);
|
||||
$start = $this->root->url() . '/';
|
||||
|
||||
$this->destination = $this->start . 'destination';
|
||||
$this->destination = $start . 'destination';
|
||||
if (is_dir($this->destination)) {
|
||||
rmdir($this->destination);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ final class RedirectExceptionTest extends TestCase
|
||||
public function testResponse(): void
|
||||
{
|
||||
$response = (new RedirectException(
|
||||
Services::response()
|
||||
service('response')
|
||||
->redirect('redirect')
|
||||
->setCookie('cookie', 'value')
|
||||
->setHeader('Redirect-Header', 'value')
|
||||
@ -65,12 +65,12 @@ final class RedirectExceptionTest extends TestCase
|
||||
'The Response object passed to RedirectException does not contain a redirect address.'
|
||||
);
|
||||
|
||||
new RedirectException(Services::response());
|
||||
new RedirectException(service('response'));
|
||||
}
|
||||
|
||||
public function testResponseWithoutStatusCode(): void
|
||||
{
|
||||
$response = (new RedirectException(Services::response()->setHeader('Location', 'location')))->getResponse();
|
||||
$response = (new RedirectException(service('response')->setHeader('Location', 'location')))->getResponse();
|
||||
|
||||
$this->assertSame('location', $response->getHeaderLine('location'));
|
||||
$this->assertSame(302, $response->getStatusCode());
|
||||
@ -82,7 +82,7 @@ final class RedirectExceptionTest extends TestCase
|
||||
|
||||
$uri = 'http://location';
|
||||
$expected = 'INFO - ' . Time::now()->format('Y-m-d') . ' --> REDIRECTED ROUTE at ' . $uri;
|
||||
$response = (new RedirectException(Services::response()->redirect($uri)))->getResponse();
|
||||
$response = (new RedirectException(service('response')->redirect($uri)))->getResponse();
|
||||
|
||||
$logs = TestHandler::getLogs();
|
||||
|
||||
@ -97,7 +97,7 @@ final class RedirectExceptionTest extends TestCase
|
||||
|
||||
$uri = 'http://location';
|
||||
$expected = 'INFO - ' . Time::now()->format('Y-m-d') . ' --> REDIRECTED ROUTE at ' . $uri;
|
||||
$response = (new RedirectException(Services::response()->redirect($uri, 'refresh')))->getResponse();
|
||||
$response = (new RedirectException(service('response')->redirect($uri, 'refresh')))->getResponse();
|
||||
|
||||
$logs = TestHandler::getLogs();
|
||||
|
||||
|
@ -54,7 +54,7 @@ final class RedirectResponseTest extends CIUnitTestCase
|
||||
$this->config = new App();
|
||||
$this->config->baseURL = 'http://example.com/';
|
||||
|
||||
$this->routes = new RouteCollection(Services::locator(), new Modules(), new Routing());
|
||||
$this->routes = new RouteCollection(service('locator'), new Modules(), new Routing());
|
||||
Services::injectMock('routes', $this->routes);
|
||||
|
||||
$this->request = new MockIncomingRequest(
|
||||
@ -237,7 +237,7 @@ final class RedirectResponseTest extends CIUnitTestCase
|
||||
{
|
||||
$_SESSION = [];
|
||||
|
||||
$baseResponse = Services::response();
|
||||
$baseResponse = service('response');
|
||||
$baseResponse->setCookie('foo', 'bar');
|
||||
|
||||
$response = new RedirectResponse(new App());
|
||||
|
@ -196,6 +196,21 @@ final class RequestTest extends CIUnitTestCase
|
||||
$this->assertCount(2, $result['ANNOUNCEMENTS']);
|
||||
}
|
||||
|
||||
public function testFetchGlobalReturnsWithListValues(): void
|
||||
{
|
||||
$post = [
|
||||
0 => ['foo' => 0],
|
||||
1 => ['bar' => 1],
|
||||
2 => ['baz' => 2],
|
||||
];
|
||||
|
||||
$this->request->setGlobal('post', $post);
|
||||
$result = $this->request->fetchGlobal('post');
|
||||
|
||||
$this->assertIsList($result);
|
||||
$this->assertSame($post, $result);
|
||||
}
|
||||
|
||||
public function testFetchGlobalWithArrayTop(): void
|
||||
{
|
||||
$post = [
|
||||
|
@ -203,7 +203,7 @@ final class ResponseCookieTest extends CIUnitTestCase
|
||||
$response->setCookie(['name' => 'bee', 'value' => 'bop', 'expire' => 1000]);
|
||||
$response->deleteCookie('bee');
|
||||
$cookie = $response->getCookie('bee');
|
||||
$this->assertSame($cookie->getExpiresTimestamp(), 0);
|
||||
$this->assertSame(0, $cookie->getExpiresTimestamp());
|
||||
|
||||
// delete cookie with wrong prefix?
|
||||
$config->prefix = 'mine';
|
||||
@ -214,7 +214,7 @@ final class ResponseCookieTest extends CIUnitTestCase
|
||||
$this->assertFalse($cookie->isExpired(), $cookie->getExpiresTimestamp() . ' should be less than ' . time());
|
||||
$response->deleteCookie('bee', '', '', 'mine');
|
||||
$cookie = $response->getCookie('bee');
|
||||
$this->assertSame($cookie->getExpiresTimestamp(), 0);
|
||||
$this->assertSame(0, $cookie->getExpiresTimestamp());
|
||||
|
||||
// delete cookie with wrong domain?
|
||||
$config->domain = '.mine.com';
|
||||
@ -225,7 +225,7 @@ final class ResponseCookieTest extends CIUnitTestCase
|
||||
$this->assertFalse($cookie->isExpired(), $cookie->getExpiresTimestamp() . ' should be less than ' . time());
|
||||
$response->deleteCookie('bees', '.mine.com', '', '');
|
||||
$cookie = $response->getCookie('bees');
|
||||
$this->assertSame($cookie->getExpiresTimestamp(), 0);
|
||||
$this->assertSame(0, $cookie->getExpiresTimestamp());
|
||||
}
|
||||
|
||||
public function testCookieDefaultSetSameSite(): void
|
||||
|
@ -18,7 +18,6 @@ use CodeIgniter\HTTP\Exceptions\HTTPException;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use CodeIgniter\Test\Mock\MockResponse;
|
||||
use Config\App;
|
||||
use Config\Services;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
@ -169,7 +168,7 @@ final class ResponseTest extends CIUnitTestCase
|
||||
$this->resetServices();
|
||||
|
||||
$response = new Response($config);
|
||||
$pager = Services::pager();
|
||||
$pager = service('pager');
|
||||
|
||||
$pager->store('default', 3, 10, 200);
|
||||
$response->setLink($pager);
|
||||
@ -390,7 +389,7 @@ final class ResponseTest extends CIUnitTestCase
|
||||
3,
|
||||
],
|
||||
];
|
||||
$expected = Services::format()->getFormatter('application/json')->format($body);
|
||||
$expected = service('format')->getFormatter('application/json')->format($body);
|
||||
|
||||
$response = new Response(new App());
|
||||
$response->setJSON($body);
|
||||
@ -409,7 +408,7 @@ final class ResponseTest extends CIUnitTestCase
|
||||
3,
|
||||
],
|
||||
];
|
||||
$expected = Services::format()->getFormatter('application/json')->format($body);
|
||||
$expected = service('format')->getFormatter('application/json')->format($body);
|
||||
|
||||
$response = new Response(new App());
|
||||
$response->setBody($body);
|
||||
@ -427,7 +426,7 @@ final class ResponseTest extends CIUnitTestCase
|
||||
3,
|
||||
],
|
||||
];
|
||||
$expected = Services::format()->getFormatter('application/xml')->format($body);
|
||||
$expected = service('format')->getFormatter('application/xml')->format($body);
|
||||
|
||||
$response = new Response(new App());
|
||||
$response->setXML($body);
|
||||
@ -446,7 +445,7 @@ final class ResponseTest extends CIUnitTestCase
|
||||
3,
|
||||
],
|
||||
];
|
||||
$expected = Services::format()->getFormatter('application/xml')->format($body);
|
||||
$expected = service('format')->getFormatter('application/xml')->format($body);
|
||||
|
||||
$response = new Response(new App());
|
||||
$response->setBody($body);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user