Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comment | File | Size | Author |
---|---|---|---|
change-boolean-to-bool.patch | 4.34 KB | pillarsdotnet | |
change-bool-to-boolean.patch | 3.5 KB | pillarsdotnet | |
Comments
Comment #1
webchickWhen 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. :)
Comment #2
Lars Toomre CreditAttribution: Lars Toomre commentedWow... 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.
Comment #3
Lars Toomre CreditAttribution: Lars Toomre commentedWhoops... cross-post.
Comment #4
pillarsdotnet CreditAttribution: pillarsdotnet commented@Lars Toomre:
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:
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.
Comment #5
pillarsdotnet CreditAttribution: pillarsdotnet commentedRemoving tag.
Comment #6
Lars Toomre CreditAttribution: Lars Toomre commentedBefore 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.
Comment #7
pillarsdotnet CreditAttribution: pillarsdotnet commented@Lars Toomre:
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:
Comment #8
pillarsdotnet CreditAttribution: pillarsdotnet commentedUpdated issue summary to reflect policy decision: #1290258: The data type should be explicitly stated for all Drupal core @param and @return documentation.
Comment #9
Lars Toomre CreditAttribution: Lars Toomre commentedI 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.
Comment #10
pillarsdotnet CreditAttribution: pillarsdotnet commented@#9:
That's a horrible example, and exactly what we're trying to avoid. Something like this would be better:
Comment #11
pillarsdotnet CreditAttribution: pillarsdotnet commentedTagging.
Comment #12
Lars Toomre CreditAttribution: Lars Toomre commentedRe #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.
Comment #13
pillarsdotnet CreditAttribution: pillarsdotnet commentedSorry, but "We" don't have permission to edit the page. Therefore, all "We" can do is sit back and complain about it.
Comment #14
Crell CreditAttribution: Crell commentedCuriously, 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.)
Comment #15
pillarsdotnet CreditAttribution: pillarsdotnet commentedThere is a similar inconsistency between
int
andinteger
. Core has it wrong; mostly.Comment #16
pillarsdotnet CreditAttribution: pillarsdotnet commentedI guess this should be duplicate, not fixed.
Further discussion at #711918: Documentation standard for @param and @return data types