{"id":29640797,"url":"https://github.com/martinsoenen/phpstan-custom-rules","last_synced_at":"2026-05-17T17:45:08.448Z","repository":{"id":305041010,"uuid":"1008643434","full_name":"martinsoenen/phpstan-custom-rules","owner":"martinsoenen","description":"Some custom PHPStan extensions to improve the readability, maintainability and overall quality of your PHP code base.","archived":false,"fork":false,"pushed_at":"2025-07-17T22:10:35.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-18T01:25:32.913Z","etag":null,"topics":["laravel","php","phpstan","phpstan-extension","phpstan-rules","rules"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/martinsoenen/phpstan-custom-rules","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/martinsoenen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-06-25T21:42:50.000Z","updated_at":"2025-07-17T22:16:52.000Z","dependencies_parsed_at":"2025-07-18T03:02:35.331Z","dependency_job_id":null,"html_url":"https://github.com/martinsoenen/phpstan-custom-rules","commit_stats":null,"previous_names":["martinsoenen/phpstan-custom-rules"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/martinsoenen/phpstan-custom-rules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinsoenen%2Fphpstan-custom-rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinsoenen%2Fphpstan-custom-rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinsoenen%2Fphpstan-custom-rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinsoenen%2Fphpstan-custom-rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martinsoenen","download_url":"https://codeload.github.com/martinsoenen/phpstan-custom-rules/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinsoenen%2Fphpstan-custom-rules/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266379339,"owners_count":23920159,"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","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":["laravel","php","phpstan","phpstan-extension","phpstan-rules","rules"],"created_at":"2025-07-21T21:05:44.321Z","updated_at":"2026-05-17T17:45:08.442Z","avatar_url":"https://github.com/martinsoenen.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHPStan Custom Rules\n\n[![CI state](https://img.shields.io/github/actions/workflow/status/martinsoenen/phpstan-custom-rules/tests.yml)](https://github.com/martinsoenen/phpstan-custom-rules)\n[![Packagist version](https://img.shields.io/packagist/v/martinsoenen/phpstan-custom-rules)](https://packagist.org/packages/martinsoenen/phpstan-custom-rules)\n\n\u003e Some custom PHPStan extensions to improve the readability, maintainability and overall quality of your PHP code base.\n\nPackage based on PHPStan. You can find the source package [here](https://phpstan.org/).\n\n### Supported PHP versions\n| PHP version | This package version |\n|-------------|----------------------|\n| 7.4, 8.x    | Latest               |\n\n## How to use it\n\n**1**: First, you may use [Composer](https://getcomposer.org) to install this package as a development dependency into your project:\n\n```bash\ncomposer require --dev \"martinsoenen/phpstan-custom-rules\"\n```\n\n**2**: Then, create a `phpstan.neon` or `phpstan.neon.dist` file in the root of your application. It might look like this:\n\n```\nincludes:\n    - vendor/martinsoenen/phpstan-custom-rules/extension.neon\n\nparameters:\n    paths:\n        - src/\n\n    # 0 to 10, level 10 is the highest level\n    level: 0\n```\n\nThe most important part is the `includes` one, that enables the rules of this package.\n\nFor all available options, please take a look at the PHPStan documentation: **https://phpstan.org/config-reference**\n\n**3**: Finally, you may start analyzing your code using the phpstan console command:\n\n```bash\n./vendor/bin/phpstan\n```\n\n## Rules\n\n### Boolean Property Naming Rule\n\n*Identifier : martinsoenen.booleanPropertyNaming*\n\nEnsure that a Boolean is always named with an “is” at the beginning of its name, to clarify the condition it represents.\n\n### Max Line Per Class Rule\n\n*Identifier : martinsoenen.maxLinePerClass*\n\nGuarantee that a class is no more than 100 lines long, to clearly separate roles between classes and encourage clarification.\n\n### Max Line Per Method Rule\n\n*Identifier : martinsoenen.maxLinePerMethod*\n\nGuarantee that a method is no more than 20 lines long, to separate roles between classes and encourage specification.\n\n### No Basic Exception Rule\n\n*Identifier : martinsoenen.noBasicException*\n\nEnsure that no base exceptions are thrown in order to make custom and specific exceptions everywhere for better maintainability.\n\n### No Delete Cascade Rule (Laravel)\n\n*Identifier : martinsoenen.noCascadeDeleteLaravel*\n\nPrevents cascading deletions in SQL to avoid uncontrolled deletions.  \nThis rule forces you to think about the need for a cascading deletion, and to handle such cases in your code if you need to, which also makes it possible to use the observers and events managed by the framework.  \n  \nThis rule only works for Laravel.  \nA Symfony rule is planned.\n\n### No Generic Word Rule\n\n*Identifier : martinsoenen.noGenericWord*\n\nPrevent generic variable names such as `array`, `string`, `str`, `result`, `res`, `data` to encourage developers to use clear and detailed names such as `users`, `filteredUsers`, `usersCount`, `cars`, ...\n\n### No Laravel Observer Rule\n\n*Identifier : martinsoenen.noLaravelObserver*\n\nForbid the use of Observers in Laravel, as the behavior of observers is sometimes incomprehensible and uncontrollable.  \nThis rule encourages the use of Events \u0026 Listeners, whose behavior is similar but much more explicit and stable.\n\n### No Try Catch Rule\n\n*Identifier : martinsoenen.noTryCatch*\n\nPrevent `try catch` usage to ensure that the user uses PHP exceptions.  \nThis makes the code more readable and errors are handled by the framework if there is one.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinsoenen%2Fphpstan-custom-rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinsoenen%2Fphpstan-custom-rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinsoenen%2Fphpstan-custom-rules/lists"}