Skip to content

Commit 2d5ab0e

Browse files
committed
Switch to official coding standard
1 parent cca4660 commit 2d5ab0e

File tree

16 files changed

+36
-614
lines changed

16 files changed

+36
-614
lines changed

.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: 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()
@@ -29,11 +30,9 @@
2930
$options = [
3031
'cacheFile' => 'build/.no-header.php-cs-fixer.cache',
3132
'finder' => $finder,
32-
'customFixers' => [
33-
new SpaceAfterCommentStartFixer(),
34-
],
35-
'customRules' => [
36-
'CodeIgniter4/space_after_comment_start' => true,
33+
'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
34+
'customRules' => [
35+
SpaceAfterCommentStartFixer::name() => true,
3736
],
3837
];
3938

.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
},

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...

system/Typography/Typography.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ public function autoTypography(string $str, bool $reduceLinebreaks = false): str
155155
continue;
156156
}
157157

158-
// Force a newline to make sure end tags get processed by _format_newlines()
158+
// Force a newline to make sure end tags get processed by _format_newlines()
159159
if ($i === $c) {
160160
$chunks[$i] .= "\n";
161161
}
162162

163-
// Convert Newlines into <p> and <br /> tags
163+
// Convert Newlines into <p> and <br /> tags
164164
$str .= $this->formatNewLines($chunks[$i]);
165165
}
166166

tests/system/CLI/CLITest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,15 @@ public function testWait()
7575
// The problem: if the block below is enabled, the phpunit tests
7676
// go catatonic when it is executed, presumably because of
7777
// the CLI::input() waiting for a key press
78-
// // test the press any key to continue...
79-
// stream_filter_register('CLITestKeyboardFilter', 'CodeIgniter\CLI\CLITestKeyboardFilter');
80-
// $spoofer = stream_filter_append(STDIN, 'CLITestKeyboardFilter');
81-
// $time = time();
82-
// CLITestKeyboardFilter::$spoofed = ' ';
83-
// CLI::wait(0);
84-
// stream_filter_remove($spoofer);
85-
// $this->assertEquals(0, time() - $time);
78+
//
79+
// // test the press any key to continue...
80+
// stream_filter_register('CLITestKeyboardFilter', 'CodeIgniter\CLI\CLITestKeyboardFilter');
81+
// $spoofer = stream_filter_append(STDIN, 'CLITestKeyboardFilter');
82+
// $time = time();
83+
// CLITestKeyboardFilter::$spoofed = ' ';
84+
// CLI::wait(0);
85+
// stream_filter_remove($spoofer);
86+
// $this->assertEquals(0, time() - $time);
8687
}
8788

8889
public function testIsWindows()

tests/system/Cache/Handlers/FileHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ public function testDecrement()
221221
$this->fileHandler->save(self::$key1, 10);
222222
$this->fileHandler->save(self::$key2, 'value');
223223

224-
// Line following commented out to force the cache to add a zero entry for key3
225-
// $this->fileHandler->save(self::$key3, 0);
224+
// Line following commented out to force the cache to add a zero entry for key3
225+
// $this->fileHandler->save(self::$key3, 0);
226226

227227
$this->assertSame(9, $this->fileHandler->decrement(self::$key1, 1));
228228
$this->assertFalse($this->fileHandler->decrement(self::$key2, 1));

tests/system/Config/ServicesTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,6 @@ public function testNewImage()
147147
$this->assertInstanceOf(ImageHandlerInterface::class, $actual);
148148
}
149149

150-
// public function testNewMigrationRunner()
151-
// {
152-
// //FIXME - docs aren't clear about setting this up to just make sure that the service
153-
// // returns a MigrationRunner
154-
// $config = new \Config\Migrations();
155-
// $db = new \CodeIgniter\Database\MockConnection([]);
156-
// $this->expectException('InvalidArgumentException');
157-
// $actual = Services::migrations($config, $db);
158-
// $this->assertInstanceOf(\CodeIgniter\Database\MigrationRunner::class, $actual);
159-
// }
160-
//
161150
public function testNewNegotiatorWithNullConfig()
162151
{
163152
$actual = Services::negotiator(null);

tests/system/I18n/TimeTest.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -643,19 +643,6 @@ public function testToFormattedDateString()
643643
$this->assertSame('May 10, 2017', $time->toFormattedDateString());
644644
}
645645

646-
/**
647-
* Unfortunately, ubuntu 14.04 (on TravisCI) fails this test and
648-
* shows a numeric version of the month instead of the textual version.
649-
* Confirmed on CentOS 7 as well.
650-
* Example: format 'MMM' for November returns 'M02' instead of 'Nov'
651-
* Not sure what the fix is just yet....
652-
*/
653-
// public function testToFormattedDateString()
654-
// {
655-
// $time = Time::parse('February 10, 2017', 'America/Chicago');
656-
// $this->assertEquals('Feb 10, 2017', $time->toFormattedDateString());
657-
// }
658-
659646
public function testToTimeString()
660647
{
661648
$time = Time::parse('January 10, 2017 13:20:33', 'America/Chicago');

tests/system/Test/TestCaseTest.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@
2222
*/
2323
final class TestCaseTest extends CIUnitTestCase
2424
{
25-
// protected function tearDown(): void
26-
// {
27-
// $buffer = ob_clean();
28-
// if (ob_get_level() > 0)
29-
// {
30-
// ob_end_clean();
31-
// }
32-
// }
33-
//
3425
public function testGetPrivatePropertyWithObject()
3526
{
3627
$obj = new __TestForReflectionHelper();
@@ -86,7 +77,6 @@ public function testPHPUnitHeadersEmitted()
8677
$response->send();
8778
ob_end_clean();
8879

89-
// Did PHPunit do its thing?
9080
$this->assertHeaderEmitted('Content-type: text/html;');
9181
$this->assertHeaderNotEmitted('Set-Cookie: foo=bar;');
9282
}

0 commit comments

Comments
 (0)