Skip to content

Commit c609e87

Browse files
authored
Merge pull request #7671 from kenjis/fix-Services-session
fix: change Services::session() config param type
2 parents 6c05c17 + e0f4094 commit c609e87

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

‎system/Config/Services.php‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -661,19 +661,16 @@ public static function security(?SecurityConfig $config = null, bool $getShared
661661
* Return the session manager.
662662
*
663663
* @return Session
664-
*
665-
* @TODO replace the first parameter type `?App` with `?SessionConfig`
666664
*/
667-
public static function session(?App $config = null, bool $getShared = true)
665+
public static function session(?SessionConfig $config = null, bool $getShared = true)
668666
{
669667
if ($getShared) {
670668
return static::getSharedInstance('session', $config);
671669
}
672670

673-
$logger = AppServices::logger();
671+
$config ??= config(SessionConfig::class);
674672

675-
$config = config(SessionConfig::class);
676-
assert($config instanceof SessionConfig, 'Missing "Config/Session.php".');
673+
$logger = AppServices::logger();
677674

678675
$driverName = $config->driver;
679676

‎tests/system/Config/ServicesTest.php‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,13 @@
5454
*/
5555
final class ServicesTest extends CIUnitTestCase
5656
{
57-
private App $config;
5857
private array $original;
5958

6059
protected function setUp(): void
6160
{
6261
parent::setUp();
6362

6463
$this->original = $_SERVER;
65-
$this->config = new App();
6664
}
6765

6866
protected function tearDown(): void
@@ -243,7 +241,7 @@ public function testNewViewcell()
243241
*/
244242
public function testNewSession()
245243
{
246-
$actual = Services::session($this->config);
244+
$actual = Services::session();
247245
$this->assertInstanceOf(Session::class, $actual);
248246
}
249247

‎user_guide_src/source/changelogs/v4.4.0.rst‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ Method Signature Changes
5050
Parameter Type Changes
5151
----------------------
5252

53-
- **Services:** The first parameter of ``Services::security()`` has been
54-
changed from ``Config\App`` to ``Config\Security``.
53+
- **Services:**
54+
- The first parameter of ``Services::security()`` has been changed from
55+
``Config\App`` to ``Config\Security``.
56+
- The first parameter of ``Services::session()`` has been changed from
57+
``Config\App`` to ``Config\Session``.
5558
- **Session:**
5659
- The second parameter of ``Session::__construct()`` has been changed from
5760
``Config\App`` to ``Config\Session``.

0 commit comments

Comments
 (0)