@@ -240,14 +240,10 @@ public function explain()
240
240
$ sniffs = array_keys ($ this ->sniffCodes );
241
241
sort ($ sniffs );
242
242
243
- ob_start ( );
243
+ $ sniffCount = count ( $ sniffs );
244
244
245
- $ lastStandard = null ;
246
- $ lastCount = 0 ;
247
- $ sniffCount = count ($ sniffs );
248
-
249
- // Add a dummy entry to the end so we loop
250
- // one last time and clear the output buffer.
245
+ // Add a dummy entry to the end so we loop one last time
246
+ // and echo out the collected info about the last standard.
251
247
$ sniffs [] = '' ;
252
248
253
249
$ summaryLine = PHP_EOL ."The $ this ->name standard contains 1 sniff " .PHP_EOL ;
@@ -257,7 +253,9 @@ public function explain()
257
253
258
254
echo $ summaryLine ;
259
255
260
- ob_start ();
256
+ $ lastStandard = null ;
257
+ $ lastCount = 0 ;
258
+ $ sniffsInStandard = [];
261
259
262
260
foreach ($ sniffs as $ i => $ sniff ) {
263
261
if ($ i === $ sniffCount ) {
@@ -269,32 +267,31 @@ public function explain()
269
267
}
270
268
}
271
269
270
+ // Reached the first item in the next standard.
271
+ // Echo out the info collected from the previous standard.
272
272
if ($ currentStandard !== $ lastStandard ) {
273
- $ sniffList = ob_get_contents ();
274
- ob_end_clean ();
275
-
276
- echo PHP_EOL .$ lastStandard .' ( ' .$ lastCount .' sniff ' ;
273
+ $ subTitle = $ lastStandard .' ( ' .$ lastCount .' sniff ' ;
277
274
if ($ lastCount > 1 ) {
278
- echo 's ' ;
275
+ $ subTitle .= 's ' ;
279
276
}
280
277
281
- echo ') ' .PHP_EOL ;
282
- echo str_repeat ('- ' , (strlen ($ lastStandard .$ lastCount ) + 10 ));
283
- echo PHP_EOL ;
284
- echo $ sniffList ;
278
+ $ subTitle .= ') ' ;
285
279
286
- $ lastStandard = $ currentStandard ;
287
- $ lastCount = 0 ;
280
+ echo PHP_EOL .$ subTitle .PHP_EOL ;
281
+ echo str_repeat ('- ' , strlen ($ subTitle )).PHP_EOL ;
282
+ echo ' ' .implode (PHP_EOL .' ' , $ sniffsInStandard ).PHP_EOL ;
283
+
284
+ $ lastStandard = $ currentStandard ;
285
+ $ lastCount = 0 ;
286
+ $ sniffsInStandard = [];
288
287
289
288
if ($ currentStandard === null ) {
290
289
break ;
291
290
}
292
-
293
- ob_start ();
294
291
}//end if
295
292
296
- echo ' ' . $ sniff. PHP_EOL ;
297
- $ lastCount ++ ;
293
+ $ sniffsInStandard [] = $ sniff ;
294
+ ++ $ lastCount ;
298
295
}//end foreach
299
296
300
297
}//end explain()
0 commit comments