diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 6a857588f64f..89605c9f92d2 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -38,7 +38,11 @@ __DIR__ . '/spark', ]); -$overrides = []; +$overrides = [ + 'no_useless_concat_operator' => [ + 'juggle_simple_strings' => true, + ], +]; $options = [ 'cacheFile' => 'build/.php-cs-fixer.cache', diff --git a/.php-cs-fixer.no-header.php b/.php-cs-fixer.no-header.php index d8241678a771..64eebf72f234 100644 --- a/.php-cs-fixer.no-header.php +++ b/.php-cs-fixer.no-header.php @@ -30,7 +30,11 @@ __DIR__ . '/admin/starter/builds', ]); -$overrides = []; +$overrides = [ + 'no_useless_concat_operator' => [ + 'juggle_simple_strings' => true, + ], +]; $options = [ 'cacheFile' => 'build/.php-cs-fixer.no-header.cache', diff --git a/.php-cs-fixer.user-guide.php b/.php-cs-fixer.user-guide.php index 1fa41bc4fb42..7bb88ccc210a 100644 --- a/.php-cs-fixer.user-guide.php +++ b/.php-cs-fixer.user-guide.php @@ -33,6 +33,9 @@ 'php_unit_internal_class' => false, 'no_unused_imports' => false, 'class_attributes_separation' => false, + 'no_useless_concat_operator' => [ + 'juggle_simple_strings' => true, + ], ]; $options = [ diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 700219fa3030..99aca6604cf5 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -1179,7 +1179,7 @@ public function unionAll($union) */ protected function addUnionStatement($union, bool $all = false) { - $this->QBUnion[] = "\n" . 'UNION ' + $this->QBUnion[] = "\nUNION " . ($all ? 'ALL ' : '') . 'SELECT * FROM ' . $this->buildSubquery($union, true, 'uwrp' . (count($this->QBUnion) + 1)); diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php index 1555725a1f24..b19cb5209262 100644 --- a/system/Database/MySQLi/Connection.php +++ b/system/Database/MySQLi/Connection.php @@ -360,7 +360,7 @@ public function escapeLikeStringDirect($str) // Escape LIKE condition wildcards return str_replace( [$this->likeEscapeChar, '%', '_'], - ['\\' . $this->likeEscapeChar, '\\' . '%', '\\' . '_'], + ['\\' . $this->likeEscapeChar, '\\%', '\\_'], $str ); } diff --git a/system/Debug/Toolbar.php b/system/Debug/Toolbar.php index 257fc6932465..f93bfa0a0f31 100644 --- a/system/Debug/Toolbar.php +++ b/system/Debug/Toolbar.php @@ -386,7 +386,7 @@ public function prepare(?RequestInterface $request = null, ?ResponseInterface $r mkdir(WRITEPATH . 'debugbar', 0777); } - write_file(WRITEPATH . 'debugbar/' . 'debugbar_' . $time . '.json', $data, 'w+'); + write_file(WRITEPATH . 'debugbar/debugbar_' . $time . '.json', $data, 'w+'); $format = $response->getHeaderLine('content-type'); diff --git a/system/Helpers/form_helper.php b/system/Helpers/form_helper.php index aaab2a46e0be..aac4736b2514 100644 --- a/system/Helpers/form_helper.php +++ b/system/Helpers/form_helper.php @@ -484,13 +484,13 @@ function form_datalist(string $name, string $value, array $options): string $out = form_input($data) . "\n"; - $out .= ""; + $out .= ""; foreach ($options as $option) { - $out .= "' . "\n"); + return $out . ("\n"); } } diff --git a/system/View/Parser.php b/system/View/Parser.php index 9b425602c904..ea8c41fd1cfa 100644 --- a/system/View/Parser.php +++ b/system/View/Parser.php @@ -277,7 +277,7 @@ protected function parsePair(string $variable, array $data, string $template): a // have something to loop over. preg_match_all( '#' . $this->leftDelimiter . '\s*' . preg_quote($variable, '#') . '\s*' . $this->rightDelimiter . '(.+?)' . - $this->leftDelimiter . '\s*' . '/' . preg_quote($variable, '#') . '\s*' . $this->rightDelimiter . '#s', + $this->leftDelimiter . '\s*/' . preg_quote($variable, '#') . '\s*' . $this->rightDelimiter . '#s', $template, $matches, PREG_SET_ORDER diff --git a/tests/system/HTTP/MessageTest.php b/tests/system/HTTP/MessageTest.php index 53cc7603f5c6..aea78b4525a9 100644 --- a/tests/system/HTTP/MessageTest.php +++ b/tests/system/HTTP/MessageTest.php @@ -156,7 +156,7 @@ public function testAppendBody() $this->message->appendBody('\n'); - $this->assertSame('moo' . '\n', $this->message->getBody()); + $this->assertSame('moo\n', $this->message->getBody()); } public function testSetHeaderReplacingHeader() diff --git a/tests/system/Images/GDHandlerTest.php b/tests/system/Images/GDHandlerTest.php index 46db29f87118..0cedd83d1c19 100644 --- a/tests/system/Images/GDHandlerTest.php +++ b/tests/system/Images/GDHandlerTest.php @@ -413,7 +413,7 @@ public function testImageConvert() public function testImageReorientLandscape() { for ($i = 0; $i <= 8; $i++) { - $source = $this->origin . 'EXIFsamples/landscape_' . '' . $i . '.jpg'; + $source = $this->origin . 'EXIFsamples/landscape_' . $i . '.jpg'; $this->handler->withFile($source); $this->handler->reorient(); @@ -429,7 +429,7 @@ public function testImageReorientLandscape() public function testImageReorientPortrait() { for ($i = 0; $i <= 8; $i++) { - $source = $this->origin . 'EXIFsamples/portrait_' . '' . $i . '.jpg'; + $source = $this->origin . 'EXIFsamples/portrait_' . $i . '.jpg'; $this->handler->withFile($source); $this->handler->reorient(); diff --git a/tests/system/Images/ImageMagickHandlerTest.php b/tests/system/Images/ImageMagickHandlerTest.php index 77fa8fee87b1..76fb15fe3f7e 100644 --- a/tests/system/Images/ImageMagickHandlerTest.php +++ b/tests/system/Images/ImageMagickHandlerTest.php @@ -408,7 +408,7 @@ public function testImageConvert() public function testImageReorientLandscape() { for ($i = 0; $i <= 8; $i++) { - $source = $this->origin . 'EXIFsamples/landscape_' . '' . $i . '.jpg'; + $source = $this->origin . 'EXIFsamples/landscape_' . $i . '.jpg'; $result = $this->root . 'landscape_' . $i . '_reoriented.jpg'; $this->handler->withFile($source); @@ -427,7 +427,7 @@ public function testImageReorientLandscape() public function testImageReorientPortrait() { for ($i = 0; $i <= 8; $i++) { - $source = $this->origin . 'EXIFsamples/portrait_' . '' . $i . '.jpg'; + $source = $this->origin . 'EXIFsamples/portrait_' . $i . '.jpg'; $result = $this->root . 'portrait_' . $i . '_reoriented.jpg'; $this->handler->withFile($source); diff --git a/user_guide_src/source/testing/benchmark/007.php b/user_guide_src/source/testing/benchmark/007.php index 00c1b7aa2b8f..4997eb1875b0 100644 --- a/user_guide_src/source/testing/benchmark/007.php +++ b/user_guide_src/source/testing/benchmark/007.php @@ -2,12 +2,6 @@ $iterator = new \CodeIgniter\Debug\Iterator(); -// Add a new task -$iterator->add('single_concat', static function () { - $str = 'Some basic' . 'little' . 'string concatenation test.'; -}); - -// Add another task -$iterator->add('double', static function ($a = 'little') { - $str = "Some basic {$little} string test."; +$iterator->add('double', static function ($word = 'little') { + "Some basic {$word} string test."; });