$this->getType(), 'level' => $this->getLevel(), 'id' => $this->getId(), 'replies' => array_map( static function ( ThreadItem $comment ) use ( $deep, $callback ) { return $deep ? $comment->jsonSerialize( $deep, $callback ) : $comment->getId(); }, $this->getReplies() ) ]; if ( $callback ) { $callback( $array, $this ); } return $array; } }