diff --git a/.no-header.php-cs-fixer.dist.php b/.no-header.php-cs-fixer.dist.php index b7e082dff72d..8f7eb0a71cf1 100644 --- a/.no-header.php-cs-fixer.dist.php +++ b/.no-header.php-cs-fixer.dist.php @@ -14,6 +14,7 @@ use Nexus\CsConfig\Factory; use PhpCsFixer\Finder; use Utils\PhpCsFixer\CodeIgniter4; +use Utils\PhpCsFixer\Fixer\Comment\SpaceAfterCommentStartFixer; $finder = Finder::create() ->files() @@ -26,8 +27,14 @@ $overrides = []; $options = [ - 'cacheFile' => 'build/.no-header.php-cs-fixer.cache', - 'finder' => $finder, + 'cacheFile' => 'build/.no-header.php-cs-fixer.cache', + 'finder' => $finder, + 'customFixers' => [ + new SpaceAfterCommentStartFixer(), + ], + 'customRules' => [ + 'CodeIgniter4/space_after_comment_start' => true, + ], ]; return Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects(); diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 15db678cbd35..95478343a53a 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -14,6 +14,7 @@ use Nexus\CsConfig\Factory; use PhpCsFixer\Finder; use Utils\PhpCsFixer\CodeIgniter4; +use Utils\PhpCsFixer\Fixer\Comment\SpaceAfterCommentStartFixer; $finder = Finder::create() ->files() @@ -34,8 +35,14 @@ $overrides = []; $options = [ - 'cacheFile' => 'build/.php-cs-fixer.cache', - 'finder' => $finder, + 'cacheFile' => 'build/.php-cs-fixer.cache', + 'finder' => $finder, + 'customFixers' => [ + new SpaceAfterCommentStartFixer(), + ], + 'customRules' => [ + 'CodeIgniter4/space_after_comment_start' => true, + ], ]; return Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary( diff --git a/system/BaseModel.php b/system/BaseModel.php index 1d777506976f..e57ac4fec6bd 100644 --- a/system/BaseModel.php +++ b/system/BaseModel.php @@ -1327,7 +1327,7 @@ public function validate($data): bool return true; } - //Validation requires array, so cast away. + // Validation requires array, so cast away. if (is_object($data)) { $data = (array) $data; } diff --git a/system/Cache/Handlers/MemcachedHandler.php b/system/Cache/Handlers/MemcachedHandler.php index 7684dffdbbbe..2667abca92a6 100644 --- a/system/Cache/Handlers/MemcachedHandler.php +++ b/system/Cache/Handlers/MemcachedHandler.php @@ -220,7 +220,7 @@ public function decrement(string $key, int $offset = 1) $key = static::validateKey($key, $this->prefix); - //FIXME: third parameter isn't other handler actions. + // FIXME: third parameter isn't other handler actions. // @phpstan-ignore-next-line return $this->memcached->decrement($key, $offset, $offset, 60); } diff --git a/system/Common.php b/system/Common.php index 4a3a6102e4de..129a3374738e 100644 --- a/system/Common.php +++ b/system/Common.php @@ -978,8 +978,8 @@ function single_service(string $name, ...$params) } if (! function_exists('slash_item')) { - //Unlike CI3, this function is placed here because - //it's not a config, or part of a config. + // Unlike CI3, this function is placed here because + // it's not a config, or part of a config. /** * Fetch a config file item with slash appended (if not empty) * diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index 80cc2b962191..c7bec269c472 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -461,7 +461,7 @@ abstract public function reconnect(); */ public function getConnection(?string $alias = null) { - //@todo work with read/write connections + // @todo work with read/write connections return $this->connID; } diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php index 07218ed47ba2..5950148984ef 100644 --- a/system/Debug/Exceptions.php +++ b/system/Debug/Exceptions.php @@ -85,7 +85,7 @@ public function __construct(ExceptionsConfig $config, IncomingRequest $request, */ public function initialize() { - //Set the Exception Handler + // Set the Exception Handler set_exception_handler([$this, 'exceptionHandler']); // Set the Error Handler diff --git a/system/Entity/Entity.php b/system/Entity/Entity.php index 74339dd6eefe..03f6327f8142 100644 --- a/system/Entity/Entity.php +++ b/system/Entity/Entity.php @@ -353,7 +353,7 @@ protected function castAs($value, string $attribute, string $method = 'get') $type = substr($type, 1); } - //In order not to create a separate handler for the + // In order not to create a separate handler for the // json-array type, we transform the required one. $type = $type === 'json-array' ? 'json[array]' : $type; @@ -363,7 +363,7 @@ protected function castAs($value, string $attribute, string $method = 'get') $params = []; - //Attempt to retrieve additional parameters if specified + // Attempt to retrieve additional parameters if specified // type[param, param2,param3] if (preg_match('/^(.+)\[(.+)\]$/', $type, $matches)) { $type = $matches[1]; diff --git a/system/HTTP/Files/UploadedFile.php b/system/HTTP/Files/UploadedFile.php index 17e9130694fe..6455a5106d8d 100644 --- a/system/HTTP/Files/UploadedFile.php +++ b/system/HTTP/Files/UploadedFile.php @@ -127,7 +127,7 @@ public function __construct(string $path, string $originalName, ?string $mimeTyp public function move(string $targetPath, ?string $name = null, bool $overwrite = false) { $targetPath = rtrim($targetPath, '/') . '/'; - $targetPath = $this->setPath($targetPath); //set the target path + $targetPath = $this->setPath($targetPath); // set the target path if ($this->hasMoved) { throw HTTPException::forAlreadyMoved(); @@ -169,7 +169,7 @@ protected function setPath(string $path): string { if (! is_dir($path)) { mkdir($path, 0777, true); - //create the index.html file + // create the index.html file if (! is_file($path . 'index.html')) { $file = fopen($path . 'index.html', 'x+b'); fclose($file); diff --git a/system/Helpers/inflector_helper.php b/system/Helpers/inflector_helper.php index ad632a3f12c8..b4d38015564f 100755 --- a/system/Helpers/inflector_helper.php +++ b/system/Helpers/inflector_helper.php @@ -27,7 +27,7 @@ function singular(string $string): string return $result; } - //Arranged in order. + // Arranged in order. $singularRules = [ '/(matr)ices$/' => '\1ix', '/(vert|ind)ices$/' => '\1ex', diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 7a9ab5010872..b3a3f8e75f56 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -1155,7 +1155,7 @@ static function ($m) use ($i) { $from = str_ireplace(':' . $tag, $pattern, $from); } - //If is redirect, No processing + // If is redirect, No processing if (! isset($options['redirect']) && is_string($to)) { // If no namespace found, add the default namespace if (strpos($to, '\\') === false || strpos($to, '\\') > 0) { diff --git a/system/Test/DOMParser.php b/system/Test/DOMParser.php index 90062f05c158..531adf737364 100644 --- a/system/Test/DOMParser.php +++ b/system/Test/DOMParser.php @@ -64,7 +64,7 @@ public function withString(string $content) // converts all special characters to utf-8 $content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'); - //turning off some errors + // turning off some errors libxml_use_internal_errors(true); if (! $this->dom->loadHTML($content)) { diff --git a/system/View/Parser.php b/system/View/Parser.php index 080a30c35674..c58f2b427dc5 100644 --- a/system/View/Parser.php +++ b/system/View/Parser.php @@ -333,7 +333,7 @@ protected function parsePair(string $variable, array $data, string $template): a $str .= $out; } - //Escape | character from filters as it's handled as OR in regex + // Escape | character from filters as it's handled as OR in regex $escapedMatch = preg_replace('/(?currentSection = $name; $this->sectionStack[] = $name; diff --git a/tests/_support/Database/Migrations/20160428212500_Create_test_tables.php b/tests/_support/Database/Migrations/20160428212500_Create_test_tables.php index b79866b446ae..07b61cdd2451 100644 --- a/tests/_support/Database/Migrations/20160428212500_Create_test_tables.php +++ b/tests/_support/Database/Migrations/20160428212500_Create_test_tables.php @@ -45,9 +45,9 @@ public function up() 'value' => ['type' => 'VARCHAR', 'constraint' => 400, 'null' => true], ])->addKey('id', true)->createTable('misc', true); - //Database Type test table - //missing types : - //TINYINT,MEDIUMINT,BIT,YEAR,BINARY , VARBINARY, TINYTEXT,LONGTEXT,YEAR,JSON,Spatial data types + // Database Type test table + // missing types : + // TINYINT,MEDIUMINT,BIT,YEAR,BINARY , VARBINARY, TINYTEXT,LONGTEXT,YEAR,JSON,Spatial data types // id must be interger else SQLite3 error on not null for autoinc field $data_type_fields = [ 'id' => ['type' => 'INTEGER', 'constraint' => 20, 'auto_increment' => true], diff --git a/tests/_support/Database/Seeds/CITestSeeder.php b/tests/_support/Database/Seeds/CITestSeeder.php index 2f90f86cdee9..0319896159ab 100644 --- a/tests/_support/Database/Seeds/CITestSeeder.php +++ b/tests/_support/Database/Seeds/CITestSeeder.php @@ -110,7 +110,7 @@ public function run() ], ]; - //set SQL times to more correct format + // set SQL times to more correct format if ($this->db->DBDriver === 'SQLite3') { $data['type_test'][0]['type_date'] = '2020/01/11'; $data['type_test'][0]['type_time'] = '15:22:00'; diff --git a/tests/system/Cache/CacheFactoryTest.php b/tests/system/Cache/CacheFactoryTest.php index 237554d5e5fd..ec978504fcfb 100644 --- a/tests/system/Cache/CacheFactoryTest.php +++ b/tests/system/Cache/CacheFactoryTest.php @@ -30,7 +30,7 @@ protected function setUp(): void $this->cacheFactory = new CacheFactory(); - //Initialize path + // Initialize path $this->config = new Cache(); $this->config->storePath .= self::$directory; } @@ -98,7 +98,7 @@ public function testGetDummyHandler() $this->assertInstanceOf(DummyHandler::class, $this->cacheFactory->getHandler($this->config)); - //Initialize path + // Initialize path $this->config = new Cache(); $this->config->storePath .= self::$directory; } @@ -117,7 +117,7 @@ public function testHandlesBadHandler() $this->assertInstanceOf(DummyHandler::class, $this->cacheFactory->getHandler($this->config, 'wincache', 'wincache')); } - //Initialize path + // Initialize path $this->config = new Cache(); $this->config->storePath .= self::$directory; } diff --git a/tests/system/Cache/Handlers/RedisHandlerTest.php b/tests/system/Cache/Handlers/RedisHandlerTest.php index 9c0a13147c5c..66f3c7fd2244 100644 --- a/tests/system/Cache/Handlers/RedisHandlerTest.php +++ b/tests/system/Cache/Handlers/RedisHandlerTest.php @@ -157,14 +157,14 @@ public function testDeleteMatchingSuffix() $this->assertSame('keys=90', $dbInfo[0]); } - //FIXME: I don't like all Hash logic very much. It's wasting memory. - //public function testIncrement() - //{ - //} - - //public function testDecrement() - //{ - //} + // FIXME: I don't like all Hash logic very much. It's wasting memory. + // public function testIncrement() + // { + // } + + // public function testDecrement() + // { + // } public function testClean() { diff --git a/tests/system/Database/Live/GetTest.php b/tests/system/Database/Live/GetTest.php index e361ce2bafc4..16424c252d29 100644 --- a/tests/system/Database/Live/GetTest.php +++ b/tests/system/Database/Live/GetTest.php @@ -93,79 +93,79 @@ public function testGetFieldData() $typeTest = $this->db->table('type_test')->get()->getFieldData(); if ($this->db->DBDriver === 'SQLite3') { - $this->assertSame('integer', $typeTest[0]->type_name); //INTEGER AUTO INC - $this->assertSame('text', $typeTest[1]->type_name); //VARCHAR - $this->assertSame('text', $typeTest[2]->type_name); //CHAR - $this->assertSame('text', $typeTest[3]->type_name); //TEXT - $this->assertSame('integer', $typeTest[4]->type_name); //SMALLINT - $this->assertSame('integer', $typeTest[5]->type_name); //INTEGER - $this->assertSame('float', $typeTest[6]->type_name); //FLOAT - $this->assertSame('float', $typeTest[7]->type_name); //NUMERIC - $this->assertSame('text', $typeTest[8]->type_name); //DATE - $this->assertSame('text', $typeTest[9]->type_name); //TIME - $this->assertSame('text', $typeTest[10]->type_name); //DATETIME - $this->assertSame('text', $typeTest[11]->type_name); //TIMESTAMP - $this->assertSame('integer', $typeTest[12]->type_name); //BIGINT - $this->assertSame('float', $typeTest[13]->type_name); //REAL - $this->assertSame('text', $typeTest[14]->type_name); //ENUM - $this->assertSame('text', $typeTest[15]->type_name); //SET - $this->assertSame('text', $typeTest[16]->type_name); //MEDIUMTEXT - $this->assertSame('float', $typeTest[17]->type_name); //DOUBLE - $this->assertSame('float', $typeTest[18]->type_name); //DECIMAL - $this->assertSame('text', $typeTest[19]->type_name); //BLOB + $this->assertSame('integer', $typeTest[0]->type_name); // INTEGER AUTO INC + $this->assertSame('text', $typeTest[1]->type_name); // VARCHAR + $this->assertSame('text', $typeTest[2]->type_name); // CHAR + $this->assertSame('text', $typeTest[3]->type_name); // TEXT + $this->assertSame('integer', $typeTest[4]->type_name); // SMALLINT + $this->assertSame('integer', $typeTest[5]->type_name); // INTEGER + $this->assertSame('float', $typeTest[6]->type_name); // FLOAT + $this->assertSame('float', $typeTest[7]->type_name); // NUMERIC + $this->assertSame('text', $typeTest[8]->type_name); // DATE + $this->assertSame('text', $typeTest[9]->type_name); // TIME + $this->assertSame('text', $typeTest[10]->type_name); // DATETIME + $this->assertSame('text', $typeTest[11]->type_name); // TIMESTAMP + $this->assertSame('integer', $typeTest[12]->type_name); // BIGINT + $this->assertSame('float', $typeTest[13]->type_name); // REAL + $this->assertSame('text', $typeTest[14]->type_name); // ENUM + $this->assertSame('text', $typeTest[15]->type_name); // SET + $this->assertSame('text', $typeTest[16]->type_name); // MEDIUMTEXT + $this->assertSame('float', $typeTest[17]->type_name); // DOUBLE + $this->assertSame('float', $typeTest[18]->type_name); // DECIMAL + $this->assertSame('text', $typeTest[19]->type_name); // BLOB } if ($this->db->DBDriver === 'MySQLi') { - $this->assertSame('long', $typeTest[0]->type_name); //INTEGER AUTOINC - $this->assertSame('var_string', $typeTest[1]->type_name); //VARCHAR - $this->assertSame('string', $typeTest[2]->type_name); //CHAR - $this->assertSame('blob', $typeTest[3]->type_name); //TEXT - $this->assertSame('short', $typeTest[4]->type_name); //SMALLINT - $this->assertSame('long', $typeTest[5]->type_name); //INTEGER - $this->assertSame('float', $typeTest[6]->type_name); //FLOAT - $this->assertSame('newdecimal', $typeTest[7]->type_name); //NUMERIC - $this->assertSame('date', $typeTest[8]->type_name); //DATE - $this->assertSame('time', $typeTest[9]->type_name); //TIME - $this->assertSame('datetime', $typeTest[10]->type_name); //DATETIME - $this->assertSame('timestamp', $typeTest[11]->type_name); //TIMESTAMP - $this->assertSame('longlong', $typeTest[12]->type_name); //BIGINT - $this->assertSame('double', $typeTest[13]->type_name); //REAL - $this->assertSame('string', $typeTest[14]->type_name); //ENUM - $this->assertSame('string', $typeTest[15]->type_name); //SET - $this->assertSame('blob', $typeTest[16]->type_name); //MEDIUMTEXT - $this->assertSame('double', $typeTest[17]->type_name); //DOUBLE - $this->assertSame('newdecimal', $typeTest[18]->type_name); //DECIMAL - $this->assertSame('blob', $typeTest[19]->type_name); //BLOB + $this->assertSame('long', $typeTest[0]->type_name); // INTEGER AUTOINC + $this->assertSame('var_string', $typeTest[1]->type_name); // VARCHAR + $this->assertSame('string', $typeTest[2]->type_name); // CHAR + $this->assertSame('blob', $typeTest[3]->type_name); // TEXT + $this->assertSame('short', $typeTest[4]->type_name); // SMALLINT + $this->assertSame('long', $typeTest[5]->type_name); // INTEGER + $this->assertSame('float', $typeTest[6]->type_name); // FLOAT + $this->assertSame('newdecimal', $typeTest[7]->type_name); // NUMERIC + $this->assertSame('date', $typeTest[8]->type_name); // DATE + $this->assertSame('time', $typeTest[9]->type_name); // TIME + $this->assertSame('datetime', $typeTest[10]->type_name); // DATETIME + $this->assertSame('timestamp', $typeTest[11]->type_name); // TIMESTAMP + $this->assertSame('longlong', $typeTest[12]->type_name); // BIGINT + $this->assertSame('double', $typeTest[13]->type_name); // REAL + $this->assertSame('string', $typeTest[14]->type_name); // ENUM + $this->assertSame('string', $typeTest[15]->type_name); // SET + $this->assertSame('blob', $typeTest[16]->type_name); // MEDIUMTEXT + $this->assertSame('double', $typeTest[17]->type_name); // DOUBLE + $this->assertSame('newdecimal', $typeTest[18]->type_name); // DECIMAL + $this->assertSame('blob', $typeTest[19]->type_name); // BLOB } if ($this->db->DBDriver === 'Postgre') { - $this->assertSame('int4', $typeTest[0]->type_name); //INTEGER AUTOINC - $this->assertSame('varchar', $typeTest[1]->type_name); //VARCHAR - $this->assertSame('bpchar', $typeTest[2]->type_name); //CHAR - $this->assertSame('text', $typeTest[3]->type_name); //TEXT - $this->assertSame('int2', $typeTest[4]->type_name); //SMALLINT - $this->assertSame('int4', $typeTest[5]->type_name); //INTEGER - $this->assertSame('float8', $typeTest[6]->type_name); //FLOAT - $this->assertSame('numeric', $typeTest[7]->type_name); //NUMERIC - $this->assertSame('date', $typeTest[8]->type_name); //DATE - $this->assertSame('time', $typeTest[9]->type_name); //TIME - $this->assertSame('timestamp', $typeTest[10]->type_name); //DATETIME - $this->assertSame('timestamp', $typeTest[11]->type_name); //TIMESTAMP - $this->assertSame('int8', $typeTest[12]->type_name); //BIGINT + $this->assertSame('int4', $typeTest[0]->type_name); // INTEGER AUTOINC + $this->assertSame('varchar', $typeTest[1]->type_name); // VARCHAR + $this->assertSame('bpchar', $typeTest[2]->type_name); // CHAR + $this->assertSame('text', $typeTest[3]->type_name); // TEXT + $this->assertSame('int2', $typeTest[4]->type_name); // SMALLINT + $this->assertSame('int4', $typeTest[5]->type_name); // INTEGER + $this->assertSame('float8', $typeTest[6]->type_name); // FLOAT + $this->assertSame('numeric', $typeTest[7]->type_name); // NUMERIC + $this->assertSame('date', $typeTest[8]->type_name); // DATE + $this->assertSame('time', $typeTest[9]->type_name); // TIME + $this->assertSame('timestamp', $typeTest[10]->type_name); // DATETIME + $this->assertSame('timestamp', $typeTest[11]->type_name); // TIMESTAMP + $this->assertSame('int8', $typeTest[12]->type_name); // BIGINT } if ($this->db->DBDriver === 'SQLSRV') { - $this->assertSame('int', $typeTest[0]->type_name); //INTEGER AUTOINC - $this->assertSame('varchar', $typeTest[1]->type_name); //VARCHAR - $this->assertSame('char', $typeTest[2]->type_name); //CHAR - $this->assertSame('text', $typeTest[3]->type_name); //TEXT - $this->assertSame('smallint', $typeTest[4]->type_name); //SMALLINT - $this->assertSame('int', $typeTest[5]->type_name); //INTEGER - $this->assertSame('float', $typeTest[6]->type_name); //FLOAT - $this->assertSame('numeric', $typeTest[7]->type_name); //NUMERIC - $this->assertNull($typeTest[8]->type_name); //DATE - $this->assertNull($typeTest[9]->type_name); //TIME - $this->assertNull($typeTest[10]->type_name); //DATETIME - $this->assertSame('bigint', $typeTest[11]->type_name); //BIGINT - $this->assertSame('real', $typeTest[12]->type_name); //REAL - $this->assertSame('decimal', $typeTest[13]->type_name); //DECIMAL + $this->assertSame('int', $typeTest[0]->type_name); // INTEGER AUTOINC + $this->assertSame('varchar', $typeTest[1]->type_name); // VARCHAR + $this->assertSame('char', $typeTest[2]->type_name); // CHAR + $this->assertSame('text', $typeTest[3]->type_name); // TEXT + $this->assertSame('smallint', $typeTest[4]->type_name); // SMALLINT + $this->assertSame('int', $typeTest[5]->type_name); // INTEGER + $this->assertSame('float', $typeTest[6]->type_name); // FLOAT + $this->assertSame('numeric', $typeTest[7]->type_name); // NUMERIC + $this->assertNull($typeTest[8]->type_name); // DATE + $this->assertNull($typeTest[9]->type_name); // TIME + $this->assertNull($typeTest[10]->type_name); // DATETIME + $this->assertSame('bigint', $typeTest[11]->type_name); // BIGINT + $this->assertSame('real', $typeTest[12]->type_name); // REAL + $this->assertSame('decimal', $typeTest[13]->type_name); // DECIMAL } } diff --git a/tests/system/HTTP/CLIRequestTest.php b/tests/system/HTTP/CLIRequestTest.php index 7940624e68bb..c31bace6b554 100644 --- a/tests/system/HTTP/CLIRequestTest.php +++ b/tests/system/HTTP/CLIRequestTest.php @@ -604,7 +604,7 @@ public function testGetIPAddressThruProxyOutofSubnet() $this->assertSame('192.168.5.21', $this->request->getIPAddress()); } - //FIXME getIPAddress should have more testing, to 100% code coverage + // FIXME getIPAddress should have more testing, to 100% code coverage public function testMethodReturnsRightStuff() { diff --git a/tests/system/HTTP/RequestTest.php b/tests/system/HTTP/RequestTest.php index d75cd0ed8665..e4ad2d6bf340 100644 --- a/tests/system/HTTP/RequestTest.php +++ b/tests/system/HTTP/RequestTest.php @@ -671,7 +671,7 @@ public function testGetIPAddressThruProxyOutofSubnet() $this->assertSame('192.168.5.21', $this->request->getIPAddress()); } - //FIXME getIPAddress should have more testing, to 100% code coverage + // FIXME getIPAddress should have more testing, to 100% code coverage public function testMethodReturnsRightStuff() { diff --git a/tests/system/Helpers/HTMLHelperTest.php b/tests/system/Helpers/HTMLHelperTest.php index 71c145fc26da..c5665ea94e05 100755 --- a/tests/system/Helpers/HTMLHelperTest.php +++ b/tests/system/Helpers/HTMLHelperTest.php @@ -35,7 +35,7 @@ protected function setUp(): void { parent::setUp(); - //URL is needed by the HTML Helper. + // URL is needed by the HTML Helper. helper('url'); helper('html'); diff --git a/tests/system/Router/RouteCollectionTest.php b/tests/system/Router/RouteCollectionTest.php index 8220f1857485..8f586a4fcbb8 100644 --- a/tests/system/Router/RouteCollectionTest.php +++ b/tests/system/Router/RouteCollectionTest.php @@ -950,7 +950,7 @@ public function testAddRedirect() { $routes = $this->getCollector(); - //The second parameter is either the new URI to redirect to, or the name of a named route. + // The second parameter is either the new URI to redirect to, or the name of a named route. $routes->addRedirect('users', 'users/index', 307); $expected = [ diff --git a/tests/system/View/ParserTest.php b/tests/system/View/ParserTest.php index 98c6c56ed9b4..547d9b549d0f 100644 --- a/tests/system/View/ParserTest.php +++ b/tests/system/View/ParserTest.php @@ -953,7 +953,7 @@ public function testRenderStringSavingData() $this->parser->setData(['testString' => 'Hello World']); $this->assertSame($expected, $this->parser->renderString($pattern, [], false)); $this->assertArrayNotHasKey('testString', $this->parser->getData()); - //last set data is not saved + // last set data is not saved $this->parser->setData(['testString' => 'Hello World']); $this->assertSame($expected, $this->parser->renderString($pattern, [], true)); $this->assertArrayHasKey('testString', $this->parser->getData()); diff --git a/tests/system/View/ViewTest.php b/tests/system/View/ViewTest.php index 6003e5134b6a..7abeff5793e6 100644 --- a/tests/system/View/ViewTest.php +++ b/tests/system/View/ViewTest.php @@ -232,7 +232,7 @@ public function testRenderStringSavingData() $view = new View($this->config, $this->viewsDir, $this->loader); $expected = '

