Looks good, but why do you introduce
> // Longer if format
> if (condition())
> {
> do_something();
> do_something_more();
> }
> else
> {
> do_something_else();
> }
now? AFAIR there was one single vote *for* it, all other prefer the PEAR
style...?
Regards,
Niels
--
| http://www.kolleg.de · Das Portal der Kollegs in Deutschland |
| http://www.bsds.de · BSDS Braczek Software- und DatenSysteme |
| Webdesign · Webhosting · e-Commerce · Joomla! Content Management |
------------------------------------------------------------------
> // short if format
> if (condition()) {
> &$do_something;
> }
Does the fact that there are tabs throughout this example also mean
that they are part of the proposed standard?
Jeremy Huntwork
LightCube Solutions
http://www.lightcubesolutions.com
First, used tabs again, which don't translate well to email/browser, I
know, but neither does space unless you force your email client into
monospaced font, so it's lose/lose.
Second, included almost every known docblock tag in this run (at least
99.44% of the ones likely to be used outside of testing) which is what
makes it long. The vast majority of these tags are optional, so let me
boil it down in this "annotated" version (presentation suggestions in
final paragraph):
NOTE: speed kills. In my haste I note I left in the param variable
name in the first posting, which the tenor of the discussion was going
against. I've removed it in the annotated version below.
Means Short file description, version, copyright and license are the
only required tags in the file docblock. Package and subpackage are
optional and should be used if there are elements in the file that are
not part of a class (loader.php comes to mind immediately as a file
that fits into this category, but I think even the "defined or die"
code in most files may be enough to trigger it in phpdoc). I really
don't see a use for category in the Joomla context, but since it's
semantically a collection of packages, I thought it should precede
package if present (same treatment for author before copyright, noting
that author should not be used for joomla core). I've tried to be
logical and consistent about the order, but now that I look at it
again, perhaps license after copyright is a more logical order.
Any tags I've not accounted for may be used, but only after the last
of these tags.
>
> // No direct access
> defined('JPATH_BASE') or die;
>
> /**
> * Short Description
> *
> * Optional longer description of the class
> *
> * @package Extensions
> * @subpackage ThisExt
> * @see [Optional]
> * @uses [Optional]
> * @link [Optional, core must link to Joomla URL]
> * @since 1.0 [Optional]
> * @deprecated 1.5 [Optional]
> * @ignore [Optional]
> * @internal [Optional]
> * @method [Optional]
> * @tutorial [Optional]
> * @access public | private | protected [Optional, as php5 subsumes
> these]
> * @abstract [Optional, as php5 subsumes it]
> * @todo [Optional]
> */
For class docblock, Short description, package and subpackage are the
only required tags. Perhaps subpackage even should drop to optional.
Tried to keep similar order for tags in common with file.
> * @param string description.
> * @param mixed description.
I realized as I was making this, I may still be confused on brace
style, so this is what I *think* the hybrid style mentioned was.
Please correct me if not right. It's not PEAR, I know.
Pretty much the rest of the file is either as before or the
differences have been discussed above.
>
> /**
> * Short Descriptor
> *
> * Optional Long description
> *
> * @param array description.
> * @param string description.
> * @param mixed A longer description that for readability
> * @param int description.
> *
> * @return int
> * @see [Optional]
> * @uses [Optional]
> * @link [Optional, core must link to Joomla URL]
> * @since 1.0 [Optional]
> * @deprecated 1.5 [Optional]
> * @ignore [Optional]
> * @internal [Optional]
> * @tutorial [Optional]
> * @access public | private | protected [Optional, as php5 subsumes
> these]
> * @abstract [Optional, as php5 subsumes it]
> * @todo [Optional]
> */
> private function _method3( $one )
> {
> while ($one > 0) {
> $one -= 1;
> }
>
> return (int) $one;
> }
>
>
>
> }
Again, any tags not listed are just dropped in a heap at the end, in
whatever order. If there's one I haven't accounted for, let me know
what it is and where it goes. If I'm listing tags we really don't care
about the order for, let me know and I'll drop them from here.
As for publication, It would seem to me the most accessible way to
present these tags would be with a different contrast on the
background for all optional tags, making it immediately clear the file
won't be filled with 1087 docblock comments. As an alternative, we
could present a file only with the required docblocks, and let people
writing code use the phpcs joomla coding standard use it to tell them
how their docblocks should be rearranged. A bit frustrating for them,
yes, but makes the initial file less daunting. Or use javascript to
show/hide optional docblock tags in the web page.
If there's a vote going on, then:
-1 for the above.
Excellent, thanks for the reply.
>> I thought you had argued in favour of parameter names in the doc blocks
>> and nobody really refuted your logic?
>
> You are half right. I am definitely in favor of them. But I was
> sensing resistance from Andrew and Chris at the least and got the
> impression Louis was on board with Chris, which puts a lot force
> behind leaving it out.
I strongly recommend to keep the variable names in the docblock. It is
the only sign showing, that the docblock is in sync with the method.
Regards,
Niels
As far as I can remember it's always been the brace on the new line
(for Mambo and Joomla) and then the hybrid was introduced in 1.5.
"Back then" I had based in on the PEAR standard but it changes over
the years (so don't get too hung up on PEAR because it does move).
What I see a lot is when you have the brace on the one line, and then
a block of code, devs put in a new line to provide readable space. In
my opinion, why not just put the brace on the new line _shrug_. Eg:
if (condition) {
many
lines
of
code
}
Makes more sense to just do:
if (condition)
{
many
lines
of
code
}
Personally I think this forces extra white space in a good way and I
like to see a balance use of breaks to improve readability. That's my
take :)
Regards,
Andrew Eddie
I know this is the style I'm used to, so I'd have to vote for it.
if (condition)
{
echo
print
whatever
}
Gets really cluttered for me. Way back in the day, it's how I wrote
my blocks, but no longer.
> I'm as yet still unsure what I think the best use of
> package/subpackage/category is.
I'd think something along the lines of:
Joomla/Library/Filters
Joomla/Library/Base
Joomla/Component/Content
Joomla/Includes/DatabaseAccess
--
Ed Stafford
We're talking about them only in terms of the docblock, I think. Which
On Nov 4, 11:23 am, Louis Landry <louis.lan...@joomla.org> wrote:
> As much as I love my tabs, I am starting to see the way of the spaces. That
> being said, I wonder what kind of impact that is going to have on file size?
might mean an extra 50-100 bytes per file. The "--tab-width=4" option
on phpcs pretty much allows them everywhere else, and I don't see a
real gain in replacing tabs with spaces as original line indents.
> I'm as yet still unsure what I think the best use ofI'm growing more convinced category doesn't belong here. There doesn't
> package/subpackage/category is.
appear to be a meaning for it in phpdoc that I've been able to notice
(unlike package/subpackage) and its existence seems only to spawn
confusion.
Looking more seriously over this, why is "Joomla" part of category/
package/subpackage considerations? Isn't *everything* here part of
that, and wouldn't 3PD's be using their own package/subpackage
arrangements? A level of a hierarchy with only one value isn't really
a level at all.
> I would, however, lean towards making @since a required tag because I doOK, filling that info in accurately might require some research,
> find it useful when looking at documentation to know which versions of the
> software something became available for.
though.
Tabs are the current and past standard (has been since 2003).
Yes, it does. switch as well.
> Does the "brace on line by itself" style hold not only for if, but for
> the other control structures (do, while, for) as well?
Yes, it does.
> Oh, and the hybrid idea is going to be hard to implement. Codesniffer
> wants a single signature for a control signature. If it's going to
> vary with length of coding block below it, I'm going to have (re)write
> a chunk of the sniffer code itself, AFAICT.
With only very few exceptions, the PEAR style is used in the core (and
evrywhere else). I see no benefit in changing that. The "brace on line
by itself" style is C, not PHP.
Regards,
Niels
--
| http://www.kolleg.de · Das Portal der Kollegs in Deutschland |
| http://www.bsds.de · BSDS Braczek Software- und DatenSysteme |
| Webdesign · Webhosting · e-Commerce · Joomla! Content Management |
------------------------------------------------------------------