8000 PropertyAccess: reading undefined array key actually *adds* that key · Issue #16056 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
PropertyAccess: reading undefined array key actually *adds* that key #16056
Closed
@weaverryan

Description

@weaverryan

Hi guys!

Code to reproduce:

use Symfony\Component\PropertyAccess\PropertyAccess;

$data = new stdClass();
$data->pizzas = array(
    'mushroom'
);

$accessor = PropertyAccess::createPropertyAccessor();
$val = $accessor->getValue($data, 'pizzas[1]');
dump($data);

This will print:

{
  +"pizzas": array:2 [
    0 => "mushroom"
    1 => null
  ]
}

Notice the 1 key has actually been added to the underlying data. The problem seems to only happen when you're working on an array inside of an object (i.e. I could not reproduce this by working with an array at the top-level).

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