Merge branch 'develop' into 4.6

This commit is contained in:
John Paul E. Balandan, CPA 2025-01-18 01:42:58 +08:00
commit 80719d473b
No known key found for this signature in database
GPG Key ID: E60D48954743FDBF
17 changed files with 23 additions and 55 deletions

View File

@ -13,7 +13,7 @@ mergeable:
regex: '### PHP Version'
- do: description
must_include:
regex: '### CodeIgniter Version'
regex: '### CodeIgniter4 Version'
- do: author
must_include:
regex: ^kenjis|lonnieezell|MGatner|michalsn|paulbalandan|samsonasik$

View File

@ -40,17 +40,7 @@ $finder = Finder::create()
]);
$overrides = [
'get_class_to_class_keyword' => true,
'trailing_comma_in_multiline' => [
'after_heredoc' => true,
'elements' => [
'arguments',
'array_destructuring',
'arrays',
'match',
'parameters',
],
],
'modernize_strpos' => ['modernize_stripos' => true],
];
$options = [

View File

@ -11,7 +11,6 @@
failOnWarning="true"
cacheDirectory="build/.phpunit.cache">
<coverage
includeUncoveredFiles="true"
pathCoverage="false"
ignoreDeprecatedCodeUnits="true"
disableCodeCoverageIgnore="true">

View File

@ -1061,7 +1061,7 @@ class Forge
protected function _attributeAutoIncrement(array &$attributes, array &$field)
{
if (! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === true
&& stripos($field['type'], 'int') !== false
&& str_contains(strtolower($field['type']), 'int')
) {
$field['auto_increment'] = ' AUTO_INCREMENT';
}

View File

@ -184,7 +184,7 @@ class Forge extends BaseForge
protected function _attributeAutoIncrement(array &$attributes, array &$field)
{
if (! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === true
&& stripos($field['type'], 'NUMBER') !== false
&& str_contains(strtolower($field['type']), 'number')
&& version_compare($this->db->getVersion(), '12.1', '>=')
) {
$field['auto_increment'] = ' GENERATED BY DEFAULT ON NULL AS IDENTITY';

View File

@ -154,7 +154,7 @@ class Forge extends BaseForge
protected function _attributeType(array &$attributes)
{
// Reset field lengths for data types that don't support it
if (isset($attributes['CONSTRAINT']) && stripos($attributes['TYPE'], 'int') !== false) {
if (isset($attributes['CONSTRAINT']) && str_contains(strtolower($attributes['TYPE']), 'int')) {
$attributes['CONSTRAINT'] = null;
}

View File

@ -360,7 +360,7 @@ class Forge extends BaseForge
protected function _attributeType(array &$attributes)
{
// Reset field lengths for data types that don't support it
if (isset($attributes['CONSTRAINT']) && stripos($attributes['TYPE'], 'int') !== false) {
if (isset($attributes['CONSTRAINT']) && str_contains(strtolower($attributes['TYPE']), 'int')) {
$attributes['CONSTRAINT'] = null;
}
@ -412,7 +412,7 @@ class Forge extends BaseForge
*/
protected function _attributeAutoIncrement(array &$attributes, array &$field)
{
if (! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === true && stripos($field['type'], 'INT') !== false) {
if (! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === true && str_contains(strtolower($field['type']), strtolower('INT'))) {
$field['auto_increment'] = ' IDENTITY(1,1)';
}
}

View File

@ -226,7 +226,7 @@ class Forge extends BaseForge
if (
! empty($attributes['AUTO_INCREMENT'])
&& $attributes['AUTO_INCREMENT'] === true
&& stripos($field['type'], 'int') !== false
&& str_contains(strtolower($field['type']), 'int')
) {
$field['type'] = 'INTEGER PRIMARY KEY';
$field['default'] = '';

View File

@ -49,10 +49,10 @@ if (! function_exists('form_open')) {
$attributes = stringify_attributes($attributes);
if (stripos($attributes, 'method=') === false) {
if (! str_contains(strtolower($attributes), 'method=')) {
$attributes .= ' method="post"';
}
if (stripos($attributes, 'accept-charset=') === false) {
if (! str_contains(strtolower($attributes), 'accept-charset=')) {
$config = config(App::class);
$attributes .= ' accept-charset="' . strtolower($config->charset) . '"';
}
@ -62,7 +62,7 @@ if (! function_exists('form_open')) {
// Add CSRF field if enabled, but leave it out for GET requests and requests to external websites
$before = service('filters')->getFilters()['before'];
if ((in_array('csrf', $before, true) || array_key_exists('csrf', $before)) && str_contains($action, base_url()) && stripos($form, 'method="get"') === false) {
if ((in_array('csrf', $before, true) || array_key_exists('csrf', $before)) && str_contains($action, base_url()) && ! str_contains(strtolower($form), strtolower('method="get"'))) {
$form .= csrf_field($csrfId ?? null);
}
@ -223,11 +223,11 @@ if (! function_exists('form_textarea')) {
}
// Unsets default rows and cols if defined in extra field as array or string.
if ((is_array($extra) && array_key_exists('rows', $extra)) || (is_string($extra) && stripos(preg_replace('/\s+/', '', $extra), 'rows=') !== false)) {
if ((is_array($extra) && array_key_exists('rows', $extra)) || (is_string($extra) && str_contains(strtolower(preg_replace('/\s+/', '', $extra)), 'rows='))) {
unset($defaults['rows']);
}
if ((is_array($extra) && array_key_exists('cols', $extra)) || (is_string($extra) && stripos(preg_replace('/\s+/', '', $extra), 'cols=') !== false)) {
if ((is_array($extra) && array_key_exists('cols', $extra)) || (is_string($extra) && str_contains(strtolower(preg_replace('/\s+/', '', $extra)), 'cols='))) {
unset($defaults['cols']);
}
@ -248,7 +248,7 @@ if (! function_exists('form_multiselect')) {
{
$extra = stringify_attributes($extra);
if (stripos($extra, 'multiple') === false) {
if (! str_contains(strtolower($extra), strtolower('multiple'))) {
$extra .= ' multiple="multiple"';
}
@ -305,7 +305,7 @@ if (! function_exists('form_dropdown')) {
}
$extra = stringify_attributes($extra);
$multiple = (count($selected) > 1 && stripos($extra, 'multiple') === false) ? ' multiple="multiple"' : '';
$multiple = (count($selected) > 1 && ! str_contains(strtolower($extra), 'multiple')) ? ' multiple="multiple"' : '';
$form = '<select ' . rtrim(parse_form_attributes($data, $defaults)) . $extra . $multiple . ">\n";
foreach ($options as $key => $val) {

View File

@ -518,7 +518,7 @@ abstract class CIUnitTestCase extends TestCase
foreach (xdebug_get_headers() as $emittedHeader) {
$found = $ignoreCase
? (stripos($emittedHeader, $header) === 0)
? (str_starts_with(strtolower($emittedHeader), strtolower($header)))
: (str_starts_with($emittedHeader, $header));
if ($found) {

View File

@ -380,12 +380,12 @@ class Fabricator
// Check some common partials
foreach (['email', 'name', 'title', 'text', 'date', 'url'] as $term) {
if (stripos($field, $term) !== false) {
if (str_contains(strtolower($field), strtolower($term))) {
return $term;
}
}
if (stripos($field, 'phone') !== false) {
if (str_contains(strtolower($field), 'phone')) {
return 'phoneNumber';
}

View File

@ -96,8 +96,8 @@ final class CacheFactoryTest extends CIUnitTestCase
$this->config->handler = 'dummy';
if (stripos('win', php_uname()) === 0) {
$this->assertTrue(true); // can't test properly if we are on Windows
if (is_windows()) {
$this->markTestSkipped('Cannot test this properly on Windows.');
} else {
$this->assertInstanceOf(DummyHandler::class, $this->cacheFactory->getHandler($this->config, 'wincache', 'wincache'));
}

View File

@ -124,7 +124,7 @@ final class ExceptionsTest extends CIUnitTestCase
$this->assertSame([500, EXIT_ERROR], $determineCodes(new RuntimeException('There.', 404)));
$this->assertSame([500, EXIT_ERROR], $determineCodes(new RuntimeException('This.', 167)));
$this->assertSame([500, EXIT_CONFIG], $determineCodes(new ConfigException('This.')));
$this->assertSame([500, EXIT_CONFIG], $determineCodes(new CastException('This.')));
$this->assertSame([500, EXIT_CONFIG], $determineCodes(CastException::forInvalidInterface('This.')));
$this->assertSame([500, EXIT_DATABASE], $determineCodes(new DatabaseException('This.')));
}

View File

@ -16,19 +16,17 @@ namespace CodeIgniter;
use CodeIgniter\Exceptions\DebugTraceableTrait;
use CodeIgniter\Exceptions\FrameworkException;
use CodeIgniter\Test\CIUnitTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
/**
* @internal
*/
#[CoversClass(DebugTraceableTrait::class)]
#[Group('Others')]
final class DebugTraceableTraitTest extends CIUnitTestCase
{
public function testFactoryInstanceReturnsWhereItIsRaised(): void
{
$e1 = new FrameworkException('Hello.');
$e1 = new FrameworkException('Hello.'); // @phpstan-ignore codeigniter.frameworkExceptionInstance
$e2 = FrameworkException::forEnabledZlibOutputCompression();
$this->assertContainsEquals(DebugTraceableTrait::class, class_uses(FrameworkException::class));

View File

@ -1,13 +0,0 @@
# total 2 errors
parameters:
ignoreErrors:
-
message: '#^Instantiating CastException using new is not allowed\. Use one of its named constructors instead\.$#'
count: 1
path: ../../tests/system/Debug/ExceptionsTest.php
-
message: '#^Instantiating FrameworkException using new is not allowed\. Use one of its named constructors instead\.$#'
count: 1
path: ../../tests/system/DebugTraceableTraitTest.php

View File

@ -2,7 +2,6 @@ includes:
- argument.type.neon
- assign.propertyType.neon
- codeigniter.cacheHandlerInstance.neon
- codeigniter.frameworkExceptionInstance.neon
- codeigniter.getReassignArray.neon
- codeigniter.modelArgumentInstanceof.neon
- codeigniter.modelArgumentType.neon

View File

@ -1,4 +1,4 @@
# total 17 errors
# total 16 errors
parameters:
ignoreErrors:
@ -12,11 +12,6 @@ parameters:
count: 2
path: ../../tests/system/CLI/CLITest.php
-
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with true will always evaluate to true\.$#'
count: 1
path: ../../tests/system/Cache/CacheFactoryTest.php
-
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with true will always evaluate to true\.$#'
count: 1