{"id":13616942,"url":"https://github.com/phpstan/phpstan-symfony","last_synced_at":"2026-01-23T12:48:38.557Z","repository":{"id":38150737,"uuid":"133347472","full_name":"phpstan/phpstan-symfony","owner":"phpstan","description":"Symfony extension for PHPStan","archived":false,"fork":false,"pushed_at":"2025-12-28T21:36:40.000Z","size":669,"stargazers_count":771,"open_issues_count":79,"forks_count":97,"subscribers_count":9,"default_branch":"2.0.x","last_synced_at":"2025-12-29T18:16:20.987Z","etag":null,"topics":["php","php7","phpstan","static-analysis","static-code-analysis","symfony","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}},"created_at":"2018-05-14T10:59:05.000Z","updated_at":"2025-12-17T16:05:14.000Z","dependencies_parsed_at":"2024-04-16T22:21:15.238Z","dependency_job_id":"79518529-e4c8-4cbb-b84f-258e3a8d4b9d","html_url":"https://github.com/phpstan/phpstan-symfony","commit_stats":{"total_commits":361,"total_committers":79,"mean_commits":4.569620253164557,"dds":0.6952908587257618,"last_synced_commit":"8148308799496abd2a78ee6a5ef2d66613af83cf"},"previous_names":[],"tags_count":137,"template":false,"template_full_name":null,"purl":"pkg:github/phpstan/phpstan-symfony","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpstan%2Fphpstan-symfony","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpstan%2Fphpstan-symfony/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpstan%2Fphpstan-symfony/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpstan%2Fphpstan-symfony/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpstan","download_url":"https://codeload.github.com/phpstan/phpstan-symfony/tar.gz/refs/heads/2.0.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpstan%2Fphpstan-symfony/sbom","scorecard":{"id":732507,"data":{"date":"2025-08-11","repo":{"name":"github.com/phpstan/phpstan-symfony","commit":"3d8847fb5865e5e3319b2189ead03fc6a3482eb2"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5,"checks":[{"name":"Code-Review","score":3,"reason":"Found 8/26 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":"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":"Maintained","score":5,"reason":"3 commit(s) and 3 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":"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":"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":"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":"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":"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":"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":"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":"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 12 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-22T14:50:05.992Z","repository_id":38150737,"created_at":"2025-08-22T14:50:05.992Z","updated_at":"2025-08-22T14:50:05.992Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28692009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T11:01:27.039Z","status":"ssl_error","status_checked_at":"2026-01-23T11:00:26.909Z","response_time":59,"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":["php","php7","phpstan","static-analysis","static-code-analysis","symfony","testing"],"created_at":"2024-08-01T20:01:35.031Z","updated_at":"2026-01-23T12:48:38.543Z","avatar_url":"https://github.com/phpstan.png","language":"PHP","readme":"# PHPStan Symfony Framework extensions and rules\n\n[![Build](https://github.com/phpstan/phpstan-symfony/workflows/Build/badge.svg)](https://github.com/phpstan/phpstan-symfony/actions)\n[![Latest Stable Version](https://poser.pugx.org/phpstan/phpstan-symfony/v/stable)](https://packagist.org/packages/phpstan/phpstan-symfony)\n[![License](https://poser.pugx.org/phpstan/phpstan-symfony/license)](https://packagist.org/packages/phpstan/phpstan-symfony)\n\n* [PHPStan](https://phpstan.org/)\n\nThis extension provides following features:\n\n* Provides correct return type for `ContainerInterface::get()` and `::has()` methods.\n* Provides correct return type for `Controller::get()` and `::has()` methods.\n* Provides correct return type for `AbstractController::get()` and `::has()` methods.\n* Provides correct return type for `ContainerInterface::getParameter()` and `::hasParameter()` methods.\n* Provides correct return type for `ParameterBagInterface::get()` and `::has()` methods.\n* Provides correct return type for `Controller::getParameter()` method.\n* Provides correct return type for `AbstractController::getParameter()` method.\n* Provides correct return type for `Request::getContent()` method based on the `$asResource` parameter.\n* Provides correct return type for `HeaderBag::get()` method based on the `$first` parameter.\n* Provides correct return type for `Envelope::all()` method based on the `$stampFqcn` parameter.\n* Provides correct return type for `InputBag::get()` method based on the `$default` parameter.\n* Provides correct return type for `InputBag::all()` method based on the `$key` parameter.\n* Provides correct return types for `TreeBuilder` and `NodeDefinition` objects.\n* Notifies you when you try to get an unregistered service from the container.\n* Notifies you when you try to get a private service from the container.\n* Optionally correct return types for `InputInterface::getArgument()`, `::getOption`, `::hasArgument`, and `::hasOption`.\n\n\n## Installation\n\nTo use this extension, require it in [Composer](https://getcomposer.org/):\n\n```\ncomposer require --dev phpstan/phpstan-symfony\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-symfony/extension.neon\n```\n\nTo perform framework-specific checks, include also this file:\n\n```\nincludes:\n    - vendor/phpstan/phpstan-symfony/rules.neon\n```\n\u003c/details\u003e\n\n# Configuration\n\nYou have to provide a path to `srcDevDebugProjectContainer.xml` or similar XML file describing your container.\n\n```yaml\nparameters:\n    symfony:\n        containerXmlPath: var/cache/dev/srcDevDebugProjectContainer.xml\n        # or with Symfony 4.2+\n        containerXmlPath: var/cache/dev/srcApp_KernelDevDebugContainer.xml\n        # or with Symfony 5+\n        containerXmlPath: var/cache/dev/App_KernelDevDebugContainer.xml\n    # If you're using PHP config files for Symfony 5.3+, you also need this for auto-loading of `Symfony\\Config`:\n    scanDirectories:\n        - var/cache/dev/Symfony/Config\n    # If you're using PHP config files (including the ones under packages/*.php) for Symfony 5.3+,\n    # you need this to load the helper functions (i.e. service(), env()):\n    scanFiles:\n        - vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php\n```\n\n## Constant hassers\n\nSometimes, when you are dealing with optional dependencies, the `::has()` methods can cause problems. For example, the following construct would complain that the condition is always either on or off, depending on whether you have the dependency for `service` installed:\n\n```php\nif ($this-\u003ehas('service')) {\n    // ...\n}\n```\n\nIn that case, you can disable the `::has()` method return type resolving like this:\n\n```\nparameters:\n\tsymfony:\n\t\tconstantHassers: false\n```\n\nBe aware that it may hide genuine errors in your application.\n\n## Analysis of Symfony Console Commands\n\nYou can opt in for more advanced analysis of [Symfony Console Commands](https://symfony.com/doc/current/console.html)\nby providing the console application from your own application. This will allow the correct argument and option types to be inferred when accessing `$input-\u003egetArgument()` or `$input-\u003egetOption()`.\n\n```neon\nparameters:\n\tsymfony:\n\t\tconsoleApplicationLoader: tests/console-application.php\n```\n\nSymfony 4:\n\n```php\n// tests/console-application.php\n\nuse App\\Kernel;\nuse Symfony\\Bundle\\FrameworkBundle\\Console\\Application;\n\nrequire __DIR__ . '/../config/bootstrap.php';\n$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);\nreturn new Application($kernel);\n```\n\nSymfony 5:\n\n```php\n// tests/console-application.php\n\nuse App\\Kernel;\nuse Symfony\\Bundle\\FrameworkBundle\\Console\\Application;\nuse Symfony\\Component\\Dotenv\\Dotenv;\n\nrequire __DIR__ . '/../vendor/autoload.php';\n\n(new Dotenv())-\u003ebootEnv(__DIR__ . '/../.env');\n\n$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);\nreturn new Application($kernel);\n```\n\n[Single Command Application](https://symfony.com/doc/current/components/console/single_command_tool.html):\n\n```php\n// tests/console-application.php\n\nuse App\\Application; // where Application extends Symfony\\Component\\Console\\SingleCommandApplication\nuse Symfony\\Component\\Console;\n\nrequire __DIR__ . '/../vendor/autoload.php';\n\n$application = new Console\\Application();\n$application-\u003eadd(new Application());\n\nreturn $application;\n```\n\nYou may then encounter an error with PhpParser:\n\n\u003e Compile Error: Cannot Declare interface PhpParser\\NodeVisitor, because the name is already in use\n\nIf this is the case, you should create a new environment for your application that will disable inlining. In `config/packages/phpstan_env/parameters.yaml`:\n\n```yaml\nparameters:\n    container.dumper.inline_class_loader: false\n```\n\nCall the new env in your `console-application.php`:\n\n```php\n$kernel = new \\App\\Kernel('phpstan_env', (bool) $_SERVER['APP_DEBUG']);\n```\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpstan%2Fphpstan-symfony","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpstan%2Fphpstan-symfony","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpstan%2Fphpstan-symfony/lists"}