I'm working on a large PHP project that's sure to have a lot of dead code in it. I have been looking for a good way to identify what code is dead so that I can delete it.
I would love to be able to use Xdebug on a live web site to record what methods were called in what classes. After collecting data for a week or two, I could then look closer at any methods that weren't called at all in that time. (Note that I'm not talking about unit tests here; unit test coverage tells me nothing about real-world use.)
It seems this could be straightforward to do; I only need to call xdebug_get_code_coverage() in the teardown code at the end of a request. But that would only give me statistics for the current request, so then I'd need a way to collect this data across multiple requests, in a way that would allow multiple web server threads to update the data simultaneously. I could write it to a database, for example.
Has anyone successfully tried this approach? Or are there other ways I could use Xdebug to help find dead code?
Received on Tue Nov 04 2014 - 21:39:30 GMT
This archive was generated by hypermail 2.2.0 : Mon Jun 25 2018 - 06:00:04 BST