Skip to content

Commit 71a17f9

Browse files
committed
Fix for PHP 8.4
1 parent 7c6a1e3 commit 71a17f9

File tree

6 files changed

+126
-113
lines changed

6 files changed

+126
-113
lines changed

application/config/Boot/production.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
|
1010
| If you set 'display_errors' to '1', CI4's detailed error report will show.
1111
*/
12+
error_reporting(E_ALL & ~E_DEPRECATED);
13+
// If you want to suppress more types of errors.
14+
// error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
1215
ini_set('display_errors', '0');
13-
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
1416

1517
/*
1618
|--------------------------------------------------------------------------

index.php

+9-8
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,19 @@
4646

4747
$paths = new App\Config\Paths();
4848

49-
// Location of the framework bootstrap file.
50-
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
51-
52-
// Load environment settings from .env files into $_SERVER and $_ENV
53-
require_once SYSTEMPATH . 'Config/DotEnv.php';
54-
(new DotEnv(ROOTPATH))->load();
55-
5649
// Define ENVIRONMENT
5750
if (! defined('ENVIRONMENT')) {
58-
define('ENVIRONMENT', env('CI_ENVIRONMENT', 'production'));
51+
// @phpstan-ignore-next-line
52+
$env = $_ENV['CI_ENVIRONMENT'] ?? $_SERVER['CI_ENVIRONMENT']
53+
?? getenv('CI_ENVIRONMENT')
54+
?: 'production';
55+
56+
define('ENVIRONMENT', $env);
5957
}
6058

59+
// Location of the framework bootstrap file.
60+
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
61+
6162
// Load Config Cache
6263
// $factoriesCache = new \CodeIgniter\Cache\FactoriesCache();
6364
// $factoriesCache->load('config');

system/CodeIgniter.php

-16
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,6 @@
3838
$benchmark->start('total_execution');
3939
$benchmark->start('bootstrap');
4040

41-
/*
42-
* ------------------------------------------------------
43-
* Load any environment-specific settings from .env file
44-
* ------------------------------------------------------
45-
*/
46-
if (is_file(APPPATH . 'config/Boot/' . ENVIRONMENT . '.php')) {
47-
require_once APPPATH . 'config/Boot/' . ENVIRONMENT . '.php';
48-
} else {
49-
// @codeCoverageIgnoreStart{
50-
header('HTTP/1.1 503 Service Unavailable.', true, 503);
51-
echo 'The application environment is not set correctly.';
52-
53-
exit(EXIT_ERROR); // EXIT_ERROR
54-
// @codeCoverageIgnoreEnd
55-
}
56-
5741
//--------------------------------------------------------------------
5842
// CSRF Protection
5943
//--------------------------------------------------------------------

system/Config/Services.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public static function routes($getShared = false)
315315
* The Router class uses a RouteCollection's array of routes, and determines
316316
* the correct Controller and Method to execute.
317317
*/
318-
public static function router(RouteCollectionInterface $routes = null, bool $getShared = false)
318+
public static function router(?RouteCollectionInterface $routes = null, bool $getShared = false)
319319
{
320320
if ($getShared === true)
321321
{

0 commit comments

Comments
 (0)