Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: enable code quality level 34 for rector #9311

Open
wants to merge 10 commits into
base: 4.6
Choose a base branch
from
12 changes: 0 additions & 12 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -7453,12 +7453,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Images/Handlers/BaseHandler.php',
];
$ignoreErrors[] = [
// identifier: return.missing
'message' => '#^Method CodeIgniter\\\\Images\\\\Handlers\\\\BaseHandler\\:\\:__call\\(\\) should return mixed but return statement is missing\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Images/Handlers/BaseHandler.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Method CodeIgniter\\\\Images\\\\Handlers\\\\BaseHandler\\:\\:_text\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
Expand Down Expand Up @@ -7609,12 +7603,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Language/Language.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Method CodeIgniter\\\\Language\\\\Language\\:\\:load\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Language/Language.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Method CodeIgniter\\\\Language\\\\Language\\:\\:parseLine\\(\\) return type has no value type specified in iterable type array\\.$#',
Expand Down
9 changes: 4 additions & 5 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
*/

use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodeQuality\Rector\If_\ShortenElseIfRector;
use Rector\CodeQuality\Rector\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector;
use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector;
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
Expand Down Expand Up @@ -171,6 +170,8 @@

// Unnecessary (string) is inserted
NullToStrictStringFuncCallArgRector::class,

CompactToVariablesRector::class,
])
// auto import fully qualified class names
->withImportNames(removeUnusedImports: true)
Expand All @@ -185,7 +186,6 @@
ChangeIfElseValueAssignToEarlyReturnRector::class,
InlineIfToExplicitIfRector::class,
PreparedValueToEarlyReturnRector::class,
ShortenElseIfRector::class,
UnusedForeachValueToArrayKeysRector::class,
ChangeArrayPushToArrayAssignRector::class,
RemoveErrorSuppressInTryCatchStmtsRector::class,
Expand All @@ -196,7 +196,6 @@
EmptyOnNullableObjectToInstanceOfRector::class,
DisallowedEmptyRuleFixerRector::class,
PrivatizeFinalClassPropertyRector::class,
CompleteDynamicPropertiesRector::class,
BooleanInIfConditionRuleFixerRector::class,
VersionCompareFuncCallToConstantRector::class,
AddClosureVoidReturnTypeWhereNoReturnRector::class,
Expand All @@ -210,4 +209,4 @@
// keep '\\' prefix string on string '\Foo\Bar'
StringClassNameToClassConstantRector::SHOULD_KEEP_PRE_SLASH => true,
])
->withCodeQualityLevel(24);
->withCodeQualityLevel(34);
4 changes: 2 additions & 2 deletions system/CLI/Commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ public function __construct($logger = null)
/**
* Runs a command given
*
* @return int|void Exit code
* @return int Exit code
*/
public function run(string $command, array $params)
{
if (! $this->verifyCommand($command, $this->commands)) {
return;
return EXIT_ERROR;
}

// The file would have already been loaded during the
Expand Down
8 changes: 6 additions & 2 deletions system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private function configureKint(): void
*
* @param bool $returnResponse Used for testing purposes only.
*
* @return ResponseInterface|void
* @return ResponseInterface|null
*/
public function run(?RouteCollectionInterface $routes = null, bool $returnResponse = false)
{
Expand Down Expand Up @@ -379,6 +379,8 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon
}

$this->sendResponse();

return null;
}

/**
Expand Down Expand Up @@ -863,7 +865,7 @@ protected function determinePath()
* controller method and make the script go. If it's not able to, will
* show the appropriate Page Not Found error.
*
* @return ResponseInterface|string|void
* @return ResponseInterface|string|null
*/
protected function startController()
{
Expand All @@ -889,6 +891,8 @@ protected function startController()
) {
throw PageNotFoundException::forControllerNotFound($this->controller, $this->method);
}

return null;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion system/Commands/Database/MigrateRollback.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function run(array $params)
$force = array_key_exists('f', $params) || CLI::getOption('f');

if (! $force && CLI::prompt(lang('Migrations.rollBackConfirm'), ['y', 'n']) === 'n') {
return;
return null;
}
// @codeCoverageIgnoreEnd
}
Expand Down Expand Up @@ -115,5 +115,7 @@ public function run(array $params)
$this->showError($e);
// @codeCoverageIgnoreEnd
}

return null;
}
}
6 changes: 4 additions & 2 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3019,7 +3019,7 @@ protected function _delete(string $table): string
*
* @param array|string $table The table to inspect
*
* @return string|void
* @return string|null
*/
protected function trackAliases($table)
{
Expand All @@ -3028,7 +3028,7 @@ protected function trackAliases($table)
$this->trackAliases($t);
}

