-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
FrameworkConfig methods not found by PHPStan and psalm #46546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Seems like they don't like the unions added on e.g. This can be improved by using conditional types, but that would make things unnecessary bloated imho. I think the best recommendation is to not static analyze the configuration. |
Closing then. |
On second thought, I think this might be worth reconsidering (given that one of the main benefits of PHP config is the ability to use industry tools for validating and autocompletion). I've submitted a fix: #46581 |
β¦wouterj) This PR was merged into the 6.2 branch. Discussion ---------- [Config] Add conditional types to conditional builders | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix #46546 | License | MIT | Doc PR | n/a Replaces #46581 , submitted to 6.2 instead. This matches with the changes proposed in #47016 and the config builder contained quite a big refactor for comments in 6.x so this avoids nasty conflicts. Original description: > One of the main benefits of using the new PHP config builders in application code is the ability to use PHP community tooling to autocomplete and validate the configuration. In this light, I think it makes sense to add the correct PHPdocs to make Psalm and PHPstan understand the config builders. > > On top of that, as these config classes are live generated, this is not something that can be easily stubbed in the special PHPstan and Psalm Symfony plugins. Commits ------- ce1087e [Config] Add conditional types to conditional builders
I might be missing something but I don't have or see a |
It's not a great solution, but you can at least hide it by ignoring it in phpstan.neon: ignoreErrors:
-
message: '#FrameworkConfig not found#'
path: packages/
|
@Tofandel those classes are generated on the fly for each bundle in your project. We cannot force each bundle to ship the generated code with their code (and that would be a maintenance nightmare as the generated code might depend on the version of the DI component). And we definitely cannot ship them all in Symfony. |
Yes I figured as much, in the end I set my ide to index the For psalm I added to psalm.xml <extraFiles>
<directory name="var/cache/*/Symfony/Config"/>
</extraFiles> |
Implemented in Symfony 6.2 through #44166 For PHPStan, see https://phpstan.org/user-guide/discovering-symbols#third-party-code-outside-of-composer-dependencies parameters:
scanDirectories:
- var/cache/dev/Symfony/Config |
Provided solution does not consider very important detail: var/cache/dev might not exist. For example in ci pipeline where everything works in test env. Setting this to var/cache/test is also not an option since this is also missing on the first run on the dev machine. So stan would fail with I did not find any solution to this at least in PhpStan docs. E.g. to make scanDirectories optional |
Symfony version(s) affected
5.4.9
Description
Similar problem as in #42342
With a
framework.php
similar to the example shown at https://symfony.com/doc/current/http_client.html#scoping-client...psalm is reporting:
and PHPStan:
Even though I do have
public function scopedClient(string $name, $value = [])
in myvar/cache/dev/Symfony/Config/Framework/HttpClientConfig.php
So it looks like adding this to
phpstan.neon
isn't enough anymore:The same error is raised for other packages, e.g.:
Was there a change recently?
How to reproduce
See above
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: