File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717 "psr/log" : " ^3.0"
1818 },
1919 "require-dev" : {
20- "boundwize/structarmed" : " 0.14.6 " ,
20+ "boundwize/structarmed" : " 0.14.7 " ,
2121 "codeigniter/phpstan-codeigniter" : " ^2.1" ,
2222 "fakerphp/faker" : " ^1.24" ,
2323 "kint-php/kint" : " ^6.1" ,
Original file line number Diff line number Diff line change @@ -185,13 +185,21 @@ function command(string $command)
185185 $ params [$ arg ] = $ value ;
186186 }
187187
188+ $ bufferLevel = ob_get_level ();
189+
188190 try {
189191 ob_start ();
190192 service ('commands ' )->run ($ command , $ params );
191193
194+ if (ob_get_level () <= $ bufferLevel ) {
195+ return false ;
196+ }
197+
192198 return ob_get_contents ();
193199 } finally {
194- ob_end_clean ();
200+ while (ob_get_level () > $ bufferLevel ) {
201+ ob_end_clean ();
202+ }
195203 }
196204 }
197205}
Original file line number Diff line number Diff 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; ' );
Original file line number Diff line number Diff 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__ ));
Original file line number Diff line number Diff 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 ' );
Original file line number Diff line number Diff 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 );
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments