rfc:strict_operators:faq
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:faq [2020/07/06 11:50] – jasny | rfc:strict_operators:faq [2020/07/06 14:56] – switch is not affected jasny | ||
---|---|---|---|
Line 8: | Line 8: | ||
* Variable parsing in strings specified in double quotes and with heredoc, is also affected. | * Variable parsing in strings specified in double quotes and with heredoc, is also affected. | ||
* Concatenation operation (using '' | * Concatenation operation (using '' | ||
+ | * '' | ||
==== Why use a directive instead of applying this behavior as default? ==== | ==== Why use a directive instead of applying this behavior as default? ==== | ||
Line 57: | Line 58: | ||
Strict comparison of arrays as unsorted hashmaps currently isn't possible and requires sorting the array, prior to comparison. | Strict comparison of arrays as unsorted hashmaps currently isn't possible and requires sorting the array, prior to comparison. | ||
- | With '' | + | With '' |
+ | |||
+ | <code php> | ||
+ | ksort($array1); | ||
+ | ksort($array2); | ||
+ | |||
+ | $array1 === $array2; | ||
+ | </ | ||
Array functions might be added to compare arrays in different ways. But that's outside the scope of this RFC. | Array functions might be added to compare arrays in different ways. But that's outside the scope of this RFC. | ||
+ | |||
+ | ==== How can objects be compared by property? ==== | ||
+ | |||
+ | With the '' | ||
+ | |||
+ | When using strict_operators, | ||
+ | |||
+ | |||
+ | <code php> | ||
+ | get_class($object1) === get_class($object2) && get_object_vars($object1) === get_object_vars($object2); | ||
+ | </ | ||
+ | |||
==== Why isn't is allowed to increment strings with strict_operators? | ==== Why isn't is allowed to increment strings with strict_operators? | ||
Line 79: | Line 99: | ||
Throwing a '' | Throwing a '' | ||
- | ==== Why is switch affected? | + | ==== Why is switch |
- | Internally the '' | + | Using strict_operators will apply only result in cases where a '' |
- | This is determined by a secondary vote. | + | Changing '' |
- | ==== Are there cases where a statement doesn't throw a TypeError but yields a different result? ==== | + | To use strict comparison, most '' |
- | No, not for operators. | + | ==== Are there cases where a statement doesn' |
- | If the secondary vote for strict comparison with '' | + | No. |
==== Will this directive disable type juggling altogether? ==== | ==== Will this directive disable type juggling altogether? ==== | ||
Line 95: | Line 115: | ||
No. Operators can still typecast under the given conditions. For instance, the concatenation ('' | No. Operators can still typecast under the given conditions. For instance, the concatenation ('' | ||
- | Typecasting | + | Type juggling |
This RFC is limited to the scope of operators. | This RFC is limited to the scope of operators. | ||
rfc/strict_operators/faq.txt · Last modified: 2020/07/06 15:01 by jasny