public static function variants($class = null, $includeSubclasses = true)
    {
        if (!$class) {
            // Build up and cache a list of all search variants (subclasses of SearchVariant)
            if (self::$variants === null) {
                $classes = ClassInfo::subclassesFor(static::class);

                $concrete = array();
                foreach ($classes as $variantclass) {
                    $ref = new ReflectionClass($variantclass);
                    if ($ref->isInstantiable()) {
                        $variant = singleton($variantclass);
                        if ($variant->appliesToEnvironment()) {
                            $concrete[$variantclass] = $variant;
                        }
                    }
                }

                self::$variants = $concrete;
            }

            return self::$variants;
        } else {
            $key = $class . '!' . $includeSubclasses;

            if (!isset(self::$class_variants[$key])) {
                self::$class_variants[$key] = array();

                foreach (self::variants() as $variantclass => $instance) {
                    if ($instance->appliesTo($class, $includeSubclasses)) {
                        self::$class_variants[$key][$variantclass] = $instance;
                    }
                }
            }

            return self::$class_variants[$key];
        }
    }