{"id":27111110,"url":"https://github.com/phauthentic/phpstan-rules","last_synced_at":"2026-02-10T01:05:11.267Z","repository":{"id":284824189,"uuid":"955843462","full_name":"Phauthentic/phpstan-rules","owner":"Phauthentic","description":"PHPStan rules focused on architectural \u0026 clean code rules","archived":false,"fork":false,"pushed_at":"2026-02-04T09:58:28.000Z","size":254,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-04T22:21:17.086Z","etag":null,"topics":["architecture","checker","clean-architecture","clean-code","phpstan","phpstan-rules"],"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/Phauthentic.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-27T09:35:54.000Z","updated_at":"2026-01-27T12:35:38.000Z","dependencies_parsed_at":"2025-03-27T21:38:53.382Z","dependency_job_id":"da8211db-a13f-4ade-9737-414a5f190a1e","html_url":"https://github.com/Phauthentic/phpstan-rules","commit_stats":null,"previous_names":["phauthentic/phpstan-rules"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/Phauthentic/phpstan-rules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phauthentic%2Fphpstan-rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phauthentic%2Fphpstan-rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phauthentic%2Fphpstan-rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phauthentic%2Fphpstan-rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Phauthentic","download_url":"https://codeload.github.com/Phauthentic/phpstan-rules/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phauthentic%2Fphpstan-rules/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29287747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T21:57:15.303Z","status":"ssl_error","status_checked_at":"2026-02-09T21:57:11.537Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["architecture","checker","clean-architecture","clean-code","phpstan","phpstan-rules"],"created_at":"2025-04-07T00:55:41.424Z","updated_at":"2026-02-10T01:05:11.262Z","avatar_url":"https://github.com/Phauthentic.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHPStan Rules\n\nAdditional rules for PHPStan, mostly focused on Clean Code and architecture conventions.\n\nThe rules help with enforcing certain method signatures, return types and dependency constraints in your codebase.\n\nFor example, you can configure the rules so that all controllers in your application must be `readonly`, no method should have more than 3 arguments, and no class should have more than 2 nested control structures.\n\n## Usage\n\n```bash\ncomposer require phauthentic/phpstan-rules --dev\n```\n\n## Rules\n\nSee individual rule documentation for detailed configuration examples. A [full configuration example](docs/Rules.md) is also available.\n\n### Architecture Rules\n\n- [Attribute Rule](docs/rules/Attribute-Rule.md)\n- [Catch Exception Of Type Not Allowed Rule](docs/rules/Catch-Exception-Of-Type-Not-Allowed-Rule.md)\n- [Circular Module Dependency Rule](docs/rules/Circular-Module-Dependency-Rule.md)\n- [Class Must Be Final Rule](docs/rules/Class-Must-Be-Final-Rule.md)\n- [Class Must Be Readonly Rule](docs/rules/Class-Must-Be-Readonly-Rule.md)\n- [Class Must Have Specification Docblock Rule](docs/rules/Class-Must-Have-Specification-Docblock-Rule.md)\n- [Classname Must Match Pattern Rule](docs/rules/Classname-Must-Match-Pattern-Rule.md)\n- [Dependency Constraints Rule](docs/rules/Dependency-Constraints-Rule.md) *(deprecated, use Forbidden Dependencies Rule)*\n- [Forbidden Accessors Rule](docs/rules/Forbidden-Accessors-Rule.md)\n- [Forbidden Dependencies Rule](docs/rules/Forbidden-Dependencies-Rule.md)\n- [Forbidden Namespaces Rule](docs/rules/Forbidden-Namespaces-Rule.md)\n- [Forbidden Static Methods Rule](docs/rules/Forbidden-Static-Methods-Rule.md)\n- [Method Must Return Type Rule](docs/rules/Method-Must-Return-Type-Rule.md)\n- [Method Signature Must Match Rule](docs/rules/Method-Signature-Must-Match-Rule.md)\n- [Methods Returning Bool Must Follow Naming Convention Rule](docs/rules/Methods-Returning-Bool-Must-Follow-Naming-Convention-Rule.md)\n- [Modular Architecture Rule](docs/rules/Modular-Architecture-Rule.md)\n- [Property Must Match Rule](docs/rules/Property-Must-Match-Rule.md)\n\n### Clean Code Rules\n\n- [Control Structure Nesting Rule](docs/rules/Control-Structure-Nesting-Rule.md)\n- [Too Many Arguments Rule](docs/rules/Too-Many-Arguments-Rule.md)\n- [Max Line Length Rule](docs/rules/Max-Line-Length-Rule.md)\n\n### Domain Specific Rules / Extending Rules\n\nThe rules in this package can be extended at project level to create self-documenting, domain-specific rules. Instead of configuring complex regex patterns in your neon file, you can create custom rule classes that encapsulate the configuration. For example, a class named `DomainClassesMustBeFinalRule` immediately communicates its purpose. See the [Extending Rules](docs/ExtendingRules.md) documentation for examples and best practices.\n\n### Using Regex in Rules\n\nA lot of the rules use regex patterns to match things. Many people are not good at writing them but thankfully there is AI today.\n\nIf you struggle to write the regex patterns you need, you can use AI tools like [ChatGPT](https://chat.openai.com/) to help you generate them. Just describe what you want to match, and it can provide you with a regex pattern that fits your needs.  The regex can be tested using online tools like [regex101](https://regex101.com/).\n\n## Why PHPStan to enforce Architectural Rules?\n\nBecause PHPStan is a widely used static analysis tool in the PHP community. It already provides a solid foundation for code quality checks, and adding custom rules allows you to enforce specific coding standards and architectural constraints is just a logical choice. You won't need more 3rd party tools to enforce your architectural constraints.\n\nIt is also more or less easy to write your own rules if you need to enforce something specific that is not covered by the existing rules.\n\n## What if I need to ignore a Rule in a certain Place?\n\nUse the inline annotations PHPStan provides and add a comment explaining *why* in this case the rule is allowed to be broken. An inline annotation is the best because you should keep the information close to where it happens, visible right at the root of the problem.\n\n### Alternative Tools\n\nIf you don't like this library, you can also check out other tools. Some of them provide a fluent interface instead of a Regex. If this feels more comfortable for you, you might want to check them out:\n\n* [Deptrac](https://github.com/deptrac/deptrac) - Checks dependencies between namespaces and classes.\n* [PHP Architecture Tester](https://www.phpat.dev/) - A tool to enforce architectural rules in PHP applications.\n* [PHPArkitect](https://github.com/phparkitect/arkitect) - A tool to enforce architectural rules in PHP applications.\n* [PHPMD](https://phpmd.org/) - A tool that scans PHP source code and looks for potential problems.\n\n## License\n\nThis library is under the MIT license.\n\nCopyright Florian Krämer","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphauthentic%2Fphpstan-rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphauthentic%2Fphpstan-rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphauthentic%2Fphpstan-rules/lists"}