1.2.874. One Letter Functions

One letter functions seems to be really short for a meaningful name. This may happens for very high usage functions, so as to keep code short, but such functions should be rare.

<?php

// Always use a meaningful name
function addition($a, $b) {
    return $a + $b;
}

// One letter functions are rarely meaningful
function f($a, $b) {
    return $a + $b;
}

?>

1.2.874.1. Suggestions

  • Use full names for functions

  • Remove the function name altogether : use a closure

1.2.874.2. Specs

Short name

Functions/OneLetterFunctions

Rulesets

All, Coding conventions, Semantics

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

function, semantics

Examples

ThinkPHP, Cleverstyle

Available in

Entreprise Edition, Exakat Cloud