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];
        }
    }
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];
        }
    }
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 ] ; } }
Returns an array of variants.

With no arguments, returns all variants

With a classname as the first argument, returns the variants that apply to that class
(optionally including subclasses)

@static
@param string $class - The class name to get variants for
@param bool $includeSubclasses - True if variants should be included if they apply to at least one subclass of $class
@return array - An array of (string)$variantClassName => (Object)$variantInstance pairs
Returns an array of variants .