Posted via @Jetbrains: what you think about this @php code?
src/Graph/Node.php#L26-L38
/** * @return array<string, mixed> */ public function toArray(): array { return [ 'id' => $this->id, 'label' => $this->label, 'kind' => $this->kind->value, 'file' => $this->file, 'line' => $this->line, ] + ($this->service === null ? [] : ['service' => $this->service]) + ($this->modifiers === [] ? [] : ['modifiers' => $this->modifiers]); }
commit 114060f
It has been a method for generating JSON output, APIs, and data serialization.
I don't know how useful this is.
Why? The nested ternaries and the combined concerns are the worst of it but using PHP language features combined to make them less explicit is bad too. this could easily be broken into separate steps or even named private functions for clarity