return;
return null;
}

// Does the string contain a comma? If so, we need to separate
Expand All @@ -3048,6 +3048,8 @@ protected function trackAliases($table)
// Store the alias, if it doesn't already exist
$this->db->addTableAlias($alias);
}

return null;
}

/**
Expand Down
9 changes: 5 additions & 4 deletions system/Filters/CSRF.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ class CSRF implements FilterInterface
*
* @param list<string>|null $arguments
*
* @return RedirectResponse|void
* @return RedirectResponse|null
*
* @throws SecurityException
*/
public function before(RequestInterface $request, $arguments = null)
{
if (! $request instanceof IncomingRequest) {
return;
return null;
}

/** @var Security $security */
Expand All @@ -57,16 +57,17 @@ public function before(RequestInterface $request, $arguments = null)

throw $e;
}

return null;
}

/**
* We don't have anything to do here.
*
* @param list<string>|null $arguments
*
* @return void
*/
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
return null;
}
}
10 changes: 5 additions & 5 deletions system/Filters/Cors.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ public function __construct(array $config = [])
/**
* @param list<string>|null $arguments
*
* @return ResponseInterface|string|void
* @return ResponseInterface|null
*/
public function before(RequestInterface $request, $arguments = null)
{
if (! $request instanceof IncomingRequest) {
return;
return null;
}

$this->createCorsService($arguments);

if (! $this->cors->isPreflightRequest($request)) {
return;
return null;
}

/** @var ResponseInterface $response */
Expand Down Expand Up @@ -88,12 +88,12 @@ private function createCorsService(?array $arguments): void
/**
* @param list<string>|null $arguments
*
* @return ResponseInterface|void
* @return ResponseInterface|null
*/
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
if (! $request instanceof IncomingRequest) {
return;
return null;
}

$this->createCorsService($arguments);
Expand Down
3 changes: 3 additions & 0 deletions system/Filters/DebugToolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class DebugToolbar implements FilterInterface
*/
public function before(RequestInterface $request, $arguments = null)
{
return null;
}

/**
Expand All @@ -41,5 +42,7 @@ public function before(RequestInterface $request, $arguments = null)
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
service('toolbar')->prepare($request, $response);

return null;
}
}
4 changes: 2 additions & 2 deletions system/Filters/FilterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface FilterInterface
*
* @param list<string>|null $arguments
*
* @return RequestInterface|ResponseInterface|string|void
* @return RequestInterface|ResponseInterface|string|null
*/
public function before(RequestInterface $request, $arguments = null);

Expand All @@ -45,7 +45,7 @@ public function before(RequestInterface $request, $arguments = null);
*
* @param list<string>|null $arguments
*
* @return ResponseInterface|void
* @return ResponseInterface|null
*/
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null);
}
9 changes: 5 additions & 4 deletions system/Filters/ForceHTTPS.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ class ForceHTTPS implements FilterInterface
*
* @param array|null $arguments
*
* @return ResponseInterface|void
* @return ResponseInterface|null
*/
public function before(RequestInterface $request, $arguments = null)
{
$config = config(App::class);

if ($config->forceGlobalSecureRequests !== true) {
return;
return null;
}

$response = service('response');
Expand All @@ -49,16 +49,17 @@ public function before(RequestInterface $request, $arguments = null)
} catch (RedirectException $e) {
return $e->getResponse();
}

return null;
}

/**
* We don't have anything to do here.
*
* @param array|null $arguments
*
* @return void
*/
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
return null;
}
}
6 changes: 5 additions & 1 deletion system/Filters/Honeypot.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ class Honeypot implements FilterInterface
public function before(RequestInterface $request, $arguments = null)
{
if (! $request instanceof IncomingRequest) {
return;
return null;
}

if (service('honeypot')->hasContent($request)) {
throw HoneypotException::isBot();
}

return null;
}

/**
Expand All @@ -52,5 +54,7 @@ public function before(RequestInterface $request, $arguments = null)
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
service('honeypot')->attachHoneypot($response);

return null;
}
}
9 changes: 4 additions & 5 deletions system/Filters/InvalidChars.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ class InvalidChars implements FilterInterface
* Check invalid characters.
*
* @param list<string>|null $arguments
*
* @return void
*/
public function before(RequestInterface $request, $arguments = null)
{
if (! $request instanceof IncomingRequest) {
return;
return null;
}

$data = [
Expand All @@ -69,17 +67,18 @@ public function before(RequestInterface $request, $arguments = null)
$this->checkEncoding($values);
$this->checkControl($values);
}

return null;
}

/**
* We don't have anything to do here.
*
* @param list<string>|null $arguments
*
* @return void
*/
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
return null;
}

/**
Expand Down
Loading
Loading