scheb/tombstone

Dead code detection with tombstones for PHP

v1.6.0 2024-03-09 21:51 UTC

README

Implements the concept of tombstones for dead code detection in PHP.

The library provides you with a toolbox to place, track and evaluate tombstones in your code.

Build Status Code Coverage Latest Stable Version Monthly Downloads Total Downloads License

Logo

What are Tombstones?

To get the basic idea, watch David Schnepper's 5 minute talk from Velocity Santa Clara 2014.

Tombstone Youtube Video

When you want to identify and clean-up dead code in a project, static code analysis tools are the weapon of choice. But these tools have some limitations, especially in a dynamic language like PHP:

  • They can only tell you, if a piece of code is referenced, not if it's actually used
  • They cannot resolve dynamic or generated call paths

Tombstones provide a way to track if a piece of code is actually invoked. They are executable markers in your code, that you can place where you suspect dead code. Then, you collect tombstone invocations on production. After a while, the logs will tell you, which tombstones are dead and which ones aren't (the so called "vampires").

Installation

The library consists of multiple components, that need to be installed and configured independently:

Read how to install scheb/tombstone-logger for placing and logging tombstones in your code.

Read how to install scheb/tombstone-analyzer, which takes log data from scheb/tombstone-logger to generate reports in various formats. For example an HTML report:

Dashboard view Code view

Security

For information about the security policy and know security issues, see SECURITY.md.

Contributing

Want to contribute to this project? See CONTRIBUTING.md.

License

This software is available under the MIT license.

Acknowledgments

The library is heavily inspired by Nestoria.com's implementation of the tombstone concept.

Thanks to Jordi Boggiano for creating Monolog, from where I lend the handler/formatter concept.

The tombstone graphic is based on a licensed illustration by "lemonadeserenade".

Support Me

I'm developing this library since 2015. I love to hear from people using it, giving me the motivation to keep working on my open source projects.

If you want to let me know you're finding it useful, please consider giving it a star ⭐ on GitHub.

If you love my work and want to say thank you, you can help me out for a beer 🍻️ via PayPal.