1.2.880. 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.880.1. Connex PHP features

1.2.880.1.1. Suggestions

  • Use full names for functions

  • Remove the function name altogether : use a closure

1.2.880.1.2. Specs

Short name

Functions/OneLetterFunctions

Rulesets

All, Changed Behavior, Coding conventions, Semantics

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Examples

ThinkPHP, Cleverstyle

Available in

Entreprise Edition, Exakat Cloud