Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-578

Entity proxy classes don't respect reference returning

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-BETA1
    • Fix Version/s: 2.0-BETA2
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      Hello, I have entity class containing a method that returns reference:

      public class &foo() { ... }
      

      But when Doctrine creates it's proxy class, the reference ampersand in the proxy class disappears:

      public class foo() { ... }
      

      It causes incompatibility of the proxy class and unexpected behaviour of the method.

      Solution:

      Here is the solution, could you please include it to the Doctrine code?

      The Doctrine\ORM\Proxy\ProxyFactory should be fixed - in method _generateMethods() there is following line:

      $methods .= PHP_EOL . '    public function ' . $method->getName() . '(';
      

      It should be replaced by something like this:

      $methods .= PHP_EOL . '    public function ';
      if ($method->returnsReference()) {
          $methods .= '&';
      }
      $methods .= $method->getName() . '(';
      

      Thank you for the fix!

        Activity

        Hide
        Christian Heinrich added a comment -

        Fixed in http://github.com/Shurakai/doctrine2 & sent pull request. Should be fixed in trunk soon.

        Thanks for reporting!

        Show
        Christian Heinrich added a comment - Fixed in http://github.com/Shurakai/doctrine2 & sent pull request. Should be fixed in trunk soon. Thanks for reporting!
        Hide
        Roman S. Borschel added a comment -

        Note though that since php5 the only remaining usecase for returning by reference I can think of are arrays, and this is a very weird thing to do.

        Show
        Roman S. Borschel added a comment - Note though that since php5 the only remaining usecase for returning by reference I can think of are arrays, and this is a very weird thing to do.

          People

          • Assignee:
            Roman S. Borschel
            Reporter:
            Jan Tichý
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: