Skip to content

[Validator] Typed property must not be accessed before initialization #35454

@greedyivan

Description

@greedyivan

Related: doctrine/orm#7944

Description:
This is the same issue when ReflectionProperty::getValue() uses an uninitialized argument.

How to reproduce:
Validate an object that has an uninitialized property with type hint:

    /**
     * @Assert\NotBlank()
     */
    public int $id;

Possible Solution:
Something similar to TypedNoDefaultReflectionProperty.php
Symfony\Component\Validator\Mapping\PropertyMetadata::getPropertyValue:

    /**
     * {@inheritdoc}
     */
    public function getPropertyValue($object)
    {
        $reflectionProperty = $this->getReflectionMember($object);

        return $object !== null && $reflectionProperty->isInitialized($object) ? $reflectionProperty->getValue($object) : null;
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions