Inclusive Function

ID

php.inclusive_function

Severity

info

Remediation Complexity

trivial

Remediation Risk

medium

Remediation Effort

low

Resource

Code Smell

Language

Php

Tags

code_smell, inclusive

Description

Reports a method or free function whose name contains a non-inclusive term such as blacklist, whitelist, master or slave. The check is a case-insensitive substring test, so names like isWhitelisted or masterReset are flagged. Magic methods (names beginning with __) are exempt because they are reserved by the PHP engine.

Rationale

Function and method names are read constantly — at every call site, in stack traces and in documentation. Terms like master/slave or whitelist/blacklist carry exclusionary connotations and have clear neutral replacements (allow/deny, primary/replica) that lose no meaning. Naming APIs inclusively keeps the codebase welcoming to all contributors.

<?php

function buildWhitelist(): array {}   // FLAW - "whitelist" is non-inclusive
function isBlacklisted(): bool {}      // FLAW - "blacklist" is non-inclusive

function buildAllowList(): array {}   // OK - neutral replacement
function isDenied(): bool {}           // OK - neutral replacement

Remediation

Rename the function to an inclusive equivalent: whitelist becomes allowList, blacklist becomes denyList, master/slave become primary/replica. Use an IDE rename refactoring so every call site updates together.