-
Notifications
You must be signed in to change notification settings - Fork 1
Description
The Problem
ModuleInterface#run()
does not return anything, and before PHP 7.0 omitting the return type. In PHP 7.1
void functions were introduced, and void
should now be the declared return type. Besides correctness, static code analysis tools such as Psalm complain if an implementing class doesn't return anything and does not declare the void
return type.
Suggested Solution
Change the signature of ModuleInterface#run()
to return void
.
Compatibilty Considerations
Many implementing modules, in compliance with the current spec, do not declare a return type. If the signature of ModuleInterface#run()
changes to return void
instead of mixed
, this would mean that the implementors' return type is more generic than the parent type, which is not acceptable because return types are covariant. PHP 7.2 adds parameter type widening, but this does not apply to return types.