Skip to content

Commit 80719d4

Browse files
committed
Merge branch 'develop' into 4.6
2 parents 17d6ade + 119330c commit 80719d4

17 files changed

+23
-55
lines changed

.github/mergeable.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mergeable:
1313
regex: '### PHP Version'
1414
- do: description
1515
must_include:
16-
regex: '### CodeIgniter Version'
16+
regex: '### CodeIgniter4 Version'
1717
- do: author
1818
must_include:
1919
regex: ^kenjis|lonnieezell|MGatner|michalsn|paulbalandan|samsonasik$

.php-cs-fixer.dist.php

+1-11
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,7 @@
4040
]);
4141

4242
$overrides = [
43-
'get_class_to_class_keyword' => true,
44-
'trailing_comma_in_multiline' => [
45-
'after_heredoc' => true,
46-
'elements' => [
47-
'arguments',
48-
'array_destructuring',
49-
'arrays',
50-
'match',
51-
'parameters',
52-
],
53-
],
43+
'modernize_strpos' => ['modernize_stripos' => true],
5444
];
5545

5646
$options = [

phpunit.xml.dist

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
failOnWarning="true"
1212
cacheDirectory="build/.phpunit.cache">
1313
<coverage
14-
includeUncoveredFiles="true"
1514
pathCoverage="false"
1615
ignoreDeprecatedCodeUnits="true"
1716
disableCodeCoverageIgnore="true">

system/Database/Forge.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ protected function _attributeUnique(array &$attributes, array &$field)
10611061
protected function _attributeAutoIncrement(array &$attributes, array &$field)
10621062
{
10631063
if (! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === true
1064-
&& stripos($field['type'], 'int') !== false
1064+
&& str_contains(strtolower($field['type']), 'int')
10651065
) {
10661066
$field['auto_increment'] = ' AUTO_INCREMENT';
10671067
}

system/Database/OCI8/Forge.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ protected function _alterTable(string $alterType, string $table, $processedField
184184
protected function _attributeAutoIncrement(array &$attributes, array &$field)
185185
{
186186
if (! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === true
187-
&& stripos($field['type'], 'NUMBER') !== false
187+
&& str_contains(strtolower($field['type']), 'number')
188188
&& version_compare($this->db->getVersion(), '12.1', '>=')
189189
) {
190190
$field['auto_increment'] = ' GENERATED BY DEFAULT ON NULL AS IDENTITY';

system/Database/Postgre/Forge.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ protected function _processColumn(array $processedField): string
154154
protected function _attributeType(array &$attributes)
155155
{
156156
// Reset field lengths for data types that don't support it
157-
if (isset($attributes['CONSTRAINT']) && stripos($attributes['TYPE'], 'int') !== false) {
157+
if (isset($attributes['CONSTRAINT']) && str_contains(strtolower($attributes['TYPE']), 'int')) {
158158
$attributes['CONSTRAINT'] = null;
159159
}
160160

system/Database/SQLSRV/Forge.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ protected function _processColumn(array $processedField): string
360360
protected function _attributeType(array &$attributes)
361361
{
362362
// Reset field lengths for data types that don't support it
363-
if (isset($attributes['CONSTRAINT']) && stripos($attributes['TYPE'], 'int') !== false) {
363+
if (isset($attributes['CONSTRAINT']) && str_contains(strtolower($attributes['TYPE']), 'int')) {
364364
$attributes['CONSTRAINT'] = null;
365365
}
366366

@@ -412,7 +412,7 @@ protected function _attributeType(array &$attributes)
412412
*/
413413
protected function _attributeAutoIncrement(array &$attributes, array &$field)
414414
{
415-
if (! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === true && stripos($field['type'], 'INT') !== false) {
415+
if (! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === true && str_contains(strtolower($field['type']), strtolower('INT'))) {
416416
$field['auto_increment'] = ' IDENTITY(1,1)';
417417
}
418418
}

system/Database/SQLite3/Forge.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ protected function _attributeAutoIncrement(array &$attributes, array &$field)
226226
if (
227227
! empty($attributes['AUTO_INCREMENT'])
228228
&& $attributes['AUTO_INCREMENT'] === true
229-
&& stripos($field['type'], 'int') !== false
229+
&& str_contains(strtolower($field['type']), 'int')
230230
) {
231231
$field['type'] = 'INTEGER PRIMARY KEY';
232232
$field['default'] = '';

system/Helpers/form_helper.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ function form_open(string $action = '', $attributes = [], array $hidden = []): s
4949

5050
$attributes = stringify_attributes($attributes);
5151

52-
if (stripos($attributes, 'method=') === false) {
52+
if (! str_contains(strtolower($attributes), 'method=')) {
5353
$attributes .= ' method="post"';
5454
}
55-
if (stripos($attributes, 'accept-charset=') === false) {
55+
if (! str_contains(strtolower($attributes), 'accept-charset=')) {
5656
$config = config(App::class);
5757
$attributes .= ' accept-charset="' . strtolower($config->charset) . '"';
5858
}
@@ -62,7 +62,7 @@ function form_open(string $action = '', $attributes = [], array $hidden = []): s
6262
// Add CSRF field if enabled, but leave it out for GET requests and requests to external websites
6363
$before = service('filters')->getFilters()['before'];
6464

65-
if ((in_array('csrf', $before, true) || array_key_exists('csrf', $before)) && str_contains($action, base_url()) && stripos($form, 'method="get"') === false) {
65+
if ((in_array('csrf', $before, true) || array_key_exists('csrf', $before)) && str_contains($action, base_url()) && ! str_contains(strtolower($form), strtolower('method="get"'))) {
6666
$form .= csrf_field($csrfId ?? null);
6767
}
6868

@@ -223,11 +223,11 @@ function form_textarea($data = '', string $value = '', $extra = ''): string
223223
}
224224

225225
// Unsets default rows and cols if defined in extra field as array or string.
226-
if ((is_array($extra) && array_key_exists('rows', $extra)) || (is_string($extra) && stripos(preg_replace('/\s+/', '', $extra), 'rows=') !== false)) {
226+
if ((is_array($extra) && array_key_exists('rows', $extra)) || (is_string($extra) && str_contains(strtolower(preg_replace('/\s+/', '', $extra)), 'rows='))) {
227227
unset($defaults['rows']);
228228
}
229229

230-
if ((is_array($extra) && array_key_exists('cols', $extra)) || (is_string($extra) && stripos(preg_replace('/\s+/', '', $extra), 'cols=') !== false)) {
230+
if ((is_array($extra) && array_key_exists('cols', $extra)) || (is_string($extra) && str_contains(strtolower(preg_replace('/\s+/', '', $extra)), 'cols='))) {
231231
unset($defaults['cols']);
232232
}
233233

@@ -248,7 +248,7 @@ function form_multiselect($name = '', array $options = [], array $selected = [],
248248
{
249249
$extra = stringify_attributes($extra);
250250

251-
if (stripos($extra, 'multiple') === false) {
251+
if (! str_contains(strtolower($extra), strtolower('multiple'))) {
252252
$extra .= ' multiple="multiple"';
253253
}
254254

@@ -305,7 +305,7 @@ function form_dropdown($data = '', $options = [], $selected = [], $extra = ''):
305305
}
306306

307307
$extra = stringify_attributes($extra);
308-
$multiple = (count($selected) > 1 && stripos($extra, 'multiple') === false) ? ' multiple="multiple"' : '';
308+
$multiple = (count($selected) > 1 && ! str_contains(strtolower($extra), 'multiple')) ? ' multiple="multiple"' : '';
309309
$form = '<select ' . rtrim(parse_form_attributes($data, $defaults)) . $extra . $multiple . ">\n";
310310

311311
foreach ($options as $key => $val) {

system/Test/CIUnitTestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ protected function getHeaderEmitted(string $header, bool $ignoreCase = false, st
518518

519519
foreach (xdebug_get_headers() as $emittedHeader) {
520520
$found = $ignoreCase
521-
? (stripos($emittedHeader, $header) === 0)
521+
? (str_starts_with(strtolower($emittedHeader), strtolower($header)))
522522
: (str_starts_with($emittedHeader, $header));
523523

524524
if ($found) {

system/Test/Fabricator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,12 @@ protected function guessFormatter($field): string
380380

381381
// Check some common partials
382382
foreach (['email', 'name', 'title', 'text', 'date', 'url'] as $term) {
383-
if (stripos($field, $term) !== false) {
383+
if (str_contains(strtolower($field), strtolower($term))) {
384384
return $term;
385385
}
386386
}
387387

388-
if (stripos($field, 'phone') !== false) {
388+
if (str_contains(strtolower($field), 'phone')) {
389389
return 'phoneNumber';
390390
}
391391

tests/system/Cache/CacheFactoryTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ public function testHandlesBadHandler(): void
9696

9797
$this->config->handler = 'dummy';
9898

99-
if (stripos('win', php_uname()) === 0) {
100-
$this->assertTrue(true); // can't test properly if we are on Windows
99+
if (is_windows()) {
100+
$this->markTestSkipped('Cannot test this properly on Windows.');
101101
} else {
102102
$this->assertInstanceOf(DummyHandler::class, $this->cacheFactory->getHandler($this->config, 'wincache', 'wincache'));
103103
}

tests/system/Debug/ExceptionsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function testDetermineCodes(): void
124124
$this->assertSame([500, EXIT_ERROR], $determineCodes(new RuntimeException('There.', 404)));
125125
$this->assertSame([500, EXIT_ERROR], $determineCodes(new RuntimeException('This.', 167)));
126126
$this->assertSame([500, EXIT_CONFIG], $determineCodes(new ConfigException('This.')));
127-
$this->assertSame([500, EXIT_CONFIG], $determineCodes(new CastException('This.')));
127+
$this->assertSame([500, EXIT_CONFIG], $determineCodes(CastException::forInvalidInterface('This.')));
128128
$this->assertSame([500, EXIT_DATABASE], $determineCodes(new DatabaseException('This.')));
129129
}
130130

tests/system/DebugTraceableTraitTest.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,17 @@
1616
use CodeIgniter\Exceptions\DebugTraceableTrait;
1717
use CodeIgniter\Exceptions\FrameworkException;
1818
use CodeIgniter\Test\CIUnitTestCase;
19-
use PHPUnit\Framework\Attributes\CoversClass;
2019
use PHPUnit\Framework\Attributes\Group;
2120

2221
/**
2322
* @internal
2423
*/
25-
#[CoversClass(DebugTraceableTrait::class)]
2624
#[Group('Others')]
2725
final class DebugTraceableTraitTest extends CIUnitTestCase
2826
{
2927
public function testFactoryInstanceReturnsWhereItIsRaised(): void
3028
{
31-
$e1 = new FrameworkException('Hello.');
29+
$e1 = new FrameworkException('Hello.'); // @phpstan-ignore codeigniter.frameworkExceptionInstance
3230
$e2 = FrameworkException::forEnabledZlibOutputCompression();
3331

3432
$this->assertContainsEquals(DebugTraceableTrait::class, class_uses(FrameworkException::class));

utils/phpstan-baseline/codeigniter.frameworkExceptionInstance.neon

-13
This file was deleted.

utils/phpstan-baseline/loader.neon

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ includes:
22
- argument.type.neon
33
- assign.propertyType.neon
44
- codeigniter.cacheHandlerInstance.neon
5-
- codeigniter.frameworkExceptionInstance.neon
65
- codeigniter.getReassignArray.neon
76
- codeigniter.modelArgumentInstanceof.neon
87
- codeigniter.modelArgumentType.neon

utils/phpstan-baseline/method.alreadyNarrowedType.neon

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 17 errors
1+
# total 16 errors
22

33
parameters:
44
ignoreErrors:
@@ -12,11 +12,6 @@ parameters:
1212
count: 2
1313
path: ../../tests/system/CLI/CLITest.php
1414

15-
-
16-
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with true will always evaluate to true\.$#'
17-
count: 1
18-
path: ../../tests/system/Cache/CacheFactoryTest.php
19-
2015
-
2116
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with true will always evaluate to true\.$#'
2217
count: 1

0 commit comments

Comments
 (0)