Skip to content

Commit 904e4f2

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.6
2 parents c05260c + d49d700 commit 904e4f2

File tree

24 files changed

+54
-36
lines changed

24 files changed

+54
-36
lines changed

rector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
5454
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
5555
use Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector;
56+
use Rector\TypeDeclaration\Rector\Closure\ClosureReturnTypeRector;
5657
use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector;
5758
use Rector\TypeDeclaration\Rector\Function_\AddFunctionVoidReturnTypeWhereNoReturnRector;
5859
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
@@ -217,6 +218,7 @@
217218
AddFunctionVoidReturnTypeWhereNoReturnRector::class,
218219
AddMethodCallBasedStrictParamTypeRector::class,
219220
TypedPropertyFromAssignsRector::class,
221+
ClosureReturnTypeRector::class,
220222
])
221223
->withConfiguredRule(StringClassNameToClassConstantRector::class, [
222224
// keep '\\' prefix string on string '\Foo\Bar'

system/Database/OCI8/Builder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ protected function _replace(string $table, array $keys, array $values): string
109109
{
110110
$fieldNames = array_map(static fn ($columnName) => trim($columnName, '"'), $keys);
111111

112-
$uniqueIndexes = array_filter($this->db->getIndexData($table), static function ($index) use ($fieldNames) {
112+
$uniqueIndexes = array_filter($this->db->getIndexData($table), static function ($index) use ($fieldNames): bool {
113113
$hasAllFields = count(array_intersect($index->fields, $fieldNames)) === count($index->fields);
114114

115115
return ($index->type === 'PRIMARY') && $hasAllFields;
116116
});
117-
$replaceableFields = array_filter($keys, static function ($columnName) use ($uniqueIndexes) {
117+
$replaceableFields = array_filter($keys, static function ($columnName) use ($uniqueIndexes): bool {
118118
foreach ($uniqueIndexes as $index) {
119119
if (in_array(trim($columnName, '"'), $index->fields, true)) {
120120
return false;
@@ -344,7 +344,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
344344
if (empty($constraints)) {
345345
$fieldNames = array_map(static fn ($columnName) => trim($columnName, '"'), $keys);
346346

347-
$uniqueIndexes = array_filter($this->db->getIndexData($table), static function ($index) use ($fieldNames) {
347+
$uniqueIndexes = array_filter($this->db->getIndexData($table), static function ($index) use ($fieldNames): bool {
348348
$hasAllFields = count(array_intersect($index->fields, $fieldNames)) === count($index->fields);
349349

350350
return ($index->type === 'PRIMARY' || $index->type === 'UNIQUE') && $hasAllFields;

system/Database/OCI8/PreparedQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function parameterize(string $sql): string
113113
// Track our current value
114114
$count = 0;
115115

116-
return preg_replace_callback('/\?/', static function ($matches) use (&$count) {
116+
return preg_replace_callback('/\?/', static function ($matches) use (&$count): string {
117117
return ':' . ($count++);
118118
}, $sql);
119119
}

system/Database/Postgre/Builder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ protected function _updateBatch(string $table, array $keys, array $values): stri
368368
$sql .= 'WHERE ' . implode(
369369
' AND ',
370370
array_map(
371-
static function ($key, $value) use ($table, $alias, $that) {
371+
static function ($key, $value) use ($table, $alias, $that): string|RawSql {
372372
if ($value instanceof RawSql && is_string($key)) {
373373
return $table . '.' . $key . ' = ' . $value;
374374
}
@@ -463,7 +463,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
463463
$constraints = $this->QBOptions['constraints'] ?? [];
464464

465465
if (empty($constraints)) {
466-
$allIndexes = array_filter($this->db->getIndexData($table), static function ($index) use ($fieldNames) {
466+
$allIndexes = array_filter($this->db->getIndexData($table), static function ($index) use ($fieldNames): bool {
467467
$hasAllFields = count(array_intersect($index->fields, $fieldNames)) === count($index->fields);
468468

469469
return ($index->type === 'UNIQUE' || $index->type === 'PRIMARY') && $hasAllFields;
@@ -575,7 +575,7 @@ protected function _deleteBatch(string $table, array $keys, array $values): stri
575575
$sql .= 'WHERE ' . implode(
576576
' AND ',
577577
array_map(
578-
static function ($key, $value) use ($table, $alias, $that) {
578+
static function ($key, $value) use ($table, $alias, $that): RawSql|string {
579579
if ($value instanceof RawSql) {
580580
return $value;
581581
}

system/Database/Postgre/PreparedQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function parameterize(string $sql): string
119119
// Track our current value
120120
$count = 0;
121121

122-
return preg_replace_callback('/\?/', static function () use (&$count) {
122+
return preg_replace_callback('/\?/', static function () use (&$count): string {
123123
$count++;
124124

125125
return "\${$count}";

system/Database/SQLSRV/Builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,15 +699,15 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
699699
if (empty($constraints)) {
700700
$tableIndexes = $this->db->getIndexData($table);
701701

702-
$uniqueIndexes = array_filter($tableIndexes, static function ($index) use ($fieldNames) {
702+
$uniqueIndexes = array_filter($tableIndexes, static function ($index) use ($fieldNames): bool {
703703
$hasAllFields = count(array_intersect($index->fields, $fieldNames)) === count($index->fields);
704704

705705
return $index->type === 'PRIMARY' && $hasAllFields;
706706
});
707707

708708
// if no primary found then look for unique - since indexes have no order
709709
if ($uniqueIndexes === []) {
710-
$uniqueIndexes = array_filter($tableIndexes, static function ($index) use ($fieldNames) {
710+
$uniqueIndexes = array_filter($tableIndexes, static function ($index) use ($fieldNames): bool {
711711
$hasAllFields = count(array_intersect($index->fields, $fieldNames)) === count($index->fields);
712712

713713
return $index->type === 'UNIQUE' && $hasAllFields;

system/Database/SQLite3/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
145145
if (empty($constraints)) {
146146
$fieldNames = array_map(static fn ($columnName) => trim($columnName, '`'), $keys);
147147

148-
$allIndexes = array_filter($this->db->getIndexData($table), static function ($index) use ($fieldNames) {
148+
$allIndexes = array_filter($this->db->getIndexData($table), static function ($index) use ($fieldNames): bool {
149149
$hasAllFields = count(array_intersect($index->fields, $fieldNames)) === count($index->fields);
150150

151151
return ($index->type === 'PRIMARY' || $index->type === 'UNIQUE') && $hasAllFields;

system/Debug/Toolbar/Collectors/Database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ protected function formatTimelineData(): array
148148
public function display(): array
149149
{
150150
$data = [];
151-
$data['queries'] = array_map(static function (array $query) {
151+
$data['queries'] = array_map(static function (array $query): array {
152152
$isDuplicate = $query['duplicate'] === true;
153153

154154
$firstNonSystemLine = '';

system/Events/Events.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static function initialize()
8484
$files = service('locator')->search('Config/Events.php');
8585
}
8686

87-
$files = array_filter(array_map(static function (string $file) {
87+
$files = array_filter(array_map(static function (string $file): false|string {
8888
if (is_file($file)) {
8989
return realpath($file) ?: $file;
9090
}

system/HTTP/ContentSecurityPolicy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ protected function generateNonces(ResponseInterface $response)
713713
$pattern = '/(' . preg_quote($this->styleNonceTag, '/')
714714
. '|' . preg_quote($this->scriptNonceTag, '/') . ')/';
715715

716-
$body = preg_replace_callback($pattern, function ($match) {
716+
$body = preg_replace_callback($pattern, function ($match): string {
717717
$nonce = $match[0] === $this->styleNonceTag ? $this->getStyleNonce() : $this->getScriptNonce();
718718

719719
return "nonce=\"{$nonce}\"";

system/HTTP/Negotiate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function parseHeader(string $header): array
233233
}
234234

235235
// Sort to get the highest results first
236-
usort($results, static function ($a, $b) {
236+
usort($results, static function ($a, $b): int {
237237
if ($a['q'] === $b['q']) {
238238
$aAst = substr_count($a['value'], '*');
239239
$bAst = substr_count($b['value'], '*');

system/Helpers/Array/ArrayHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public static function recursiveCount(array $array, int $counter = 0): int
307307
*/
308308
public static function sortValuesByNatural(array &$array, $sortByIndex = null): bool
309309
{
310-
return usort($array, static function ($currentValue, $nextValue) use ($sortByIndex) {
310+
return usort($array, static function ($currentValue, $nextValue) use ($sortByIndex): int {
311311
if ($sortByIndex !== null) {
312312
return strnatcmp((string) $currentValue[$sortByIndex], (string) $nextValue[$sortByIndex]);
313313
}

system/Helpers/url_helper.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,15 @@ function safe_mailto(string $email, string $title = '', $attributes = ''): strin
351351
function auto_link(string $str, string $type = 'both', bool $popup = false): string
352352
{
353353
// Find and replace any URLs.
354-
if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[a-z0-9]+(-+[a-z0-9]+)*(\.[a-z0-9]+(-+[a-z0-9]+)*)+(/([^\s()<>;]+\w)?/?)?#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
354+
if (
355+
$type !== 'email'
356+
&& preg_match_all(
357+
'#([a-z][a-z0-9+\-.]*://|www\.)[a-z0-9]+(-+[a-z0-9]+)*(\.[a-z0-9]+(-+[a-z0-9]+)*)+(/([^\s()<>;]+\w)?/?)?#i',
358+
$str,
359+
$matches,
360+
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
361+
)
362+
) {
355363
// Set our target HTML if using popup links.
356364
$target = ($popup) ? ' target="_blank"' : '';
357365

@@ -370,7 +378,15 @@ function auto_link(string $str, string $type = 'both', bool $popup = false): str
370378
}
371379

372380
// Find and replace any emails.
373-
if ($type !== 'url' && preg_match_all('#([\w\.\-\+]+@[a-z0-9\-]+\.[a-z0-9\-\.]+[^[:punct:]\s])#i', $str, $matches, PREG_OFFSET_CAPTURE)) {
381+
if (
382+
$type !== 'url'
383+
&& preg_match_all(
384+
'#([\w\.\-\+]+@[a-z0-9\-]+\.[a-z0-9\-\.]+[^[:punct:]\s])#i',
385+
$str,
386+
$matches,
387+
PREG_OFFSET_CAPTURE
388+
)
389+
) {
374390
foreach (array_reverse($matches[0]) as $match) {
375391
if (filter_var($match[0], FILTER_VALIDATE_EMAIL) !== false) {
376392
$str = substr_replace($str, safe_mailto($match[0]), $match[1], strlen($match[0]));

system/Router/Router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ protected function checkRoutes(string $uri): bool
434434
// Is this route supposed to redirect to another?
435435
if ($this->collection->isRedirect($routeKey)) {
436436
// replacing matched route groups with references: post/([0-9]+) -> post/$1
437-
$redirectTo = preg_replace_callback('/(\([^\(]+\))/', static function () {
437+
$redirectTo = preg_replace_callback('/(\([^\(]+\))/', static function (): string {
438438
static $i = 1;
439439

440440
return '$' . $i++;

system/View/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ protected function replaceSingle($pattern, $content, $template, bool $escape = f
534534
$content = (string) $content;
535535

536536
// Replace the content in the template
537-
return preg_replace_callback($pattern, function ($matches) use ($content, $escape) {
537+
return preg_replace_callback($pattern, function ($matches) use ($content, $escape): string {
538538
// Check for {! !} syntax to not escape this one.
539539
if (
540540
str_starts_with($matches[0], $this->leftDelimiter . '!')

tests/system/Commands/Utilities/NamespacesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function tearDown(): void
4242
*/
4343
protected function getBuffer()
4444
{
45-
return preg_replace_callback('/(\|\s*[^|]+\s*\|\s*)(.*?)(\s*\|\s*[^|]+\s*\|)/', static function (array $matches) {
45+
return preg_replace_callback('/(\|\s*[^|]+\s*\|\s*)(.*?)(\s*\|\s*[^|]+\s*\|)/', static function (array $matches): string {
4646
$matches[2] = str_replace(DIRECTORY_SEPARATOR, '/', $matches[2]);
4747

4848
return $matches[1] . $matches[2] . $matches[3];

tests/system/DataConverter/DataConverterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ public function testReconstructObjectWithClosure(): void
606606
'created_at' => 'datetime',
607607
'updated_at' => 'datetime',
608608
];
609-
$reconstructor = static function ($array) {
609+
$reconstructor = static function ($array): User {
610610
$user = new User();
611611
$user->fill($array);
612612

@@ -703,7 +703,7 @@ public function testExtractWithClosure(): void
703703
'created_at' => 'datetime',
704704
'updated_at' => 'datetime',
705705
];
706-
$extractor = static function ($obj) {
706+
$extractor = static function ($obj): array {
707707
$array['id'] = $obj->id;
708708
$array['name'] = $obj->name;
709709
$array['created_at'] = $obj->created_at;

tests/system/Debug/TimerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function testRecordFunctionNoReturn(): void
144144
public function testRecordFunctionWithReturn(): void
145145
{
146146
$timer = new Timer();
147-
$returnValue = $timer->record('longjohn', static function () {
147+
$returnValue = $timer->record('longjohn', static function (): string {
148148
usleep(100000);
149149

150150
return 'test';

tests/system/Events/EventsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function testCancelEvent(): void
121121

122122
// This should cancel the flow of events, and leave
123123
// $result = 1.
124-
Events::on('foo', static function ($arg) use (&$result) {
124+
Events::on('foo', static function ($arg) use (&$result): bool {
125125
$result = 1;
126126

127127
return false;
@@ -138,14 +138,14 @@ public function testPriority(): void
138138
{
139139
$result = 0;
140140

141-
Events::on('foo', static function () use (&$result) {
141+
Events::on('foo', static function () use (&$result): bool {
142142
$result = 1;
143143

144144
return false;
145145
}, EVENT_PRIORITY_NORMAL);
146146
// Since this has a higher priority, it will
147147
// run first.
148-
Events::on('foo', static function () use (&$result) {
148+
Events::on('foo', static function () use (&$result): bool {
149149
$result = 2;
150150

151151
return false;

tests/system/Helpers/URLHelper/MiscUrlTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ public static function provideAutoLinkUrl(): iterable
523523
],
524524
'test06' => [
525525
'This one: ://codeigniter.com must not break this one: http://codeigniter.com',
526-
'This one: <a href="://codeigniter.com">://codeigniter.com</a> must not break this one: <a href="http://codeigniter.com">http://codeigniter.com</a>',
526+
'This one: ://codeigniter.com must not break this one: <a href="http://codeigniter.com">http://codeigniter.com</a>',
527527
],
528528
'test07' => [
529529
'Visit example.com or email [email protected]',
@@ -623,7 +623,7 @@ public static function provideAutolinkBoth(): iterable
623623
],
624624
'test06' => [
625625
'This one: ://codeigniter.com must not break this one: http://codeigniter.com',
626-
'This one: <a href="://codeigniter.com">://codeigniter.com</a> must not break this one: <a href="http://codeigniter.com">http://codeigniter.com</a>',
626+
'This one: ://codeigniter.com must not break this one: <a href="http://codeigniter.com">http://codeigniter.com</a>',
627627
],
628628
'test07' => [
629629
'Visit example.com or email [email protected]',
@@ -675,7 +675,7 @@ public static function provideAutoLinkPopup(): iterable
675675
],
676676
'test06' => [
677677
'This one: ://codeigniter.com must not break this one: http://codeigniter.com',
678-
'This one: <a href="://codeigniter.com" target="_blank">://codeigniter.com</a> must not break this one: <a href="http://codeigniter.com" target="_blank">http://codeigniter.com</a>',
678+
'This one: ://codeigniter.com must not break this one: <a href="http://codeigniter.com" target="_blank">http://codeigniter.com</a>',
679679
],
680680
'test07' => [
681681
'Visit example.com or email [email protected]',

tests/system/Test/FeatureTestTraitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function testCallValidationTwice(): void
153153
[
154154
'POST',
155155
'section/create',
156-
static function () {
156+
static function (): string {
157157
$validation = Services::validation();
158158
$validation->setRule('title', 'title', 'required|min_length[3]');
159159

tests/system/Validation/ValidationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public function testClosureRuleWithParamError(): void
311311
$this->validation->setRules([
312312
'foo' => [
313313
'required',
314-
static function ($value, $data, &$error, $field) {
314+
static function ($value, $data, &$error, $field): bool {
315315
if ($value !== 'abc') {
316316
$error = 'The ' . $field . ' value is not "abc"';
317317

tests/system/View/ParserTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ public function testParserPluginClosure(): void
806806

807807
public function testParserPluginParams(): void
808808
{
809-
$this->parser->addPlugin('growth', static function ($str, array $params) {
809+
$this->parser->addPlugin('growth', static function ($str, array $params): string {
810810
$step = $params['step'] ?? 1;
811811
$count = $params['count'] ?? 2;
812812

@@ -853,7 +853,7 @@ public function testParserSingleTagWithSingleParams(): void
853853

854854
public function testParserSingleTagWithQuotedParams(): void
855855
{
856-
$this->parser->addPlugin('count', static function (array $params = []) {
856+
$this->parser->addPlugin('count', static function (array $params = []): string {
857857
$out = '';
858858

859859
foreach ($params as $index => $param) {
@@ -870,7 +870,7 @@ public function testParserSingleTagWithQuotedParams(): void
870870

871871
public function testParserSingleTagWithNamedParams(): void
872872
{
873-
$this->parser->addPlugin('read_params', static function (array $params = []) {
873+
$this->parser->addPlugin('read_params', static function (array $params = []): string {
874874
$out = '';
875875

876876
foreach ($params as $index => $param) {

user_guide_src/source/general/ajax.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ React
5656
htmx
5757
====
5858

59-
You can use `ajax-header <https://htmx.org/extensions/ajax-header/>`_ extension.
59+
You can use `ajax-header <https://github.com/bigskysoftware/htmx-extensions/blob/main/src/ajax-header/README.md>`_ extension.
6060

6161
.. code-block:: html
6262

0 commit comments

Comments
 (0)