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' regex: '### PHP Version'
- do: description - do: description
must_include: must_include:
regex: '### CodeIgniter Version' regex: '### CodeIgniter4 Version'
- do: author - do: author
must_include: must_include:
regex: ^kenjis|lonnieezell|MGatner|michalsn|paulbalandan|samsonasik$ regex: ^kenjis|lonnieezell|MGatner|michalsn|paulbalandan|samsonasik$

View File

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

View File

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

View File

@ -1061,7 +1061,7 @@ class Forge
protected function _attributeAutoIncrement(array &$attributes, array &$field) protected function _attributeAutoIncrement(array &$attributes, array &$field)
{ {
if (! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === true 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'; $field['auto_increment'] = ' AUTO_INCREMENT';
} }

View File

@ -184,7 +184,7 @@ class Forge extends BaseForge
protected function _attributeAutoIncrement(array &$attributes, array &$field) protected function _attributeAutoIncrement(array &$attributes, array &$field)
{ {
if (! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === true 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', '>=') && version_compare($this->db->getVersion(), '12.1', '>=')
) { ) {
$field['auto_increment'] = ' GENERATED BY DEFAULT ON NULL AS IDENTITY'; $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) protected function _attributeType(array &$attributes)
{ {
// Reset field lengths for data types that don't support it // 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; $attributes['CONSTRAINT'] = null;
} }

View File

@ -360,7 +360,7 @@ class Forge extends BaseForge
protected function _attributeType(array &$attributes) protected function _attributeType(array &$attributes)
{ {
// Reset field lengths for data types that don't support it // 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; $attributes['CONSTRAINT'] = null;
} }
@ -412,7 +412,7 @@ class Forge extends BaseForge
*/ */
protected function _attributeAutoIncrement(array &$attributes, array &$field) 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)'; $field['auto_increment'] = ' IDENTITY(1,1)';
} }
} }

View File

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

View File

@ -49,10 +49,10 @@ if (! function_exists('form_open')) {
$attributes = stringify_attributes($attributes); $attributes = stringify_attributes($attributes);
if (stripos($attributes, 'method=') === false) { if (! str_contains(strtolower($attributes), 'method=')) {
$attributes .= ' method="post"'; $attributes .= ' method="post"';
} }
if (stripos($attributes, 'accept-charset=') === false) { if (! str_contains(strtolower($attributes), 'accept-charset=')) {
$config = config(App::class); $config = config(App::class);
$attributes .= ' accept-charset="' . strtolower($config->charset) . '"'; $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 // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites
$before = service('filters')->getFilters()['before']; $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); $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. // 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']); 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']); unset($defaults['cols']);
} }
@ -248,7 +248,7 @@ if (! function_exists('form_multiselect')) {
{ {
$extra = stringify_attributes($extra); $extra = stringify_attributes($extra);
if (stripos($extra, 'multiple') === false) { if (! str_contains(strtolower($extra), strtolower('multiple'))) {
$extra .= ' multiple="multiple"'; $extra .= ' multiple="multiple"';
} }
@ -305,7 +305,7 @@ if (! function_exists('form_dropdown')) {
} }
$extra = stringify_attributes($extra); $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"; $form = '<select ' . rtrim(parse_form_attributes($data, $defaults)) . $extra . $multiple . ">\n";
foreach ($options as $key => $val) { foreach ($options as $key => $val) {

View File

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

View File

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

View File

@ -96,8 +96,8 @@ final class CacheFactoryTest extends CIUnitTestCase
$this->config->handler = 'dummy'; $this->config->handler = 'dummy';
if (stripos('win', php_uname()) === 0) { if (is_windows()) {
$this->assertTrue(true); // can't test properly if we are on Windows $this->markTestSkipped('Cannot test this properly on Windows.');
} else { } else {
$this->assertInstanceOf(DummyHandler::class, $this->cacheFactory->getHandler($this->config, 'wincache', 'wincache')); $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('There.', 404)));
$this->assertSame([500, EXIT_ERROR], $determineCodes(new RuntimeException('This.', 167))); $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 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.'))); $this->assertSame([500, EXIT_DATABASE], $determineCodes(new DatabaseException('This.')));
} }

View File

@ -16,19 +16,17 @@ namespace CodeIgniter;
use CodeIgniter\Exceptions\DebugTraceableTrait; use CodeIgniter\Exceptions\DebugTraceableTrait;
use CodeIgniter\Exceptions\FrameworkException; use CodeIgniter\Exceptions\FrameworkException;
use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\CIUnitTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\Group;
/** /**
* @internal * @internal
*/ */
#[CoversClass(DebugTraceableTrait::class)]
#[Group('Others')] #[Group('Others')]
final class DebugTraceableTraitTest extends CIUnitTestCase final class DebugTraceableTraitTest extends CIUnitTestCase
{ {
public function testFactoryInstanceReturnsWhereItIsRaised(): void public function testFactoryInstanceReturnsWhereItIsRaised(): void
{ {
$e1 = new FrameworkException('Hello.'); $e1 = new FrameworkException('Hello.'); // @phpstan-ignore codeigniter.frameworkExceptionInstance
$e2 = FrameworkException::forEnabledZlibOutputCompression(); $e2 = FrameworkException::forEnabledZlibOutputCompression();
$this->assertContainsEquals(DebugTraceableTrait::class, class_uses(FrameworkException::class)); $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 - argument.type.neon
- assign.propertyType.neon - assign.propertyType.neon
- codeigniter.cacheHandlerInstance.neon - codeigniter.cacheHandlerInstance.neon
- codeigniter.frameworkExceptionInstance.neon
- codeigniter.getReassignArray.neon - codeigniter.getReassignArray.neon
- codeigniter.modelArgumentInstanceof.neon - codeigniter.modelArgumentInstanceof.neon
- codeigniter.modelArgumentType.neon - codeigniter.modelArgumentType.neon

View File

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