{"id":13616922,"url":"https://github.com/phpstan/phpstan-phpunit","last_synced_at":"2026-02-14T11:07:54.421Z","repository":{"id":25705181,"uuid":"105883921","full_name":"phpstan/phpstan-phpunit","owner":"phpstan","description":"PHPUnit extensions and rules for PHPStan","archived":false,"fork":false,"pushed_at":"2025-09-03T09:55:49.000Z","size":342,"stargazers_count":504,"open_issues_count":36,"forks_count":50,"subscribers_count":9,"default_branch":"2.0.x","last_synced_at":"2025-09-15T12:40:06.052Z","etag":null,"topics":["php","php7","phpstan","phpunit","static-analysis","static-code-analysis","testing"],"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/phpstan.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":"2017-10-05T11:51:58.000Z","updated_at":"2025-09-08T08:53:40.000Z","dependencies_parsed_at":"2024-04-14T01:44:50.676Z","dependency_job_id":"15a1c2a7-1145-4055-a3ad-56772ec23f44","html_url":"https://github.com/phpstan/phpstan-phpunit","commit_stats":{"total_commits":228,"total_committers":33,"mean_commits":6.909090909090909,"dds":"0.42543859649122806","last_synced_commit":"f93aec74624bcdb9773da40a729f111df1f6e22a"},"previous_names":[],"tags_count":71,"template":false,"template_full_name":null,"purl":"pkg:github/phpstan/phpstan-phpunit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpstan%2Fphpstan-phpunit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpstan%2Fphpstan-phpunit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpstan%2Fphpstan-phpunit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpstan%2Fphpstan-phpunit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpstan","download_url":"https://codeload.github.com/phpstan/phpstan-phpunit/tar.gz/refs/heads/2.0.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpstan%2Fphpstan-phpunit/sbom","scorecard":{"id":489747,"data":{"date":"2025-08-11","repo":{"name":"github.com/phpstan/phpstan-phpunit","commit":"1d7eb7e5d8e7daefb033df1beaa497dfeed72c04"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":3,"reason":"Found 7/20 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":5,"reason":"4 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch '2.0.x'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: github.com/phpstan/.github/SECURITY.md:1","Info: Found linked content: github.com/phpstan/.github/SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/phpstan/.github/SECURITY.md:1","Info: Found text in security policy: github.com/phpstan/.github/SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 19 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T18:46:05.101Z","repository_id":25705181,"created_at":"2025-08-19T18:46:05.101Z","updated_at":"2025-08-19T18:46:05.101Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29443447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T10:51:12.367Z","status":"ssl_error","status_checked_at":"2026-02-14T10:50:52.088Z","response_time":53,"last_error":"SSL_read: 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":["php","php7","phpstan","phpunit","static-analysis","static-code-analysis","testing"],"created_at":"2024-08-01T20:01:34.818Z","updated_at":"2026-02-14T11:07:54.415Z","avatar_url":"https://github.com/phpstan.png","language":"PHP","readme":"# PHPStan PHPUnit extensions and rules\n\n[![Build](https://github.com/phpstan/phpstan-phpunit/workflows/Build/badge.svg)](https://github.com/phpstan/phpstan-phpunit/actions)\n[![Latest Stable Version](https://poser.pugx.org/phpstan/phpstan-phpunit/v/stable)](https://packagist.org/packages/phpstan/phpstan-phpunit)\n[![License](https://poser.pugx.org/phpstan/phpstan-phpunit/license)](https://packagist.org/packages/phpstan/phpstan-phpunit)\n\n* [PHPStan](https://phpstan.org/)\n* [PHPUnit](https://phpunit.de)\n\nThis extension provides following features:\n\n* `createMock()`, `getMockForAbstractClass()` and `getMockFromWsdl()` methods return an intersection type (see the [detailed explanation of intersection types](https://phpstan.org/blog/union-types-vs-intersection-types)) of the mock object and the mocked class so that both methods from the mock object (like `expects`) and from the mocked class are available on the object.\n* `getMock()` called on `MockBuilder` is also supported.\n* Interprets `Foo|MockObject` in phpDoc so that it results in an intersection type instead of a union type.\n* Defines early terminating method calls for the `PHPUnit\\Framework\\TestCase` class to prevent undefined variable errors.\n* Specifies types of expressions passed to various `assert` methods like `assertInstanceOf`, `assertTrue`, `assertInternalType` etc.\n* Combined with PHPStan's level 4, it points out always-true and always-false asserts like `assertTrue(true)` etc.\n\nIt also contains this strict framework-specific rules (can be enabled separately):\n\n* Check that you are not using `assertSame()` with `true` as expected value. `assertTrue()` should be used instead.\n* Check that you are not using `assertSame()` with `false` as expected value. `assertFalse()` should be used instead.\n* Check that you are not using `assertSame()` with `null` as expected value. `assertNull()` should be used instead.\n* Check that you are not using `assertSame()` with `count($variable)` as second parameter. `assertCount($variable)` should be used instead.\n* Check that you are not using `assertEquals()` with same types (`assertSame()` should be used)\n* Check that you are not using `assertNotEquals()` with same types (`assertNotSame()` should be used)\n\n## How to document mock objects in phpDocs?\n\nIf you need to configure the mock even after you assign it to a property or return it from a method, you should add `\\PHPUnit\\Framework\\MockObject\\MockObject` to the type:\n\n```php\nprivate function createFooMock(): Foo\u0026\\PHPUnit\\Framework\\MockObject\\MockObject\n{\n\treturn $this-\u003ecreateMock(Foo::class);\n}\n\npublic function testSomething(): void\n{\n\t$fooMock = $this-\u003ecreateFooMock();\n\t$fooMock-\u003emethod('doFoo')-\u003ewill($this-\u003ereturnValue('test'));\n\t$fooMock-\u003edoFoo();\n}\n```\n\nIf you cannot use native intersection types yet, you can use PHPDoc instead.\n\n```php\n/**\n * @return Foo\u0026\\PHPUnit\\Framework\\MockObject\\MockObject\n */\nprivate function createFooMock(): Foo\n{\n\treturn $this-\u003ecreateMock(Foo::class);\n}\n```\n\nPlease note that the correct syntax for intersection types is `Foo\u0026\\PHPUnit\\Framework\\MockObject\\MockObject`. `Foo|\\PHPUnit\\Framework\\MockObject\\MockObject` is also supported, but only for ecosystem and legacy reasons.\n\nIf the mock is fully configured and only the methods of the mocked class are supposed to be called on the value, it's fine to typehint only the mocked class:\n\n```php\nprivate Foo $foo;\n\nprotected function setUp(): void\n{\n\t$fooMock = $this-\u003ecreateMock(Foo::class);\n\t$fooMock-\u003emethod('doFoo')-\u003ewill($this-\u003ereturnValue('test'));\n\t$this-\u003efoo = $fooMock;\n}\n\npublic function testSomething(): void\n{\n\t$this-\u003efoo-\u003edoFoo();\n\t// $this-\u003efoo-\u003emethod() and expects() can no longer be called\n}\n```\n\n\n## Installation\n\nTo use this extension, require it in [Composer](https://getcomposer.org/):\n\n```\ncomposer require --dev phpstan/phpstan-phpunit\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 extension.neon in your project's PHPStan config:\n\n```\nincludes:\n    - vendor/phpstan/phpstan-phpunit/extension.neon\n```\n\nTo perform framework-specific checks, include also this file:\n\n```\n    - vendor/phpstan/phpstan-phpunit/rules.neon\n```\n\n\u003c/details\u003e\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpstan%2Fphpstan-phpunit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpstan%2Fphpstan-phpunit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpstan%2Fphpstan-phpunit/lists"}