First of all it is a question of concept. Doctrine shouldn't assume anything about entities outside of their fields. It already introduces a level of complication when we explain how to clone/serialize objects, which was very confusing.
Asking for the purpose of an identifier field getter method is in my opinion again an attempt of making assumptions over user's code...
What if the user wrote something like:
public function getIdentifierField1()
{
return $this->identifierField1? $this->_myInitializationStuff() : null;
}
private function _myInitializationStuff()
{
//open files, check stuff, make things difficult for the D2 team 
}
For instance, opening file handlers, sockets, whatever... This is a case that would break the entity because of optimization introduced by the ProxyFactory. (not to mention when getIdentifierField1 does some conversion, like return $this->identifierField1 + self::OFFSET_REQUIRED_BY_WEBSERVICE;
I'm not arguing about the validity of this optimization, but that the checks are too lazy.
I've read something about moving the ProxyFactory to common and using code scanner tools, and the check should be about applying the optimization only when the form is
return $this->identifierField1;
That's why I put the example of the regex. That would probably not be as safe as using some reflection-based tool, but surely more than just checking if the code is <= 4 lines...
Can you explain why you think this is necessary?
You are right an id method with logic could exist in 4 lines of code, but for what purpose?