Skip to content

Commit 3bb0f3b

Browse files
authored
chore: fix phpstan notice on latest 2.2.15 (#10584)
* chore: fix phpstan notice on latest 2.2.15 * chore: regenerate baseline for on purpose test * final touch: avoid regenerate baseline, fix instead
1 parent c9efbbc commit 3bb0f3b

15 files changed

Lines changed: 36 additions & 19 deletions

File tree

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"mikey179/vfsstream": "^1.6.12",
2525
"nexusphp/tachycardia": "^2.0",
2626
"phpstan/extension-installer": "^1.4",
27-
"phpstan/phpstan": "^2.2.1",
27+
"phpstan/phpstan": "^2.2.15",
2828
"phpstan/phpstan-strict-rules": "^2.0",
2929
"phpunit/phpcov": "^9.0.2 || ^10.0",
3030
"phpunit/phpunit": "^10.5.16 || ^11.2",

‎tests/system/Config/ServicesTest.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ public function testNewUnsharedLanguage(): void
197197
{
198198
$actual = Services::language(null, false);
199199
$this->assertInstanceOf(Language::class, $actual);
200-
$this->assertSame('en', $actual->getLocale());
200+
$locale = $actual->getLocale();
201+
$this->assertSame('en', $locale);
201202

202203
Services::language('la', false);
203204
$this->assertSame('en', $actual->getLocale());

‎tests/system/Email/EmailTest.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,8 @@ public function testSetPriorityFallback(): void
713713

714714
// Priority 6 is invalid, falls back to 3
715715
$email->setPriority(6);
716-
$this->assertSame(3, $this->getPrivateProperty($email, 'priority'));
716+
$priority = $this->getPrivateProperty($email, 'priority');
717+
$this->assertSame(3, $priority);
717718

718719
// Priority 0 is invalid, falls back to 3
719720
$email->setPriority(0);

‎tests/system/Encryption/Handlers/OpenSSLHandlerTest.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ public function testInternalKeyNotModifiedByParams(): void
149149
$encrypter = $this->encryption->initialize($params);
150150
$this->assertInstanceOf(OpenSSLHandler::class, $encrypter);
151151

152-
$this->assertSame('original-key-value', $encrypter->key);
152+
$key = $encrypter->key;
153+
$this->assertSame('original-key-value', $key);
153154

154155
$message = 'This is a plain-text message.';
155156
$differentKey = 'temporary-param-key';

‎tests/system/Encryption/Handlers/SodiumHandlerTest.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ public function testInternalKeyNotModifiedByParams(): void
139139
$encrypter = $this->encryption->initialize($this->config);
140140
$this->assertInstanceOf(SodiumHandler::class, $encrypter);
141141

142-
$this->assertSame($originalKey, $encrypter->key);
142+
$key = $encrypter->key;
143+
$this->assertSame($originalKey, $key);
143144

144145
$message = 'This is a plain-text message.';
145146
$differentKey = sodium_crypto_secretbox_keygen();

‎tests/system/Entity/EntityTest.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,9 @@ public function testCastInteger(): void
373373

374374
$entity->first = 3.1;
375375

376-
$this->assertIsInt($entity->first);
377-
$this->assertSame(3, $entity->first);
376+
$first = $entity->first;
377+
$this->assertIsInt($first);
378+
$this->assertSame(3, $first);
378379

379380
$entity->first = 3.6;
380381

‎tests/system/Events/EventsTest.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ public function testInitialize(): void
6969

7070
// but we should be able to change it through the backdoor
7171
MockEvents::setFiles(['/peanuts']);
72-
$this->assertSame(['/peanuts'], Events::getFiles());
72+
$files = Events::getFiles();
73+
$this->assertSame(['/peanuts'], $files);
7374

7475
// re-initializing should have no effect
7576
MockEvents::initialize();

‎tests/system/HTTP/IncomingRequestTest.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,8 @@ public function testGetIPAddressNormal(): void
10571057
$request = new Request(new App());
10581058
$request->populateHeaders();
10591059

1060-
$this->assertSame($expected, $request->getIPAddress());
1060+
$ipAddress = $request->getIPAddress();
1061+
$this->assertSame($expected, $ipAddress);
10611062
// call a second time to exercise the initial conditional block in getIPAddress()
10621063
$this->assertSame($expected, $request->getIPAddress());
10631064
}

‎tests/system/HTTP/RequestTest.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,8 @@ public function testGetIPAddressNormal(): void
562562
$expected = '123.123.123.123';
563563
service('superglobals')->setServer('REMOTE_ADDR', $expected);
564564
$this->request = new Request(new App());
565-
$this->assertSame($expected, $this->request->getIPAddress());
565+
$ipAddress = $this->request->getIPAddress();
566+
$this->assertSame($expected, $ipAddress);
566567
// call a second time to exercise the initial conditional block in getIPAddress()
567568
$this->assertSame($expected, $this->request->getIPAddress());
568569
}

‎tests/system/Helpers/FormHelperTest.php‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,8 @@ public function testSetValue(): void
870870
public function testSetSelect(): void
871871
{
872872
$_SESSION['_ci_old_input']['post']['foo'] = 'bar';
873-
$this->assertSame(' selected="selected"', set_select('foo', 'bar'));
873+
$selected = set_select('foo', 'bar');
874+
$this->assertSame(' selected="selected"', $selected);
874875

875876
$_SESSION['_ci_old_input']['post']['foo'] = ['foo' => 'bar'];
876877
$this->assertSame(' selected="selected"', set_select('foo', 'bar'));
@@ -890,7 +891,8 @@ public function testSetCheckbox(): void
890891
],
891892
];
892893

893-
$this->assertSame(' checked="checked"', set_checkbox('foo', 'bar'));
894+
$checked = set_checkbox('foo', 'bar');
895+
$this->assertSame(' checked="checked"', $checked);
894896

895897
$_SESSION = [
896898
'_ci_old_input' => [
@@ -919,7 +921,8 @@ public function testSetCheckboxWithValueZero(): void
919921
],
920922
];
921923

922-
$this->assertSame(' checked="checked"', set_checkbox('foo', '0'));
924+
$checked = set_checkbox('foo', '0');
925+
$this->assertSame(' checked="checked"', $checked);
923926

924927
$_SESSION = [
925928
'_ci_old_input' => [

0 commit comments

Comments
 (0)