Skip to content

Commit 4ab9d66

Browse files
Switch to official coding standard (#5038)
* Switch to official coding standard * Update .no-header.php-cs-fixer.dist.php Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
1 parent cca4660 commit 4ab9d66

18 files changed

Lines changed: 48 additions & 719 deletions

File tree

.github/workflows/test-phpunit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
- name: Install dependencies
124124
run: |
125125
composer update --ansi --no-interaction
126-
composer remove --ansi --dev --unused -W rector/rector phpstan/phpstan friendsofphp/php-cs-fixer nexusphp/cs-config
126+
composer remove --ansi --dev --unused -W rector/rector phpstan/phpstan friendsofphp/php-cs-fixer nexusphp/cs-config codeigniter/coding-standard
127127
php -r 'file_put_contents("vendor/laminas/laminas-zendframework-bridge/src/autoload.php", "");'
128128
env:
129129
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}

.no-header.php-cs-fixer.dist.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,29 @@
1111
* the LICENSE file that was distributed with this source code.
1212
*/
1313

14+
use CodeIgniter\CodingStandard\CodeIgniter4;
1415
use Nexus\CsConfig\Factory;
16+
use Nexus\CsConfig\Fixer\Comment\SpaceAfterCommentStartFixer;
17+
use Nexus\CsConfig\FixerGenerator;
1518
use PhpCsFixer\Finder;
16-
use Utils\PhpCsFixer\CodeIgniter4;
17-
use Utils\PhpCsFixer\Fixer\Comment\SpaceAfterCommentStartFixer;
1819

1920
$finder = Finder::create()
2021
->files()
2122
->in([
2223
__DIR__ . '/admin',
2324
__DIR__ . '/app',
2425
__DIR__ . '/public',
25-
]);
26+
])
27+
->notName('#Logger\.php$#');
2628

2729
$overrides = [];
2830

2931
$options = [
3032
'cacheFile' => 'build/.no-header.php-cs-fixer.cache',
3133
'finder' => $finder,
32-
'customFixers' => [
33-
new SpaceAfterCommentStartFixer(),
34-
],
35-
'customRules' => [
36-
'CodeIgniter4/space_after_comment_start' => true,
34+
'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
35+
'customRules' => [
36+
SpaceAfterCommentStartFixer::name() => true,
3737
],
3838
];
3939

.php-cs-fixer.dist.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
* the LICENSE file that was distributed with this source code.
1212
*/
1313

14+
use CodeIgniter\CodingStandard\CodeIgniter4;
1415
use Nexus\CsConfig\Factory;
16+
use Nexus\CsConfig\Fixer\Comment\SpaceAfterCommentStartFixer;
17+
use Nexus\CsConfig\FixerGenerator;
1518
use PhpCsFixer\Finder;
16-
use Utils\PhpCsFixer\CodeIgniter4;
17-
use Utils\PhpCsFixer\Fixer\Comment\SpaceAfterCommentStartFixer;
1819

1920
$finder = Finder::create()
2021
->files()
@@ -37,11 +38,9 @@
3738
$options = [
3839
'cacheFile' => 'build/.php-cs-fixer.cache',
3940
'finder' => $finder,
40-
'customFixers' => [
41-
new SpaceAfterCommentStartFixer(),
42-
],
43-
'customRules' => [
44-
'CodeIgniter4/space_after_comment_start' => true,
41+
'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
42+
'customRules' => [
43+
SpaceAfterCommentStartFixer::name() => true,
4544
],
4645
];
4746

admin/framework/composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
"psr/log": "^1.1"
1616
},
1717
"require-dev": {
18+
"codeigniter/coding-standard": "^1.1",
1819
"fakerphp/faker": "^1.9",
19-
"friendsofphp/php-cs-fixer": "^3.0",
20+
"friendsofphp/php-cs-fixer": "^3.1",
2021
"mikey179/vfsstream": "^1.6",
21-
"nexusphp/cs-config": "^3.1",
22+
"nexusphp/cs-config": "^3.3",
2223
"phpunit/phpunit": "^9.1",
2324
"predis/predis": "^1.1"
2425
},

app/Config/Services.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@
1919
*/
2020
class Services extends BaseService
2121
{
22-
// public static function example($getShared = true)
23-
// {
24-
// if ($getShared)
25-
// {
26-
// return static::getSharedInstance('example');
27-
// }
28-
//
29-
// return new \CodeIgniter\Example();
30-
// }
22+
/*
23+
* public static function example($getShared = true)
24+
* {
25+
* if ($getShared) {
26+
* return static::getSharedInstance('example');
27+
* }
28+
*
29+
* return new \CodeIgniter\Example();
30+
* }
31+
*/
3132
}

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
"psr/log": "^1.1"
1616
},
1717
"require-dev": {
18+
"codeigniter/coding-standard": "^1.1",
1819
"fakerphp/faker": "^1.9",
19-
"friendsofphp/php-cs-fixer": "^3.0",
20+
"friendsofphp/php-cs-fixer": "^3.1",
2021
"mikey179/vfsstream": "^1.6",
21-
"nexusphp/cs-config": "^3.1",
22+
"nexusphp/cs-config": "^3.3",
2223
"nexusphp/tachycardia": "^1.0",
2324
"phpstan/phpstan": "^0.12.91",
2425
"phpunit/phpunit": "^9.1",

system/Database/BaseConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ public function protectIdentifiers($item, bool $prefixSingle = false, ?bool $pro
10041004
// we have nothing more to do other than escape the item
10051005
//
10061006
// NOTE: The ! empty() condition prevents this method
1007-
// from breaking when QB isn't enabled.
1007+
// from breaking when QB isn't enabled.
10081008
if (! empty($this->aliasedTables) && in_array($parts[0], $this->aliasedTables, true)) {
10091009
if ($protectIdentifiers === true) {
10101010
foreach ($parts as $key => $val) {

system/Email/Email.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,8 +1459,8 @@ protected function prepQEncoding($str)
14591459

14601460
if ($this->charset === 'UTF-8') {
14611461
// Note: We used to have mb_encode_mimeheader() as the first choice
1462-
// here, but it turned out to be buggy and unreliable. DO NOT
1463-
// re-add it! -- Narf
1462+
// here, but it turned out to be buggy and unreliable. DO NOT
1463+
// re-add it! -- Narf
14641464
if (extension_loaded('iconv')) {
14651465
$output = @iconv_mime_encode('', $str, [
14661466
'scheme' => 'Q',

system/Session/Session.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ public function __set(string $key, $value)
565565
public function __get(string $key)
566566
{
567567
// Note: Keep this order the same, just in case somebody wants to
568-
// use 'session_id' as a session data key, for whatever reason
568+
// use 'session_id' as a session data key, for whatever reason
569569
if (isset($_SESSION[$key])) {
570570
return $_SESSION[$key];
571571
}

system/Test/Mock/MockIncomingRequest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515

1616
class MockIncomingRequest extends IncomingRequest
1717
{
18-
// public function populateHeaders()
19-
// {
20-
// // Don't do anything... force the tester to manually set the headers they want.
21-
// }
22-
2318
protected function detectURI($protocol, $baseURL)
2419
{
2520
// Do nothing...

0 commit comments

Comments
 (0)