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

Open
opened 2026-01-22 14:51:48 +01:00 by admin · 0 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:48 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4906