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

Exactly the same as #4101 and original #4080 to fix #4012
Merge pull request #4262 from nazar-pc/patch-3

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