{"id":18986188,"url":"https://github.com/brainbits/phpstan-rules","last_synced_at":"2025-04-19T20:37:15.787Z","repository":{"id":46283268,"uuid":"240021562","full_name":"brainbits/phpstan-rules","owner":"brainbits","description":"brainbits phpstan rules","archived":false,"fork":false,"pushed_at":"2024-02-22T11:04:38.000Z","size":31,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-24T15:26:39.956Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/brainbits.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}},"created_at":"2020-02-12T13:37:35.000Z","updated_at":"2023-05-30T11:07:07.000Z","dependencies_parsed_at":"2024-11-08T16:35:10.639Z","dependency_job_id":"6565bfe1-6bdd-437b-981a-3de80f7011ae","html_url":"https://github.com/brainbits/phpstan-rules","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":0.08333333333333337,"last_synced_commit":"25cc80076606aa075a19b0e875df8ce6d29efa5a"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainbits%2Fphpstan-rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainbits%2Fphpstan-rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainbits%2Fphpstan-rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainbits%2Fphpstan-rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brainbits","download_url":"https://codeload.github.com/brainbits/phpstan-rules/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249241846,"owners_count":21236356,"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-08T16:30:08.627Z","updated_at":"2025-04-16T14:32:45.419Z","avatar_url":"https://github.com/brainbits.png","language":"PHP","readme":"# PHPStan Clean Test rules\n\n![Continuous Integration](https://github.com/brainbits/phpstan-rules/workflows/Tests/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/brainbits/phpstan-rules/badge.svg?branch=master)](https://coveralls.io/github/brainbits/phpstan-rules?branch=master)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/881bcaeeaa2a45f59b0a77680f15fafe)](https://www.codacy.com/manual/brainbits/phpstan-rules?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=brainbits/phpstan-rules\u0026amp;utm_campaign=Badge_Grade)\n[![Latest Stable Version](https://poser.pugx.org/brainbits/phpstan-rules/version)](https://packagist.org/packages/brainbits/phpstan-rules)\n[![License](https://poser.pugx.org/brainbits/phpstan-rules/license)](https://packagist.org/packages/brainbits/phpstan-rules)\n\n-   [PHPStan](https://github.com/phpstan/phpstan)\n-   [PHPStan-PHPUnit extension](https://github.com/phpstan/phpstan-phpunit)\n\nThis extension provides highly opinionated and strict rules for test cases for the PHPStan static analysis tool.\n\n## Installation\n\nRun\n\n```shell\n$ composer require --dev brainbits/phpstan-rules\n```\n\n## Usage\n\nAll of the [rules](https://github.com/brainbits/phpstan-rules#rules) provided by this library are included in [`rules.neon`](rules.neon).\n\nWhen you are using [`phpstan/extension-installer`](https://github.com/phpstan/extension-installer), `rules.neon` will be automatically included.\n\nOtherwise you need to include `rules.neon` in your `phpstan.neon`:\n\n```yaml\n# phpstan.neon\nincludes:\n    - vendor/brainbits/phpstan-rules/rules.neon\n```\n\n## Rules\n\nThis package provides the following rules for use with [`phpstan/phpstan`](https://github.com/phpstan/phpstan):\n-   [`Brainbits\\PHPStan\\Rules\\CoversClassExistsRule`](#CoversClassExistsRule)\n-   [`Brainbits\\PHPStan\\Rules\\CoversClassPresentRule`](#CoversClassPresentRule)\n\n### `CoversClassExistsRule`\n\nThis rule checks that classes that are covered by `@covers` annotation or `#[CoversClass]` attribute exist.\n\n### `CoversClassPresentRule`\n\nThis rule forces you to specify either a `@covers` annotation or `#[CoversClass]`, `#[CoversFunction]` or `#[CoversNothing]` attributes in unit tests (default: `PHPUnit\\Framework\\TestCase`).\n\n**Why:**\n1. It prevents code coverage sums to show higher values than expected. \n\n:x:\n\n```php\n// tests/ExampleTestCase/Unit/MyInvalidClassTest.php\nnamespace ExampleTestCase\\Unit;\n\nfinal class MyInvalidClassTest extends \\PHPUnit\\Framework\\TestCase {}\n```\n\u003cbr /\u003e\n\n:white_check_mark:\n\n```php\n// tests/ExampleTestCase/Unit/MyClassTest.php\nnamespace ExampleTestCase\\Unit;\n\n#[\\PHPUnit\\Framework\\Attributes\\CoversClass(MyClass::class)\nfinal class MyClassTest extends \\PHPUnit\\Framework\\TestCase {}\n```\n\n#### Defaults\n\n-   By default, this rule detects unit tests by checking the namespace (it must contain the string `Unit`) and the class name ending (it must end with the string `Test`).\n\n#### Detecting unit tests namespace\nIf you want to change the namespace string check described above, you can set your own string to be checked in the `unitTestNamespaceContainsString` parameter.\n\n```yaml\n# phpstan.neon\nparameters:\n    brainbits:\n        unitTestNamespaceContainsString: CustomTestPath\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrainbits%2Fphpstan-rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrainbits%2Fphpstan-rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrainbits%2Fphpstan-rules/lists"}