Re: [PEPr] 0 for PHP::PHP_ArrayOf

From: Date: Fri, 25 Apr 2008 14:56:51 +0000
Subject: Re: [PEPr] 0 for PHP::PHP_ArrayOf
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-49896@lists.php.net to get a copy of this message
Alan Knowles wrote: > Alan Knowles (http://pear.php.net/user/alan_k) has voted 0 on the proposal for > PHP::PHP_ArrayOf. > > Proposal information: > http://pear.php.net/pepr/pepr-proposal-show.php?id=518 > Vote information: > > http://pear.php.net/pepr/pepr-vote-show.php?id=518&handle=alan_k > > Comment: > > I'm a bit perplexed about what use this package is, > > - adding contraint's that throw exceptions / errors when adding to arrays, > appears to be just hiding code, and supprising coders.. > The package is only to be used if you want to do typed arrays. So if an array can accept anything, there is of course no point of using this. I wouldn't use it for basic variable types either, since PHP is loosely typed. The purpose is to: - Be able to use strongly typed arrays as part of type hinting for instance. - Provide array access with [] while encapsulating the checking of data, so you don't have to do "if (!($a instanceof Class_Here)) { throw new Exception();..." in every methods that expect data. - Help write better code and catch errors sooner to avoid WTF when sometimes only passing regular arrays. As with every tool, there is also performance hit, so this is not necessarily for everyone. But neither are all the PEAR packages. But you know the all dev time vs. hardware cost, and so on... > - (I would probably be pissed if I had to edit someone's code who had used this). It's up to you ;-) But if oranges are required, and you're passing apples, wouldn't you want to know about it instead of saying "but it's a fruit"? As long as whatever application is using this package is well documented (and with type hinting, it's self-documented), nobody should really be caught by surprise. > Anyway. > General Comments > - Exception file looks very cluttered. All that @licence, @author on each > class is a huge overkill? > Each class should have a class docblock header, so do exceptions. But yeah, agree it adds lines, if PEAR CS are updated to exclude Exceptions from this requirement, then the extra docblocks/tags could be dropped. > - Not sure the name 'ArrayOf' really defines what the class is supposed to > do, or it's purpose. - (It's purpose being a little unclear...) > I'm opened to suggestion for the name. Keep in mind that the class is abstract, so you could give it whatever name you like when you extend it. > I'm tempted to -1 it.. but not so aggreesive in my old age ; That's why there's PEPr :-) -Philippe

« previous php.pear.dev (#49896) next »