mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
commit
02ac2de62d
@ -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, '.-_');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -688,7 +688,7 @@ abstract class BaseModel
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function shouldUpdate($data) : bool
|
||||
protected function shouldUpdate($data): bool
|
||||
{
|
||||
return ! empty($this->getIdValue($data));
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -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[] = [
|
||||
|
@ -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();
|
||||
|
||||
|
@ -448,9 +448,7 @@ if (! function_exists('word_wrap')) {
|
||||
}
|
||||
|
||||
// remove any trailing newline
|
||||
$output = rtrim($output);
|
||||
|
||||
return $output;
|
||||
return rtrim($output);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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()]);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 = [
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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'],
|
||||
],
|
||||
|
@ -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;
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user