Skip to content

Instantly share code, notes, and snippets.

Last active Nov 4, 2020
What would you like to do?
PHP spaceship operator example
usort($descriptors, function (AbstractDescriptor $a, AbstractDescriptor $b): int {
    $order = ['semantic' => 0, 'safe' => 1, 'unsafe' => 2, 'idempotent' => 3];
    return $order[$a->type] <=> $order[$b->type]; // sort by type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment