WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#28409 closed enhancement (fixed)

switch statements should be formatted consistently

Reported by: wonderboymusic Owned by: wonderboymusic
Milestone: 4.0 Priority: normal
Severity: normal Version: 4.0
Component: General Keywords:
Focuses: Cc:
PR Number:

Description (last modified by wonderboymusic)

I have been looking at a number of issues over at #27882.

There are a variety of places in core that format switch statements differently. IMO, default should always be at the bottom. It's more consistent, and it doesn't confuse static analysis tools (we don't have to do everything that is suggested by automated tools).

switch ( $var ) {
    case 1:
        $return = 'match';
        break;
    default:
        break;
}

is better than:

switch ( $var ) {
    default:
        break;
    case 1:
        $return = 'match';
        break;
}

Change History (4)

#1 @wonderboymusic
5 years ago

  • Description modified (diff)

#2 @wonderboymusic
5 years ago

Almost every time is in an external library (boo) - but I did find 2 on us.

#3 @wonderboymusic
5 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 28633:

Cleanup for switch statements:

  • Move default to the bottom in WP_Theme_Install_List_Table
  • switch/endswitch syntax is not supported in Hack. Switch to switch (...) { .... } syntax. (A few template-type instances linger).

Fixes #28409.
See #27881.

#4 @wonderboymusic
5 years ago

In 28634:

Move default to the bottom in _wp_mysql_week().

See #28409.

Note: See TracTickets for help on using tickets.