ObGetCleanCanBeUsed
warning on by default quick-fixGroup: Control flow · PhpStorm name: ObGetCleanCanBeUsedInspection
Reading the output buffer with ob_get_contents() and then discarding it with ob_end_clean() in the next statement is exactly what the single built-in ob_get_clean() does. Merge the two calls.
Example
php
<?php
function renderPanel($tpl) {
ob_start();
include $tpl;
$markup = ob_get_contents();
ob_end_clean();
ob_start();
show_footer();
$size = strlen(\ob_get_contents());
// drop the buffer
ob_end_clean();
ob_start();
echo ob_get_contents();
ob_end_clean();
ob_start();
$copy = ob_get_contents();
flush_logs();
ob_end_clean();
ob_start();
$last = ob_get_contents();
$ok = ob_end_clean();
return [$markup, $size, $copy, $last, $ok];
}php
<?php
function renderPanel($tpl) {
ob_start();
include $tpl;
$markup = ob_get_clean();
ob_start();
show_footer();
$size = strlen(\ob_get_clean());
// drop the buffer
ob_start();
echo ob_get_contents();
ob_end_clean();
ob_start();
$copy = ob_get_contents();
flush_logs();
ob_end_clean();
ob_start();
$last = ob_get_contents();
$ok = ob_end_clean();
return [$markup, $size, $copy, $last, $ok];
}Reported:
- line 5: Use ob_get_clean() instead of ob_get_contents() + ob_end_clean().
- line 10: Use ob_get_clean() instead of ob_get_contents() + ob_end_clean().
Configure
In custos.json:
json
{
"rules": {
"ObGetCleanCanBeUsed": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file), either of:
php
// @custos-ignore ObGetCleanCanBeUsed
/**
* @noinspection ObGetCleanCanBeUsedInspection
*/