@@ -343,7 +342,7 @@
setStatusCode(http_response_code());
?>
diff --git a/phpstan-baseline.php b/phpstan-baseline.php
index 7c0fb2d51540..2e8f42656230 100644
--- a/phpstan-baseline.php
+++ b/phpstan-baseline.php
@@ -18361,12 +18361,6 @@
'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\\.$#',
@@ -18379,18 +18373,6 @@
'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\\(\\)\\.$#',
diff --git a/system/Autoloader/Autoloader.php b/system/Autoloader/Autoloader.php
index 28c183f12552..bba6d3c5cebd 100644
--- a/system/Autoloader/Autoloader.php
+++ b/system/Autoloader/Autoloader.php
@@ -19,7 +19,6 @@
use Config\Autoload;
use Config\Kint as KintConfig;
use Config\Modules;
-use Config\Services;
use InvalidArgumentException;
use Kint;
use Kint\Renderer\CliRenderer;
@@ -537,7 +536,7 @@ private function configureKint(): void
Kint::$plugins = $config->plugins;
}
- $csp = Services::csp();
+ $csp = service('csp');
if ($csp->enabled()) {
RichRenderer::$js_nonce = $csp->getScriptNonce();
RichRenderer::$css_nonce = $csp->getStyleNonce();
diff --git a/system/BaseModel.php b/system/BaseModel.php
index 2b364bdc1917..46bab107218f 100644
--- a/system/BaseModel.php
+++ b/system/BaseModel.php
@@ -26,7 +26,6 @@
use CodeIgniter\Pager\Pager;
use CodeIgniter\Validation\ValidationInterface;
use Config\Feature;
-use Config\Services;
use InvalidArgumentException;
use ReflectionClass;
use ReflectionException;
@@ -1609,7 +1608,7 @@ public function getValidationRules(array $options = []): array
protected function ensureValidation(): void
{
if ($this->validation === null) {
- $this->validation = Services::validation(null, false);
+ $this->validation = service('validation', null, false);
}
}
diff --git a/system/Boot.php b/system/Boot.php
index 54468a5cc192..8b75908ded09 100644
--- a/system/Boot.php
+++ b/system/Boot.php
@@ -246,12 +246,12 @@ protected static function loadAutoloader(): void
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 @@ protected static function checkMissingExtensions(): void
protected static function initializeKint(): void
{
- Services::autoloader()->initializeKint(CI_DEBUG);
+ service('autoloader')->initializeKint(CI_DEBUG);
}
protected static function loadConfigCache(): FactoriesCache
@@ -308,7 +308,7 @@ protected static function loadConfigCache(): FactoriesCache
*/
protected static function initializeCodeIgniter(): CodeIgniter
{
- $app = Config\Services::codeigniter();
+ $app = service('codeigniter');
$app->initialize();
$context = is_cli() ? 'php-cli' : 'web';
$app->setContext($context);
diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php
index 54ca6a5ca97e..236e5b685fff 100644
--- a/system/CLI/CLI.php
+++ b/system/CLI/CLI.php
@@ -14,7 +14,6 @@
namespace CodeIgniter\CLI;
use CodeIgniter\CLI\Exceptions\CLIException;
-use Config\Services;
use InvalidArgumentException;
use Throwable;
@@ -416,7 +415,7 @@ protected static function validate(string $field, string $value, $rules): bool
{
$label = $field;
$field = 'temp';
- $validation = Services::validation(null, false);
+ $validation = service('validation', null, false);
$validation->setRules([
$field => [
'label' => $label,
diff --git a/system/Commands/Utilities/Routes/FilterCollector.php b/system/Commands/Utilities/Routes/FilterCollector.php
index 002a529b953e..b646dcb250a1 100644
--- a/system/Commands/Utilities/Routes/FilterCollector.php
+++ b/system/Commands/Utilities/Routes/FilterCollector.php
@@ -13,7 +13,6 @@
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 @@ public function get(string $method, string $uri): array
];
}
- $request = Services::incomingrequest(null, false);
+ $request = service('incomingrequest', null, false);
$request->setMethod($method);
$router = $this->createRouter($request);
@@ -86,7 +85,7 @@ public function get(string $method, string $uri): array
*/
public function getRequiredFilters(): array
{
- $request = Services::incomingrequest(null, false);
+ $request = service('incomingrequest', null, false);
$request->setMethod(Method::GET);
$router = $this->createRouter($request);
diff --git a/system/Config/Services.php b/system/Config/Services.php
index 28e521df3f0e..c0d5fcc392d2 100644
--- a/system/Config/Services.php
+++ b/system/Config/Services.php
@@ -705,7 +705,7 @@ public static function session(?SessionConfig $config = null, bool $getShared =
// 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();
}
diff --git a/system/Database/MigrationRunner.php b/system/Database/MigrationRunner.php
index 055b8ba6eaf3..cf736171a7cf 100644
--- a/system/Database/MigrationRunner.php
+++ b/system/Database/MigrationRunner.php
@@ -19,7 +19,6 @@
use CodeIgniter\I18n\Time;
use Config\Database;
use Config\Migrations as MigrationsConfig;
-use Config\Services;
use RuntimeException;
use stdClass;
@@ -390,7 +389,7 @@ public function force(string $path, string $namespace, ?string $group = null)
*/
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 @@ public function findMigrations(): array
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 @@ protected function migrationFromFile(string $path, string $namespace)
return false;
}
- $locator = Services::locator(true);
+ $locator = service('locator', true);
$migration = new stdClass();
diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php
index e5f7ecb04881..aa353732c197 100644
--- a/system/Debug/Exceptions.php
+++ b/system/Debug/Exceptions.php
@@ -22,7 +22,6 @@
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 @@ public function exceptionHandler(Throwable $exception)
[$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 @@ public function exceptionHandler(Throwable $exception)
}
}
- $this->response = Services::response();
+ $this->response = service('response');
if (method_exists($this->config, 'handler')) {
// Use new ExceptionHandler
diff --git a/system/Debug/Toolbar.php b/system/Debug/Toolbar.php
index 9f20f987f59c..b939e208fd21 100644
--- a/system/Debug/Toolbar.php
+++ b/system/Debug/Toolbar.php
@@ -25,7 +25,6 @@
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 @@ public function prepare(?RequestInterface $request = null, ?ResponseInterface $r
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 @@ protected function format(string $data, string $format = 'html'): string
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();
diff --git a/system/Debug/Toolbar/Collectors/Logs.php b/system/Debug/Toolbar/Collectors/Logs.php
index 2194526c733e..f36dfb1d12b5 100644
--- a/system/Debug/Toolbar/Collectors/Logs.php
+++ b/system/Debug/Toolbar/Collectors/Logs.php
@@ -13,8 +13,6 @@
namespace CodeIgniter\Debug\Toolbar\Collectors;
-use Config\Services;
-
/**
* Loags collector
*/
@@ -92,6 +90,6 @@ protected function collectLogs()
return $this->data;
}
- return $this->data = Services::logger(true)->logCache ?? [];
+ return $this->data = service('logger', true)->logCache ?? [];
}
}
diff --git a/system/Debug/Toolbar/Collectors/Routes.php b/system/Debug/Toolbar/Collectors/Routes.php
index b6862dcee73c..561399fbf37f 100644
--- a/system/Debug/Toolbar/Collectors/Routes.php
+++ b/system/Debug/Toolbar/Collectors/Routes.php
@@ -14,7 +14,6 @@
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 @@ public function display(): array
*/
public function getBadgeValue(): int
{
- $rawRoutes = Services::routes(true);
+ $rawRoutes = service('routes', true);
return count($rawRoutes->getRoutes());
}
diff --git a/system/Debug/Toolbar/Collectors/Timers.php b/system/Debug/Toolbar/Collectors/Timers.php
index 163c9f5743f0..d450cc5c306a 100644
--- a/system/Debug/Toolbar/Collectors/Timers.php
+++ b/system/Debug/Toolbar/Collectors/Timers.php
@@ -13,8 +13,6 @@
namespace CodeIgniter\Debug\Toolbar\Collectors;
-use Config\Services;
-
/**
* Timers collector
*/
@@ -52,7 +50,7 @@ protected function formatTimelineData(): array
{
$data = [];
- $benchmark = Services::timer(true);
+ $benchmark = service('timer', true);
$rows = $benchmark->getTimers(6);
foreach ($rows as $name => $info) {
diff --git a/system/Exceptions/PageNotFoundException.php b/system/Exceptions/PageNotFoundException.php
index b1af079e3a54..1a3b27a76a87 100644
--- a/system/Exceptions/PageNotFoundException.php
+++ b/system/Exceptions/PageNotFoundException.php
@@ -13,7 +13,6 @@
namespace CodeIgniter\Exceptions;
-use Config\Services;
use OutOfBoundsException;
class PageNotFoundException extends OutOfBoundsException implements ExceptionInterface, HTTPExceptionInterface
@@ -78,7 +77,7 @@ public static function forLocaleNotSupported(string $locale)
*/
private static function lang(string $line, array $args = []): string
{
- $lang = Services::language(null, false);
+ $lang = service('language', null, false);
return $lang->getLine($line, $args);
}
diff --git a/system/Filters/Honeypot.php b/system/Filters/Honeypot.php
index c2fb98c62d60..cdff293aacb4 100644
--- a/system/Filters/Honeypot.php
+++ b/system/Filters/Honeypot.php
@@ -17,7 +17,6 @@
use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
-use Config\Services;
/**
* Honeypot filter
@@ -40,7 +39,7 @@ public function before(RequestInterface $request, $arguments = null)
return;
}
- if (Services::honeypot()->hasContent($request)) {
+ if (service('honeypot')->hasContent($request)) {
throw HoneypotException::isBot();
}
}
diff --git a/system/HTTP/RedirectResponse.php b/system/HTTP/RedirectResponse.php
index 95bfadcd4299..c8c76607b651 100644
--- a/system/HTTP/RedirectResponse.php
+++ b/system/HTTP/RedirectResponse.php
@@ -15,7 +15,6 @@
use CodeIgniter\Cookie\CookieStore;
use CodeIgniter\HTTP\Exceptions\HTTPException;
-use Config\Services;
/**
* Handle a redirect response
@@ -148,7 +147,7 @@ public function with(string $key, $message)
*/
public function withCookies()
{
- $this->cookieStore = new CookieStore(Services::response()->getCookies());
+ $this->cookieStore = new CookieStore(service('response')->getCookies());
return $this;
}
@@ -163,7 +162,7 @@ public function withCookies()
*/
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 {
diff --git a/system/HTTP/Response.php b/system/HTTP/Response.php
index a19fbb5fee14..ac853c3de93b 100644
--- a/system/HTTP/Response.php
+++ b/system/HTTP/Response.php
@@ -18,7 +18,6 @@
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 @@ public function __construct($config) // @phpstan-ignore-line
$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([]);
diff --git a/system/Log/Handlers/ChromeLoggerHandler.php b/system/Log/Handlers/ChromeLoggerHandler.php
index 192f7f2951b8..37c7c0ffeddf 100644
--- a/system/Log/Handlers/ChromeLoggerHandler.php
+++ b/system/Log/Handlers/ChromeLoggerHandler.php
@@ -14,7 +14,6 @@
namespace CodeIgniter\Log\Handlers;
use CodeIgniter\HTTP\ResponseInterface;
-use Config\Services;
/**
* Class ChromeLoggerHandler
@@ -157,7 +156,7 @@ protected function format($object)
public function sendLogs(?ResponseInterface &$response = null)
{
if (! $response instanceof ResponseInterface) {
- $response = Services::response(null, true);
+ $response = service('response', null, true);
}
$data = base64_encode(
diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php
index 231711c48aac..74c34d6ad518 100644
--- a/system/Router/RouteCollection.php
+++ b/system/Router/RouteCollection.php
@@ -21,7 +21,6 @@
use Config\App;
use Config\Modules;
use Config\Routing;
-use Config\Services;
use InvalidArgumentException;
/**
@@ -283,7 +282,7 @@ public function __construct(FileLocatorInterface $locator, Modules $moduleConfig
$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, '\\') . '\\';
diff --git a/system/Test/ControllerTestTrait.php b/system/Test/ControllerTestTrait.php
index ab1a1aef3907..99e9cf330274 100644
--- a/system/Test/ControllerTestTrait.php
+++ b/system/Test/ControllerTestTrait.php
@@ -109,14 +109,14 @@ protected function setUpControllerTestTrait(): void
$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 @@ public function withUri(string $uri)
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;
diff --git a/system/Test/FeatureTestTrait.php b/system/Test/FeatureTestTrait.php
index 0f2467ffd897..a1d492f85fdd 100644
--- a/system/Test/FeatureTestTrait.php
+++ b/system/Test/FeatureTestTrait.php
@@ -200,10 +200,10 @@ public function call(string $method, string $path, ?array $params = null)
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 @@ protected function setupRequest(string $method, ?string $path = null): IncomingR
Services::injectMock('uri', $uri);
- $request = Services::incomingrequest($config, false);
+ $request = service('incomingrequest', $config, false);
$request->setMethod($method);
$request->setProtocolVersion('1.1');
diff --git a/system/Test/bootstrap.php b/system/Test/bootstrap.php
index 4a068a4c97b1..d2b47aaf21fb 100644
--- a/system/Test/bootstrap.php
+++ b/system/Test/bootstrap.php
@@ -13,7 +13,6 @@
use CodeIgniter\Boot;
use Config\Paths;
-use Config\Services;
error_reporting(E_ALL);
ini_set('display_errors', '1');
@@ -88,4 +87,4 @@
* ---------------------------------------------------------------
*/
-Services::routes()->loadRoutes();
+service('routes')->loadRoutes();
diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php
index 66ed1f8e48a3..5eae6b52c9a5 100644
--- a/system/Validation/Validation.php
+++ b/system/Validation/Validation.php
@@ -21,7 +21,6 @@
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\Validation\Exceptions\ValidationException;
use CodeIgniter\View\RendererInterface;
-use Config\Services;
use Config\Validation as ValidationConfig;
use InvalidArgumentException;
use LogicException;
@@ -796,7 +795,7 @@ protected function fillPlaceholders(array $rules, array $data): array
$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;
diff --git a/system/View/Cell.php b/system/View/Cell.php
index 28b249a60e1c..f2801e4194ec 100644
--- a/system/View/Cell.php
+++ b/system/View/Cell.php
@@ -17,7 +17,6 @@
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 @@ public function render(string $library, $params = null, int $ttl = 0, ?string $c
}
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)) {
diff --git a/tests/system/Autoloader/AutoloaderTest.php b/tests/system/Autoloader/AutoloaderTest.php
index 8529d79dc118..d56afbafaf84 100644
--- a/tests/system/Autoloader/AutoloaderTest.php
+++ b/tests/system/Autoloader/AutoloaderTest.php
@@ -20,7 +20,6 @@
use CodeIgniter\Test\ReflectionHelper;
use Config\Autoload;
use Config\Modules;
-use Config\Services;
use InvalidArgumentException;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
@@ -112,7 +111,7 @@ public function testInitializeTwice(): void
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);
@@ -122,7 +121,7 @@ public function testServiceAutoLoaderFromShareInstances(): void
public function testServiceAutoLoader(): void
{
- $autoloader = Services::autoloader(false);
+ $autoloader = service('autoloader', false);
$autoloader->initialize(new Autoload(), new Modules());
$autoloader->register();
diff --git a/tests/system/CodeIgniterTest.php b/tests/system/CodeIgniterTest.php
index 2928777271fd..735aed389552 100644
--- a/tests/system/CodeIgniterTest.php
+++ b/tests/system/CodeIgniterTest.php
@@ -58,7 +58,7 @@ protected function setUp(): void
$this->codeigniter = new MockCodeIgniter(new App());
- $response = Services::response();
+ $response = service('response');
$response->pretend();
}
@@ -110,11 +110,11 @@ public function testRunClosureRoute(): void
$_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();
@@ -131,10 +131,10 @@ public function testRun404Override(): void
$_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();
@@ -151,10 +151,10 @@ public function testRun404OverrideControllerReturnsResponse(): void
$_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);
@@ -169,10 +169,10 @@ public function testRun404OverrideReturnResponse(): void
$_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);
@@ -186,12 +186,12 @@ public function testRun404OverrideByClosure(): void
$_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();
@@ -211,12 +211,12 @@ public function testControllersCanReturnString(): void
$_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();
@@ -235,14 +235,14 @@ public function testControllersCanReturnResponseObject(): void
$_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();
@@ -264,13 +264,13 @@ public function testControllersCanReturnDownloadResponseObject(): void
$_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();
@@ -289,14 +289,14 @@ public function testRunExecuteFilterByClassName(): void
$_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 +319,15 @@ public function testRegisterSameFilterTwiceWithDifferentArgument(): void
$_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 +338,7 @@ public function testRegisterSameFilterTwiceWithDifferentArgument(): void
'before' => ['pages/*'],
],
];
- Services::filters($filterConfig);
+ service('filters', $filterConfig);
$this->codeigniter->run();
@@ -354,13 +354,13 @@ public function testDisableControllerFilters(): void
$_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();
@@ -378,7 +378,7 @@ public function testResponseConfigEmpty(): void
$_SERVER['argv'] = ['index.php', '/'];
$_SERVER['argc'] = 2;
- $response = Services::response(null, false);
+ $response = service('response', null, false);
$this->assertInstanceOf(Response::class, $response);
}
@@ -389,7 +389,7 @@ public function testRoutesIsEmpty(): void
$_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();
@@ -478,12 +478,12 @@ public function testRunRedirectionWithNamed(): void
$_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();
@@ -502,12 +502,12 @@ public function testRunRedirectionWithURI(): void
$_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();
@@ -531,11 +531,11 @@ public function testRunRedirectionWithGET(): void
$_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();
@@ -558,10 +558,10 @@ public function testRunRedirectionWithGETAndHTTPCode301(): void
$_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();
@@ -583,10 +583,10 @@ public function testRunRedirectionWithPOSTAndHTTPCode301(): void
$_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();
@@ -606,12 +606,12 @@ public function testRedirectExceptionDeprecated(): void
$_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);
@@ -626,7 +626,7 @@ public function testStoresPreviousURL(): void
$_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();
@@ -648,10 +648,10 @@ public function testNotStoresPreviousURL(): void
$_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();
@@ -670,13 +670,13 @@ public function testNotStoresPreviousURLByCheckingContentType(): void
$_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();
@@ -713,7 +713,7 @@ public function testRunCLIRoute(): void
$_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();
@@ -735,7 +735,7 @@ public function testSpoofRequestMethodCanUsePUT(): void
$_POST['_method'] = Method::PUT;
- $routes = \Config\Services::routes();
+ $routes = service('routes');
$routes->setDefaultNamespace('App\Controllers');
$routes->resetRoutes();
$routes->post('/', 'Home::index');
@@ -745,7 +745,7 @@ public function testSpoofRequestMethodCanUsePUT(): void
$this->codeigniter->run();
ob_get_clean();
- $this->assertSame(Method::PUT, Services::incomingrequest()->getMethod());
+ $this->assertSame(Method::PUT, service('incomingrequest')->getMethod());
}
public function testSpoofRequestMethodCannotUseGET(): void
@@ -760,7 +760,7 @@ public function testSpoofRequestMethodCannotUseGET(): void
$_POST['_method'] = 'GET';
- $routes = \Config\Services::routes();
+ $routes = service('routes');
$routes->setDefaultNamespace('App\Controllers');
$routes->resetRoutes();
$routes->post('/', 'Home::index');
@@ -770,7 +770,7 @@ public function testSpoofRequestMethodCannotUseGET(): void
$this->codeigniter->run();
ob_get_clean();
- $this->assertSame('POST', Services::incomingrequest()->getMethod());
+ $this->assertSame('POST', service('incomingrequest')->getMethod());
}
/**
@@ -789,22 +789,22 @@ public function testPageCacheSendSecureHeaders(): void
$_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();
@@ -812,7 +812,7 @@ public function testPageCacheSendSecureHeaders(): void
$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);
@@ -822,7 +822,7 @@ public function testPageCacheSendSecureHeaders(): void
$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);
@@ -868,18 +868,18 @@ public function testPageCacheWithCacheQueryString(
$_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
@@ -952,14 +952,14 @@ public function testRunControllerNotFoundBeforeFilter(): void
$_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);
diff --git a/tests/system/Commands/BaseCommandTest.php b/tests/system/Commands/BaseCommandTest.php
index 9e9a2d3408a0..cffb7963af44 100644
--- a/tests/system/Commands/BaseCommandTest.php
+++ b/tests/system/Commands/BaseCommandTest.php
@@ -15,7 +15,6 @@
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
diff --git a/tests/system/Commands/CommandTest.php b/tests/system/Commands/CommandTest.php
index d783d25ddab0..84fa6ecac993 100644
--- a/tests/system/Commands/CommandTest.php
+++ b/tests/system/Commands/CommandTest.php
@@ -17,7 +17,6 @@
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 @@ protected function setUp(): void
parent::setUp();
- $this->logger = Services::logger();
- $this->commands = Services::commands();
+ $this->logger = service('logger');
+ $this->commands = service('commands');
}
protected function getBuffer(): string
diff --git a/tests/system/Commands/RoutesTest.php b/tests/system/Commands/RoutesTest.php
index 2ee9f44f1bac..7859156ccf93 100644
--- a/tests/system/Commands/RoutesTest.php
+++ b/tests/system/Commands/RoutesTest.php
@@ -46,7 +46,7 @@ protected function getBuffer()
private function getCleanRoutes(): RouteCollection
{
- $routes = Services::routes();
+ $routes = service('routes');
$routes->resetRoutes();
$routes->loadRoutes();
@@ -243,7 +243,7 @@ public function testRoutesCommandRouteLegacy(): void
public function testRoutesCommandRouteWithRegexp(): void
{
- $routes = Services::routes();
+ $routes = service('routes');
$routes->resetRoutes();
$routes->options('picker/(.+)', 'Options::index');
diff --git a/tests/system/Commands/ScaffoldGeneratorTest.php b/tests/system/Commands/ScaffoldGeneratorTest.php
index aca2bf2a2469..fe99f2c38ccd 100644
--- a/tests/system/Commands/ScaffoldGeneratorTest.php
+++ b/tests/system/Commands/ScaffoldGeneratorTest.php
@@ -17,7 +17,6 @@
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();
}
diff --git a/tests/system/Commands/Translation/LocalizationFinderTest.php b/tests/system/Commands/Translation/LocalizationFinderTest.php
index 85bb59c7c09b..f40ae88098f5 100644
--- a/tests/system/Commands/Translation/LocalizationFinderTest.php
+++ b/tests/system/Commands/Translation/LocalizationFinderTest.php
@@ -16,7 +16,6 @@
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 @@ public function testUpdateWithIncorrectLocaleOption(): void
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 @@ public function testUpdateWithIncorrectDirOption(): void
{
$this->makeLocaleDirectory();
- $status = Services::commands()->run('lang:find', [
+ $status = service('commands')->run('lang:find', [
'dir' => 'Translation/NotExistFolder',
]);
diff --git a/tests/system/Commands/Utilities/ConfigCheckTest.php b/tests/system/Commands/Utilities/ConfigCheckTest.php
index 535cb0dd0489..c075ac3df422 100644
--- a/tests/system/Commands/Utilities/ConfigCheckTest.php
+++ b/tests/system/Commands/Utilities/ConfigCheckTest.php
@@ -16,7 +16,6 @@
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\StreamFilterTrait;
use Config\App;
-use Config\Services;
use PHPUnit\Framework\Attributes\Group;
/**
@@ -74,7 +73,7 @@ public function testCommandConfigCheckNonexistentClass(): void
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 @@ public function testGetKintD(): void
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());
diff --git a/tests/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollectorTest.php b/tests/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollectorTest.php
index a669385568dd..3413d1a83b86 100644
--- a/tests/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollectorTest.php
+++ b/tests/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollectorTest.php
@@ -16,7 +16,6 @@
use CodeIgniter\HTTP\Method;
use CodeIgniter\Test\CIUnitTestCase;
use Config\Filters;
-use Config\Services;
use PHPUnit\Framework\Attributes\Group;
/**
@@ -34,7 +33,7 @@ protected function setUp(): void
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 @@ private function createAutoRouteCollector(array $filterConfigFilters): AutoRoute
/** @var Filters $filterConfig */
$filterConfig = config('Filters');
$filterConfig->filters = $filterConfigFilters;
- Services::filters($filterConfig);
+ service('filters', $filterConfig);
return new AutoRouteCollector(
$namespace,
diff --git a/tests/system/Commands/Utilities/Routes/FilterCollectorTest.php b/tests/system/Commands/Utilities/Routes/FilterCollectorTest.php
index e3b86fcf9a56..fb6c0e5e8ebd 100644
--- a/tests/system/Commands/Utilities/Routes/FilterCollectorTest.php
+++ b/tests/system/Commands/Utilities/Routes/FilterCollectorTest.php
@@ -15,7 +15,6 @@
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');
diff --git a/tests/system/Commands/Utilities/Routes/FilterFinderTest.php b/tests/system/Commands/Utilities/Routes/FilterFinderTest.php
index d96571c6b2f2..7bba11d9c968 100644
--- a/tests/system/Commands/Utilities/Routes/FilterFinderTest.php
+++ b/tests/system/Commands/Utilities/Routes/FilterFinderTest.php
@@ -13,7 +13,6 @@
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 @@ protected function setUp(): void
{
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 @@ protected function setUp(): void
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',
diff --git a/tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php b/tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php
index d5f3d4a542c8..6b5c10e45ea0 100644
--- a/tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php
+++ b/tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php
@@ -13,7 +13,6 @@
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 @@ public static function provideGet(): iterable
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}'
diff --git a/tests/system/CommonFunctionsTest.php b/tests/system/CommonFunctionsTest.php
index faa96e1fea4e..d708b193f56b 100644
--- a/tests/system/CommonFunctionsTest.php
+++ b/tests/system/CommonFunctionsTest.php
@@ -630,11 +630,11 @@ public function testViewNotSaveData(): void
#[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 @@ public function testDWithCSP(): void
$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 @@ public function testTraceWithCSP(): void
$config->CSPEnabled = true;
// Initialize Kint
- Services::autoloader()->initializeKint(CI_DEBUG);
+ service('autoloader')->initializeKint(CI_DEBUG);
Kint::$cli_detection = false;
diff --git a/tests/system/CommonHelperTest.php b/tests/system/CommonHelperTest.php
index 90b417d41639..db304ecfdb70 100644
--- a/tests/system/CommonHelperTest.php
+++ b/tests/system/CommonHelperTest.php
@@ -82,7 +82,7 @@ private function cleanUpDummyHelpers(): void
private function getMockLocator()
{
return $this->getMockBuilder(FileLocator::class)
- ->setConstructorArgs([Services::autoloader()])
+ ->setConstructorArgs([service('autoloader')])
->onlyMethods(['search'])
->getMock();
}
@@ -90,7 +90,7 @@ private function getMockLocator()
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 @@ public function testHelperLoadsOnce(): void
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 {
diff --git a/tests/system/CommonSingleServiceTest.php b/tests/system/CommonSingleServiceTest.php
index a8b4c6dabc32..6a07695dfbe1 100644
--- a/tests/system/CommonSingleServiceTest.php
+++ b/tests/system/CommonSingleServiceTest.php
@@ -48,7 +48,7 @@ public function testSingleServiceWithAtLeastOneParamSupplied(string $service): v
{
if ($service === 'commands') {
$locator = $this->getMockBuilder(FileLocator::class)
- ->setConstructorArgs([Services::autoloader()])
+ ->setConstructorArgs([service('autoloader')])
->onlyMethods(['listFiles'])
->getMock();
diff --git a/tests/system/Config/ServicesTest.php b/tests/system/Config/ServicesTest.php
index 2c093724ac71..e2679757f9a9 100644
--- a/tests/system/Config/ServicesTest.php
+++ b/tests/system/Config/ServicesTest.php
@@ -216,7 +216,7 @@ public function testNewThrottler(): void
public function testNewToolbar(): void
{
- $actual = Services::toolbar(null);
+ $actual = service('toolbar', null);
$this->assertInstanceOf(Toolbar::class, $actual);
}
@@ -385,7 +385,7 @@ public function testFilters(): void
public function testFormat(): void
{
- $this->assertInstanceOf(Format::class, Services::format());
+ $this->assertInstanceOf(Format::class, service('format'));
}
public function testUnsharedFormat(): void
diff --git a/tests/system/ControllerTest.php b/tests/system/ControllerTest.php
index ffdcd9589f8a..55664c42c779 100644
--- a/tests/system/ControllerTest.php
+++ b/tests/system/ControllerTest.php
@@ -23,7 +23,6 @@
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;
@@ -61,7 +60,7 @@ protected function setUp(): void
$config = new App();
$this->request = new IncomingRequest($config, new SiteURI($config), null, new UserAgent());
$this->response = new Response($config);
- $this->logger = Services::logger();
+ $this->logger = service('logger');
}
public function testConstructor(): void
@@ -149,7 +148,7 @@ public function testValidateWithStringRulesFoundReadMessagesFromValidationConfig
$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
@@ -174,7 +173,7 @@ public function testValidateWithStringRulesFoundUseMessagesParameter(): void
'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
@@ -196,7 +195,7 @@ public function testValidateData(): void
$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')
);
}
@@ -225,11 +224,11 @@ public function testValidateDataWithCustomErrorMessage(): void
$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')
);
}
@@ -263,11 +262,11 @@ public function testValidateDataWithCustomErrorMessageLabeledStyle(): void
$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')
);
}
diff --git a/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce1Test.php b/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce1Test.php
index 8a0980f853a9..c3e744749909 100644
--- a/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce1Test.php
+++ b/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce1Test.php
@@ -16,7 +16,6 @@
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\DatabaseTestTrait;
use Config\Database;
-use Config\Services;
use PHPUnit\Framework\Attributes\Group;
/**
@@ -68,7 +67,7 @@ protected function setUp(): void
protected function setUpAddNamespace(): void
{
- Services::autoloader()->addNamespace(
+ service('autoloader')->addNamespace(
'Tests\Support\MigrationTestMigrations',
SUPPORTPATH . 'MigrationTestMigrations'
);
diff --git a/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce2Test.php b/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce2Test.php
index 5c4013e055e1..7820b83c06c7 100644
--- a/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce2Test.php
+++ b/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce2Test.php
@@ -16,7 +16,6 @@
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\DatabaseTestTrait;
use Config\Database;
-use Config\Services;
use PHPUnit\Framework\Attributes\Group;
/**
@@ -68,7 +67,7 @@ protected function setUp(): void
protected function setUpAddNamespace(): void
{
- Services::autoloader()->addNamespace(
+ service('autoloader')->addNamespace(
'Tests\Support\MigrationTestMigrations',
SUPPORTPATH . 'MigrationTestMigrations'
);
diff --git a/tests/system/Database/DatabaseTestCaseTest.php b/tests/system/Database/DatabaseTestCaseTest.php
index c6a03022df72..76867e852e23 100644
--- a/tests/system/Database/DatabaseTestCaseTest.php
+++ b/tests/system/Database/DatabaseTestCaseTest.php
@@ -16,7 +16,6 @@
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 @@ protected function setUp(): void
protected function setUpAddNamespace(): void
{
- Services::autoloader()->addNamespace(
+ service('autoloader')->addNamespace(
'Tests\Support\MigrationTestMigrations',
SUPPORTPATH . 'MigrationTestMigrations'
);
diff --git a/tests/system/Database/Migrations/MigrationRunnerTest.php b/tests/system/Database/Migrations/MigrationRunnerTest.php
index 547eec670ce4..0ecd2ca0b051 100644
--- a/tests/system/Database/Migrations/MigrationRunnerTest.php
+++ b/tests/system/Database/Migrations/MigrationRunnerTest.php
@@ -21,7 +21,6 @@
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 @@ protected function setUp(): void
protected function setUpAddNamespace(): void
{
- Services::autoloader()->addNamespace(
+ service('autoloader')->addNamespace(
'Tests\Support\MigrationTestMigrations',
SUPPORTPATH . 'MigrationTestMigrations'
);
diff --git a/tests/system/Debug/ExceptionHandlerTest.php b/tests/system/Debug/ExceptionHandlerTest.php
index 85eaed74621b..ddb1304c3d7e 100644
--- a/tests/system/Debug/ExceptionHandlerTest.php
+++ b/tests/system/Debug/ExceptionHandlerTest.php
@@ -107,8 +107,8 @@ public function testHandleWebPageNotFoundExceptionDoNotAcceptHTML(): void
{
$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 @@ public function testHandleWebPageNotFoundExceptionAcceptHTML(): void
{
$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 @@ public function testHandleCLIPageNotFoundException(): void
$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);
diff --git a/tests/system/Filters/CSRFTest.php b/tests/system/Filters/CSRFTest.php
index c0d85b02150d..d1977e4f5cea 100644
--- a/tests/system/Filters/CSRFTest.php
+++ b/tests/system/Filters/CSRFTest.php
@@ -51,7 +51,7 @@ public function testDoNotCheckCliRequest(): void
];
$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 @@ public function testPassGetRequest(): void
'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';
diff --git a/tests/system/Filters/CorsTest.php b/tests/system/Filters/CorsTest.php
index 78023ddfdadc..bbbbefc0b413 100644
--- a/tests/system/Filters/CorsTest.php
+++ b/tests/system/Filters/CorsTest.php
@@ -22,7 +22,6 @@
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 @@ private function handle(RequestInterface $request): ResponseInterface
return $response;
}
- $response ??= Services::response();
+ $response ??= service('response');
$response = $this->cors->after($request, $response);
- $response ??= Services::response();
+ $response ??= service('response');
$this->response = $response;
diff --git a/tests/system/Filters/DebugToolbarTest.php b/tests/system/Filters/DebugToolbarTest.php
index 6cb716ee9556..0826a04afca8 100644
--- a/tests/system/Filters/DebugToolbarTest.php
+++ b/tests/system/Filters/DebugToolbarTest.php
@@ -13,9 +13,9 @@
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 @@ protected function setUp(): void
{
parent::setUp();
- $this->request = Services::request();
- $this->response = Services::response();
+ $this->request = service('request');
+ $this->response = service('response');
}
public function testDebugToolbarFilter(): void
diff --git a/tests/system/Filters/FiltersTest.php b/tests/system/Filters/FiltersTest.php
index 3a35920989e5..d4a390c113e0 100644
--- a/tests/system/Filters/FiltersTest.php
+++ b/tests/system/Filters/FiltersTest.php
@@ -13,7 +13,6 @@
namespace CodeIgniter\Filters;
-use CodeIgniter\Config\Services;
use CodeIgniter\Exceptions\ConfigException;
use CodeIgniter\Filters\Exceptions\FilterException;
use CodeIgniter\Filters\fixtures\GoogleCurious;
@@ -66,16 +65,16 @@ protected function setUp(): void
'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::request();
+ $request ??= service('request');
return new Filters($config, $request, $this->response);
}
diff --git a/tests/system/Filters/HoneypotTest.php b/tests/system/Filters/HoneypotTest.php
index 79519709d72c..2d45b35a20b0 100644
--- a/tests/system/Filters/HoneypotTest.php
+++ b/tests/system/Filters/HoneypotTest.php
@@ -13,10 +13,10 @@
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 @@ public function testBeforeTriggered(): void
'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 @@ public function testBeforeClean(): void
];
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 @@ public function testAfter(): void
'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 @@ public function testAfterNotApplicable(): void
'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';
diff --git a/tests/system/Filters/SecureHeadersTest.php b/tests/system/Filters/SecureHeadersTest.php
index 48ff8bb7d04f..5b446d523647 100644
--- a/tests/system/Filters/SecureHeadersTest.php
+++ b/tests/system/Filters/SecureHeadersTest.php
@@ -13,7 +13,6 @@
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);
diff --git a/tests/system/Filters/fixtures/GoogleYou.php b/tests/system/Filters/fixtures/GoogleYou.php
index c01c5d534435..7d2913866b30 100644
--- a/tests/system/Filters/fixtures/GoogleYou.php
+++ b/tests/system/Filters/fixtures/GoogleYou.php
@@ -13,7 +13,6 @@
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;
diff --git a/tests/system/HTTP/CorsTest.php b/tests/system/HTTP/CorsTest.php
index 9f2a7280bee4..bdb29567df59 100644
--- a/tests/system/HTTP/CorsTest.php
+++ b/tests/system/HTTP/CorsTest.php
@@ -14,7 +14,6 @@
namespace CodeIgniter\HTTP;
use CodeIgniter\Test\CIUnitTestCase;
-use Config\Services;
use PHPUnit\Framework\Attributes\Group;
/**
@@ -41,7 +40,7 @@ private function createCors(array $config = []): Cors
private function createRequest(): IncomingRequest
{
- return Services::incomingrequest(null, false);
+ return service('incomingrequest', null, false);
}
/**
@@ -103,7 +102,7 @@ public function testHandlePreflightRequestSingleAllowedOrigin(): void
->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 @@ public function testHandlePreflightRequestMultipleAllowedOriginsAllowed(): void
->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 @@ public function testHandlePreflightRequestMultipleAllowedOriginsAllowedAlreadyVa
->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 @@ public function testHandlePreflightRequestMultipleAllowedOriginsNotAllowed(): vo
->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 @@ public function testHandlePreflightRequestAllowedOriginsPatternsAllowed(): void
->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 @@ public function testHandlePreflightRequestAllowedOriginsPatternsNotAllowed(): vo
->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 @@ public function testHandlePreflightRequestSingleAllowedOriginWithCredentials():
->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 @@ public function testAddResponseHeadersSingleAllowedOriginSimpleRequest(): void
->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 @@ public function testAddResponseHeadersSingleAllowedOriginRealRequest(): void
->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 @@ public function testAddResponseHeadersSingleAllowedOriginWithCredentials(): void
->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 @@ public function testAddResponseHeadersSingleAllowedOriginWithExposeHeaders(): vo
->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 @@ public function testAddResponseHeadersMultipleAllowedOriginsAllowed(): void
->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 @@ public function testAddResponseHeadersMultipleAllowedOriginsAllowedAlreadyVary()
->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 @@ public function testAddResponseHeadersMultipleAllowedOriginsNotAllowed(): void
->withMethod('PUT')
->setHeader('Origin', 'https://bad.site.com');
- $response = Services::response(null, false);
+ $response = service('response', null, false);
$response = $cors->addResponseHeaders($request, $response);
diff --git a/tests/system/HTTP/RedirectExceptionTest.php b/tests/system/HTTP/RedirectExceptionTest.php
index e77c0ea060d3..cd90a9aa148c 100644
--- a/tests/system/HTTP/RedirectExceptionTest.php
+++ b/tests/system/HTTP/RedirectExceptionTest.php
@@ -46,7 +46,7 @@ protected function tearDown(): void
public function testResponse(): void
{
$response = (new RedirectException(
- Services::response()
+ service('response')
->redirect('redirect')
->setCookie('cookie', 'value')
->setHeader('Redirect-Header', 'value')
@@ -65,12 +65,12 @@ public function testResponseWithoutLocation(): void
'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 @@ public function testLoggingLocationHeader(): void
$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 @@ public function testLoggingRefreshHeader(): void
$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();
diff --git a/tests/system/HTTP/RedirectResponseTest.php b/tests/system/HTTP/RedirectResponseTest.php
index 41ac8139bdc4..1614244d762b 100644
--- a/tests/system/HTTP/RedirectResponseTest.php
+++ b/tests/system/HTTP/RedirectResponseTest.php
@@ -54,7 +54,7 @@ protected function setUp(): void
$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 @@ public function testWithCookies(): void
{
$_SESSION = [];
- $baseResponse = Services::response();
+ $baseResponse = service('response');
$baseResponse->setCookie('foo', 'bar');
$response = new RedirectResponse(new App());
diff --git a/tests/system/HTTP/ResponseTest.php b/tests/system/HTTP/ResponseTest.php
index bb939741dda1..3137620029bc 100644
--- a/tests/system/HTTP/ResponseTest.php
+++ b/tests/system/HTTP/ResponseTest.php
@@ -18,7 +18,6 @@
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 @@ public function testSetLink(): void
$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 @@ public function testJSONWithArray(): void
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 @@ public function testJSONGetFromNormalBody(): void
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 @@ public function testXMLWithArray(): void
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 @@ public function testXMLGetFromNormalBody(): void
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);
diff --git a/tests/system/HTTP/URITest.php b/tests/system/HTTP/URITest.php
index 8a953ee3cab1..517e2d888973 100644
--- a/tests/system/HTTP/URITest.php
+++ b/tests/system/HTTP/URITest.php
@@ -1046,7 +1046,7 @@ public function testBasedNoIndex(): void
$config->indexPage = '';
Factories::injectMock('config', 'App', $config);
- $request = Services::request($config);
+ $request = service('request', $config);
Services::injectMock('request', $request);
// going through request
@@ -1080,7 +1080,7 @@ public function testBasedWithIndex(): void
$config->indexPage = 'index.php';
Factories::injectMock('config', 'App', $config);
- $request = Services::request($config);
+ $request = service('request', $config);
Services::injectMock('request', $request);
// going through request
@@ -1120,7 +1120,7 @@ public function testForceGlobalSecureRequests(): void
$config->forceGlobalSecureRequests = true;
Factories::injectMock('config', 'App', $config);
- $request = Services::request($config);
+ $request = service('request', $config);
Services::injectMock('request', $request);
// Detected by request
diff --git a/tests/system/Helpers/CookieHelperTest.php b/tests/system/Helpers/CookieHelperTest.php
index b672e4da9104..c6bfba193054 100644
--- a/tests/system/Helpers/CookieHelperTest.php
+++ b/tests/system/Helpers/CookieHelperTest.php
@@ -49,7 +49,7 @@ protected function setUp(): void
$this->expire = 9999;
Services::injectMock('response', new MockResponse(new App()));
- $this->response = Services::response();
+ $this->response = service('response');
$request = new IncomingRequest(new App(), new SiteURI(new App()), null, new UserAgent());
Services::injectMock('request', $request);
diff --git a/tests/system/Helpers/FormHelperTest.php b/tests/system/Helpers/FormHelperTest.php
index fc9eb0ab021a..9023fd73ac6f 100644
--- a/tests/system/Helpers/FormHelperTest.php
+++ b/tests/system/Helpers/FormHelperTest.php
@@ -48,7 +48,7 @@ private function setRequest(): void
$uri = new SiteURI($config);
Services::injectMock('uri', $uri);
- $request = Services::request($config);
+ $request = service('request', $config);
Services::injectMock('request', $request);
}
@@ -1050,7 +1050,7 @@ public function testValidationErrorsFromSession(): void
public function testValidationErrorsFromValidation(): void
{
- $validation = Services::validation();
+ $validation = service('validation');
$validation->setRule('id', 'ID', 'required')->run([]);
$this->assertSame(['id' => 'The ID field is required.'], validation_errors());
@@ -1058,7 +1058,7 @@ public function testValidationErrorsFromValidation(): void
public function testValidationListErrors(): void
{
- $validation = Services::validation();
+ $validation = service('validation');
$validation->setRule('id', 'ID', 'required')->run([]);
$html = validation_list_errors();
@@ -1068,7 +1068,7 @@ public function testValidationListErrors(): void
public function testValidationShowError(): void
{
- $validation = Services::validation();
+ $validation = service('validation');
$validation->setRule('id', 'ID', 'required')->run([]);
$html = validation_show_error('id');
@@ -1081,7 +1081,7 @@ public function testValidationShowError(): void
public function testValidationShowErrorForWildcards(): void
{
- $validation = Services::validation();
+ $validation = service('validation');
$validation->setRule('user.*.name', 'Name', 'required')
->run([
'user' => [
diff --git a/tests/system/Helpers/URLHelper/MiscUrlTest.php b/tests/system/Helpers/URLHelper/MiscUrlTest.php
index a006ec80c6ae..e12b7873f9e2 100644
--- a/tests/system/Helpers/URLHelper/MiscUrlTest.php
+++ b/tests/system/Helpers/URLHelper/MiscUrlTest.php
@@ -44,7 +44,7 @@ protected function setUp(): void
parent::setUp();
Services::reset(true);
- Services::routes()->loadRoutes();
+ service('routes')->loadRoutes();
// Set a common base configuration (overriden by individual tests)
$this->config = new App();
@@ -956,7 +956,7 @@ public function testUrlToMissingArgument(): void
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Missing argument for "(:alpha)" in route "(:alpha)/login".');
- $routes = Services::routes();
+ $routes = service('routes');
$routes->group('(:alpha)', static function ($routes): void {
$routes->match(['GET'], 'login', 'Common\LoginController::loginView', ['as' => 'loginURL']);
});
diff --git a/tests/system/Honeypot/HoneypotTest.php b/tests/system/Honeypot/HoneypotTest.php
index ee048a1a785c..3878a5d957ff 100644
--- a/tests/system/Honeypot/HoneypotTest.php
+++ b/tests/system/Honeypot/HoneypotTest.php
@@ -14,11 +14,11 @@
namespace CodeIgniter\Honeypot;
use CodeIgniter\Config\Factories;
-use CodeIgniter\Config\Services;
use CodeIgniter\Filters\Filters;
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\App;
@@ -39,7 +39,7 @@ final class HoneypotTest extends CIUnitTestCase
/**
* @var CLIRequest|IncomingRequest
*/
- private $request;
+ private RequestInterface $request;
private Response $response;
@@ -54,8 +54,8 @@ protected function setUp(): void
$_SERVER['REQUEST_METHOD'] = 'POST';
$_POST[$this->config->name] = 'hey';
- $this->request = Services::request(null, false);
- $this->response = Services::response();
+ $this->request = service('request', null, false);
+ $this->response = service('response');
}
public function testAttachHoneypot(): void
@@ -99,7 +99,7 @@ public function testAttachHoneypotAndContainerWithCSP(): void
$config = new App();
$config->CSPEnabled = true;
Factories::injectMock('config', 'App', $config);
- $this->response = Services::response($config, false);
+ $this->response = service('response', $config, false);
$this->config = new HoneypotConfig();
$this->honeypot = new Honeypot($this->config);
@@ -118,7 +118,7 @@ public function testNotAttachHoneypotWithCSP(): void
$config = new App();
$config->CSPEnabled = true;
Factories::injectMock('config', 'App', $config);
- $this->response = Services::response($config, false);
+ $this->response = service('response', $config, false);
$this->config = new HoneypotConfig();
$this->honeypot = new Honeypot($this->config);
@@ -132,7 +132,7 @@ public function testNotAttachHoneypotWithCSP(): void
public function testHasntContent(): void
{
unset($_POST[$this->config->name]);
- $this->request = Services::request();
+ $this->request = service('request');
$this->assertFalse($this->honeypot->hasContent($this->request));
}
diff --git a/tests/system/Language/LanguageTest.php b/tests/system/Language/LanguageTest.php
index 8dd3a290b286..cb1cfff267aa 100644
--- a/tests/system/Language/LanguageTest.php
+++ b/tests/system/Language/LanguageTest.php
@@ -15,7 +15,6 @@
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\Mock\MockLanguage;
-use Config\Services;
use MessageFormatter;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
@@ -296,7 +295,7 @@ public function testLanguageSameKeyAndFileName(): void
public function testGetLocale(): void
{
- $this->lang = Services::language('en', false);
+ $this->lang = service('language', 'en', false);
$this->assertSame('en', $this->lang->getLocale());
}
@@ -353,7 +352,7 @@ public function testBundleUniqueKeys($bundle): void
public function testBaseFallbacks(): void
{
- $this->lang = Services::language('en-ZZ', false);
+ $this->lang = service('language', 'en-ZZ', false);
// key is in both base and variant; should pick variant
$this->assertSame("It's made of cheese", $this->lang->getLine('More.notaMoon'));
@@ -372,7 +371,7 @@ public function testBaseFallbacks(): void
*/
public function testLangKeepLocale(): void
{
- $this->lang = Services::language('en', true);
+ $this->lang = service('language', 'en', true);
lang('Language.languageGetLineInvalidArgumentException');
$this->assertSame('en', $this->lang->getLocale());
@@ -399,7 +398,7 @@ public function testLangKeepLocale(): void
*/
public function testAllTheWayFallbacks(): void
{
- $this->lang = Services::language('ab-CD', false);
+ $this->lang = service('language', 'ab-CD', false);
$this->assertSame('Allin.none', $this->lang->getLine('Allin.none'));
$this->assertSame('Pyramid of Giza', $this->lang->getLine('Allin.one'));
$this->assertSame('gluttony', $this->lang->getLine('Allin.two'));
diff --git a/tests/system/Log/Handlers/ChromeLoggerHandlerTest.php b/tests/system/Log/Handlers/ChromeLoggerHandlerTest.php
index 3dc0b1ccee80..73461c3c96ed 100644
--- a/tests/system/Log/Handlers/ChromeLoggerHandlerTest.php
+++ b/tests/system/Log/Handlers/ChromeLoggerHandlerTest.php
@@ -56,7 +56,7 @@ public function testSendLogs(): void
$logger = new ChromeLoggerHandler($config->handlers['CodeIgniter\Log\Handlers\TestHandler']);
$logger->sendLogs();
- $response = Services::response(null, true);
+ $response = service('response', null, true);
$this->assertTrue($response->hasHeader('X-ChromeLogger-Data'));
}
diff --git a/tests/system/Models/ValidationModelRuleGroupTest.php b/tests/system/Models/ValidationModelRuleGroupTest.php
index b08f73c9a04e..34e51bcf07bc 100644
--- a/tests/system/Models/ValidationModelRuleGroupTest.php
+++ b/tests/system/Models/ValidationModelRuleGroupTest.php
@@ -15,7 +15,6 @@
use CodeIgniter\Database\BaseConnection;
use CodeIgniter\Model;
-use Config\Services;
use PHPUnit\Framework\Attributes\Group;
use stdClass;
use Tests\Support\Config\Validation;
@@ -40,7 +39,7 @@ protected function setUp(): void
protected function createModel(string $modelName, ?BaseConnection $db = null): Model
{
$config = new Validation();
- $validation = new \CodeIgniter\Validation\Validation($config, Services::renderer());
+ $validation = new \CodeIgniter\Validation\Validation($config, service('renderer'));
$this->db = $db ?? $this->db;
$this->model = new $modelName($this->db, $validation);
diff --git a/tests/system/Pager/PagerTest.php b/tests/system/Pager/PagerTest.php
index c652a3793738..13d0d846f07c 100644
--- a/tests/system/Pager/PagerTest.php
+++ b/tests/system/Pager/PagerTest.php
@@ -64,7 +64,7 @@ private function createPager(string $requestUri): void
Services::injectMock('request', $request);
$this->config = new PagerConfig();
- $this->pager = new Pager($this->config, Services::renderer());
+ $this->pager = new Pager($this->config, service('renderer'));
}
public function testSetPathRemembersPath(): void
@@ -493,7 +493,7 @@ public function testBasedURI(): void
Services::injectMock('request', $request);
$this->config = new PagerConfig();
- $this->pager = new Pager($this->config, Services::renderer());
+ $this->pager = new Pager($this->config, service('renderer'));
$_GET['page_foo'] = 2;
diff --git a/tests/system/RESTful/ResourceControllerTest.php b/tests/system/RESTful/ResourceControllerTest.php
index 77ca329248dc..580909cdff76 100644
--- a/tests/system/RESTful/ResourceControllerTest.php
+++ b/tests/system/RESTful/ResourceControllerTest.php
@@ -69,14 +69,14 @@ private function createCodeigniter(): void
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
// Inject mock router.
- $this->routes = Services::routes();
+ $this->routes = service('routes');
$this->routes->resource('work', ['controller' => '\\' . Worker::class]);
Services::injectMock('routes', $this->routes);
$config = new App();
$this->codeigniter = new MockCodeIgniter($config);
- $response = Services::response();
+ $response = service('response');
$response->pretend();
}
diff --git a/tests/system/RESTful/ResourcePresenterTest.php b/tests/system/RESTful/ResourcePresenterTest.php
index e5614adfd1c0..3617e7a18e67 100644
--- a/tests/system/RESTful/ResourcePresenterTest.php
+++ b/tests/system/RESTful/ResourcePresenterTest.php
@@ -63,7 +63,7 @@ private function createCodeigniter(): void
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
// Inject mock router.
- $this->routes = Services::routes();
+ $this->routes = service('routes');
$this->routes->presenter('work', ['controller' => '\\' . Worker2::class]);
Services::injectMock('routes', $this->routes);
diff --git a/tests/system/Router/AutoRouterImprovedTest.php b/tests/system/Router/AutoRouterImprovedTest.php
index 0f4c75162a2f..56e334dc96d9 100644
--- a/tests/system/Router/AutoRouterImprovedTest.php
+++ b/tests/system/Router/AutoRouterImprovedTest.php
@@ -14,7 +14,6 @@
namespace CodeIgniter\Router;
use CodeIgniter\Config\Factories;
-use CodeIgniter\Config\Services;
use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\HTTP\Method;
use CodeIgniter\Router\Controllers\BlogController;
@@ -42,7 +41,7 @@ protected function setUp(): void
$moduleConfig = new Modules();
$moduleConfig->enabled = false;
- $this->collection = new RouteCollection(Services::locator(), $moduleConfig, new Routing());
+ $this->collection = new RouteCollection(service('locator'), $moduleConfig, new Routing());
}
private function createNewAutoRouter(string $namespace = 'CodeIgniter\Router\Controllers'): AutoRouterImproved
diff --git a/tests/system/Router/DefinedRouteCollectorTest.php b/tests/system/Router/DefinedRouteCollectorTest.php
index 7c493c028512..3c1d29abc023 100644
--- a/tests/system/Router/DefinedRouteCollectorTest.php
+++ b/tests/system/Router/DefinedRouteCollectorTest.php
@@ -13,7 +13,6 @@
namespace CodeIgniter\Router;
-use CodeIgniter\Config\Services;
use CodeIgniter\HTTP\Method;
use CodeIgniter\Test\CIUnitTestCase;
use Config\Modules;
@@ -34,9 +33,9 @@ private function createRouteCollection(array $config = [], $moduleConfig = null)
];
$config = array_merge($config, $defaults);
- Services::autoloader()->addNamespace($config);
+ service('autoloader')->addNamespace($config);
- $loader = Services::locator();
+ $loader = service('locator');
if ($moduleConfig === null) {
$moduleConfig = new Modules();
diff --git a/tests/system/Router/RouteCollectionReverseRouteTest.php b/tests/system/Router/RouteCollectionReverseRouteTest.php
index ebe344293f46..ca70b315f5b6 100644
--- a/tests/system/Router/RouteCollectionReverseRouteTest.php
+++ b/tests/system/Router/RouteCollectionReverseRouteTest.php
@@ -13,7 +13,6 @@
namespace CodeIgniter\Router;
-use CodeIgniter\Config\Services;
use CodeIgniter\HTTP\Method;
use CodeIgniter\Router\Exceptions\RouterException;
use CodeIgniter\Test\CIUnitTestCase;
@@ -44,9 +43,9 @@ protected function getCollector(array $config = [], array $files = [], $moduleCo
];
$config = array_merge($config, $defaults);
- Services::autoloader()->addNamespace($config);
+ service('autoloader')->addNamespace($config);
- $loader = Services::locator();
+ $loader = service('locator');
if ($moduleConfig === null) {
$moduleConfig = new Modules();
diff --git a/tests/system/Router/RouteCollectionTest.php b/tests/system/Router/RouteCollectionTest.php
index bfd53a3ebf7c..5e398cfdf2a3 100644
--- a/tests/system/Router/RouteCollectionTest.php
+++ b/tests/system/Router/RouteCollectionTest.php
@@ -14,7 +14,6 @@
namespace CodeIgniter\Router;
use App\Controllers\Product;
-use CodeIgniter\Config\Services;
use CodeIgniter\controller;
use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\HTTP\Method;
@@ -47,9 +46,9 @@ protected function getCollector(array $config = [], array $files = [], $moduleCo
];
$config = array_merge($config, $defaults);
- Services::autoloader()->addNamespace($config);
+ service('autoloader')->addNamespace($config);
- $loader = Services::locator();
+ $loader = service('locator');
if ($moduleConfig === null) {
$moduleConfig = new Modules();
@@ -148,7 +147,7 @@ public function testAddIgnoresDefaultNamespaceWhenExists(): void
public function testAddWorksWithCurrentHTTPMethods(): void
{
- Services::request()->setMethod(Method::GET);
+ service('request')->setMethod(Method::GET);
$routes = $this->getCollector();
@@ -180,7 +179,7 @@ public function testAddWithLeadingSlash(): void
public function testMatchIgnoresInvalidHTTPMethods(): void
{
- Services::request()->setMethod(Method::GET);
+ service('request')->setMethod(Method::GET);
$routes = $this->getCollector();
@@ -193,7 +192,7 @@ public function testMatchIgnoresInvalidHTTPMethods(): void
public function testAddWorksWithArrayOFHTTPMethods(): void
{
- Services::request()->setMethod(Method::POST);
+ service('request')->setMethod(Method::POST);
$routes = $this->getCollector();
@@ -714,7 +713,7 @@ public function testPresenterScaffoldsCorrectly(): void
public function testResourcesWithCustomController(): void
{
- Services::request()->setMethod(Method::GET);
+ service('request')->setMethod(Method::GET);
$routes = $this->getCollector();
$routes->resource('photos', ['controller' => '