[development] Time for a new chapter of an endless debate

Jeremy Epstein jazepstein at gmail.com
Sun Jul 2 16:36:57 UTC 2006

Another advantage of arrays over objects, is that arrays work almost
exactly the same in PHP4 as they do in PHP5. By ditching objects, it
should make it much easier to keep Drupal compatible with both of
these PHP versions.

For example, I just discovered today that in PHP5, object variables
are always created as references to the underlying object. So when you
copy an object, you're just copying the reference (unless you clone
the object). And when you pass the object to a function/method, you're
passing the reference (whether or not the parameter is specified as
'by reference'). In PHP4, however, object variables are not
references, unless this is explicitly specified. If we don't use
objects anymore, we won't have to worry about differing behaviours
(across PHP versions) such as this one.

Objects are one of the most poorly designed constructs in PHP4,
whereas arrays are one of the best and most powerful constructs in all
of PHP. I'm all for using arrays across the board in Drupal.


On 7/3/06, Karoly Negyesi <karoly at negyesi.net> wrote:
> Hi,
> Drupal uses objects. Reasons are probably lost by now in the ancient past.
> PHP is still not the best. I can write:
> somefunction(array('this' => 'that'))
> while there is no similar construct for objects.
> Also we use arrays for links, menus, links and soon mails.
> So, I propose removal of objects on practical grounds: shorter notation
> and a very little memory gain.
> If you have an opinion please share but I think we are only furthered by
> _practical_ viewpoints. No theory can make Drupal faster or lower its
> memory usage.
> The change looks big but it's not, it's scriptable and I can whip up such
> a script in a very short time.
> Regards
> NK
> Ps. Readability issues? I do not think there is any difference.

More information about the development mailing list