Tag: php
-
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 […]
-
PHP – Get methods of a class along with arguments
Lately, I’ve been using the command line a lot more often at work. I found two things hard about using the command line to interact with PHP files: Figuring out the require path every time I opened an interactive shell Remember what methods were available in a class and what arguments the method expected The […]
-
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 […]