phanalist

E0054: Dynamic Variable Creation

In plain English: extract() and variable variables such as $$name create local variable names from data. The code becomes hard to follow, and user input can overwrite variables you did not expect.

Why it matters: A request key can replace a local variable, including a security-sensitive one. It also makes it difficult to see which variables a function reads or writes.

Bad

extract($_POST);

$$name = 'value';
${$key} = 'value';

Good

$name = $input['name'] ?? '';
$email = $input['email'] ?? '';

return compact('name', 'email');

What the rule checks

When it does not report

How to fix

Model limits

Configuration

E0054 has no configuration options and is enabled by default.