Skip to content

Commit 543dd5e

Browse files
committed
Release v4.2.11
1 parent 6ffad15 commit 543dd5e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+633
-335
lines changed

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@
33
## What is CodeIgniter?
44

55
CodeIgniter is a PHP full-stack web framework that is light, fast, flexible and secure.
6-
More information can be found at the [official site](http://codeigniter.com).
6+
More information can be found at the [official site](https://codeigniter.com).
77

8-
This repository holds the distributable version of the framework,
9-
including the user guide. It has been built from the
8+
This repository holds the distributable version of the framework.
9+
It has been built from the
1010
[development repository](https://github.com/codeigniter4/CodeIgniter4).
1111

12-
More information about the plans for version 4 can be found in [the announcement](http://forum.codeigniter.com/thread-62615.html) on the forums.
12+
More information about the plans for version 4 can be found in [CodeIgniter 4](https://forum.codeigniter.com/forumdisplay.php?fid=28) on the forums.
1313

14-
The user guide corresponding to this version of the framework can be found
14+
The user guide corresponding to the latest version of the framework can be found
1515
[here](https://codeigniter4.github.io/userguide/).
1616

17-
1817
## Important Change with index.php
1918

2019
`index.php` is no longer in the root of the project! It has been moved inside the *public* folder,
@@ -46,11 +45,10 @@ Please read the [*Contributing to CodeIgniter*](https://github.com/codeigniter4/
4645
PHP version 7.4 or higher is required, with the following extensions installed:
4746

4847
- [intl](http://php.net/manual/en/intl.requirements.php)
49-
- [libcurl](http://php.net/manual/en/curl.requirements.php) if you plan to use the HTTP\CURLRequest library
48+
- [mbstring](http://php.net/manual/en/mbstring.installation.php)
5049

5150
Additionally, make sure that the following extensions are enabled in your PHP:
5251

5352
- json (enabled by default - don't turn it off)
54-
- [mbstring](http://php.net/manual/en/mbstring.installation.php)
55-
- [mysqlnd](http://php.net/manual/en/mysqlnd.install.php)
56-
- xml (enabled by default - don't turn it off)
53+
- [mysqlnd](http://php.net/manual/en/mysqlnd.install.php) if you plan to use MySQL
54+
- [libcurl](http://php.net/manual/en/curl.requirements.php) if you plan to use the HTTP\CURLRequest library

app/Config/App.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,18 +332,21 @@ class App extends BaseConfig
332332
*
333333
* If your server is behind a reverse proxy, you must whitelist the proxy
334334
* IP addresses from which CodeIgniter should trust headers such as
335-
* HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify
335+
* X-Forwarded-For or Client-IP in order to properly identify
336336
* the visitor's IP address.
337337
*
338-
* You can use both an array or a comma-separated list of proxy addresses,
339-
* as well as specifying whole subnets. Here are a few examples:
338+
* You need to set a proxy IP address or IP address with subnets and
339+
* the HTTP header for the client IP address.
340340
*
341-
* Comma-separated: '10.0.1.200,192.168.5.0/24'
342-
* Array: ['10.0.1.200', '192.168.5.0/24']
341+
* Here are some examples:
342+
* [
343+
* '10.0.1.200' => 'X-Forwarded-For',
344+
* '192.168.5.0/24' => 'X-Real-IP',
345+
* ]
343346
*
344-
* @var string|string[]
347+
* @var array<string, string>
345348
*/
346-
public $proxyIPs = '';
349+
public $proxyIPs = [];
347350

348351
/**
349352
* --------------------------------------------------------------------------

app/Config/Autoload.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ class Autoload extends AutoloadConfig
3434
*```
3535
* $psr4 = [
3636
* 'CodeIgniter' => SYSTEMPATH,
37-
* 'App' => APPPATH
37+
* 'App' => APPPATH
3838
* ];
3939
*```
4040
*
41-
* @var array<string, string>
41+
* @var array<string, array<int, string>|string>
42+
* @phpstan-var array<string, string|list<string>>
4243
*/
4344
public $psr4 = [
4445
APP_NAMESPACE => APPPATH, // For custom app namespace
@@ -76,8 +77,8 @@ class Autoload extends AutoloadConfig
7677
*
7778
* Prototype:
7879
* ```
79-
* $files = [
80-
* '/path/to/my/file.php',
80+
* $files = [
81+
* '/path/to/my/file.php',
8182
* ];
8283
* ```
8384
*

app/Config/Logger.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,14 @@ class Logger extends BaseConfig
141141
* Uncomment this block to use it.
142142
*/
143143
// 'CodeIgniter\Log\Handlers\ErrorlogHandler' => [
144-
// /* The log levels this handler can handle. */
145-
// 'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'],
144+
// /* The log levels this handler can handle. */
145+
// 'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'],
146146
//
147-
// /*
148-
// * The message type where the error should go. Can be 0 or 4, or use the
149-
// * class constants: `ErrorlogHandler::TYPE_OS` (0) or `ErrorlogHandler::TYPE_SAPI` (4)
150-
// */
151-
// 'messageType' => 0,
147+
// /*
148+
// * The message type where the error should go. Can be 0 or 4, or use the
149+
// * class constants: `ErrorlogHandler::TYPE_OS` (0) or `ErrorlogHandler::TYPE_SAPI` (4)
150+
// */
151+
// 'messageType' => 0,
152152
// ],
153153
];
154154
}

app/Config/Toolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Toolbar extends BaseConfig
4949
* Collect Var Data
5050
* --------------------------------------------------------------------------
5151
*
52-
* If set to false var data from the views will not be colleted. Usefull to
52+
* If set to false var data from the views will not be colleted. Useful to
5353
* avoid high memory usage when there are lots of data passed to the view.
5454
*
5555
* @var bool

app/Views/welcome_message.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@
270270
<p>CodeIgniter is a community-developed open source project, with several
271271
venues for the community members to gather and exchange ideas. View all
272272
the threads on <a href="https://forum.codeigniter.com/"
273-
target="_blank">CodeIgniter's forum</a>, or <a href="https://codeigniterchat.slack.com/"
273+
target="_blank">CodeIgniter's forum</a>, or <a href="https://join.slack.com/t/codeigniterchat/shared_invite/zt-rl30zw00-obL1Hr1q1ATvkzVkFp8S0Q"
274274
target="_blank">chat on Slack</a> !</p>
275275

276276
<h2>

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"license": "MIT",
77
"require": {
88
"php": "^7.4 || ^8.0",
9-
"ext-curl": "*",
109
"ext-intl": "*",
1110
"ext-json": "*",
1211
"ext-mbstring": "*",
@@ -17,13 +16,14 @@
1716
"require-dev": {
1817
"codeigniter/coding-standard": "^1.5",
1918
"fakerphp/faker": "^1.9",
20-
"friendsofphp/php-cs-fixer": "~3.13.0",
19+
"friendsofphp/php-cs-fixer": "3.13.0",
2120
"mikey179/vfsstream": "^1.6",
2221
"nexusphp/cs-config": "^3.6",
2322
"phpunit/phpunit": "^9.1",
2423
"predis/predis": "^1.1 || ^2.0"
2524
},
2625
"suggest": {
26+
"ext-curl": "If you use CURLRequest class",
2727
"ext-imagick": "If you use Image class ImageMagickHandler",
2828
"ext-gd": "If you use Image class GDHandler",
2929
"ext-exif": "If you run Image class tests",
@@ -57,7 +57,7 @@
5757
"test": "phpunit"
5858
},
5959
"support": {
60-
"forum": "http://forum.codeigniter.com/",
60+
"forum": "https://forum.codeigniter.com/",
6161
"source": "https://github.com/codeigniter4/CodeIgniter4",
6262
"slack": "https://codeigniterchat.slack.com"
6363
}

preload.php

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php
2+
3+
/**
4+
* This file is part of CodeIgniter 4 framework.
5+
*
6+
* (c) CodeIgniter Foundation <[email protected]>
7+
*
8+
* For the full copyright and license information, please view
9+
* the LICENSE file that was distributed with this source code.
10+
*/
11+
12+
/*
13+
*---------------------------------------------------------------
14+
* Sample file for Preloading
15+
*---------------------------------------------------------------
16+
* See https://www.php.net/manual/en/opcache.preloading.php
17+
*
18+
* How to Use:
19+
* 0. Copy this file to your project root folder.
20+
* 1. Set the $paths property of the preload class below.
21+
* 2. Set opcache.preload in php.ini.
22+
* php.ini:
23+
* opcache.preload=/path/to/preload.php
24+
*/
25+
26+
// Load the paths config file
27+
require __DIR__ . '/app/Config/Paths.php';
28+
29+
// Path to the front controller
30+
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR);
31+
32+
/**
33+
* See https://www.php.net/manual/en/function.str-contains.php#126277
34+
*/
35+
if (! function_exists('str_contains')) {
36+
/**
37+
* Polyfill of str_contains()
38+
*/
39+
function str_contains(string $haystack, string $needle): bool
40+
{
41+
return empty($needle) || strpos($haystack, $needle) !== false;
42+
}
43+
}
44+
45+
class preload
46+
{
47+
/**
48+
* @var array Paths to preload.
49+
*/
50+
private array $paths = [
51+
[
52+
'include' => __DIR__ . '/vendor/codeigniter4/framework/system',
53+
'exclude' => [
54+
// Not needed if you don't use them.
55+
'/system/Database/OCI8/',
56+
'/system/Database/Postgre/',
57+
'/system/Database/SQLSRV/',
58+
// Not needed.
59+
'/system/Database/Seeder.php',
60+
'/system/Test/',
61+
'/system/Language/',
62+
'/system/CLI/',
63+
'/system/Commands/',
64+
'/system/Publisher/',
65+
'/system/ComposerScripts.php',
66+
'/Views/',
67+
// Errors occur.
68+
'/system/Config/Routes.php',
69+
'/system/ThirdParty/',
70+
],
71+
],
72+
];
73+
74+
public function __construct()
75+
{
76+
$this->loadAutoloader();
77+
}
78+
79+
private function loadAutoloader()
80+
{
81+
$paths = new Config\Paths();
82+
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
83+
}
84+
85+
/**
86+
* Load PHP files.
87+
*/
88+
public function load()
89+
{
90+
foreach ($this->paths as $path) {
91+
$directory = new RecursiveDirectoryIterator($path['include']);
92+
$fullTree = new RecursiveIteratorIterator($directory);
93+
$phpFiles = new RegexIterator(
94+
$fullTree,
95+
'/.+((?<!Test)+\.php$)/i',
96+
RecursiveRegexIterator::GET_MATCH
97+
);
98+
99+
foreach ($phpFiles as $key => $file) {
100+
foreach ($path['exclude'] as $exclude) {
101+
if (str_contains($file[0], $exclude)) {
102+
continue 2;
103+
}
104+
}
105+
106+
require_once $file[0];
107+
echo 'Loaded: ' . $file[0] . "\n";
108+
}
109+
}
110+
}
111+
}
112+
113+
(new preload())->load();

system/API/ResponseTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ trait ResponseTrait
6666
/**
6767
* How to format the response data.
6868
* Either 'json' or 'xml'. If blank will be
69-
* determine through content negotiation.
69+
* determined through content negotiation.
7070
*
7171
* @var string
7272
*/

system/Autoloader/Autoloader.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,19 @@ public function initialize(Autoload $config, Modules $modules)
8888

8989
// We have to have one or the other, though we don't enforce the need
9090
// to have both present in order to work.
91-
if (empty($config->psr4) && empty($config->classmap)) {
91+
if ($config->psr4 === [] && $config->classmap === []) {
9292
throw new InvalidArgumentException('Config array must contain either the \'psr4\' key or the \'classmap\' key.');
9393
}
9494

95-
if (isset($config->psr4)) {
95+
if ($config->psr4 !== []) {
9696
$this->addNamespace($config->psr4);
9797
}
9898

99-
if (isset($config->classmap)) {
99+
if ($config->classmap !== []) {
100100
$this->classmap = $config->classmap;
101101
}
102102

103-
if (isset($config->files)) {
103+
if ($config->files !== []) {
104104
$this->files = $config->files;
105105
}
106106

@@ -148,7 +148,8 @@ public function register()
148148
/**
149149
* Registers namespaces with the autoloader.
150150
*
151-
* @param array|string $namespace
151+
* @param array<string, array<int, string>|string>|string $namespace
152+
* @phpstan-param array<string, list<string>|string>|string $namespace
152153
*
153154
* @return $this
154155
*/

0 commit comments

Comments
 (0)