Issues

ZF-10744: Zend_Acl->getRoles() does not properly documented or implemented

Description

I'm not quite sure, is this documentation or code issue. Taking in mind Zend_Acl->getRoles() method doc, i expected roles instances:

source:

/**
 * @return array of registered roles
 */
public function getRoles()
{
    return array_keys($this->_getRoleRegistry()->getRoles());
}

So, the implementation can not return role instances, just IDs. I think this should be documented unequivocally or corrected in case if instances have been mentioned.

And IMHO: On the one hand current behavior is reasonable, but in case if custom roles implementation is necessary, Zend_Acl can not be used as unique roles registry. It is not a catastrophe, but not so comfortably as well.

Comments

This is expected, as there is a unittest in place that verifies this behaviour.

If you want access to the role instances, you could simply subclass Zend_Acl:


class My_Acl extends Zend_Acl
{
    public function getRoles()
    {
        return $this->_getRoleRegistry()->getRoles();
    }
}

Unless you have any objections, this issue can be closed.

I have no objections, thanks for answer. May be there's meaning to change method doc for prevent misunderstanding.

Fixed in svn r23529 and merged to 1.11 release branch in svn r23530

RE: previous comment

I've improved the docblock for the getRoles() method, so that it's clear that only role ID's are returned.