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
Updated 3 restaurants
I walked 3.1km in 29m25s
I walked 4.4km in 45m01s
I walked 5.4km in 55m28s
Updated a restaurant; Confirmed a hotel
I walked 6.3km in 1h12m59s
Paraphrasing opening keynote speaker at ConFoo: "Should we go back to the waterfall method of writing massive specs upfront to feed to AI coding agents?"
I walked 1.6km in 17m29s
I walked 2.1km in 17m44s
Updated a pub
I walked 2.6km in 26m41s
Merged pull request #1065
Comparison whether class is userland or internal used the wrong macro
PHP 8.6: zend_enum.h now mixes code with declarations
PHP 8.6: Argument names are now stored as zend_strings
Updated a bench and a waste_basket
I walked 8.3km in 1h25m37s
Created a recycling
I walked 10.5km in 1h46m57s
An interesting journey in story form, showing how English changed over time.
https://www.deadlanguagesociety.com/p/how-far-back-in-time-understand-english
A much better writer than I is summing up perfectly why I have such disdain for Generative AI/LLMs.
https://jonn.substack.com/p/so-why-do-i-feel-so-angry-about-this
Created a waste_basket; Updated a waste_basket; Deleted a bench
Created a bench; Updated 7 benches and a gate; Deleted 2 benches and a gate
Created 10 benches and 2 waste_baskets; Updated an information


Shortlink
This article has a short URL available: https://drck.me/adv1317-afc