Enable PSR-12 normative rules

This commit is contained in:
John Paul E. Balandan, CPA 2021-07-03 00:56:44 +08:00
parent 8ac891bd3f
commit 3e1b205205
No known key found for this signature in database
GPG Key ID: FB7B51499BC27610
10 changed files with 30 additions and 18 deletions

View File

@ -122,7 +122,7 @@ class Toolbar
Kint::$display_called_from = false;
$kint = @Kint::dump($value);
$kint = substr($kint, strpos($kint, '</style>') + 8 );
$kint = substr($kint, strpos($kint, '</style>') + 8);
Kint::$mode_default = $oldKintMode;
Kint::$display_called_from = $oldKintCalledFrom;
@ -356,7 +356,7 @@ class Toolbar
Kint::$mode_default = Kint::MODE_RICH;
$kintScript = @Kint::dump('');
Kint::$mode_default = $oldKintMode;
$kintScript = substr($kintScript, 0, strpos($kintScript, '</style>') + 8 );
$kintScript = substr($kintScript, 0, strpos($kintScript, '</style>') + 8);
$script = PHP_EOL
. '<script type="text/javascript" {csp-script-nonce} id="debugbar_loader" '

View File

@ -2,7 +2,7 @@
namespace CodeIgniter;
use \CodeIgniter\Config\Services;
use CodeIgniter\Config\Services;
use CodeIgniter\Router\RouteCollection;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\Mock\MockCodeIgniter;

View File

@ -71,6 +71,6 @@ final class InfoCacheTest extends CIUnitTestCase
cache()->delete('foo');
command('cache:info');
$this->assertStringNotContainsString ('foo', $this->getBuffer());
$this->assertStringNotContainsString('foo', $this->getBuffer());
}
}

View File

@ -83,7 +83,7 @@ final class InsertTest extends CIUnitTestCase
$this->assertInstanceOf(Query::class, $query);
$raw = 'INSERT INTO "jobs" ("description", "id", "name") VALUES (:description:,:id:,:name:), (:description.1:,:id.1:,:name.1:)';
$this->assertSame($raw, str_replace("\n", ' ', $query->getOriginalQuery() ));
$this->assertSame($raw, str_replace("\n", ' ', $query->getOriginalQuery()));
$expected = "INSERT INTO \"jobs\" (\"description\", \"id\", \"name\") VALUES ('There''s something in your teeth',2,'Commedian'), ('I am yellow',3,'Cab Driver')";
$this->assertSame($expected, str_replace("\n", ' ', $query->getQuery()));
@ -110,7 +110,7 @@ final class InsertTest extends CIUnitTestCase
$this->assertInstanceOf(Query::class, $query);
$raw = 'INSERT INTO "ip_table" ("ip", "ip2") VALUES (:ip:,:ip2:), (:ip.1:,:ip2.1:), (:ip.2:,:ip2.2:), (:ip.3:,:ip2.3:)';
$this->assertSame($raw, str_replace("\n", ' ', $query->getOriginalQuery() ));
$this->assertSame($raw, str_replace("\n", ' ', $query->getOriginalQuery()));
$expected = "INSERT INTO \"ip_table\" (\"ip\", \"ip2\") VALUES ('1.1.1.0','1.1.1.2'), ('2.2.2.0','2.2.2.2'), ('3.3.3.0','3.3.3.2'), ('4.4.4.0','4.4.4.2')";
$this->assertSame($expected, str_replace("\n", ' ', $query->getQuery()));

View File

@ -149,7 +149,7 @@ final class UpdateTest extends CIUnitTestCase
WHERE "id" IN(2,3)
EOF;
$this->assertSame($expected, $query->getQuery() );
$this->assertSame($expected, $query->getQuery());
}
public function testUpdateBatchThrowsExceptionWithNoData()

View File

@ -51,7 +51,7 @@ final class MigrationRunnerTest extends CIUnitTestCase
$this->assertInstanceOf(BaseConnection::class, $db);
$this->assertSame(
($dbConfig->tests['DBDriver'] === 'SQLite3' ? WRITEPATH : '' ) . $dbConfig->tests['database'],
($dbConfig->tests['DBDriver'] === 'SQLite3' ? WRITEPATH : '') . $dbConfig->tests['database'],
$this->getPrivateProperty($db, 'database')
);
$this->assertSame($dbConfig->tests['DBDriver'], $this->getPrivateProperty($db, 'DBDriver'));

