Skip to content

Commit a88b4f2

Browse files
lucasmichotLucas Michot
andauthored
Combine consecutive isset and unset (#59685)
Co-authored-by: Lucas Michot <lucas@zaiple.com>
1 parent b89e2f1 commit a88b4f2

7 files changed

Lines changed: 10 additions & 16 deletions

File tree

pint.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
"class_definition": true,
3232
"class_reference_name_casing": true,
3333
"clean_namespace": true,
34+
"combine_consecutive_issets": true,
35+
"combine_consecutive_unsets": true,
3436
"compact_nullable_type_declaration": true,
3537
"concat_space": true,
3638
"constant_case": {

src/Illuminate/Foundation/Testing/TestCase.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,11 @@ public function createApplication()
4848

4949
$this->traitsUsedByTest = class_uses_recursive(static::class);
5050

51-
if (isset(CachedState::$cachedConfig) &&
52-
isset($this->traitsUsedByTest[WithCachedConfig::class])) {
51+
if (isset(CachedState::$cachedConfig, $this->traitsUsedByTest[WithCachedConfig::class])) {
5352
$this->markConfigCached($app);
5453
}
5554

56-
if (isset(CachedState::$cachedRoutes) &&
57-
isset($this->traitsUsedByTest[WithCachedRoutes::class])) {
55+
if (isset(CachedState::$cachedRoutes, $this->traitsUsedByTest[WithCachedRoutes::class])) {
5856
$app->booting(fn () => $this->markRoutesCached($app));
5957
}
6058

src/Illuminate/Http/Client/PendingRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ protected function parseMultipartBodyFormat(array $data)
11581158
->flatMap(function ($value, $key) {
11591159
if (is_array($value)) {
11601160
// If the array has 'name' and 'contents' keys, it's already formatted for multipart...
1161-
if (isset($value['name']) && isset($value['contents'])) {
1161+
if (isset($value['name'], $value['contents'])) {
11621162
return [$value];
11631163
}
11641164

tests/Database/DatabaseEloquentModelTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4165,8 +4165,7 @@ class EloquentModelBootingTestStub extends Model
41654165
{
41664166
public static function unboot()
41674167
{
4168-
unset(static::$booted[static::class]);
4169-
unset(static::$bootedCallbacks[static::class]);
4168+
unset(static::$booted[static::class], static::$bootedCallbacks[static::class]);
41704169
}
41714170

41724171
public static function isBooted()
@@ -4756,8 +4755,7 @@ class EloquentModelBootingCallbackTestStub extends Model
47564755

47574756
public static function unboot()
47584757
{
4759-
unset(static::$booted[static::class]);
4760-
unset(static::$bootedCallbacks[static::class]);
4758+
unset(static::$booted[static::class], static::$bootedCallbacks[static::class]);
47614759
static::$bootHasFinished = false;
47624760
}
47634761
}

tests/Foundation/FoundationApplicationBuilderTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ class FoundationApplicationBuilderTest extends TestCase
99
{
1010
protected function tearDown(): void
1111
{
12-
unset($_ENV['APP_BASE_PATH']);
13-
14-
unset($_ENV['LARAVEL_STORAGE_PATH'], $_SERVER['LARAVEL_STORAGE_PATH']);
12+
unset($_ENV['APP_BASE_PATH'], $_ENV['LARAVEL_STORAGE_PATH'], $_SERVER['LARAVEL_STORAGE_PATH']);
1513

1614
parent::tearDown();
1715
}

tests/Integration/Console/CommandEventsTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ protected function setUp(): void
4242
$this->beforeApplicationDestroyed(function () {
4343
$this->files->delete($this->logfile);
4444

45-
unset($this->files);
46-
unset($this->logfile);
45+
unset($this->files, $this->logfile);
4746
});
4847

4948
parent::setUp();

tests/Pipeline/PipelineTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ public function testThenMethodInputValue()
210210
$this->assertSame('pipe::then::not_foo::', $result);
211211
$this->assertSame('::not_foo::', $_SERVER['__test.then.arg']);
212212

213-
unset($_SERVER['__test.then.arg']);
214-
unset($_SERVER['__test.pipe.return']);
213+
unset($_SERVER['__test.then.arg'], $_SERVER['__test.pipe.return']);
215214
}
216215

217216
public function testPipelineUsageWithParameters()

0 commit comments

Comments
 (0)