Problem/Motivation
See #3455549: Add return typehints to protected test helper methods
Steps to reproduce
Proposed resolution
Use \Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector
to add void return type to protected test methods. This rule may need manipulating to skip public methods.
private function shouldSkipClassMethod(ClassMethod $classMethod) : bool
{
// Add this to skip public methods.
if ($classMethod->isPublic()) {
return \true;
}
// The rest of the method body remains here ...
// Comment out this bit.
// if ($classMethod->isProtected()) {
// return !$this->classModifierChecker->isInsideFinalClass($classMethod);
// }
return $this->classModifierChecker->isInsideAbstractClass($classMethod) && $classMethod->getStmts() === [];
}