Skip to content

Commit 6f63602

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.5
2 parents 3e98e2b + 815b802 commit 6f63602

File tree

12 files changed

+69
-35
lines changed

12 files changed

+69
-35
lines changed

system/Autoloader/Autoloader.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,21 @@ public function initialize(Autoload $config, Modules $modules)
124124
}
125125

126126
if (is_file(COMPOSER_PATH)) {
127-
$this->loadComposerInfo($modules);
127+
$this->loadComposerAutoloader($modules);
128128
}
129129

130130
return $this;
131131
}
132132

133-
private function loadComposerInfo(Modules $modules): void
133+
private function loadComposerAutoloader(Modules $modules): void
134134
{
135-
/**
136-
* @var ClassLoader $composer
137-
*/
135+
// The path to the vendor directory.
136+
// We do not want to enforce this, so set the constant if Composer was used.
137+
if (! defined('VENDORPATH')) {
138+
define('VENDORPATH', dirname(COMPOSER_PATH) . DIRECTORY_SEPARATOR);
139+
}
140+
141+
/** @var ClassLoader $composer */
138142
$composer = include COMPOSER_PATH;
139143

140144
$this->loadComposerClassmap($composer);

system/CLI/CLI.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public static function init()
179179
* Named options must be in the following formats:
180180
* php index.php user -v --v -name=John --name=John
181181
*
182-
* @param string $prefix You may specify a string with which to prompt the user.
182+
* @param string|null $prefix You may specify a string with which to prompt the user.
183183
*/
184184
public static function input(?string $prefix = null): string
185185
{
@@ -210,9 +210,9 @@ public static function input(?string $prefix = null): string
210210
* // Do not provide options but requires a valid email
211211
* $email = CLI::prompt('What is your email?', null, 'required|valid_email');
212212
*
213-
* @param string $field Output "field" question
214-
* @param array|string $options String to a default value, array to a list of options (the first option will be the default value)
215-
* @param array|string $validation Validation rules
213+
* @param string $field Output "field" question
214+
* @param array|string $options String to a default value, array to a list of options (the first option will be the default value)
215+
* @param array|string|null $validation Validation rules
216216
*
217217
* @return string The user input
218218
*
@@ -258,7 +258,7 @@ public static function prompt(string $field, $options = null, $validation = null
258258
$input = trim(static::input()) ?: $default;
259259

260260
if ($validation) {
261-
while (! static::validate(trim($field), $input, $validation)) {
261+
while (! static::validate('"' . trim($field) . '"', $input, $validation)) {
262262
$input = static::prompt($field, $options, $validation);
263263
}
264264
}
@@ -448,7 +448,7 @@ public static function print(string $text = '', ?string $foreground = null, ?str
448448
}
449449

450450
/**
451-
* Outputs a string to the cli on it's own line.
451+
* Outputs a string to the cli on its own line.
452452
*
453453
* @return void
454454
*/
@@ -574,10 +574,10 @@ public static function clearScreen()
574574
* Returns the given text with the correct color codes for a foreground and
575575
* optionally a background color.
576576
*
577-
* @param string $text The text to color
578-
* @param string $foreground The foreground color
579-
* @param string $background The background color
580-
* @param string $format Other formatting to apply. Currently only 'underline' is understood
577+
* @param string $text The text to color
578+
* @param string $foreground The foreground color
579+
* @param string|null $background The background color
580+
* @param string|null $format Other formatting to apply. Currently only 'underline' is understood
581581
*
582582
* @return string The color coded string
583583
*/
@@ -834,7 +834,7 @@ public static function showProgress($thisStep = 1, int $totalSteps = 10)
834834
* width.
835835
*
836836
* If an int is passed into $pad_left, then all strings after the first
837-
* will padded with that many spaces to the left. Useful when printing
837+
* will pad with that many spaces to the left. Useful when printing
838838
* short descriptions that need to start on an existing line.
839839
*/
840840
public static function wrap(?string $string = null, int $max = 0, int $padLeft = 0): string

system/CLI/Console.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace CodeIgniter\CLI;
1313

1414
use CodeIgniter\CodeIgniter;
15+
use Config\App;
1516
use Config\Services;
1617
use Exception;
1718

@@ -31,6 +32,10 @@ class Console
3132
*/
3233
public function run()
3334
{
35+
// Create CLIRequest
36+
$appConfig = config(App::class);
37+
Services::createRequest($appConfig, true);
38+
3439
$runner = Services::commands();
3540
$params = array_merge(CLI::getSegments(), CLI::getOptions());
3641
$params = $this->parseParamsForHelpOption($params);

system/Commands/Utilities/Routes/FilterCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function get(string $method, string $uri): array
5151
];
5252
}
5353

54-
$request = Services::request(null, false);
54+
$request = Services::incomingrequest(null, false);
5555
$request->setMethod($method);
5656

5757
$router = $this->createRouter($request);

system/Filters/Filters.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ public function __construct($config, RequestInterface $request, ResponseInterfac
126126
*
127127
* Sample :
128128
* $filters->aliases['custom-auth'] = \Acme\Blob\Filters\BlobAuth::class;
129+
*
130+
* @deprecated 4.4.2 Use Registrar instead.
129131
*/
130132
private function discoverFilters(): void
131133
{

system/Test/ControllerTestTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ protected function setUpControllerTestTrait(): void
105105
}
106106

107107
if (empty($this->request)) {
108-
// Do some acrobatics so we can use the Request service with our own URI
108+
// Do some acrobatics, so we can use the Request service with our own URI
109109
$tempUri = Services::uri();
110110
Services::injectMock('uri', $this->uri);
111111

112-
$this->withRequest(Services::request($this->appConfig, false));
112+
$this->withRequest(Services::incomingrequest($this->appConfig, false));
113113

114114
// Restore the URI service
115115
Services::injectMock('uri', $tempUri);

system/Test/ControllerTester.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ protected function setUpControllerTester(): void
108108
$tempUri = Services::uri();
109109
Services::injectMock('uri', $this->uri);
110110

111-
$this->withRequest(Services::request($this->appConfig, false)->setBody($this->body));
111+
$this->withRequest(Services::incomingrequest($this->appConfig, false)->setBody($this->body));
112112

113113
// Restore the URI service
114114
Services::injectMock('uri', $tempUri);

system/Test/FeatureTestTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ protected function setupRequest(string $method, ?string $path = null): IncomingR
289289

290290
Services::injectMock('uri', $uri);
291291

292-
$request = Services::request($config, false);
292+
$request = Services::incomingrequest($config, false);
293293

294294
$request->setMethod($method);
295295
$request->setProtocolVersion('1.1');

system/bootstrap.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,3 @@
104104
// Initialize and register the loader with the SPL autoloader stack.
105105
Services::autoloader()->initialize(new Autoload(), new Modules())->register();
106106
Services::autoloader()->loadHelpers();
107-
108-
// Now load Composer's if it's available
109-
if (is_file(COMPOSER_PATH)) {
110-
/*
111-
* The path to the vendor directory.
112-
*
113-
* We do not want to enforce this, so set the constant if Composer was used.
114-
*/
115-
if (! defined('VENDORPATH')) {
116-
define('VENDORPATH', dirname(COMPOSER_PATH) . DIRECTORY_SEPARATOR);
117-
}
118-
119-
require_once COMPOSER_PATH;
120-
}

user_guide_src/source/changelogs/v4.4.2.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@ Changes
2929
Deprecations
3030
************
3131

32+
- **Filters:** The Auto-Discovery for Filters and ``Filters::discoverFilters()``
33+
is deprecated. Use :ref:`registrars` instead. See :ref:`modules-filters` for
34+
details.
35+
3236
Bugs Fixed
3337
**********
3438

3539
- **CodeIgniter:** Fixed a bug that returned "200 OK" response status code when
3640
Page Not Found.
41+
- **Spark:** Fixed a bug that caused spark to not display exceptions in the
42+
production mode or to display backtrace in json when an exception occurred.
3743

3844
See the repo's
3945
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_

user_guide_src/source/general/modules.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,18 @@ the **Modules** config file, described above.
160160
When working with modules, it can be a problem if the routes in the application contain wildcards.
161161
In that case, see :ref:`routing-priority`.
162162

163+
.. _modules-filters:
164+
163165
Filters
164166
=======
165167

168+
.. deprecated:: 4.4.2
169+
170+
.. note:: This feature is deprecated. Use :ref:`registrars` instead like the
171+
following:
172+
173+
.. literalinclude:: modules/015.php
174+
166175
By default, :doc:`filters <../incoming/filters>` are automatically scanned for within modules.
167176
It can be turned off in the **Modules** config file, described above.
168177

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace CodeIgniter\Shield\Config;
4+
5+
use CodeIgniter\Shield\Filters\SessionAuth;
6+
use CodeIgniter\Shield\Filters\TokenAuth;
7+
8+
class Registrar
9+
{
10+
/**
11+
* Registers the Shield filters.
12+
*/
13+
public static function Filters(): array
14+
{
15+
return [
16+
'aliases' => [
17+
'session' => SessionAuth::class,
18+
'tokens' => TokenAuth::class,
19+
],
20+
];
21+
}
22+
}

0 commit comments

Comments
 (0)