Skip to content

EnumReflectionProperty throws Fatal Error #423

@jawira

Description

@jawira

Bug Report

Q A
Version 4.0.0

Versions < 4.0.0 are more than likely also impacted by this bug.

Summary

Hello, I am the developer of DoctrineDiagramBundle. With this bundle I can generate class diagrams from my Doctrine entities.
The problem is that when an entity has a Enum type property my bundle fails and throws a Fatal error.

After some hours of research I identified the problem: some methods in \Doctrine\Persistence\Reflection\EnumReflectionProperty don't work properly and generate a fatal error.
More precisely, any inherited method in EnumReflectionProperty will generate an error.

Internal error: Failed to retrieve the reflection object

Image

Current behavior

Methods defined in EnumReflectionProperty work as expected, for example:

  • \Doctrine\Persistence\Reflection\EnumReflectionProperty::getName Ok
  • \Doctrine\Persistence\Reflection\EnumReflectionProperty::isPrivate Ok

But methods inherited from parent will fail, for example:

  • \Doctrine\Persistence\Reflection\EnumReflectionProperty::hasDefaultValue Fatal error
  • \Doctrine\Persistence\Reflection\EnumReflectionProperty::isPublic Fatal error

Expected behavior

All methods from EnumReflectionProperty must work properly without any error.

How to reproduce

To reproduce the issue simply call any inherited method in EnumReflectionProperty.

I reproduced the issue installing and using DoctrineDiagramBundle:

Solution

As per documentation, when a Reflection class is extended and constructor overwritten, then the parent's constructor must also be called.

Image

Source: https://www.php.net/manual/en/reflection.extending.php

I have created a PR that fixes this issue: #422

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions