Skip to content

Commit 03f4a7b

Browse files
committed
fix: satisfy PHPStan 2.2.3
- Remove redundant output-buffer level checks after ob_start() - Narrow output-buffer helper return types Signed-off-by: memleakd <121398829+memleakd@users.noreply.github.com>
1 parent 01da624 commit 03f4a7b

6 files changed

Lines changed: 10 additions & 26 deletions

File tree

system/Common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function clean_path(string $path): string
119119
*
120120
* > command('migrate:create SomeMigration');
121121
*
122-
* @return false|string
122+
* @return string
123123
*/
124124
function command(string $command)
125125
{

tests/system/CommonFunctionsSendTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ public function testRedirectResponseCookiesSent(): void
5858
// send it
5959
ob_start();
6060
$response->send();
61-
if (ob_get_level() > 0) {
62-
ob_end_clean();
63-
}
61+
ob_end_clean();
6462

6563
// and what actually got sent?
6664
$this->assertHeaderEmitted('Set-Cookie: foo=onething;');

tests/system/HTTP/DownloadResponseTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,7 @@ public function testRealOutput(): void
377377
// send it
378378
ob_start();
379379
$response->send();
380-
if (ob_get_level() > 0) {
381-
ob_end_clean();
382-
}
380+
ob_end_clean();
383381

384382
// and what actually got sent?
385383
$this->assertHeaderEmitted('Content-Length: ' . filesize(__FILE__));

tests/system/HTTP/ResponseSendTest.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ public function testHeadersMissingDate(): void
6767
// send it
6868
ob_start();
6969
$response->send();
70-
if (ob_get_level() > 0) {
71-
ob_end_clean();
72-
}
70+
ob_end_clean();
7371

7472
// and what actually got sent?
7573
$this->assertHeaderEmitted('Date:');
@@ -102,9 +100,7 @@ public function testHeadersWithCSP(): void
102100
// send it
103101
ob_start();
104102
$response->send();
105-
if (ob_get_level() > 0) {
106-
ob_end_clean();
107-
}
103+
ob_end_clean();
108104

109105
// and what actually got sent?; test both ways
110106
$this->assertHeaderEmitted('Content-Security-Policy:');
@@ -140,9 +136,7 @@ public function testRedirectResponseCookies(): void
140136
// send it
141137
ob_start();
142138
$response->send();
143-
if (ob_get_level() > 0) {
144-
ob_end_clean();
145-
}
139+
ob_end_clean();
146140

147141
// and what actually got sent?
148142
$this->assertHeaderEmitted('Set-Cookie: foo=bar;');
@@ -213,9 +207,7 @@ public function testHeaderOverride(): void
213207
header('Access-Control-Expose-Headers: Content-Encoding');
214208
header('Allow: GET, POST');
215209
$response->send();
216-
if (ob_get_level() > 0) {
217-
ob_end_clean();
218-
}
210+
ob_end_clean();
219211

220212
// single header
221213
$this->assertHeaderEmitted('Vary: Accept-Encoding');

tests/system/Test/BootstrapFCPATHTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private function fileContents(): string
100100
return $fileContents . 'echo FCPATH;' . PHP_EOL;
101101
}
102102

103-
private function readOutput(string $file): false|string
103+
private function readOutput(string $file): string
104104
{
105105
ob_start();
106106
system('php -f ' . $file);

tests/system/Test/TestCaseEmissionsTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ public function testHeadersEmitted(): void
6262
// send it
6363
ob_start();
6464
$response->send();
65-
if (ob_get_level() > 0) {
66-
ob_end_clean();
67-
}
65+
ob_end_clean();
6866

6967
// and what actually got sent?; test both ways
7068
$this->assertHeaderEmitted('Set-Cookie: foo=bar;');
@@ -90,9 +88,7 @@ public function testHeadersNotEmitted(): void
9088
// send it
9189
ob_start();
9290
$response->send(); // what really was sent
93-
if (ob_get_level() > 0) {
94-
ob_end_clean();
95-
}
91+
ob_end_clean();
9692

9793
$this->assertHeaderNotEmitted('Set-Cookie: pop=corn', true);
9894
}

0 commit comments

Comments
 (0)