{"id":16390186,"url":"https://github.com/slamdunk/phpstan-extensions","last_synced_at":"2025-05-16T05:04:37.214Z","repository":{"id":46177552,"uuid":"116389020","full_name":"Slamdunk/phpstan-extensions","owner":"Slamdunk","description":"Extensions for PHPStan","archived":false,"fork":false,"pushed_at":"2025-05-11T14:50:14.000Z","size":224,"stargazers_count":69,"open_issues_count":4,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-11T15:34:37.526Z","etag":null,"topics":["php","phpstan","static-analysis","yii2"],"latest_commit_sha":null,"homepage":null,"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/Slamdunk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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":["Slamdunk"],"custom":"https://paypal.me/filippotessarotto"}},"created_at":"2018-01-05T13:41:18.000Z","updated_at":"2025-05-11T14:50:17.000Z","dependencies_parsed_at":"2024-03-28T14:01:43.881Z","dependency_job_id":"46425784-aa4b-40f7-aafd-377b1ab658aa","html_url":"https://github.com/Slamdunk/phpstan-extensions","commit_stats":{"total_commits":147,"total_committers":11,"mean_commits":"13.363636363636363","dds":0.4965986394557823,"last_synced_commit":"7e5d146ca33f77dfb4ef68358291a2eaf059649c"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Slamdunk%2Fphpstan-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Slamdunk%2Fphpstan-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Slamdunk%2Fphpstan-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Slamdunk%2Fphpstan-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Slamdunk","download_url":"https://codeload.github.com/Slamdunk/phpstan-extensions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254471060,"owners_count":22076585,"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":["php","phpstan","static-analysis","yii2"],"created_at":"2024-10-11T04:35:11.536Z","updated_at":"2025-05-16T05:04:37.198Z","avatar_url":"https://github.com/Slamdunk.png","language":"PHP","readme":"# Slam PHPStan extensions\n\n[![Latest Stable Version](https://img.shields.io/packagist/v/slam/phpstan-extensions.svg)](https://packagist.org/packages/slam/phpstan-extensions)\n[![Downloads](https://img.shields.io/packagist/dt/slam/phpstan-extensions.svg)](https://packagist.org/packages/slam/phpstan-extensions)\n[![Integrate](https://github.com/Slamdunk/phpstan-extensions/workflows/CI/badge.svg)](https://github.com/Slamdunk/phpstan-extensions/actions)\n[![Code Coverage](https://codecov.io/gh/Slamdunk/phpstan-extensions/coverage.svg)](https://codecov.io/gh/Slamdunk/phpstan-extensions)\n\nExtensions for [PHPStan](https://phpstan.org/)\n\n## Installation\n\nTo use this extension, require it in [Composer](https://getcomposer.org/):\n\n```bash\ncomposer require --dev slam/phpstan-extensions\n```\n\n## Usage\n\nWhen you are using [`phpstan/extension-installer`](https://github.com/phpstan/extension-installer),\n`conf/slam-rules.neon` will be automatically included.\n\nOtherwise you need to include `conf/slam-rules.neon` in your `phpstan.neon`:\n\n```yaml\nincludes:\n    - vendor/slam/phpstan-extensions/conf/slam-rules.neon\n```\n\n## Rules\n\n1. `SlamPhpStan\\UnusedVariableRule`: check for variable inside functions never used after initial assignment\n1. `SlamPhpStan\\MissingClosureParameterTypehintRule`: requires parameter typehints for closures; WARNING: no PhpDoc\nallowed, see [`phpstan/phpstan-strict-rules#87`](https://github.com/phpstan/phpstan-strict-rules/issues/87)\n1. `SlamPhpStan\\StringToClassRule`: requires strings that refer to classes to be expressed with `::class` notation\n1. `SlamPhpStan\\GotoRule`: no goto allowed\n1. `SlamPhpStan\\ClassNotationRule`:\n    1. Interfaces must end with \"Interface\"\n    1. Traits must end with \"Trait\"\n    1. Abstract classes must start with \"Abstract\"\n    1. Exceptions must end with \"Exception\"\n1. `SlamPhpStan\\PhpUnitFqcnAnnotationRule`: classes found in following PHPUnit annotations must exist:\n    1. `@expectedException`\n    1. `@covers`\n    1. `@coversDefaultClass`\n    1. `@uses`\n1.  `SlamPhpStan\\AccessGlobalVariableWithinContextRule`: inhibit the access to globals within\nclasses that extend or implement a certain class/interface\n1.  `SlamPhpStan\\AccessStaticPropertyWithinModelContextRule`: inhibit the access to static attributes of a class within\nclasses that extend or implement a certain class/interface, useful to prohibit usage of singletons in models\n\n## Not-NOW config\n\nA `not-now-rules.neon` config is present for forbidding raw date system calls:\n\n```yaml\nincludes:\n    - vendor/slam/phpstan-extensions/conf/not-now-rules.neon\n```\n\nThese rules forbid:\n\n1. `new DateTimeImmutable()`\n1. `new DateTime('yesterday')`\n1. `date('Y-m-d')`\n1. `time()`\n1. `strtotime('noon')`\n\nYou should instead rely on a clock abstraction like [`lcobucci/clock`](https://github.com/lcobucci/clock).\n\nWARNING: the rules are not perfect, a user can tricks them easily; they are meant only to help the transition to\na proper clock abstraction.\n\n## Symfony-specific config\n\nA `symfony-rules.neon` config is present for Symfony projects:\n\n```yaml\nincludes:\n    - vendor/slam/phpstan-extensions/conf/symfony-rules.neon\n```\n\nWith the following configurations:\n\n1. `SlamPhpStan\\SymfonyFilesystemRule`: forbid calls to raw filesystem functions well wrapped by\n[`symfony/filesystem`](https://github.com/symfony/filesystem) component\n1. `SlamPhpStan\\SymfonyProcessRule`: forbid calls to raw system functions well wrapped by\n[`symfony/process`](https://github.com/symfony/process) component\n\n## Yii-specific config\n\nA `yii-rules.neon` config is present for Yii projects:\n\n```yaml\nincludes:\n    - vendor/slam/phpstan-extensions/conf/yii-rules.neon\n```\n\nWith the following configurations:\n\n1. `SlamPhpStan\\AccessGlobalVariableWithinContextRule` to deny the usage of `$_GET`, `$_POST` and other global variables\nin models implementing `yii\\db\\ActiveRecordInterface`: accessing to singletons in models is considered an anti-pattern\n1. `SlamPhpStan\\AccessStaticPropertyWithinModelContextRule` to deny the usage of `yii\\BaseYii` static variables like\n`$app` in models implementing `yii\\db\\ActiveRecordInterface`: accessing to singletons in models is considered an\nanti-pattern\n","funding_links":["https://github.com/sponsors/Slamdunk","https://paypal.me/filippotessarotto"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslamdunk%2Fphpstan-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslamdunk%2Fphpstan-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslamdunk%2Fphpstan-extensions/lists"}