public function addRole(string $role, ?array $parents = null): void
    {
        $this->roles[] = $role;
        
        if(null !== $parents) {
            $map = [];
            foreach ($parents as $parent) {
                $map[] = $parent;
                $map = \array_merge($map, $this->getRoles($parent));
            }
            unset($map[0]);
            
            $this->map[$role] = \array_values(\array_unique($map));
        }
    }
public function addRole(string $role, ?array $parents = null): void
    {
        $this->roles[] = $role;
        
        if(null !== $parents) {
            $map = [];
            foreach ($parents as $parent) {
                $map[] = $parent;
                $map = \array_merge($map, $this->getRoles($parent));
            }
            unset($map[0]);
            
            $this->map[$role] = \array_values(\array_unique($map));
        }
    }
public function addRole ( string $ role , ? array $ parents = null ) : void { $ this -> roles [ ] = $ role ; if ( null !== $ parents ) { $ map = [ ] ; foreach ( $ parents as $ parent ) { $ map [ ] = $ parent ; $ map = \ array_merge ( $ map , $ this -> getRoles ( $ parent ) ) ; } unset ( $ map [ 0 ] ) ; $ this -> map [ $ role ] = \ array_values ( \ array_unique ( $ map ) ) ; } }
Add a role into the hierarchy

@param string $role
Role to add
@param array|null $parents
Parents for this role. Leave to null if none

@throws UndefinedRoleException
When a parent role cannot be resolved
Add a role into the hierarchy