Skip to content

Ensure that the closing brace is properly aligned #1474

@david-binda

Description

@david-binda

The Kernighan opening function Brace Sniff ( Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace ) which is part of the WordPress Coding Standard on it's own does not always produce desired output when it comes to running phpcbf.

WordPress Coding Standards v1.0 was used for updating following function in WordPress:

function is_admin() {return true;} 

with following result:

function is_admin() { return true;} 

See https://core.trac.wordpress.org/changeset/42343/trunk/src/wp-admin/includes/noop.php for real-live example.

Imho, such a change does not really improve readability of the code. From my point of view, the desired output should be as follows:

function is_admin() { return true; } 

While this is not explicitly defined in the WordPress coding standards, an example which can be found in https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#space-usage is very similar to the desired output described above:

function sum( $a, $b ): float { return $a + $b; } 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions