getStates() as $state){ $name = $state->getName(); foreach($state->getStates() as $propertyName => $value){ if($value instanceof IntTag || $value instanceof StringTag){ $rawValue = $value->getValue(); }elseif($value instanceof ByteTag){ $rawValue = match($value->getValue()){ 0 => false, 1 => true, default => throw new AssumptionFailedError("Unexpected ByteTag value for $name -> $propertyName ($value)") }; }else{ throw new AssumptionFailedError("Unexpected tag type for $name -> $propertyName ($value)"); } $reportMap[$name][$propertyName][get_class($value) . ":" . $value->getValue()] = $rawValue; } } foreach($reportMap as $blockName => $propertyList){ foreach($propertyList as $propertyName => $propertyValues){ ksort($reportMap[$blockName][$propertyName]); $reportMap[$blockName][$propertyName] = array_values($propertyValues); } } ksort($reportMap, SORT_STRING); file_put_contents($argv[2], json_encode($reportMap, JSON_PRETTY_PRINT));