After Rob came up with the idea for
xdebug_print_function_stack() from episode 17 he filed another issue. This new issue request thats a new setting to be added to Xdebug that allows users to decide whether notices and warnings should be treated as (fatal) errors. It's very much like GCC's
-Werror setting which converts every compiler warning into an error that aborts the compilation process. The article for episode 4 talks a bit more about GCC's flags.
But as we are talking about PHP and Xdebug here, lets focus on this new feature that I added.
xdebug.halt_level is a setting that allows you to configure a mask. This mask determines which notices get converted to errors. Right now, you can configure notices and warnings that are generated by PHP, and notices and warnings that you generate yourself (by means of trigger_error()). For example, to convert the warning of
strlen() (without arguments) to an error, you would do:
<?php ini_set('xdebug.halt_level', E_WARNING); strlen(); ?>
Which will then result in the showing of the error message, and the abortion of the script.
echo "Hi!\n"; will not be executed.
The new setting is a bit mask, so to convert all notices and warnings into errors for all applications, you can set this in php.ini:
And that means, that errors created by
trigger_error() also cause the termination of the script.
This new feature is going to be part of Xdebug 2.3. Stay tuned!