PHPackages                             staabm/side-effects-detector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. staabm/side-effects-detector

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

staabm/side-effects-detector
============================

A static analysis tool to detect side effects in PHP code

1.0.5(1y ago)14876.3M—1.4%3[4 issues](https://github.com/staabm/side-effects-detector/issues)[2 PRs](https://github.com/staabm/side-effects-detector/pulls)12MITPHPPHP ^7.4 || ^8.0CI passing

Since Oct 17Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/staabm/side-effects-detector)[ Packagist](https://packagist.org/packages/staabm/side-effects-detector)[ GitHub Sponsors](https://github.com/staabm)[ RSS](/packages/staabm-side-effects-detector/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (6)Versions (11)Used By (12)

Analyzes php-code for side-effects.

When code has no side-effects it can e.g. be used with `eval($code)` in the same process without interfering. [Side-effects are classified](https://github.com/staabm/side-effects-detector/blob/main/lib/SideEffect.php) into categories to filter them more easily depending on your use-case.

This library is used e.g. in PHPUnit to [improve performance of PHPT test-cases](https://staabm.github.io/2024/10/19/phpunit-codesprint-munich.html).

Install
-------

[](#install)

`composer require staabm/side-effects-detector`

Usage
-----

[](#usage)

Example:

```
use staabm\SideEffectsDetector\SideEffectsDetector;

$code = '
