So for context, I am using PHPStan on max level. And when I want to inspect the vfs structure, the documented way is https://github.com/bovigo/vfsStream/wiki/Visitors:
vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure()
My issue is with the (docblock) return type of vfsStream::inspct() which is vfsStreamVisitor (interface). That interface does not have a getStructure-method call. It's the child-type vfsStreamStructureVisitor that has the method.
So currently I have to use the "yo, trust me bro... this is type X" 🤣 by using an var assignment and a @var-docblock like this:
final class FoobarTest extends TestCase
{
private vfsStreamStructureVisitor $vfsVisitor;
protected function setUp(): void
{
parent::setUp();
vfsStream::setup();
/** @var vfsStreamStructureVisitor $vfsVisitor */ // <-----------------------
$vfsVisitor = vfsStream::inspect(new vfsStreamStructureVisitor());
$this->vfsVisitor = $vfsVisitor;
}
}
I would rather not have to use an intermediate variable assignment and the docblock.
The most straight forward way to solve this would be to update the docblock, but not sure if that's a viable solution.
edit:
I see I also need to run execute vfsStream::inspect(new vfsStreamStructureVisitor()) whenever I want to inspect the actual structure. So above code does not make sense, but my point about invalid return type is still valid.
So for context, I am using PHPStan on max level. And when I want to inspect the vfs structure, the documented way is https://github.com/bovigo/vfsStream/wiki/Visitors:
My issue is with the (docblock) return type of
vfsStream::inspct()which isvfsStreamVisitor(interface). That interface does not have agetStructure-method call. It's the child-typevfsStreamStructureVisitorthat has the method.So currently I have to use the "yo, trust me bro... this is type X" 🤣 by using an var assignment and a
@var-docblock like this:I would rather not have to use an intermediate variable assignment and the docblock.
The most straight forward way to solve this would be to update the docblock, but not sure if that's a viable solution.
edit:
I see I also need to run execute
vfsStream::inspect(new vfsStreamStructureVisitor())whenever I want to inspect the actual structure. So above code does not make sense, but my point about invalid return type is still valid.