Page MenuHomePhabricator

phpcs should enforce spacing in function signature
Closed, ResolvedPublic

Description

During code review we discovered a linting inconsistency
https://gerrit.wikimedia.org/r/#/c/319067/7/tests/phpunit/MobileFormatterTest.php,unified

private function makeSectionHeading( $heading, $innerHtml, $sectionNumber=1 ) {

VS

private function makeSectionHeading( $heading, $innerHtml, $sectionNumber = 1 ) {

We should enforce and standardise on one of these styles

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 3 2016, 10:45 AM
pmiazga added a subscriber: pmiazga.EditedNov 14 2016, 7:09 PM

It is possible by adding to rules.xml following rule:

<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
        <properties>
                <property name="equalsSpacing" value="1" />
                <property name="requiredSpacesAfterOpen" value="1"/>
                <property name="requiredSpacesBeforeClose" value="1" />
        </properties>
</rule>

phpcs output after enabling Squiz.Functions.FunctionDeclarationArgumentSpacing can be found here: https://phabricator.wikimedia.org/P4433

jhobs triaged this task as Low priority.Nov 15 2016, 6:40 PM

Change 333831 had a related patch set uploaded (by Niedzielski):
Hygiene: add phpcs rule for function declaration equals spacing

https://gerrit.wikimedia.org/r/333831

Niedzielski added a subscriber: Niedzielski.

I just tried to copy @pmiazga's comment :]

Change 333831 merged by jenkins-bot:
Hygiene: add phpcs rule for function declaration equals spacing

https://gerrit.wikimedia.org/r/333831

yup, I'll check it

Works really nice! @Niedzielski good job !

pmiazga closed this task as Resolved.Jan 26 2017, 1:18 AM