summaryrefslogtreecommitdiff
path: root/ext/mbstring/php_mbregex.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-03-31 18:03:30 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-03-31 20:49:39 +0200
commitf182309e87cd45de0d110516c6af4b05da3ce266 (patch)
tree5cd029cf6254a1354954a18ad26bb93773206ec9 /ext/mbstring/php_mbregex.c
parentdaf45f68d25af0e7e909214719f3fbe0306abb7a (diff)
downloadphp-git-f182309e87cd45de0d110516c6af4b05da3ce266.tar.gz
Refactor operator implementations
Instead of looping, use straight-line code with the following layout: 1. Try to apply the base operation on the dereferenced operands. 2. Try overloaded object operations. 3. Try to convert operands to number, else error out. 4. Apply the base operation on the converted operands. This makes the code easier to reason about and fixes some edge-case bugs: 1. We should only try invoking operator overloading once prior to type conversion. Previously it was invoked both before and after type conversion. 2. We should not modify any values if an exception is thrown. Previously we sometimes modified the LHS of a compound assignment operator. 3. If conversion of the first operand fails, we no longer try to convert the second operand. I think the previous behavior here was fine as well, but this still seems a more typical. This will also make some followup changes I have in mind simpler.
Diffstat (limited to 'ext/mbstring/php_mbregex.c')
0 files changed, 0 insertions, 0 deletions