DDC-578: Entity proxy classes don't respect reference returning #5084

doctrinebot opened this Issue May 7, 2010 · 3 comments

1 participant


Jira issue originally created by user jantichy:

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.


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!


Comment created by shurakai:

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

Thanks for reporting!


Comment created by romanb:

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.


Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added this to the 2.0-BETA2 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment