Merge pull request #4926 from paulbalandan/r-rules

Define "r" rules
This commit is contained in:
John Paul E. Balandan, CPA 2021-07-09 20:55:22 +08:00 committed by GitHub
commit 02ac2de62d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 47 additions and 45 deletions

View File

@ -305,9 +305,7 @@ class Autoloader
$filename = preg_replace('/[^0-9\p{L}\s\/\-\_\.\:\\\\]/u', '', $filename);
// Clean up our filename edges.
$filename = trim($filename, '.-_');
return $filename;
return trim($filename, '.-_');
}
/**

View File

@ -123,7 +123,7 @@ class FileLocator
*
* @return string
*/
public function getClassname(string $file) : string
public function getClassname(string $file): string
{
$php = file_get_contents($file);
$tokens = token_get_all($php);
@ -209,9 +209,7 @@ class FileLocator
}
// Remove any duplicates
$foundPaths = array_unique($foundPaths);
return $foundPaths;
return array_unique($foundPaths);
}
/**

View File

@ -688,7 +688,7 @@ abstract class BaseModel
*
* @return bool
*/
protected function shouldUpdate($data) : bool
protected function shouldUpdate($data): bool
{
return ! empty($this->getIdValue($data));
}

View File

@ -560,15 +560,13 @@ class Forge
}
// createTableStr will usually have the following format: "%s %s (%s\n)"
$sql = sprintf(
return sprintf(
$this->createTableStr . '%s',
$sql,
$this->db->escapeIdentifiers($table),
$columns,
$this->_createTableAttributes($attributes)
);
return $sql;
}
//--------------------------------------------------------------------

View File

@ -154,7 +154,7 @@ class Events
foreach ($listeners as $listener) {
$start = microtime(true);
$result = static::$simulate === false ? call_user_func($listener, ...$arguments) : true;
$result = static::$simulate === false ? $listener(...$arguments) : true;
if (CI_DEBUG) {
static::$performanceLog[] = [

View File

@ -133,7 +133,7 @@ class DownloadResponse extends Response
*
* @return int
*/
public function getContentLength() : int
public function getContentLength(): int
{
if (is_string($this->binary)) {
return strlen($this->binary);
@ -200,7 +200,7 @@ class DownloadResponse extends Response
*
* @return string
*/
private function getContentDisposition() : string
private function getContentDisposition(): string
{
$downloadFilename = $this->getDownloadFileName();

View File

@ -448,9 +448,7 @@ if (! function_exists('word_wrap')) {
}
// remove any trailing newline
$output = rtrim($output);
return $output;
return rtrim($output);
}
}

View File

@ -606,7 +606,7 @@ class Model extends BaseModel
*
* @return bool
*/
protected function shouldUpdate($data) : bool
protected function shouldUpdate($data): bool
{
// When useAutoIncrement feature is disabled check
// in the database if given record already exists

View File

@ -481,7 +481,7 @@ class Pager implements PagerInterface
*
* @return Pager
*/
public function only(array $queries):Pager
public function only(array $queries): Pager
{
$this->only = $queries;

View File

@ -1218,7 +1218,7 @@ class RouteCollection implements RouteCollectionInterface
*
* @return string
*/
protected function localizeRoute(string $route) :string
protected function localizeRoute(string $route): string
{
return strtr($route, ['{locale}' => Services::request()->getLocale()]);
}

View File

@ -344,7 +344,7 @@ class Table
if ($cell === '' || $cell === null) {
$out .= $this->emptyCells;
} elseif (isset($this->function)) {
$out .= call_user_func($this->function, $cell);
$out .= ($this->function)($cell);
} else {
$out .= $cell;
}

View File

@ -14,7 +14,7 @@ class CastBase64 extends BaseCast
*
* @return mixed
*/
public static function get($value, array $params = []) : string
public static function get($value, array $params = []): string
{
return base64_decode($value);
}
@ -27,7 +27,7 @@ class CastBase64 extends BaseCast
*
* @return mixed
*/
public static function set($value, array $params = []) : string
public static function set($value, array $params = []): string
{
return base64_encode($value);
}

View File

@ -997,7 +997,7 @@ final class EntityTest extends CIUnitTestCase
};
}
protected function getCastEntity($data = null) : Entity
protected function getCastEntity($data = null): Entity
{
return new class($data) extends Entity {
protected $attributes = [

View File

@ -151,7 +151,7 @@ final class ValidationModelTest extends LiveModelTestCase
'foo' => 'bar',
];
$rules = call_user_func($cleaner, $rules, null);
$rules = $cleaner($rules, null);
$this->assertEmpty($rules);
}
@ -168,7 +168,7 @@ final class ValidationModelTest extends LiveModelTestCase
'foo' => 'bar',
];
$rules = call_user_func($cleaner, $rules, $data);
$rules = $cleaner($rules, $data);
$this->assertArrayHasKey('foo', $rules);
$this->assertArrayNotHasKey('name', $rules);
}
@ -187,7 +187,7 @@ final class ValidationModelTest extends LiveModelTestCase
'name' => null,
];
$rules = call_user_func($cleaner, $rules, $data);
$rules = $cleaner($rules, $data);
$this->assertArrayHasKey('foo', $rules);
$this->assertArrayHasKey('name', $rules);
}

View File

@ -48,12 +48,12 @@ final class BootstrapFCPATHTest extends CIUnitTestCase
return realpath(__DIR__ . '/../../../public') . DIRECTORY_SEPARATOR;
}
private function buildDirectories() : void
private function buildDirectories(): void
{
mkdir($this->dir1, 0777, true);
}
private function deleteDirectories() : void
private function deleteDirectories(): void
{
// these need to be executed in reverse order: dir 2 in inside dir1
if (is_dir($this->dir1)) {
@ -61,13 +61,13 @@ final class BootstrapFCPATHTest extends CIUnitTestCase
}
}
private function writeFiles() : void
private function writeFiles(): void
{
file_put_contents($this->file1, $this->fileContents());
chmod($this->file1, 0777);
}
private function deleteFiles() : void
private function deleteFiles(): void
{
if (file_exists($this->file1)) {
unlink($this->file1);

View File

@ -376,19 +376,29 @@ final class CodeIgniter4 extends AbstractRuleset
'pow_to_exponentiation' => true,
'protected_to_private' => true,
'psr_autoloading' => ['dir' => null],
'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,
'switch_case_space' => true,
'switch_continue_to_break' => true,
'ternary_operator_spaces' => true,
'ternary_to_elvis_operator' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline' => [
'random_api_migration' => [
'replacements' => [
'getrandmax' => 'mt_getrandmax',
'rand' => 'mt_rand',
'srand' => 'mt_srand',
],
],
'regular_callable_call' => true,
'return_assignment' => true,
'return_type_declaration' => ['space_before' => 'none'],
'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,
'switch_case_space' => true,
'switch_continue_to_break' => true,
'ternary_operator_spaces' => true,
'ternary_to_elvis_operator' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline' => [
'after_heredoc' => true,
'elements' => ['arrays'],
],

View File

@ -51,7 +51,7 @@ final class RemoveErrorSuppressInTryCatchStmtsRector extends AbstractRector
return null;
}
$inStmts = (bool) $this->betterNodeFinder->findFirst((array) $tryCatch->stmts, static function (Node $n) use ($node) : bool {
$inStmts = (bool) $this->betterNodeFinder->findFirst((array) $tryCatch->stmts, static function (Node $n) use ($node): bool {
return $n === $node;
});