What about doing this instead?
```
if (!isset($parent->$k))
{
    $parent->$k = new \stdClass;
}
```
It gives a lower overall NPath Complexity. (From what I understand, every ternary operation adds an extra 2 points beyond a single if.)