Unused parameters in methods in abstract classes
Abstract classes can contain abstract methods which are required to be overloaded, but they can also contain empty methods which are optional to overload.
abstract class Foo
{
// Required to be overloaded.
abstract public function bar($param);
// Optional to be overloaded.
public function baz($param) {
}
}
This standard will throw a Unused function parameter $param.(VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable) warning for the second method bax().
While technically correct, IMHO it would be sane to make an exception for these kind of "optional overload" (empty) methods in abstract classes.
I agree. Maybe something like "if the variable is an argument of a function that is a method of an abstract class and the method body is empty, then do not mark unused".
Just thinking - maybe it should be: ""if the variable is an argument of a function that is a method of an abstract class and the method body is empty or only contains return;, then do not mark unused"."
Indeed, I think I'm running into an abstract class method defined as abstract public function decompress( $compressed_item, $compressed_data_layer );, where we don't use $compressed_data_layer, but need to include it to match overload signature.