Recursively cast to array in PHP

I recently ran into an issue where JSON encoding some objects in my code wasn’t working properly. After experimenting, I realized that casting everything to an array before JSON encoding magically fixed things.  Casting an object to an array is simple enough: But, what happens when an object or array contains references to other objects … Read more

Do while false in PHP?

I was working on something in Jetpack recently, and was mind-boggled when I came across a do…while( false ) loop. What confused me so much, is why even use the loop if the condition was always false? Not able to figure out what this bit of code did, I brought the issue up to my … Read more

Print PHP Stack Trace

I was having a bit of trouble tracking down exactly where a method was getting called from today. Usually a search in my project directory will turn up the result very quickly, but I wasn’t having luck with PHPStorm for some reason. So, the next best thing was to get a stack trace so that … Read more