facebook/hhvm — pull request #1410 by bdurette (2013-12-21 04:54:05+00:00)
Title: Zend compatibility - strtr

Zend does not convert arrays or resources to strings in `strtr`. Instead, it raises a warning and then returns empty. If from is an array, it raises notice and then converts to string. It's pretty hard to get excited about making hhvm compatible with this kind of inconsistency, but alas, here's the code.

Unfortunately, the other strtr_variation[n] tests that are failing are failing because of the way hhvm marshalls php arguments to C++ functions. The C++ signature is:

```c++
Variant f_strtr(const String& str, CVarRef from, CVarRef to /* = null_variant */);
```

If an array is passed in PHP to the first argument, then it is converted to a String before this code is run. Ergo, there's no way to tell if the argument was the literal `'Array'` or was `array()`. Thus achieving parity with the zend behavior is impossible.

Would love some thoughts on workarounds. The only thing I can think to do is change that first parameter to `CVarRef`, but that's ugly given the specification.