Opened 8 years ago
Closed 3 years ago
#38296 closed enhancement (fixed)
Remove $sep variable duplication from Ternary Operator
Reported by: | joelcj91 | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.9 | Priority: | normal |
Severity: | minor | Version: | 3.1 |
Component: | Administration | Keywords: | has-patch |
Focuses: | administration, coding-standards | Cc: |
Description
In WP_List_Table class, we are using ternary operators a lot. We know that the main advantage of the ternary operator is, it makes code shorter.
Instead of uisng ternary operator like this,
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
Can we use,
$sep = ( $i == $action_count ) ? '' : ' | ';
So the variable $sep is written once. Shortening the code a bit.
Attachments (3)
Change History (11)
#2
@
6 years ago
- Keywords needs-refresh added
- Milestone changed from Awaiting Review to Future Release
- Version changed from 4.6.1 to 3.1
Thanks for this, @joelcj91! Sorry that it took so long to receive a response.
This is a good suggestion, IMO. Are you able to refresh the patch to apply cleanly to trunk
?
#3
@
6 years ago
- Keywords needs-refresh removed
Thanks, @desrosj. I have updated the patch after updating the trunk.
#4
@
3 years ago
- Resolution set to fixed
- Status changed from new to closed
Closing this ticket as fixed since it looks like it was previously fixed in another one.
Now the related code is:
$sep = ( $i < $action_count ) ? ' | ' : '';
#5
@
3 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Hmm. Reopening this ticket as it appears that the issue wasn't fixed for every files.
Patch incoming.
@
3 years ago
Coding standards: Fix an inconsistency in the usage of ternary operators for the $sep
variable/
Patch to remove variable duplication