title: Is it good to use magic find methods from Doctrine EntityRepository?
body: <p>I'm asking in context of symfony framework.</p>
  
  <p>I am wondering if this is a good practice to use magic find methods (like find($id), findByField($value) etc...).</p>
  
  <p>Those methods neither has return type nor are defined at all. This leads my IDE to mark warnings around them. Also I have to mark type of returned value all the time I use those methods, to make code completion working on those variables.</p>
  
  <p>As a solution I am usually writing getters inside custom repository classes. In symfony docs there is example of such getter, that overload an variant of magic findBy method.</p>
  
  <p>I have a bad feelings about such overloading magic find methods too, because it kind of mixes my own repo implementation with the parent EntityRepository one.</p>
  
  <p>So I end up with writing custom getters that uses "get" prefix instead of "find".</p>
  
  <p>Now, can someone tell me whats the best practice and why ?</p>
  
  <h2><strong>EDIT</strong></h2>
  
  <p>Recently i was looking for some ways to optimize doctrine, and I have found advise not to use magic finders, so its another argument against magic finders.</p>
  
  <p>I have also read doctrine docs about magic finders and found that:
  <a href="http://docs.doctrine-project.org/projects/doctrine1/en/latest/en/manual/dql-doctrine-query-language.html#magic-finders" rel="nofollow">http://docs.doctrine-project.org/projects/doctrine1/en/latest/en/manual/dql-doctrine-query-language.html#magic-finders</a></p>
  
  <blockquote>
    <p>These are very limited magic finders and it is <strong>always recommended to expand your queries to be manually written DQL queries</strong>. These methods are meant for only quickly accessing single records, no relationships, and are good for prototyping code quickly. </p>
  </blockquote>
  
  <p>So I have finally worked out my own opinion (and use case) for magic finders. Use them only for speed up coding, and always mark them with TODO, to rewrite them into custom repository methods while cleaning up code.</p>