DDC-3941: Compatibility issue with PHP 7.0 on proxy generation. #4818

Closed
opened 2026-01-22 14:49:55 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Oct 7, 2015).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user naroga:

When using a return typehint on the entity getter/setter, the proxies are not generated with the typehint, which throws an error when called.

Example:

/****
 * @ORM\Table(name="carro_marca")
 * @ORM\Entity
 */
class Marca
{
    /****
     * @ORM\Column(name="marca_id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="NONE")
     */
    private $id;

    /****
     * @return integer
     */
    public function getId() : \int
    {
        return $this->id;
    }
}

Creates the following getId on the Proxy:

class Marca extends \AppBundle\Entity\Carro\Marca implements \Doctrine\ORM\Proxy\Proxy
    {
        ...
        /****
         * {@inheritDoc}
         */
        public function getId()
        {
            ...
        }
}

Which makes my application throw the following error:

{quote}
Compile Error: Declaration of Proxies*CG*\AppBundle\Entity\Carro\Marca::getId() must be compatible with AppBundle\Entity\Carro\Marca::getId(): int
{quote}

Originally created by @doctrinebot on GitHub (Oct 7, 2015). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user naroga: When using a return typehint on the entity getter/setter, the proxies are not generated with the typehint, which throws an error when called. Example: ``` /**** * @ORM\Table(name="carro_marca") * @ORM\Entity */ class Marca { /**** * @ORM\Column(name="marca_id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="NONE") */ private $id; /**** * @return integer */ public function getId() : \int { return $this->id; } } ``` Creates the following `getId` on the Proxy: ``` class Marca extends \AppBundle\Entity\Carro\Marca implements \Doctrine\ORM\Proxy\Proxy { ... /**** * {@inheritDoc} */ public function getId() { ... } } ``` Which makes my application throw the following error: {quote} Compile Error: Declaration of Proxies*_CG_*\AppBundle\Entity\Carro\Marca::getId() must be compatible with AppBundle\Entity\Carro\Marca::getId(): int {quote}
admin added the Bug label 2026-01-22 14:49:55 +01:00
admin closed this issue 2026-01-22 14:49:55 +01:00
Author
Owner

@doctrinebot commented on GitHub (Oct 7, 2015):

Comment created by naroga:

Apparently, there is already a PR that fixes this for 2.6.0: https://github.com/doctrine/common/pull/376

@doctrinebot commented on GitHub (Oct 7, 2015): Comment created by naroga: Apparently, there is already a PR that fixes this for 2.6.0: https://github.com/doctrine/common/pull/376
Author
Owner

@doctrinebot commented on GitHub (Oct 7, 2015):

Comment created by naroga:

Fixed in https://github.com/doctrine/common/pull/376 (DCOM-294).

@doctrinebot commented on GitHub (Oct 7, 2015): Comment created by naroga: Fixed in https://github.com/doctrine/common/pull/376 ([DCOM-294](http://www.doctrine-project.org/jira/browse/DCOM-294)).
Author
Owner

@doctrinebot commented on GitHub (Oct 7, 2015):

Issue was closed with resolution "Duplicate"

@doctrinebot commented on GitHub (Oct 7, 2015): Issue was closed with resolution "Duplicate"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4818