scheb / tombstone
Dead code detection with tombstones for PHP
Installs: 409 963
Dependents: 0
Suggesters: 0
Security: 0
Stars: 260
Watchers: 10
Forks: 17
Open Issues: 4
Requires
- php: >=7.1.3
- ext-dom: *
- ext-json: *
- nikic/php-parser: ^4.0|^5.0
- phpunit/php-text-template: ^1.2.1|^2.0|^3.0
- psr/log: ^1.0|^2.0|^3.0
- symfony/config: ^3.4|^4.0|^5.0|^6.0
- symfony/console: ^3.4|^4.0|^5.0|^6.0
- symfony/finder: ^4.1|^5.0|^6.0
- symfony/yaml: ^3.4|^4.0|^5.0|^6.0
Requires (Dev)
- escapestudios/symfony2-coding-standard: ^3.9
- phpunit/phpunit: ^7.5|^8.0|^9.0
- squizlabs/php_codesniffer: ^3.5
- symfony/css-selector: ^4.4|^5.0
- symfony/dom-crawler: ^4.4|^5.0
- vimeo/psalm: ^4.30|^5.22
Replaces
- scheb/tombstone-analyzer: ^1.0
- scheb/tombstone-core: ^1.0
- scheb/tombstone-logger: ^1.0
This package is auto-updated.
Last update: 2024-10-09 23:17:58 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.
What are Tombstones?
To get the basic idea, watch David Schnepper's 5 minute talk from Velocity Santa Clara 2014.
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:
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.