Contributing Advent 20: Xdebug halting on error
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:
xdebug.halt_level=E_WARNING|E_NOTICE|E_USER_WARNING|E_USER_NOTICE
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!
Comments
Ok this is good and it's probably a bit late to comment, but instead of halting it would be nice to make it stop (not error/exit) like a breakpoint. Or are we talking about the same thing? :)
Thanks for a great product!
Andrew
@Andrew: Xdebug already supports that through an exception breakpoint on Notice. Not many IDEs support that though.
Life Line
This is indeed no more a clothes shop, but a restaurant
Created 2 waste_baskets, 2 boards, and 2 benches; Updated 8 benches, 6 waste_baskets, and 2 other objects; Deleted 2 waste_baskets and a bench
Updated a pub
Merge branch 'v2022'
Merge branch 'php_gh_19803' into v2022
Fix PHP GH-19803: Parsing a string with a single white space does cre…
Merge branch 'xdebug_3_5'
Back to -dev
Go with 3.5.1
Thanks Brussels, you've been lovely to me this weekend.
And I've a lot to process from the conference too.
I walked 3.9km in 36m24s
I walked 1.1km in 11m31s
Updated a restaurant; Confirmed 3 fast_foods, a convenience shop, and 2 other objects
I walked 4.4km in 44m06s
I walked 5.1km in 56m16s
I walked 3.8km in 37m43s
I'm up early to get the Eurostar to #FOSDEM and I've already seen friends being made.
Fixed another address
Fixed address for flats
Fixed address, and ass missing service way
I walked 6.4km in 1h20m58s
I walked 11.4km in 9m22s
I walked 10.4km in 1h41m18s
I walked 7.4km in 1h26m49s
Good job antivaxer shit heads:
BBC News: UK loses measles elimination status


Shortlink
This article has a short URL available: https://drck.me/adv1320-aff