I see getter and setter code that has been implemented as a implicit de facto standard in our PHP apps, to the effect that every instance variable in the project classes might as well be public.
I don't want to see a list of getters and setters of every single instance variable in code every time I open a class. They're usually the first thing I see and usually the length of them surpasses the core content of the class which does something other than set and get, so I have to spend a minute scrolling like a muppet in a sea of getters and setters, especially when they are arranged like this:
$this->getter();
$this->setter();
$this->actualstuff();
$this->getter();
$this->setter();
$this->getter();
$this->getter();
$this->setter();
$this->actualstuff();
$this->getter();
$this->setter();
When I am on my death bed I will realize that half of my life will have been wasted looking at setters and getters, so I'm trying to appeal to my colleagues to not automatically generate them upon finishing instance variables out of habit and getting them pointlessly depended upon.
The issue here is that my colleagues like that they appear in the IDE (we use PHPstorm) code completion, which makes things easier when typing out.
I'm wondering if there is a technique to get getter code completion that doesn't use magic methods. A phpstorm plugin or PHP class perhaps.
class Product{
private $price;
private $amount;
public function toGetter(){
$return = array();
$return['price'] = $this->price;
$return['amount'] = $this->amount;
$getter = new GetterObject($return); //Hypothetical solution class
return $getter;
}
}
$Product = new Product();
$Product->toGetter()->getPrice(); //appears in PHPstorm code completion
I'll take any other kind of suggestion.