diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index c9c24c7a06f8..e9240c590917 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -40,17 +40,7 @@ ]); $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 = [ diff --git a/system/Database/Forge.php b/system/Database/Forge.php index 83cf1b88d9f4..6bf574818919 100644 --- a/system/Database/Forge.php +++ b/system/Database/Forge.php @@ -1061,7 +1061,7 @@ protected function _attributeUnique(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 + && str_contains(strtolower($field['type']), 'int') ) { $field['auto_increment'] = ' AUTO_INCREMENT'; } diff --git a/system/Database/OCI8/Forge.php b/system/Database/OCI8/Forge.php index 4b09372d778e..f761045d9784 100644 --- a/system/Database/OCI8/Forge.php +++ b/system/Database/OCI8/Forge.php @@ -184,7 +184,7 @@ protected function _alterTable(string $alterType, string $table, $processedField 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'; diff --git a/system/Database/Postgre/Forge.php b/system/Database/Postgre/Forge.php index 704f3e576047..b0a38c90ed23 100644 --- a/system/Database/Postgre/Forge.php +++ b/system/Database/Postgre/Forge.php @@ -154,7 +154,7 @@ protected function _processColumn(array $processedField): string 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; } diff --git a/system/Database/SQLSRV/Forge.php b/system/Database/SQLSRV/Forge.php index f187b9981f88..7b1da6e85ba7 100644 --- a/system/Database/SQLSRV/Forge.php +++ b/system/Database/SQLSRV/Forge.php @@ -360,7 +360,7 @@ protected function _processColumn(array $processedField): string 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 @@ protected function _attributeType(array &$attributes) */ 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)'; } } diff --git a/system/Database/SQLite3/Forge.php b/system/Database/SQLite3/Forge.php index 03120dd7a0da..31c2a7ed58a6 100644 --- a/system/Database/SQLite3/Forge.php +++ b/system/Database/SQLite3/Forge.php @@ -226,7 +226,7 @@ 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['type'] = 'INTEGER PRIMARY KEY'; $field['default'] = ''; diff --git a/system/Helpers/form_helper.php b/system/Helpers/form_helper.php index ae4505c26597..7b89bb9ec173 100644 --- a/system/Helpers/form_helper.php +++ b/system/Helpers/form_helper.php @@ -49,10 +49,10 @@ function form_open(string $action = '', $attributes = [], array $hidden = []): s $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 @@ function form_open(string $action = '', $attributes = [], array $hidden = []): s // 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 @@ function form_textarea($data = '', string $value = '', $extra = ''): 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']); } - 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 @@ function form_multiselect($name = '', array $options = [], array $selected = [], { $extra = stringify_attributes($extra); - if (stripos($extra, 'multiple') === false) { + if (! str_contains(strtolower($extra), strtolower('multiple'))) { $extra .= ' multiple="multiple"'; } @@ -305,7 +305,7 @@ function form_dropdown($data = '', $options = [], $selected = [], $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 = '