https://phpstan.org/r/58d5ff2a2e05bfcba9851d98cfe94fa5
Not sure if it's by design and documented, but classes like RecursiveDirectoryIterator seem to proxy unsupported method calls to the wrapped iterators. With the @var annotation, PhpStorm, for example, understands that the call will be made on a RecursiveDirectoryIterator instance and doesn't flag the code as incorrect, but PHPStan does.
Calling getSubPathName() on RecursiveDirectoryIterator doesn't seem a valid fix since it produces different results.