Repository navigation
Commit d564e4e
committed
Tests: Use the null coalescing operators in the test suite.
Replaces `isset()` and `array_key_exists()` ternaries that return the tested value or a fallback of `null` or `''` with the null coalescing operator (`??`), and self-referencing `$x = $x ?? $y` assignments with the null coalescing assignment operator (`??=`).
**Why this is safe**
- `??` and `isset()` test the same condition, so the fallback is used in exactly the same cases.
- `array_key_exists()` and `??` only differ for a key that exists with a `null` value. Every converted `array_key_exists()` site falls back to `null`, so both forms return `null` in that case as well.
- `??=` requires PHP 7.4, which is already the minimum supported version.
- No behavior change; this is test-only code.
Developed in WordPress/wordpress-develop#14616.
Follow-up to r63609, r63633.
Props Soean, huzaifaalmesbah.
See #65819.
Built from https://develop.svn.wordpress.org/trunk@64675
git-svn-id: http://core.svn.wordpress.org/trunk@63825 1a063a9b-81f0-0310-95a4-ce76da25c4cd1 parent 4ee9bdf commit d564e4e
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
0 commit comments