PS detects the class, but not its properties
I have a method that type hints a known class, and inside that method the properties of that class are marked as not found:
use App\Resource;
class Cache {
function timesets(Resource $resource) {
$this->set('timesets_' . $resource->club_id);
}
}
/**
* @property int $club_id
*/
class ActiveRecord {
}
class Resource extends ActiveRecord {
function copy($name) {
}
}
Inside Cache::timesets() PS knows that $resource is a App\Resource. But it doesn't know that $resource has a $club_id property or copy() method.
What also doesn't work:
* Adding the @property to Resource
* Adding a @param to Cache::timesets
* Adding a @var inside Cache::timesets
What's the problem? Clicking on Resource opens the right class. Hovering over $resource shows `Resource $resource : Resource`. Where does it go wrong? It does work for other classes here, and for Resource in other places.
Edit 1:
In other places, where Resource does work, the tooltip shows `$resource : App\Resource` so I guess it doesn't really detect the class in Cache::timesets()... A valid type hint should be enough, no?
Edit 2:
It looks like Resource is special... Maybe a reserved word or something? https://www.screencast.com/t/LptFXhvMji Both Club and Resource are imported, and valid classes, but only Club works... Resource only works indirectly, not as a type hint. Why??
Please sign in to leave a comment.
Hi there,
https://youtrack.jetbrains.com/issue/WI-15619
Sooo how do we fix this? Seems like a pretty significant bug. Can I tell PS to forget about primitives? Or make it case sensitive? Anything?
https://youtrack.jetbrains.com/issue/WI-7943#comment=27-333683 says something about 'removing fake classes'. Is that a thing? How?
This bug isn't fixed yet. Did you try typehinting it using this workaround: https://youtrack.jetbrains.com/issue/WI-15619#comment=27-419541 or https://youtrack.jetbrains.com/issue/WI-15619#comment=27-1333630?
> says something about 'removing fake classes'. Is that a thing? How?
That's a developer's clarification comment, not an advise/workaround.