Page MenuHomePhabricator

Standardize return type hint spacing
Open, Stalled, LowPublic

Description

Currently both ): and ) : are used in our code for return type hints. We should standardize on one of those and a have a sniff for it.

Please discuss here

Event Timeline

I quote from https://www.mediawiki.org/wiki/Manual:Coding_conventions/CSS:

We love whitespace.

And from https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP

MediaWiki favors a heavily-spaced style for optimum readability.

Therefore, it seems like a no-brainer to use function () : type.

Return type hints are used more and more. I would also support more spaces here ") : "

Can we avoid having the discussion in two places, please? There’s already a lot more arguments on the mw.org talk page (also linked in the task description).

I evaluated my arguments from the mw.org talk page and still think the character sequence … ) : … is not automatically better. I still suggest to follow PSR and enforce … ): ….

Can we avoid having the discussion in two places, please? There’s already a lot more arguments on the mw.org talk page (also linked in the task description).

Marking stalled to highlight it’s blocked on a discussion. Desc tweaked

DannyS712 changed the task status from Open to Stalled.Dec 2 2019, 11:55 AM

Can we avoid having the discussion in two places, please? There’s already a lot more arguments on the mw.org talk page (also linked in the task description).

Marking stalled to highlight it’s blocked on a discussion. Desc tweaked

Discussion was archived without any result

Reedy triaged this task as Low priority.Apr 2 2021, 3:22 AM

Can we avoid having the discussion in two places, please? There’s already a lot more arguments on the mw.org talk page (also linked in the task description).

Marking stalled to highlight it’s blocked on a discussion. Desc tweaked

Discussion was archived without any result

Specifically, https://www.mediawiki.org/wiki/Manual_talk:Coding_conventions/PHP/Archive#Declaring_of_return_types was archived by @Krinkle because he decided to collapse all the talk pages onto one.

In the absence of consensus, how about we just go with spaces for now?

Change 679844 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/tools/codesniffer@master] Add new FunctionTypehintWhiteSpaceSniff

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

The upstream sniff PSR12.Functions.ReturnTypeDeclaration is for PS12 without spaces between ) and :

But it could be used to give some ideas on how to do it.