DDC-4019: Proxy generator is not including PHP7 return type hints #4907

Closed
opened 2026-01-22 14:51:50 +01:00 by admin · 7 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 25, 2015).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user radmen:

Proxy generator skips return type hints which results in generating non-compatible proxies.

Entity example:

<?php

namespace Domain\Members;

use Doctrine\ORM\Mapping as ORM;

/****
 * @ORM\Entity
 */
class Member
{

    /****
     * @ORM\Id()
     * @ORM\Column(type="guid")
     * @var string
     */
    private $id;

    public function getId(): string
    {
        return $this->id;
    }
}

Generated proxy:

<?php

namespace DoctrineProxies\*_CG_*\Domain\Members;

/****
 * DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
 */
class Member extends \Domain\Members\Member implements \Doctrine\ORM\Proxy\Proxy
{

    // CUT

    /****
     * {@inheritDoc}
     */
    public function getId()
    {

        $this->*_initializer__ && $this->__initializer__->_*invoke($this, 'getId', array());

        return parent::getId();
    }

}

Currently only workaround for this is to remove return type hints definitions.

Originally created by @doctrinebot on GitHub (Nov 25, 2015). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user radmen: Proxy generator skips return type hints which results in generating non-compatible proxies. Entity example: ``` <?php namespace Domain\Members; use Doctrine\ORM\Mapping as ORM; /**** * @ORM\Entity */ class Member { /**** * @ORM\Id() * @ORM\Column(type="guid") * @var string */ private $id; public function getId(): string { return $this->id; } } ``` Generated proxy: ``` <?php namespace DoctrineProxies\*_CG_*\Domain\Members; /**** * DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR */ class Member extends \Domain\Members\Member implements \Doctrine\ORM\Proxy\Proxy { // CUT /**** * {@inheritDoc} */ public function getId() { $this->*_initializer__ && $this->__initializer__->_*invoke($this, 'getId', array()); return parent::getId(); } } ``` Currently only workaround for this is to remove return type hints definitions.
admin added the Bug label 2026-01-22 14:51:50 +01:00
admin closed this issue 2026-01-22 14:51:51 +01:00
Author
Owner

@thomask commented on GitHub (Dec 22, 2015):

Didn't properly investigate, but I think the same might go for scalar type hints (doctrine/orm v2.4.8)

@thomask commented on GitHub (Dec 22, 2015): Didn't properly investigate, but I think the same might go for scalar type hints (doctrine/orm v2.4.8)
Author
Owner

@Majkl578 commented on GitHub (Dec 22, 2015):

I think this is fixed by https://github.com/doctrine/common/pull/376/files, but it's unfortunately only in 2.6.0 which can't be installed with docrine/orm=2.5.*.

@Majkl578 commented on GitHub (Dec 22, 2015): I think this is fixed by https://github.com/doctrine/common/pull/376/files, but it's unfortunately only in 2.6.0 which can't be installed with docrine/orm=2.5.*.
Author
Owner

@BenMorel commented on GitHub (Dec 24, 2015):

This is a major issue, that affects scalar type hints as well indeed. In its current state, the ORM just cannot work with entities using scalar type hints or return types.

What prevents doctrine/common 2.6.0 from being used with doctrine/orm 2.5.* exactly?

@BenMorel commented on GitHub (Dec 24, 2015): This is a major issue, that affects scalar type hints as well indeed. In its current state, the ORM just cannot work with entities using scalar type hints or return types. What prevents doctrine/common 2.6.0 from being used with doctrine/orm 2.5.\* exactly?
Author
Owner

@Ocramius commented on GitHub (Dec 24, 2015):

Time, and the lack of it.
On Dec 24, 2015 4:32 AM, "Benjamin Morel" notifications@github.com wrote:

This is a major issue, that affects scalar type hints as well indeed. In
its current state, the ORM just cannot work with entities using scalar type
hints or return types.

What prevents doctrine/common 2.6.0 from being used with doctrine/orm
2.5.* exactly?


Reply to this email directly or view it on GitHub
https://github.com/doctrine/doctrine2/issues/4884#issuecomment-167013662
.

@Ocramius commented on GitHub (Dec 24, 2015): Time, and the lack of it. On Dec 24, 2015 4:32 AM, "Benjamin Morel" notifications@github.com wrote: > This is a major issue, that affects scalar type hints as well indeed. In > its current state, the ORM just cannot work with entities using scalar type > hints or return types. > > What prevents doctrine/common 2.6.0 from being used with doctrine/orm > 2.5.\* exactly? > > — > Reply to this email directly or view it on GitHub > https://github.com/doctrine/doctrine2/issues/4884#issuecomment-167013662 > .
Author
Owner

@BenMorel commented on GitHub (Dec 24, 2015):

I mean, is it just a matter of updating the composer.json file?

If I force using 2.6.0 ("doctrine/common": "2.6.0 as 2.5.3"), it seems to work fine.

I can open a PR on the ORM and DBAL packages to modify their composer.json, but I'm not sure if there is another problem as you guys could do this modification in 2 clicks?

@BenMorel commented on GitHub (Dec 24, 2015): I mean, is it just a matter of updating the `composer.json` file? If I force using 2.6.0 (`"doctrine/common": "2.6.0 as 2.5.3"`), it seems to work fine. I can open a PR on the ORM and DBAL packages to modify their `composer.json`, but I'm not sure if there is another problem as you guys could do this modification in 2 clicks?
Author
Owner

@Ocramius commented on GitHub (Dec 24, 2015):

Yup, just a matter of doing that and preparing a new release ;-)
On Dec 24, 2015 12:13, "Benjamin Morel" notifications@github.com wrote:

I mean, is it just a matter of updating the composer.json file?

If I force using 2.6.0 ("doctrine/common": "2.6.0 as 2.5.3"), it seems to
work fine.

I can open a PR on the ORM and DBAL packages to modify their composer.json,
but I'm not sure if there is another problem as you guys could do this
modification in 2 clicks?


Reply to this email directly or view it on GitHub
https://github.com/doctrine/doctrine2/issues/4884#issuecomment-167094600
.

@Ocramius commented on GitHub (Dec 24, 2015): Yup, just a matter of doing that and preparing a new release ;-) On Dec 24, 2015 12:13, "Benjamin Morel" notifications@github.com wrote: > I mean, is it just a matter of updating the composer.json file? > > If I force using 2.6.0 ("doctrine/common": "2.6.0 as 2.5.3"), it seems to > work fine. > > I can open a PR on the ORM and DBAL packages to modify their composer.json, > but I'm not sure if there is another problem as you guys could do this > modification in 2 clicks? > > — > Reply to this email directly or view it on GitHub > https://github.com/doctrine/doctrine2/issues/4884#issuecomment-167094600 > .
Author
Owner

@BenMorel commented on GitHub (Dec 26, 2015):

Thanks @Ocramius 👍

@BenMorel commented on GitHub (Dec 26, 2015): Thanks @Ocramius :+1:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4907