View File

@ -711,7 +711,7 @@ final class FileCollectionTest extends CIUnitTestCase
$files = $collection->getFileMultiple('userfiletest');
$this->assertNull( $files);
$this->assertNull($files);
}
//--------------------------------------------------------------------
@ -766,7 +766,7 @@ final class FileCollectionTest extends CIUnitTestCase
$collection = new FileCollection();
$files = $collection->getFileMultiple('my-form.details.avatars');
$this->assertIsArray( $files);
$this->assertIsArray($files);
$this->assertCount(2, $files);
$this->assertInstanceOf(UploadedFile::class, $files[0]);
@ -821,7 +821,7 @@ final class FileCollectionTest extends CIUnitTestCase
$collection = new FileCollection();
$files = $collection->getFileMultiple('my-form.details.avatars');
$this->assertNull( $files);
$this->assertNull($files);
}
//--------------------------------------------------------------------
@ -854,7 +854,7 @@ final class FileCollectionTest extends CIUnitTestCase
$files = $collection->getFileMultiple('userfile');
$this->assertCount(2, $files);
$this->assertIsArray( $files);
$this->assertIsArray($files);
$this->assertInstanceOf(UploadedFile::class, $files[0]);
$this->assertSame(124, $files[0]->getSize());
@ -888,7 +888,7 @@ final class FileCollectionTest extends CIUnitTestCase
$collection = new FileCollection();
$files = $collection->getFileMultiple('userfile');
$this->assertNull( $files);
$this->assertNull($files);
}
//--------------------------------------------------------------------

View File

@ -317,7 +317,7 @@ function rrmdir($src)
$dir = opendir($src);
while (false !== $file = readdir($dir)) {
if (( $file !== '.' ) && ( $file !== '..' )) {
if (($file !== '.') && ($file !== '..')) {
$full = $src . '/' . $file;
if (is_dir($full)) {

View File

@ -50,27 +50,27 @@ final class BootstrapFCPATHTest extends CIUnitTestCase
private function buildDirectories() : void
{
mkdir( $this->dir1, 0777, true);
mkdir($this->dir1, 0777, true);
}
private function deleteDirectories() : void
{
// these need to be executed in reverse order: dir 2 in inside dir1
if (is_dir($this->dir1)) {
rmdir( $this->dir1 );
rmdir($this->dir1);
}
}
private function writeFiles() : void
{
file_put_contents( $this->file1, $this->fileContents());
file_put_contents($this->file1, $this->fileContents());
chmod($this->file1, 0777);
}
private function deleteFiles() : void
{
if (file_exists($this->file1)) {
unlink( $this->file1 );
unlink($this->file1);
}
}

View File

@ -165,10 +165,21 @@ final class CodeIgniter4 extends AbstractRuleset
'no_alias_language_construct_call' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => false, // @todo enable fully when `header_comment` is required
'no_blank_lines_before_namespace' => false, // conflicts with `single_blank_line_before_namespace`
'no_break_comment' => ['comment_text' => 'no break'],
'no_closing_tag' => true,
'no_leading_import_slash' => true,
'no_short_bool_cast' => true,
'no_spaces_after_function_name' => true,
'no_spaces_inside_parenthesis' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_trailing_whitespace_in_string' => true,
'no_unreachable_default_argument_value' => true,
'no_unset_cast' => true,
'no_whitespace_before_comma_in_array' => ['after_heredoc' => true],
'no_whitespace_in_blank_line' => true,
'not_operator_with_space' => false,
'not_operator_with_successor_space' => true,
'normalize_index_brace' => true,
@ -287,6 +298,7 @@ final class CodeIgniter4 extends AbstractRuleset
'set_type_to_cast' => true,
'short_scalar_cast' => true,
'simple_to_complex_string_variable' => true,
'single_blank_line_before_namespace' => true,
'standardize_increment' => true,
'static_lambda' => true,
'switch_case_semicolon_to_colon' => true,