src/PHPFormatter/Fixer/UseSortFixer.php
private function createGroups(array $namespaces)
    {
        $groups = [];

        foreach ($this->groups as $group) {
            if (is_array($group)) {
                $groups[] = array_fill_keys($group, []);
            } else {
                $groups[$group] = [];
            }
        }

        if (!array_key_exists('_main', $groups)) {
            $groups = array_merge(
                ['_main' => []],
                $groups
            );
        }

        foreach ($namespaces as $namespace) {
            foreach ($groups as $groupKey => $group) {
                if (is_int($groupKey)) {
                    foreach ($group as $subGroupKey => $subGroup) {
                        if (strpos($namespace, $subGroupKey) === 0) {
                            array_push($groups[$groupKey][$subGroupKey], $namespace);

                            continue 3;
                        }
                    }
                } elseif (is_string($groupKey) && strpos($namespace, $groupKey) === 0) {
                    array_push($groups[$groupKey], $namespace);

                    continue 2;
                }
            }

            array_push($groups['_main'], $namespace);
        }

        return $groups;
    }
private function createGroups(array $namespaces)
    {
        $groups = [];

        foreach ($this->groups as $group) {
            if (is_array($group)) {
                $groups[] = array_fill_keys($group, []);
            } else {
                $groups[$group] = [];
            }
        }

        if (!array_key_exists('_main', $groups)) {
            $groups = array_merge(
                ['_main' => []],
                $groups
            );
        }

        foreach ($namespaces as $namespace) {
            foreach ($groups as $groupKey => $group) {
                if (is_int($groupKey)) {
                    foreach ($group as $subGroupKey => $subGroup) {
                        if (strpos($namespace, $subGroupKey) === 0) {
                            array_push($groups[$groupKey][$subGroupKey], $namespace);

                            continue 3;
                        }
                    }
                } elseif (is_string($groupKey) && strpos($namespace, $groupKey) === 0) {
                    array_push($groups[$groupKey], $namespace);

                    continue 2;
                }
            }

            array_push($groups['_main'], $namespace);
        }

        return $groups;
    }
private function createGroups ( array $ namespaces ) { $ groups = [ ] ; foreach ( $ this -> groups as $ group ) { if ( is_array ( $ group ) ) { $ groups [ ] = array_fill_keys ( $ group , [ ] ) ; } else { $ groups [ $ group ] = [ ] ; } } if ( ! array_key_exists ( '_main' , $ groups ) ) { $ groups = array_merge ( [ '_main' => [ ] ] , $ groups ) ; } foreach ( $ namespaces as $ namespace ) { foreach ( $ groups as $ groupKey => $ group ) { if ( is_int ( $ groupKey ) ) { foreach ( $ group as $ subGroupKey => $ subGroup ) { if ( strpos ( $ namespace , $ subGroupKey ) === 0 ) { array_push ( $ groups [ $ groupKey ] [ $ subGroupKey ] , $ namespace ) ; continue 3 ; } } } elseif ( is_string ( $ groupKey ) && strpos ( $ namespace , $ groupKey ) === 0 ) { array_push ( $ groups [ $ groupKey ] , $ namespace ) ; continue 2 ; } } array_push ( $ groups [ '_main' ] , $ namespace ) ; } return $ groups ; }
Create blocks.

@param array $namespaces Namespaces

@return array Groups
Create blocks .