Open jaydiablo opened 4 years ago
How about:
while (ob_get_level() > 0) {
ob_end_clean();
}
I think that would end up the same result, be static analysis safe, and actually throw in case of a non-cleanable buffer?
@jaydiablo Do you agree with @asherkin or do you still think we should do a special case for ob_end_clean?
Ran into some code that was doing this:
Safe defines
ob_end_clean
as avoid
return: https://github.com/thecodingmachine/safe/blob/master/generated/outcontrol.php#L22However,
ob_end_clean
will returntrue
when it successfully clears the buffer.If we use
Safe\ob_end_clean
in this situation, static analyzers complain that the output of avoid
returning function is used (since it's used in the while loop's condition).Shouldn't the signature of this function remain as returning a
bool
(justtrue
if thefalse
condition throws the Safe exception)?We could modify the code to do this:
Which is fine, just doesn't seem to match what users of the native
ob_end_clean
function may be expecting.