"string" type hint, and "method not implemented" inspection regarding "_toString"

In a method I'm using (from SF `Kernel` class) I have the following:

public function __construct(string $environment, bool $debug)

And down the line $environment will be used like

this:$loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob');

But on this line (and others like it), I receive the following inspection warning:

Warning:(63, 47) Method __toString is not implemented for '\Symfony\Component\HttpKernel\string'

string here is not a class, but a primitve, but the inspection treating as a class that doesn't implement `_toString`, which doesn't make any sense for a string primitive.

Is there any workaround that doesn't involve disabling that inspection completely?

10 comments

It sounds like this one: https://youtrack.jetbrains.com/issue/WI-30024
But it's been fixed years ago.

Is there a chance you could share the project with us on [our issue tracker](https://youtrack.jetbrains.com/newIssue?project=WI)?
Maybe not the whole project, but some stub reproducing the issue.

Thank you!

0

Can't find the time to create an empty project to properly replicate this.

But today I found the same issue.

Curiously enough, happens when I switch to "light" theme (sometimes inmediately, sometimes after restarting PhpStorm), most of the time goes away when I switch back to Darkula (and I always had to restart). Rediscovered the issue thanks to having to change my theme because of a too sunny morrning and a ill positioned screen:

 

Not even in the same version of PhpStorm since I originally posted this, but the issue persists. Sadness.

0

We need a reproducible sample badly, that's hard to tell what's going on there without having one.

0

Created this basic repo where I can reproduce the problem.

https://gitlab.com/yivi/php-storm-bug

Barebones symfony install. There is a screenshot in the root showing how I see it right now

(PhpStorm 2018.3 - Build #PS-183.4284.150, built on November 21, 2018)

Although as shown in my previous message, the bug can be erratic. In my post from November, the same code could show the problem or not depending on me changing the editor color scheme.

0

Also seeing this behaviour, its very irritating

 

Seems it can be fixed with invalidate cache and restart

 

1

No luck with reproducing this issue so far. Something must break caches occasionally, probably a 3rd party plugin.

Info, do you have any installed? Settings/Preferences | Plugins | Installed | Downloaded

0

It is totally intermittent though is affecting multiple people in our office

0

These are my plugins. We have a couple matches, I guess we could always start by disabling those.

 

0

I have a same issue with typehinting, but (what is strange for me) only for bool types. Some occurances of this issue gone away when I've restarted the IDE, but this still persist.

 

 

This is my list of installed plugins:

This bug is very irritating as Info said, also occurs very randomly. This one for example comes from new project from files. I have PHP language level 7.1.
What is really weird is that this issue occurs only on bool types (for me). I've disabled all my plugins but still the same result - expected  \Something\Somewhere\bool, got bool.

Even changing theme to Dracula does not help - only brings back more issues with bool typehint (all downloaded plugins were off):

Only invalidating cache and restart helps me.

 

0

Please sign in to leave a comment.