In plain English: Methods inside classes should always have an explicit visibility modifier (public, protected, or private) rather than relying on legacy default visibility.
Why it matters: Leaving methods without explicit modifiers creates ambiguity about whether a method is intended to be part of the public API or internal helper logic. Explicit visibility enforces proper encapsulation and class design.
class Calculator {
// Missing visibility modifier
function add(int $a, int $b): int {
return $a + $b;
}
}
class Calculator {
public function add(int $a, int $b): int {
return $a + $b;
}
}
public, protected, private).public, protected, or private to every method definition.E0003 has no configuration options and is enabled by default.
Always explicitly declare public, protected, or private on every method you write.