Jump to content

dexdyne

New Members
  • Posts

    5
  • Joined

  • Last visited

dexdyne's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Not strictly php, but this seems a reasonable place to ask If documenting a routine ( which may or not directly throw an exception ), but whichh calls another one which definitely DOES, how would one write the @throws lines in the procedure header? 1. Ignore the exceptions thrown by called routines. 2. Attempt to create and maintain a list of @throws which reflect ANYTHING the routine and its callees can throw. 3. List exceptions thrown by this routine explicitly, and add @throws as fred() for each routine we know is called and may throw something. 1. Is consistent and easy to maintain, but scarcely useful. 2. Is a maintenance nightmare. 3. Is a slightly smaller nightmare. I guess what is needed is an automated system that scans the routine source but I haven't been introduced to anything of that ilk. David
  2. Oh, and another goody, just a bit further down.. $smsTotal = array_pop($smsIds); if($smsId) { $smsId = intval($smsId); if($smsId < 0 || $smsId > $smsTotal) $smsId = NULL; } if $smsIds is an empty array, $smsTotal will be NULL, and here we are doing 'greater than' on it. I hope someone can assure me that NULL is arithmetically interchangeable with zero in PHP, or I've got a lot o f patches coming.
  3. Just as a follow-up, and on the same lines... it seems to me that the following code does in fact print "NO". I'm not sure if it is defined to do so, or in fact prints "YES" or "NO" at random. $x=array() if ($x) { echo "YES"; }else{ echo "NO" } Does the answer to that question relate to, and/or help with the main question?
  4. I have inherited some php code, but I am not a real php programmer. I have just chased down a bug, and I'd like some advice on it. The code is full of snippets like: $paramNum = ControlCentre::getElementIds(ControlCentre::PARAMETER, $bdb, 1, $filterType, $filterId); $numberOfDpText = $paramNum ? " - (".count($paramNum)." %datapoints)" : ""; Now getElementIds can return a NULL for failure, if the underlying sql reports one ( yes I know that's rubbish too ). It is defined as returning an empty array if there are no elements to report on, but it turns out that it returns a NULL for that situation too. I will eventually make it do what it says on the can, but there may/will be cascade effects on code like the above. So -- it is clear that the code does if() on a variable which may hold an array, or may be NULL. If this were C, then that would be a common, if mucky, method to ask if ( NULL == $paramNum ) but this ISN'T C. So - do the panel agree that the code snippet above is just basically rubbish programming, or is there something subtle in PHP that I don't grok which makes it sensible and well-defined.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.