8000 [Validator] Typed property must not be accessed before initialization · Issue #35454 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[Validator] Typed property must not be accessed before initialization #35454
Closed
@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

      0