public function getRolesAndSubRoles(RoleHierarchy $roleHierarchy) {

		$possibleRoles = [];
		
		foreach($this->roles as $role) {
			
			$possibleRoles[] = $role;
			$possibleRoles = array_merge($possibleRoles, $roleHierarchy->getSubRoles($role));
			
			return $possibleRoles;

		}
	}
public function getRolesAndSubRoles(RoleHierarchy $roleHierarchy) {

		$possibleRoles = [];
		
		foreach($this->roles as $role) {
			
			$possibleRoles[] = $role;
			$possibleRoles = array_merge($possibleRoles, $roleHierarchy->getSubRoles($role));
			
			return $possibleRoles;

		}
	}
public function getRolesAndSubRoles ( RoleHierarchy $ roleHierarchy ) { $ possibleRoles = [ ] ; foreach ( $ this -> roles as $ role ) { $ possibleRoles [ ] = $ role ; $ possibleRoles = array_merge ( $ possibleRoles , $ roleHierarchy -> getSubRoles ( $ role ) ) ; return $ possibleRoles ; } }
return all possible roles and subroles - defined by a role
hierarchy - the user can take

@param RoleHierarchy $roleHierarchy
@return Role[]
return all possible roles and subroles - defined by a role hierarchy - the user can take