Contributing Advent 17: Printing stacks
Anybody who is vaguely familiar with Xdebug probably has seen its glorious orange stack traces gracing their screens. In case you have not, they look like:
In this case, the tell_a_lie_and_hurt_you() function tried to call strlen() with incorrect arguments.
Xdebug overloads PHP's internal error handler to do this, but it is also possible to trigger stack traces yourself. You can of course use trigger_error(), but Xdebug also provides the xdebug_print_function_stack() function. Running xdebug_print_function_stack() instead of the erroneous strlen() results in:
As the documentation state, you can also provide your own message:
<?php
function tell_a_lie_and_hurt_you()
{
xdebug_print_function_stack("You have been rickrolled!");
}
Which then results in:
This was all good, and then my friend Rob asked:
hypothetically, how hard would it be to change xdebug_print_function_stack() so that it didn't output the filename and line number in the orange box?
Well, it didn't turn out to be very hard. Rob requested this feature because he was writing his own error handler. And with your own error handler it does not make a whole lot of sense to show where xdebug_print_function_stack() was called from. After my commit, you can now supply a second argument to xdebug_print_function_stack():
<?php
function tell_a_lie_and_hurt_you()
{
xdebug_print_function_stack("You have been rickrolled!", XDEBUG_STACK_NO_DESC);
}
Which then results in a stack trace without header:
This new feature will be part of Xdebug 2.3.
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/adv1317-afc