Skip to content

Commit 65872e5

Browse files
authored
Merge pull request #9253 from samsonasik/refactor-enable-flip-type-control
refactor: enable FlipTypeControlToUseExclusiveTypeRector
2 parents 3435872 + 3e672fa commit 65872e5

File tree

14 files changed

+16
-14
lines changed

14 files changed

+16
-14
lines changed

rector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
2020
use Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector;
2121
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
22+
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
2223
use Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector;
2324
use Rector\CodeQuality\Rector\If_\CombineIfRector;
2425
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
@@ -213,6 +214,7 @@
213214
TypedPropertyFromAssignsRector::class,
214215
ClosureReturnTypeRector::class,
215216
SimplifyBoolIdenticalTrueRector::class,
217+
FlipTypeControlToUseExclusiveTypeRector::class,
216218
])
217219
->withConfiguredRule(StringClassNameToClassConstantRector::class, [
218220
// keep '\\' prefix string on string '\Foo\Bar'

system/CodeIgniter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ protected function tryToRouteIt(?RouteCollectionInterface $routes = null)
819819
{
820820
$this->benchmark->start('routing');
821821

822-
if ($routes === null) {
822+
if (! $routes instanceof RouteCollectionInterface) {
823823
$routes = service('routes')->loadRoutes();
824824
}
825825

system/Common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ function _solidus(?DocTypes $docTypesConfig = null): string
869869
{
870870
static $docTypes = null;
871871

872-
if ($docTypesConfig !== null) {
872+
if ($docTypesConfig instanceof DocTypes) {
873873
$docTypes = $docTypesConfig;
874874
}
875875

system/Database/BaseConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ public function query(string $sql, $binds = null, bool $setEscapeFlags = true, s
684684
// Let others do something with this query.
685685
Events::trigger('DBQuery', $query);
686686

687-
if ($exception !== null) {
687+
if ($exception instanceof DatabaseException) {
688688
throw new DatabaseException(
689689
$exception->getMessage(),
690690
$exception->getCode(),

system/Database/Migration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(?Forge $forge = null)
4545
{
4646
if (isset($this->DBGroup)) {
4747
$this->forge = Database::forge($this->DBGroup);
48-
} elseif ($forge !== null) {
48+
} elseif ($forge instanceof Forge) {
4949
$this->forge = $forge;
5050
} else {
5151
$this->forge = Database::forge(config(Database::class)->defaultGroup);

system/Database/Seeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function __construct(Database $config, ?BaseConnection $db = null)
105105
*/
106106
public static function faker(): ?Generator
107107
{
108-
if (self::$faker === null && class_exists(Factory::class)) {
108+
if (! self::$faker instanceof Generator && class_exists(Factory::class)) {
109109
self::$faker = Factory::create();
110110
}
111111

system/HTTP/DownloadResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function __construct(string $filename, bool $setMime)
8585
*/
8686
public function setBinary(string $binary)
8787
{
88-
if ($this->file !== null) {
88+
if ($this->file instanceof File) {
8989
throw DownloadException::forCannotSetBinary();
9090
}
9191

@@ -309,7 +309,7 @@ public function sendBody()
309309
return $this->sendBodyByBinary();
310310
}
311311

312-
if ($this->file !== null) {
312+
if ($this->file instanceof File) {
313313
return $this->sendBodyByFilePath();
314314
}
315315

system/HTTP/Exceptions/RedirectException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function __construct($message = '', int $code = 0, ?Throwable $previous =
6969

7070
public function getResponse(): ResponseInterface
7171
{
72-
if (null === $this->response) {
72+
if (! $this->response instanceof ResponseInterface) {
7373
$this->response = service('response')
7474
->redirect(base_url($this->getMessage()), 'auto', $this->getCode());
7575
}

system/HTTP/Negotiate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Negotiate
3939
*/
4040
public function __construct(?RequestInterface $request = null)
4141
{
42-
if ($request !== null) {
42+
if ($request instanceof RequestInterface) {
4343
assert($request instanceof IncomingRequest);
4444

4545
$this->request = $request;

system/HTTP/SiteURI.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ public function siteUrl($relativePath = '', ?string $scheme = null, ?App $config
421421
$relativePath = $this->stringifyRelativePath($relativePath);
422422

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

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

system/Log/Handlers/ChromeLoggerHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ protected function format($object)
156156
*/
157157
public function sendLogs(?ResponseInterface &$response = null)
158158
{
159-
if ($response === null) {
159+
if (! $response instanceof ResponseInterface) {
160160
$response = Services::response(null, true);
161161
}
162162

system/Validation/FileRules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class FileRules
3838
*/
3939
public function __construct(?RequestInterface $request = null)
4040
{
41-
if ($request === null) {
41+
if (! $request instanceof RequestInterface) {
4242
$request = service('request');
4343
}
4444

tests/system/API/ResponseTraitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private function createRequestAndResponse(string $routePath = '', array $userHea
8787
$config = $this->createAppConfig();
8888
$this->createCookieConfig();
8989

90-
if ($this->request === null) {
90+
if (! $this->request instanceof MockIncomingRequest) {
9191
$this->request = new MockIncomingRequest(
9292
$config,
9393
new SiteURI($config, $routePath),

utils/src/Rector/UnderscoreToCamelCaseVariableNameRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private function processRenameVariable(Node $node): ?Variable
164164

165165
private function updateDocblock(string $variableName, string $camelCaseName, ?FunctionLike $functionLike): void
166166
{
167-
if ($functionLike === null) {
167+
if (! $functionLike instanceof FunctionLike) {
168168
return;
169169
}
170170

0 commit comments

Comments
 (0)