User:Jeroen De Dauw/Code style

From mediawiki.org

This is a list of guidelines I'd like to see applied in both core and extensions, but that are not mentioned in the coding conventions manual and are regular not applied in core and extensions.

Sorted DESC by my level of annoyance:

  • Document every function, even if it's just a single line comment, and include @return when something is returned.
  • Use type hinting when possible, and always indicate the parameter types with @param.
  • Indicate visibility level of methods and fields. Using 'var' for fields or just 'function' for methods is unclear, and it's not 2008 any more.
  • Use @since to indicate when a function, field or hook was added, esp for everything non-private. Similarly use @deprecated since.
  • Use new lines. New lines before and after every if block and loop on the same level, as well as between lines of code that are 'unrelated'.

Another point, although this is 'included' in the coding conventions manual: