Add return types to html encoding functions (#8633)
commitd6a145f4ecf17d4c85798cc9fb05da3b1f78c26d
authorLexidor Digital <31805625+lexidor@users.noreply.github.com>
Wed, 18 Mar 2020 21:43:35 +0000 (18 14:43 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 18 Mar 2020 21:48:02 +0000 (18 14:48 -0700)
tree5be9bf166026f59a38ae098652338157c4810196
parent91f9ca1890865df11dce67b7f19c6ccf48052b6a
Add return types to html encoding functions (#8633)

Summary:
These functions have signatures like `String HHVM_FUNCTION(function_name_here, ...`.
So they always return strings.

https://github.com/facebook/hhvm/blob/master/hphp/runtime/ext/string/ext_string.cpp#L1698
https://github.com/facebook/hhvm/blob/master/hphp/runtime/ext/string/ext_string.cpp#L1708
https://github.com/facebook/hhvm/blob/master/hphp/runtime/ext/string/ext_string.cpp#L1720
https://github.com/facebook/hhvm/blob/master/hphp/runtime/ext/string/ext_string.cpp#L1727

If it wasn't for the TAny in the HHI I would have never gone to the PHP docs and read the following for htmlspecialchars:
`If the input string contains an invalid code unit sequence within the given encoding an empty string will be returned, unless either the ENT_IGNORE or ENT_SUBSTITUTE flags are set. `
I assumed false on failure since that is the PHP-way.
Pull Request resolved: https://github.com/facebook/hhvm/pull/8633

Reviewed By: DavidSnider

Differential Revision: D20349451

fbshipit-source-id: 57affd3361d677343a4b50676b3fd1d8ffbcb768
hphp/hack/hhi/stdlib/builtins_string.hhi