If you send a
LIST command to list all mailboxes, the entry for
* LIST (\HasChildren \Noselect) "/" "[Gmail]"
That is, this mailbox cannot be selected (
I'd guess that
imap_getmailboxes doesn't care about the
\Noselect flag and tries to select that mailbox anyway.