Backport for 3.4 branch: Fix for phar:// stream wrapper with no stub

Exactly the same as #4101 and original #4080 to fix #4012