I've generally found the behavior of builtin PHP methods to be less predictable and more involved than in JS, so I wonder if the best approach to writing a transpiler in this case would be to go to the C source and negotiate from there.
Having done PHP for years and years before the language itself found adequate elegance, I wouldn't want the burden of replicating all its weird behaviors for something like this, at least without seeing the source to understand what's happening.