Skip to content

Commit e273ab9

Browse files
committed
fix: remove declare(strict_types=1)
1 parent 5c6fafb commit e273ab9

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

system/CodeIgniter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
/**
64
* This file is part of CodeIgniter 4 framework.
75
*
@@ -881,6 +879,8 @@ protected function runController($class)
881879
// This is a Web request or PHP CLI request
882880
$params = $this->router->params();
883881

882+
// The controller method param types may not be string.
883+
// So cannot set `declare(strict_types=1)` in this file.
884884
$output = method_exists($class, '_remap')
885885
? $class->_remap($this->method, ...$params)
886886
: $class->{$this->method}(...$params);

system/Config/BaseConfig.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
/**
64
* This file is part of CodeIgniter 4 framework.
75
*
@@ -166,6 +164,9 @@ protected function initEnvValue(&$property, string $name, string $prefix, string
166164
$value = (float) $value;
167165
}
168166

167+
// If the default value of the property is `null` and the type is not
168+
// `string`, TypeError will happen.
169+
// So cannot set `declare(strict_types=1)` in this file.
169170
$property = $value;
170171
}
171172
}

system/Test/ControllerTestTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
/**
64
* This file is part of CodeIgniter 4 framework.
75
*
@@ -163,6 +161,8 @@ public function execute(string $method, ...$params)
163161

164162
try {
165163
ob_start();
164+
// The controller method param types may not be string.
165+
// So cannot set `declare(strict_types=1)` in this file.
166166
$response = $this->controller->{$method}(...$params);
167167
} catch (Throwable $e) {
168168
$code = $e->getCode();

system/View/Parser.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
/**
64
* This file is part of CodeIgniter 4 framework.
75
*
@@ -618,6 +616,7 @@ protected function applyFilters(string $replace, array $filters): string
618616
}
619617

620618
// Filter it....
619+
// We can't know correct param types, so can't set `declare(strict_types=1)`.
621620
$replace = $this->config->filters[$filter]($replace, ...$param);
622621
}
623622

tests/system/Debug/ExceptionsTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
/**
64
* This file is part of CodeIgniter 4 framework.
75
*
@@ -73,6 +71,7 @@ public function testDeprecationsOnPhp81DoNotThrow(): void
7371
$maybeNull = PHP_VERSION_ID >= 80100 ? null : 'random string';
7472

7573
try {
74+
// We test DEPRECATED error, so cannot set `declare(strict_types=1)` in this file.
7675
strlen($maybeNull);
7776
$this->assertLogContains('error', '[DEPRECATED] strlen(): ');
7877
} catch (ErrorException $e) {

0 commit comments

Comments
 (0)