Req #15618 [Opn]: [patch] support arrayAccess interface

From: Date: Sun, 01 Apr 2012 22:04:41 +0000
Subject: Req #15618 [Opn]: [patch] support arrayAccess interface
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-8500@lists.php.net to get a copy of this message
Edit report at https://pear.php.net/bugs/bug.php?id=15618&edit=1 ID: 15618 Updated by: cweiske@php.net Reported By: pear at sebastianmendel dot de Summary: [patch] support arrayAccess interface Status: Open Type: Feature/Change Request Package: HTML_QuickForm2 Package Version: CVS PHP Version: Irrelevant Roadmap Versions: New Comment: I think the readonly stuff would suffice for most use cases. Previous Comments: ------------------------------------------------------------------------ [2012-04-01 22:48:28] avb If we are trying to mimic SimpleXML here, then we probably should use ArrayAccess for attributes (and that should be implemented in HTML_Common2). Also note that SimpleXML itself allows $xml->foo = 'bar'; only for text content, you still have to do $xml->foo->addChild('bar', 'text'); to add a child element. We generally don't do text content in QF2 and semantics of $form->foo = array('bar') are difficult to understand, IMO. Are we adding element of type 'bar' named 'foo' or vice versa? What happens if form already contains element named 'foo' (or 'bar')? Current __call()-based methods $form->addBar('foo'); or $form->addFoo('bar'); are sufficiently short, IMO. And less confusing. I do think magic __get() / __isset() methods can be implemented as a shorthand for getElementById(), though. But let's keep this stuff read-only. ------------------------------------------------------------------------ [2011-11-07 21:42:13] mansion I like this too, but we have to check for side cases first. With ArrayAccess, things can get ugly. ------------------------------------------------------------------------ [2011-11-07 18:24:02] cweiske I'd love to see this. ------------------------------------------------------------------------ [2009-01-12 10:41:32] cybot very short incomplete example usage: $form['container'] = array('fieldset'); $form['container']['element_id'] = array('text'); echo $form['element_id']; echo $form['container']['element_id']; unset($form['container']); with Smarty: {$form.element_id} {$form.container.element_id} ------------------------------------------------------------------------ [2009-01-12 10:28:51] cybot Description: ------------ These patch implements arrayAccess Interface into HTML_QuickForm2_Container ------------------------------------------------------------------------ -- Edit this bug report at https://pear.php.net/bugs/bug.php?id=15618&edit=1

« previous php.pear.bugs (#8500) next »