This is an error 404
There are `0` results
preferences:
146.54 ms | 1399 KiB | 7 Q<?hh //strict
interface Comparer<T> {
public function __invoke(T $a, T $b): int;
}
class Box<T> {
public T $property;
public function __construct(T $property){
$this->property = $property;
}
}
class BoxComparer<T> implements Comparer<Box<T>> {
public function __invoke(Box<T> $a, Box<T> $b): int {
if ($a->property < $b->property) {
return -1;
} elseif ($b->property < $a->property) {
return 1;
} else {
return 0;
}
}
}
class Sorter<T> {
public function __invoke(Collection<T> $items, (function(T, T): int) $comparer): void {
echo __METHOD__, PHP_EOL;
}
}
$collection = Vector {new Box(1), new Box(2)};
$sorter = new Sorter();
$sorter($collection, new BoxComparer());
$sorter($collection, 1);