{"id":18929386,"url":"https://github.com/thecodingmachine/phpstan-strict-rules","last_synced_at":"2025-05-16T06:08:11.858Z","repository":{"id":45866909,"uuid":"95015216","full_name":"thecodingmachine/phpstan-strict-rules","owner":"thecodingmachine","description":"A set of additional rules for PHPStan based on best practices followed at TheCodingMachine","archived":false,"fork":false,"pushed_at":"2021-12-01T08:53:23.000Z","size":108,"stargazers_count":288,"open_issues_count":11,"forks_count":25,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-05-10T13:05:54.254Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/thecodingmachine.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}},"created_at":"2017-06-21T14:50:35.000Z","updated_at":"2025-02-13T08:54:06.000Z","dependencies_parsed_at":"2022-07-22T11:03:05.570Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/phpstan-strict-rules","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fphpstan-strict-rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fphpstan-strict-rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fphpstan-strict-rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fphpstan-strict-rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/phpstan-strict-rules/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253650795,"owners_count":21942217,"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":[],"created_at":"2024-11-08T11:32:17.848Z","updated_at":"2025-05-16T06:08:06.850Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest Stable Version](https://poser.pugx.org/thecodingmachine/phpstan-strict-rules/v/stable)](https://packagist.org/packages/thecodingmachine/phpstan-strict-rules)\n[![Total Downloads](https://poser.pugx.org/thecodingmachine/phpstan-strict-rules/downloads)](https://packagist.org/packages/thecodingmachine/phpstan-strict-rules)\n[![Latest Unstable Version](https://poser.pugx.org/thecodingmachine/phpstan-strict-rules/v/unstable)](https://packagist.org/packages/thecodingmachine/phpstan-strict-rules)\n[![License](https://poser.pugx.org/thecodingmachine/phpstan-strict-rules/license)](https://packagist.org/packages/thecodingmachine/phpstan-strict-rules)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/thecodingmachine/phpstan-strict-rules/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/thecodingmachine/phpstan-strict-rules/?branch=master)\n[![Build Status](https://travis-ci.org/thecodingmachine/phpstan-strict-rules.svg?branch=master)](https://travis-ci.org/thecodingmachine/phpstan-strict-rules)\n[![Coverage Status](https://coveralls.io/repos/thecodingmachine/phpstan-strict-rules/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/thecodingmachine/phpstan-strict-rules?branch=master)\n\n\nTheCodingMachine's additional rules for PHPStan\n===============================================\n\nThis package contains a set of rules to be added to the [wonderful PHPStan static analyzer](https://phpstan.org/).\n\nThose rules come from [TheCodingMachine best practices](http://bestpractices.thecodingmachine.com/).\nThey are more \"strict\" than the default PHPStan rules and some may be controversial. We use those at TheCodingMachine, have found them to help us in our daily work, and ask anyone working with us to follow them.\n\n## Rules list\n\n### Exception related rules\n\n- You should not throw the \"Exception\" base class directly [but throw a sub-class instead](http://bestpractices.thecodingmachine.com/php/error_handling.html#subtyping-exceptions).\n- You should not have empty catch statements\n- When throwing an exception inside a catch block, [you should pass the catched exception as the \"previous\" exception](http://bestpractices.thecodingmachine.com/php/error_handling.html#wrapping-an-exception-do-not-lose-the-previous-exception)\n- If you catch a `Throwable`, an `Exception` or a `RuntimeException`, you must rethrow the exception.\n\n### Superglobal related rules\n\n- The use of [`$_GET`, `$_POST`, `$_FILES`, `$_COOKIE`, `$_SESSION`, `$_REQUEST` is forbidden](http://bestpractices.thecodingmachine.com/php/organize_your_code.html#stop-using-superglobals-).\n  You should instead use your framework's request/session object.\n- Superglobal usage is still tolerated at the root scope (because it is typically used once in `index.php` to initialize\n  PSR-7 request object)\n\n### Condition related rules\n\n- Switch statements should always check for unexpected values by [implementing a default case (and throwing an exception)](http://bestpractices.thecodingmachine.com/php/defensive_programming.html#always-check-for-unexpected-values)\n\n### Work-in-progress\n\n    // Never use public properties\n    // Never use globals\n\n## Installation\n\nWe assume that [PHPStan](https://phpstan.org/) is already installed in your project.\n\nTo use this extension, require it in [Composer](https://getcomposer.org/):\n\n```bash\ncomposer require --dev thecodingmachine/phpstan-strict-rules\n```\n\nIf you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set!\n\n\u003cdetails\u003e\n  \u003csummary\u003eManual installation\u003c/summary\u003e\n\nIf you don't want to use `phpstan/extension-installer`, include phpstan-strict-rules.neon in your project's PHPStan config:\n\n```yml\nincludes:\n    - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon\n```\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fphpstan-strict-rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Fphpstan-strict-rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fphpstan-strict-rules/lists"}