Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#28409 closed enhancement (fixed)

switch statements should be formatted consistently

Reported by: wonderboymusic's profile wonderboymusic Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.0 Priority: normal
Severity: normal Version: 4.0
Component: General Keywords:
Focuses: Cc:

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
10 years ago

  • Description modified (diff)

#2 @wonderboymusic
10 years ago

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

#3 @wonderboymusic
10 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
10 years ago

In 28634:

Move default to the bottom in _wp_mysql_week().

See #28409.

Note: See TracTickets for help on using tickets.