Skip to content

Commit

Permalink
Merge pull request #9253 from samsonasik/refactor-enable-flip-type-co…
Browse files Browse the repository at this point in the history
…ntrol

refactor: enable FlipTypeControlToUseExclusiveTypeRector
  • Loading branch information
samsonasik authored Nov 5, 2024
2 parents 3435872 + 3e672fa commit 65872e5
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 14 deletions.
2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
use Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector;
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector;
use Rector\CodeQuality\Rector\If_\CombineIfRector;
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
Expand Down Expand Up @@ -213,6 +214,7 @@
TypedPropertyFromAssignsRector::class,
ClosureReturnTypeRector::class,
SimplifyBoolIdenticalTrueRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
])
->withConfiguredRule(StringClassNameToClassConstantRector::class, [
// keep '\\' prefix string on string '\Foo\Bar'
Expand Down
2 changes: 1 addition & 1 deletion system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ protected function tryToRouteIt(?RouteCollectionInterface $routes = null)
{
$this->benchmark->start('routing');

if ($routes === null) {
if (! $routes instanceof RouteCollectionInterface) {
$routes = service('routes')->loadRoutes();
}

Expand Down
2 changes: 1 addition & 1 deletion system/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ function _solidus(?DocTypes $docTypesConfig = null): string
{
static $docTypes = null;

if ($docTypesConfig !== null) {
if ($docTypesConfig instanceof DocTypes) {
$docTypes = $docTypesConfig;
}

Expand Down
2 changes: 1 addition & 1 deletion system/Database/BaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ public function query(string $sql, $binds = null, bool $setEscapeFlags = true, s
// Let others do something with this query.
Events::trigger('DBQuery', $query);

if ($exception !== null) {
if ($exception instanceof DatabaseException) {
throw new DatabaseException(
$exception->getMessage(),
$exception->getCode(),
Expand Down
2 changes: 1 addition & 1 deletion system/Database/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(?Forge $forge = null)
{
if (isset($this->DBGroup)) {
$this->forge = Database::forge($this->DBGroup);
} elseif ($forge !== null) {
} elseif ($forge instanceof Forge) {
$this->forge = $forge;
} else {
$this->forge = Database::forge(config(Database::class)->defaultGroup);
Expand Down
2 changes: 1 addition & 1 deletion system/Database/Seeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function __construct(Database $config, ?BaseConnection $db = null)
*/
public static function faker(): ?Generator
{
if (self::$faker === null && class_exists(Factory::class)) {
if (! self::$faker instanceof Generator && class_exists(Factory::class)) {
self::$faker = Factory::create();
}

Expand Down
4 changes: 2 additions & 2 deletions system/HTTP/DownloadResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function __construct(string $filename, bool $setMime)
*/
public function setBinary(string $binary)
{
if ($this->file !== null) {
if ($this->file instanceof File) {
throw DownloadException::forCannotSetBinary();
}

Expand Down Expand Up @@ -309,7 +309,7 @@ public function sendBody()
return $this->sendBodyByBinary();
}

if ($this->file !== null) {
if ($this->file instanceof File) {
return $this->sendBodyByFilePath();
}

Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/Exceptions/RedirectException.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct($message = '', int $code = 0, ?Throwable $previous =

public function getResponse(): ResponseInterface
{
if (null === $this->response) {
if (! $this->response instanceof ResponseInterface) {
$this->response = service('response')
->redirect(base_url($this->getMessage()), 'auto', $this->getCode());
}
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/Negotiate.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Negotiate
*/
public function __construct(?RequestInterface $request = null)
{
if ($request !== null) {
if ($request instanceof RequestInterface) {
assert($request instanceof IncomingRequest);

$this->request = $request;
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/SiteURI.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ public function siteUrl($relativePath = '', ?string $scheme = null, ?App $config
$relativePath = $this->stringifyRelativePath($relativePath);

// Check current host.
$host = $config === null ? $this->getHost() : null;
$host = ! $config instanceof App ? $this->getHost() : null;

$config ??= config(App::class);

Expand Down
2 changes: 1 addition & 1 deletion system/Log/Handlers/ChromeLoggerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected function format($object)
*/
public function sendLogs(?ResponseInterface &$response = null)
{
if ($response === null) {
if (! $response instanceof ResponseInterface) {
$response = Services::response(null, true);
}

Expand Down
2 changes: 1 addition & 1 deletion system/Validation/FileRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class FileRules
*/
public function __construct(?RequestInterface $request = null)
{
if ($request === null) {
if (! $request instanceof RequestInterface) {
$request = service('request');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/system/API/ResponseTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private function createRequestAndResponse(string $routePath = '', array $userHea
$config = $this->createAppConfig();
$this->createCookieConfig();

if ($this->request === null) {
if (! $this->request instanceof MockIncomingRequest) {
$this->request = new MockIncomingRequest(
$config,
new SiteURI($config, $routePath),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private function processRenameVariable(Node $node): ?Variable

private function updateDocblock(string $variableName, string $camelCaseName, ?FunctionLike $functionLike): void
{
if ($functionLike === null) {
if (! $functionLike instanceof FunctionLike) {
return;
}

Expand Down

0 comments on commit 65872e5

Please sign in to comment.