Hello World

'; - //I think saveData is sava current data, is not clean already set data. + // I think saveData is sava current data, is not clean already set data. $view->setVar('testString', 'Hello World'); $this->assertSame($expected, $view->renderString('

', [], false)); $this->assertArrayNotHasKey('testString', $view->getData()); diff --git a/utils/PhpCsFixer/Fixer/Comment/SpaceAfterCommentStartFixer.php b/utils/PhpCsFixer/Fixer/Comment/SpaceAfterCommentStartFixer.php new file mode 100644 index 000000000000..d7322c32d308 --- /dev/null +++ b/utils/PhpCsFixer/Fixer/Comment/SpaceAfterCommentStartFixer.php @@ -0,0 +1,95 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Utils\PhpCsFixer\Fixer\Comment; + +use PhpCsFixer\AbstractFixer; +use PhpCsFixer\FixerDefinition\CodeSample; +use PhpCsFixer\FixerDefinition\FixerDefinition; +use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; +use PhpCsFixer\Preg; +use PhpCsFixer\Tokenizer\Token; +use PhpCsFixer\Tokenizer\Tokens; +use SplFileInfo; + +/** + * @internal + */ +final class SpaceAfterCommentStartFixer extends AbstractFixer +{ + /** + * {@inheritDoc} + */ + public function getName(): string + { + return 'CodeIgniter4/' . parent::getName(); + } + + /** + * {@inheritDoc} + */ + public function getDefinition(): FixerDefinitionInterface + { + return new FixerDefinition( + 'There should be a single whitespace after the comment start', + [new CodeSample("isTokenKindFound(T_COMMENT); + } + + /** + * {@inheritDoc} + * + * Must run after NoEmptyCommentFixer + */ + public function getPriority(): int + { + return 3; + } + + /** + * {@inheritDoc} + */ + protected function applyFix(SplFileInfo $file, Tokens $tokens): void + { + for ($index = 1, $count = $tokens->count(); $index < $count; $index++) { + /** @var Token $token */ + $token = $tokens[$index]; + + if (! $token->isGivenKind(T_COMMENT)) { + continue; + } + + $comment = $token->getContent(); + + if (substr($comment, 0, 2) !== '//') { + continue; + } + + if (Preg::match('/^\/\/(?!\s+)(.+)/', $comment, $matches) !== 1) { + continue; + } + + if (Preg::match('/\-+/', $matches[1]) === 1 || Preg::match('/\=+/', $matches[1]) === 1) { + continue; + } + + $tokens[$index] = new Token([T_COMMENT, '// ' . $matches[1]]); + } + } +}