public toSerializableArray ( ) : array | ||
리턴 | array |
public function toSerializableArray()
{
$arr = ['message' => $this->getMessage()];
$locations = Utils::map($this->getLocations(), function (SourceLocation $loc) {
return $loc->toSerializableArray();
});
if (!empty($locations)) {
$arr['locations'] = $locations;
}
if (!empty($this->path)) {
$arr['path'] = $this->path;
}
return $arr;
}
/** * @it serializes to include path */ public function testSerializesToIncludePath() { $e = new Error('msg', null, null, null, ['path', 3, 'to', 'field']); $this->assertEquals(['path', 3, 'to', 'field'], $e->path); $this->assertEquals(['message' => 'msg', 'path' => ['path', 3, 'to', 'field']], $e->toSerializableArray()); }