type = $info['type']; $this->value = $info['value'] ?? null; $this->description = $info['description']; } /** * Compare two Expectation objects, and return a value less than, equal to, * or greater than zero, depending on whether $a is less than, equal to, or * greater than $b respectively. * * This is used to sort expectations before combining them into SyntaxError * descriptions. * * @param Expectation $a * @param Expectation $b * @return int */ public static function compare(Expectation $a, Expectation $b) { return $a->type <=> $b->type ?: $a->value <=> $b->value ?: $a->description <=> $b->description; } /** * Emit a JSON serialization similar to JS, for testing * @return array */ public function jsonSerialize() { return [ 'type' => $this->type, 'value' => $this->value, 'description' => $this->description ]; } }