Neither core nor coding standards set any clear precedent on which is preferred:

bobvin@bowie:~/www/8.x$ grep -r '@param bool ' includes modules | wc -l
7
bobvin@bowie:~/www/8.x$ grep -r '@param boolean ' includes modules | wc -l
12

May I get a ruling please?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webchick’s picture

Issue tags: -Needs committer feedback

When in doubt, we do as PEAR does, which according to http://pear.php.net/manual/en/standards.sample.php is 'bool'.

And please reserve the "Needs committer feedback" tag to things that are deadlocked or otherwise actually need a committer to take time away from committing patches to comment on. :)

Lars Toomre’s picture

Issue tags: +Needs committer feedback

Wow... I did not realize that a boolean value was so inconsistent in existing core documentation. I vote that we apply the change-boot-to-boolean.patch. bool should be fully spelled out and not abbreviated.

Before that patch is applied though, I would respectfully request that we also correct each of the incorrect docblocks that the resulting patch touches. For instance, in 'abstract class FileTransfer', there are a number of @param docs without explanation right after another. Also, in 'class UserRolesAssignmentTestCase extends DrupalWebTestCase', the @param explanation is not indented on the next line. While it will not clean up all of the offending docblocks, such fixes will make the documentation at least a bit better/compliant.

Lars Toomre’s picture

Issue tags: -Needs committer feedback

Whoops... cross-post.

pillarsdotnet’s picture

Category: bug » support
Status: Needs review » Closed (fixed)

@Lars Toomre:

Before that patch is applied though, I would respectfully request that we also correct each of the incorrect docblocks that the resulting patch touches.

Sorry; I didn't seriously mean for either of those two patches to be accepted as-is; I just need a decision so that I can properly re-roll the *other* patches that touch the same docblocks.

@webchick:

When in doubt, we do as PEAR does

I respectfully submit that PEAR does a lot of very wrong things, such as calling static functions in a non-static context, and vice-versa.

Nevertheless, since I've received an answer, I'll go ahead and close this.

pillarsdotnet’s picture

Removing tag.

Lars Toomre’s picture

Before this is closed, shouldn't we roll a patch for the examples section of the document standards? I am thinking we should also include an inline comment stating not to use 'boolean'. The other thought is wondering if @param bool or @param boolean currently exists in the D7 code base.

pillarsdotnet’s picture

@Lars Toomre:

Before this is closed, shouldn't we roll a patch for the examples section of the document standards?

How do you roll a patch to something with no "view source" button? And even if I extracted the source from this page (tedious but possible), how would a maintainer apply the resultant patch to the page?

As for your second question, that is easily answered:

bobvin@bowie:~/www/7.x$ egrep -r '@(param|return) bool(ean|) ' includes modules themes profiles | wc -l
26
pillarsdotnet’s picture

Lars Toomre’s picture

I was thinking of a patch for http://drupal.org/node/1354 something along the lines of:

* @param array $myarray
* An array.
* @param bool $flag // Nota bene: use bool and not boolean <-- added via patch
* A boolean variable (with values like TRUE or FALSE). <-- added via patch
* @param int $myinteger
* An integer.
* @param string $mystring

Hopefully this makes sense and @webchick can apply the resulting patch to document for all about her decision in this issue.

pillarsdotnet’s picture

@#9:

 * @param array $myarray
 *   An array.

That's a horrible example, and exactly what we're trying to avoid. Something like this would be better:

 * @param array $things
 *   A list of fooClass objects that will be passed to the whozit() function.
pillarsdotnet’s picture

Issue tags: +Coding standards

Tagging.

Lars Toomre’s picture

Re #9 - Sorry @pillarsdotnet.... Other than the two lines regarding bool/boolean, the rest of that text came directly out of Documenting functions and methods.

When we go in to correct/define the bool/boolean issue, we also need to go through and add type hinting throughout many of the examples on that page. We also should probably correct the example documentation as you proposed in #10.

pillarsdotnet’s picture

Sorry, but "We" don't have permission to edit the page. Therefore, all "We" can do is sit back and complain about it.

Crell’s picture

Curiously, both bool and boolean work when casting a variable to boolean. :-) Doesn't affect the decision, I just thought it was amusing. (If one of them had actually broken, that would have been our answer.)

pillarsdotnet’s picture

There is a similar inconsistency between int and integer. Core has it wrong; mostly.

pillarsdotnet’s picture

Status: Closed (fixed) » Closed (duplicate)

I guess this should be duplicate, not fixed.

Further discussion at #711918: Documentation standard for @param and @return data types