-
Notifications
You must be signed in to change notification settings - Fork 653
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
Mixed issues not being reported #9619
Comments
I found these snippets: https://psalm.dev/r/34a696dcc4<?php
/**
* Safely access the values in $this->params.
*
* @param string $name The name or dotted path to parameter.
* @param mixed $default The default value if `$name` is not set. Default `null`.
* @return mixed
*/
function getParam(string $name, $default = null)
{
if ($name && $default) {} // suppress unused name warnings
return null;
}
$type = getParam('type');
$type = strtolower($type);
echo $type;
|
Can you try to see if you get them at |
Yes I do the same results as the playground with I expect using |
Yeah, seems like the doc is wrongly worded. It seems currently that it was only made for silencing mixed issues. For legacy reasons, it's somewhat of a mess. Note: I don't know what your motives are for doing that, it seems like a bad idea to me on first glance. A lot of issues above level 5 will cause mixed to appear out of nowhere. If you don't display those, you'll see the mixed part without seeing the cause of it. However, if you want to fix things, it should not be too difficult. The main thing to understand is: Line 1082 in 7b541ed
This is what turns a config in xml into a property of Config. Once you get that, the property is used twice. It should be easy to track that and find out why it doesn't behave properly |
I am working with an existing codebase and even level 4 generates hundreds of errors and going through the list is too tedious. Passing mixed type values to arguments which expects string (like the various string functions) is a common type of error that's occurring after turning on strict typing, so I was hoping to turn on just the related issue handlers and potentially get a more manageable list of errors.
I'll see if I can find the time to dig into it 🙂. |
Seems like a job for the baseline :). Just ignore everything and fix incoming errors as they arrive In my experience, on existing codebase, the list of Mixed issue is rarely the shortest! |
The problem is we have (naively) added |
You might want to take a look at https://github.com/orklah/psalm-strict-types This is very much not perfect, but it should tell you if you have flagrant issues with strict_types and also tell you if entire files are safe to add strict_types. |
Thank you!! I'll give it a shot. |
The plugin has So can't try it with psalm 5.9 😞 |
I think it would be ready to go for Psalm 5, all is missing is someone to test it so if you're up for it, just try it! |
For the following config
running psalm for this code
I would expect the same errors to be reported as seen on https://psalm.dev/r/34a696dcc4
yet I get
No errors found!
.The text was updated successfully, but these errors were encountered: