Page MenuHomePhabricator

OpeningFunctionBraceKernighanRitchie.ContentAfterBrace sniff doesn't properly expand functions that were originally one line
Closed, InvalidPublic

Description

When enabling the Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace sniff and then running composer test as well as composer fix, the automatic fix didn't properly expand these functions which were originally on 1 line.

For reference: https://gerrit.wikimedia.org/r/#/c/426726/1/UserStats/includes/UserLevel.php

The original code was:

UserStats/includes/UserLevel.php
	public function getLevelName() { return $this->level_name; }
	public function getLevelNumber() { return $this->level_number; }
	public function getNextLevelName() { return $this->next_level_name; }

When running composer fix, it expanded the functions improperly as shown below, which has:

  • mixed tabs and spaces
  • improper indentation
  • improper placement of closing brace
UserStats/includes/UserLevel.php
	public function getLevelName() {
 return $this->level_name; }
	public function getLevelNumber() {
 return $this->level_number; }
	public function getNextLevelName() {
 return $this->next_level_name; }

When running composer fix, it should've looked like this below (which I had manually fixed in patchset 2 for this file):

UserStats/includes/UserLevel.php
	public function getLevelName() {
		return $this->level_name;
	}

	public function getLevelNumber() {
		return $this->level_number;
	}

	public function getNextLevelName() {
		return $this->next_level_name;
	}