Re: [PEPr] Comment on PHP::PHP_ArrayOf

From: Date: Tue, 04 Dec 2007 05:30:27 +0000
Subject: Re: [PEPr] Comment on PHP::PHP_ArrayOf
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-48656@lists.php.net to get a copy of this message
Hi Chuck, You're right, it makes sense to go all-out and throw an exception when someone accesses an undefined key. Since the package is really about type hints and better control over the data/variable handled, might as well be more rigorous over the indexes. Thanks, -Philippe Chuck Burgess wrote: > Chuck Burgess (http://pear.php.net/user/ashnazg) has commented on the proposal for > PHP::PHP_ArrayOf. > > Comment: > > Looks well organized. > > I'm curious about using trigger_error() in the offsetGet() method though. > If the overall intent is strong typing behavior, would you want this > attempt to use a non-existent array offset to go unnoticed by anything but > a PHP Notice? I'd probably lean towards an exception here, to stay > consistent with enforcing strong typing and your otherwise global use of > exceptions... Java would give you an ArrayIndexOutOfBounds exception in > such a scenario. Not doing so seems to lean back a little towards PHP's > weak typing. > > I do like this package, though. I'm actually curious to see if there are > other packages that create strong typing wrappers for PHP, thereby avoiding > other pushes for PHP itself to become more strongly typed. Using this to > start a group of such packages together into a strong-typed object library > would make sense to me. > > Proposal information: > http://pear.php.net/pepr/pepr-proposal-show.php?id=518 >

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