Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove CodeIgniter\Services #6053

Merged
merged 5 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions phpstan-baseline.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,6 @@ parameters:
count: 1
path: system/Debug/Exceptions.php

-
message: "#^Property CodeIgniter\\\\Debug\\\\Exceptions\\:\\:\\$formatter \\(CodeIgniter\\\\Format\\\\FormatterInterface\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: system/Debug/Exceptions.php

-
message: "#^Property Config\\\\Exceptions\\:\\:\\$sensitiveDataInTrace \\(array\\) in isset\\(\\) is not nullable\\.$#"
count: 1
Expand Down Expand Up @@ -660,11 +655,6 @@ parameters:
count: 1
path: system/Log/Logger.php

-
message: "#^Property CodeIgniter\\\\RESTful\\\\ResourceController\\:\\:\\$formatter \\(CodeIgniter\\\\Format\\\\FormatterInterface\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: system/RESTful/ResourceController.php

-
message: "#^Call to an undefined method CodeIgniter\\\\Router\\\\RouteCollectionInterface\\:\\:getDefaultNamespace\\(\\)\\.$#"
count: 3
Expand Down Expand Up @@ -835,11 +825,6 @@ parameters:
count: 1
path: system/Test/Mock/MockConnection.php

-
message: "#^Property CodeIgniter\\\\Test\\\\Mock\\\\MockResourcePresenter\\:\\:\\$formatter \\(CodeIgniter\\\\Format\\\\FormatterInterface\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: system/Test/Mock/MockResourcePresenter.php

-
message: "#^Property CodeIgniter\\\\Throttle\\\\Throttler\\:\\:\\$testTime \\(int\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
Expand Down
2 changes: 1 addition & 1 deletion system/API/ResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ trait ResponseTrait
/**
* Current Formatter instance. This is usually set by ResponseTrait::format
*
* @var FormatterInterface
* @var FormatterInterface|null
*/
protected $formatter;

Expand Down
5 changes: 0 additions & 5 deletions system/Test/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@
require_once SYSTEMPATH . 'Config/Services.php';
require_once APPPATH . 'Config/Services.php';

// Use Config\Services as CodeIgniter\Services
if (! class_exists('CodeIgniter\Services', false)) {
class_alias(Services::class, 'CodeIgniter\Services');
}

// Initialize and register the loader with the SPL autoloader stack.
Services::autoloader()->initialize(new Autoload(), new Modules())->register();

Expand Down
5 changes: 0 additions & 5 deletions system/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@
require_once SYSTEMPATH . 'Config/Services.php';
require_once APPPATH . 'Config/Services.php';

// Use Config\Services as CodeIgniter\Services
if (! class_exists('CodeIgniter\Services', false)) {
class_alias(Services::class, 'CodeIgniter\Services');
}

// Initialize and register the loader with the SPL autoloader stack.
Services::autoloader()->initialize(new Autoload(), new Modules())->register();

Expand Down
66 changes: 0 additions & 66 deletions tests/_support/Services.php

This file was deleted.

6 changes: 3 additions & 3 deletions tests/system/CommonFunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace CodeIgniter;

use CodeIgniter\Config\BaseService;
use CodeIgniter\Config\Services;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\Response;
use CodeIgniter\HTTP\URI;
Expand All @@ -29,6 +28,7 @@
use Config\App;
use Config\Logger;
use Config\Modules;
use Config\Services;
use Kint;
use stdClass;
use Tests\Support\Models\JobModel;
Expand Down Expand Up @@ -118,8 +118,8 @@ public function testRedirectReturnsRedirectResponse()
Services::locator(),
new Modules()
);
\CodeIgniter\Services::injectMock('response', $response);
\CodeIgniter\Services::injectMock('routes', $routes);
Services::injectMock('response', $response);
Services::injectMock('routes', $routes);

$routes->add('home/base', 'Controller::index', ['as' => 'base']);
$response->method('redirect')->willReturnArgument(0);
Expand Down
3 changes: 2 additions & 1 deletion tests/system/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Validation\Exceptions\ValidationException;
use Config\App;
use Config\Services;
use Psr\Log\LoggerInterface;

/**
Expand Down Expand Up @@ -56,7 +57,7 @@ protected function setUp(): void
$this->config = new App();
$this->request = new IncomingRequest($this->config, new URI('https://somwhere.com'), null, new UserAgent());
$this->response = new Response($this->config);
$this->logger = \Config\Services::logger();
$this->logger = Services::logger();
}

public function testConstructor()
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Helpers/FormHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
namespace CodeIgniter\Helpers;

use CodeIgniter\HTTP\URI;
use CodeIgniter\Services;
use CodeIgniter\Test\CIUnitTestCase;
use Config\App;
use Config\Filters;
use Config\Services;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Log/Handlers/ChromeLoggerHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

namespace CodeIgniter\Log\Handlers;

use CodeIgniter\Services;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\Mock\MockLogger as LoggerConfig;
use CodeIgniter\Test\Mock\MockResponse;
use Config\App;
use Config\Services;
use stdClass;

/**
Expand Down