Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision |
rfc:strict_operators [2020/07/06 15:12] – jasny | rfc:strict_operators [2020/07/06 18:31] – Added case for comparing objects with custom handlers jasny |
---|
The one exception is that [[http://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#jls-5.1.2|widening primitive conversion]] is allowed for ''%%int%%'' to ''%%float%%''. When doing a operation with an ''%%int%%'' and a ''%%float%%'', the ''%%int%%'' will silently casted to a ''%%float%%''. | The one exception is that [[http://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#jls-5.1.2|widening primitive conversion]] is allowed for ''%%int%%'' to ''%%float%%''. When doing a operation with an ''%%int%%'' and a ''%%float%%'', the ''%%int%%'' will silently casted to a ''%%float%%''. |
| |
Using ''strict_operators'' does not affect the behavior of an operator besides throwing a ''TypeError'' for unsupported types. | Using ''strict_operators'' never changes the outcome of an operation. |
| |
===== Details for operands ===== | ===== Details for operands ===== |
| |
When used with a ''%%bool%%'', ''%%string%%'', ''%%array%%'', ''%%object%%'', or ''%%resource%%'' operand, a ''%%TypeError%%'' will be thrown. | When used with a ''%%bool%%'', ''%%string%%'', ''%%array%%'', ''%%object%%'', or ''%%resource%%'' operand, a ''%%TypeError%%'' will be thrown. |
| |
| Custom compare handlers of objects (like ''DateTime'' and ''gmp'') will be applied regardless of ''strict_operators''. The ''ZEND_COMPARE_OBJECTS_FALLBACK'' macro will throw a ''TypeError'' if two objects are compared with different handlers. |
| |
==== String concatenation ==== | ==== String concatenation ==== |