{"id":13607796,"url":"https://github.com/spaze/phpstan-disallowed-calls","last_synced_at":"2026-03-14T00:30:31.311Z","repository":{"id":33228743,"uuid":"138666999","full_name":"spaze/phpstan-disallowed-calls","owner":"spaze","description":"PHPStan rules to detect disallowed method \u0026 function calls, constant, namespace, attribute \u0026 superglobal usages, with powerful rules to re-allow a call or a usage in places where it should be allowed.","archived":false,"fork":false,"pushed_at":"2025-05-15T23:21:12.000Z","size":822,"stargazers_count":296,"open_issues_count":2,"forks_count":22,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-16T04:05:54.784Z","etag":null,"topics":["disallowed-calls","php","phpstan","phpstan-rules","static-analysis"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spaze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"spaze"}},"created_at":"2018-06-26T01:09:59.000Z","updated_at":"2025-05-15T23:21:15.000Z","dependencies_parsed_at":"2023-02-13T02:01:50.031Z","dependency_job_id":"2fde943b-3610-458e-b0a1-67dfd53d75f9","html_url":"https://github.com/spaze/phpstan-disallowed-calls","commit_stats":{"total_commits":203,"total_committers":12,"mean_commits":"16.916666666666668","dds":"0.17733990147783252","last_synced_commit":"d598c896bcc05f77e8b270f5a249910680686e65"},"previous_names":[],"tags_count":74,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaze%2Fphpstan-disallowed-calls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaze%2Fphpstan-disallowed-calls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaze%2Fphpstan-disallowed-calls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaze%2Fphpstan-disallowed-calls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spaze","download_url":"https://codeload.github.com/spaze/phpstan-disallowed-calls/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254464895,"owners_count":22075570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["disallowed-calls","php","phpstan","phpstan-rules","static-analysis"],"created_at":"2024-08-01T19:01:21.694Z","updated_at":"2026-03-14T00:30:31.305Z","avatar_url":"https://github.com/spaze.png","language":"PHP","funding_links":["https://github.com/sponsors/spaze"],"categories":["PHP"],"sub_categories":[],"readme":"# Disallowed calls for PHPStan\n[PHPStan](https://github.com/phpstan/phpstan) rules to detect disallowed calls and more, without running the code.\n\n[![PHP Tests](https://github.com/spaze/phpstan-disallowed-calls/workflows/PHP%20Tests/badge.svg)](https://github.com/spaze/phpstan-disallowed-calls/actions?query=workflow%3A%22PHP+Tests%22)\n\nThere are some functions, methods, constants, namespaces, attributes, variables and properties which should not be used in production code. One good example is the `var_dump()` function,\nit is often used to quickly debug problems but should be removed before committing the code. And sometimes it's not.\n\nAnother example would be a generic logger. Let's say you're using one of the generic logging libraries but you have your own logger\nthat will add some more info, or sanitize data, before calling the generic logger. Your code should not call the generic logger directly\nbut should instead use your custom logger.\n\nThis [PHPStan](https://github.com/phpstan/phpstan) extension will detect such usage, if configured. It should be noted that this extension\nis not a way to defend against or detect hostile developers, as they can obfuscate the calls for example. This extension is meant to be\nanother pair of eyes, detecting your own mistakes, it doesn't aim to detect-all-the-things.\n\n[Tests](tests) will provide examples what is ***currently*** detected. If it's not covered by tests, it might be, but most probably will not be detected.\n`*Test.php` files are the tests, start with those, the analyzed test code is in [src](tests/src), required test classes in [libs](tests/libs).\n\nFeel free to file [issues](https://github.com/spaze/phpstan-disallowed-calls/issues) or create [pull requests](https://github.com/spaze/phpstan-disallowed-calls/pulls) if you need to detect more calls.\n\n## Installation\n\nInstall the extension using [Composer](https://getcomposer.org/):\n```\ncomposer require --dev spaze/phpstan-disallowed-calls\n```\n\n[PHPStan](https://github.com/phpstan/phpstan), the PHP Static Analysis Tool, is a requirement.\n\nIf you use [phpstan/extension-installer](https://github.com/phpstan/extension-installer), you are all set and can skip to configuration.\n\nFor manual installation, add this to your `phpstan.neon`:\n\n```neon\nincludes:\n    - vendor/spaze/phpstan-disallowed-calls/extension.neon\n```\n\n## Configuration files\n\nYou can start with [bundled configuration files](docs/configuration-bundled.md).\n\n## Custom rules\n\nThe extension supports versatile [custom rules](docs/custom-rules.md), too.\n\n### Allow some previously disallowed calls or usages\n\nLet's say you have disallowed the `foo()` function (or any other supported items like constants or method calls etc.) with custom rules. But you want to re-allow it when used in your custom wrapper, or when the first parameter equals, or not, a specified value. The extension offers multiple ways of doing that:\n\n- [Ignore errors](docs/allow-ignore-errors.md) the PHPStan way\n- [Allow in paths](docs/allow-in-paths.md)\n- [Allow in methods or functions](docs/allow-in-methods.md)\n- [Allow with specified parameters](docs/allow-with-parameters.md)\n- [Allow with specified flags](docs/allow-with-flags.md)\n- [Allow in classes, child classes, classes implementing an interface](docs/allow-in-instance-of.md) (same as the `instanceof` operator)\n- [Allow in class with given attributes](docs/allow-in-class-with-attributes.md)\n- [Allow in methods or functions with given attributes](docs/allow-in-methods.md)\n- [Allow in class with given attributes on any method](docs/allow-in-class-with-method-attributes.md)\n\n[Re-allowing attributes](docs/allow-attributes.md) uses a similar [configuration](docs/allow-attributes.md).\n\n\n## Disallow disabled functions \u0026 classes\n\nUse the [provided generator](docs/disallow-disabled-functions-classes.md) to generate a configuration snippet from PHP's `disable_functions` \u0026 `disable_classes` configuration directives.\n\n## Example output\n\n```\n ------ --------------------------------------------------------\n  Line   libraries/Report/Processor/CertificateTransparency.php\n ------ --------------------------------------------------------\n  116    Calling var_dump() is forbidden, use logger instead\n ------ --------------------------------------------------------\n```\n\n## Case-(in)sensitivity\n\nFunction names, method names, class names, namespaces are matched irrespective of their case (disallowing `print_r` will also find `print_R` calls), while anything else like constants, file names, paths are not.\n\n## No other rules\n\nYou can also use this extension [without any other PHPStan rules](docs/phpstan-custom-ruleset.md). This may be useful if you want to for example check a third-party code for some calls or usage of something.\n\n## Running tests\n\nIf you want to contribute (awesome, thanks!), you should add/run tests for your contributions.\nFirst install dev dependencies by running `composer install`, then run PHPUnit tests with `composer test`, see `scripts` in `composer.json`. Tests are also run on GitHub with Actions on each push.\n\nYou can fix coding style issues automatically by running `composer cs-fix`.\n\n## See also\nThere's a similar project with a slightly different configuration, created almost at the same time (just a few days difference): [PHPStan Banned Code](https://github.com/ekino/phpstan-banned-code).\n\n## Framework or package-specific configurations\n- For [Nette Framework](https://github.com/spaze/phpstan-disallowed-calls-nette)\n- For [Symfony](https://github.com/spaze/phpstan-disallowed-calls-symfony)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspaze%2Fphpstan-disallowed-calls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspaze%2Fphpstan-disallowed-calls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspaze%2Fphpstan-disallowed-calls/lists"}