Bug #67655 [NEW]: php_strip_whitespace outputs warnings instead of going through the error_handle

From: Date: Sat, 19 Jul 2014 22:25:23 +0000
Subject: Bug #67655 [NEW]: php_strip_whitespace outputs warnings instead of going through the error_handle
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186751@lists.php.net to get a copy of this message
From:             seld
Operating system: Linux
PHP version:      Irrelevant
Package:          Output Control
Bug Type:         Bug
Bug description:php_strip_whitespace outputs warnings instead of going through the error_handle

Description:
------------
php_strip_whitespace appears to be bypassing the error handler and
output buffering. If you run it in CLI and there is a warning like
"Unterminated comment starting line .." then that is output to the user
with no chance to intercept.

More infos at https://github.com/composer/composer/issues/3030
and a
test run showing various issues at http://3v4l.org/pS3LE

The only workaround found was to @-silence the call, which is alright
but I thought I'd report it anyway because it's pretty strange behavior.

Test script:
---------------
<?php
function log_error($num, $str, $file, $line, $context = null) {
    throw new ErrorException( $str, 0, $num, $file, $line );
}
set_error_handler('log_error');
ob_start();

// uncommenting the line below might help surface the problem:
//error_reporting(-1); ini_set('display_errors', 1);

file_put_contents('test.php', '<?php /*');
$out = php_strip_whitespace('test.php');
unlink('test.php');

var_dump(ob_get_clean(), $out); 


Expected result:
----------------
string(0) ""
string(6) "<?php "

Actual result:
--------------
Warning: Unterminated comment starting line 1 in repro.php on line 9
string(0) ""
string(6) "<?php "

-- 
Edit bug report at https://bugs.php.net/bug.php?id=67655&edit=1
-- 



Thread (2 messages)

« previous php.bugs (#186751) next »