Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [phoenix-dev] ProjectInfoAPI Documenation

I discovered a bit of a limitation in the class in that things which are usually arrays like newsgroups or mailinglists return non-array data when only one entry is present. That requires that your code check every time it gets something back to see if it's an array or not. So Bjorn came up with the idea of allowing you to request the key as a plural word and always get back an array even if there is only 1 element. I implemented this in the attached file. So for example, say the ECF project has only 1 mailing list. If I said:

$x = $projectinfo->mailinglist
if(count($x) > 1) {
   ...
}

I get a fatal error on count() unless I check is_array() every time first. Then I have to have two paths everywhere in my code where I use the data. Instead with the attached version (incorporating Nathan's fix) I can say:

$x = $projectinfo->mailinglists   <--------- note the 's'
if(count($x) > 1) {
  ...
}

And get no error. And I don't have to check is_array() every time I use the data nor maintain multiple paths through my code.

Also, I implemented Countable on each of the two classes allowing you to say count($projectinfo) to see how many keys you got back. Or count($projectinfovalues) to see how many fields you have for a mainkey.

Cheers,

Karl



Karl Matthias wrote:
+1 Looks great to me.

Karl

Bjorn Freeman-Benson wrote:
Nathan,
Thanks for the code review and fix.
+1

- Bjorn

Nathan Gervais wrote:
Can we get some more +1's to move this forward?

------------------------------------------------------------------------

_______________________________________________
phoenix-dev mailing list
phoenix-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/phoenix-dev
_______________________________________________
phoenix-dev mailing list
phoenix-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/phoenix-dev

Attachment: projectinfo.zip
Description: Zip archive


Back to the top