Hello Andreas,
With @var you indicate the type of a specific property and, as I see it, can provide information regarding the type of the property, such as
whether it has a character limitations. Often the @var description is used in place of the summary or description of the element itself;
semantically sub-optimal but understandable (I do it too ;)).
the intention of the tag is to add information regarding the type of the value contained in the subsequent element.
If you have multiple properties in one statement and feel the need to provide a description for each of them then [..] use the @type's description (though I can't really recommend this).
2013/12/3 Mike van Riel <draco...@gmail.com>
Hello Andreas,
With @var you indicate the type of a specific property and, as I see it, can provide information regarding the type of the property, such as
whether it has a character limitations. Often the @var description is used in place of the summary or description of the element itself;
semantically sub-optimal but understandable (I do it too ;)).
Is this already documented or agreed upon somewhere, or is this your personal point of view or an observation from what most people do?(no offense, just asking)
My own post came from looking at the English meaning of "var" and "type" and "param", not from any observation of what others do - if I tried that, it would be very biased anyway, so pointless.
In human language, "var" ("variable") mean the entire thing such as $nCows, whereas "type" only means the type.From this human language perspective, with "var" or "param" I would expect all information about @nCows to be under this tag.
Using the term "var" only to describe the type conflicts with the human language meaning of "var" or "variable".Of course if enough people already use it this way, then maybe we should just go with the flow.
Btw, where would you put the "may range between 0 and 80." on a @param? If the @param also has a description?
If you have multiple properties in one statement and feel the need to provide a description for each of them then [..] use the @type's description (though I can't really recommend this).
And it would conflict with the natural language understanding of "type".
Not that I particularly like multiple properties in one statement.. but having a docblock syntax that *can* be used on multiple properties, without being semantically nonsense, seems like a good thing to ask for.
On 12/03/2013 01:31 PM, Andreas Hennings wrote:
@Mike,
which docblock syntax would you recommend for local variables, e.g. for $name and $plugin in
foreach ($plugins as $name => $plugin) {
..
}
Would you use @var or @type? Would you put the docblock within the foreach or outside? How do you distinguish both variables, if they are in the same docblock? Does it allow a type, information regarding the type, and a description about the purpose of the variable?
Does the deprecation of @var apply here, or is this only for properties?
The original purpose of `@var` was purely for properties (as described in the original documentation), it has become practice to use @var also for the situation that you describe but this is semantically incorrect. This is exactly why I propose to move to `@type`, to remove the ambiguity.
So my proposal would be:
```
/**
* @type string $name
* @type Plugin $plugin
*/```
foreach ($plugins as $name => $plugin) {
..
}
I'm a supporter of @type as a successor to @var that better describes what itactually does and has a name that logically applies to variables, properties, andconstants.The problem of what to do when you're describing two variables or whatever in the sameblock is a thorny one, but its something that PHPDoc in general is just not wellequipped for.
There MUST NOT be more than one property declared per statement.
I disagree, my opinion is that there should be no relationship or as little possible between PSRs. Also, I want PSR-5 to focus on syntax; not coding standards. Coding standards are in my opinion definitely out of scope for this PSR.
With that, sometimes it is necessary to concede that some things are not possible, our should be solved on the implementor's side, when using a specific coding construct.
As I see it, multiple properties in one declaration is fine. You can use multiple @type tags to define additional information for each property and the summary and description to provide details on that group of properties.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/9cba0cb2-d234-4f0f-8e8d-32e9353207ce%40googlegroups.com.
Do we really want to have to re-write every property docblock just because "@type" makes more sense?
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/9b2ec1a6-fe0d-41a6-9674-80003c714883%40googlegroups.com.
Guilherme,
For this reason there is a clause in PSR-5 that deals with conflicts.
All tags, and thus annotations, provided by third parties should be namespaced, or prefixed with a vendor string and hyphen, in order to comply with PSR-5.
It is impossible to prevent conflicts with all the annotations that are out there, and as such the only option that remains its to require all tags outside of PSR-5 to be namespaced.
For doctrine this is simple as doctrine is able to resolve namespaces aliases and as such you can use an alias to prefix the tag.
Kind regards,
Mike
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CAFp73Xvj2dc4aH6WgdwPEmPF5_9hhAtrqGpDvfADnUMYj54pMA%40mail.gmail.com.
Yeah, but... The real problem here, IMO, is that PSR-5 is proposing to invent completely new documentation tags where there is no real reason, aside from "ooooh, doesn't this seem like it would be beautiful".
Sorry, I'm sounding like a broken record, saying this same thing over and over again... But I really don't get it. If PSR-5's objective is to be beautiful, then by all means, make up as many new tags as you like and it will be lovely and pure and semantically clean, but no one will want to adopt it because it conflicts with standards in the rest of the industry, existing code, Doctrine, etc. If PSR-5's objective is to be a practical standard that tool projects and code projects can actually use, then be practical and drop @type in favor of @var, and make sure the other tags and standards are compliant with what people already think are the best practices.
Matthieu,
Do not worry, I did not find your text aggressive.
Naming conflicts between annotation users and PHPDoc will always be an issue, regardless of @type.
That two annotation providers did not clash earlier is
fortunate but is in my opinion also a coincidence. So the standard
needs a way to deal with conflicts. The easiest way is to
namespace your annotations as most providers already provide that
ability.
My alternate suggestion would be to allow
non-namespaced annotations but name someone, which I think would
be the PHPDoc standard, as being authoritative. That would still
mean that where annotation providers and the PHPDoc Standard
conflict that the PHPDoc Standard's interpretation is leading.
(simply put: annotation providers can change behaviour, PHPDoc
cannot after being approved).
If you think there are other ways to resolve a naming
conflict, please do suggest it. It is not my intention to make
things more difficult but I feel that such things should be
described in the PSR.
With regards to @type, it does not necessarily come out
of nowhere, it has been discussed between me, Chuck Burgess and
several contributors.
Also: @var is not replaced by @type but a new tag @type is
introduced and @var is deprecated. This means that people do not
have to change their property DocBlocks to be compliant but can
start using the new tag with properties, constants and variables
from this PSR on.
And tools will have to change after this PSR anyway due to the new syntax that is being introduced to cover the new features; so I don't think that is a showstopper in this case.
You mentioned that the meaning of the description for
@type and @var differ and there I disagree; property docblocks
have always had a summary, description and @var description;
nothing changes there. This PSR describes existing practices and
adds missing features. The only way we can base this on existing
experiences is by delaying this PSR, codify it in phpDocumentor,
wait 2 years until it is adopted and then retry this PSR.
Is this better than what I am attempting now?
My alternate suggestion would be to allow non-namespaced annotations but name someone, which I think would be the PHPDoc standard, as being authoritative. That would still mean that where annotation providers and the PHPDoc Standard conflict that the PHPDoc Standard's interpretation is leading. (simply put: annotation providers can change behaviour, PHPDoc cannot after being approved).
If you think there are other ways to resolve a naming conflict, please do suggest it. It is not my intention to make things more difficult but I feel that such things should be described in the PSR.
With regards to @type, it does not necessarily come out of nowhere, it has been discussed between me, Chuck Burgess and several contributors.
Also: @var is not replaced by @type but a new tag @type is introduced and @var is deprecated. This means that people do not have to change their property DocBlocks to be compliant but can start using the new tag with properties, constants and variables from this PSR on.
And tools will have to change after this PSR anyway due to the new syntax that is being introduced to cover the new features; so I don't think that is a showstopper in this case.
You mentioned that the meaning of the description for @type and @var differ and there I disagree; property docblocks have always had a summary, description and @var description; nothing changes there. This PSR describes existing practices and adds missing features. The only way we can base this on existing experiences is by delaying this PSR, codify it in phpDocumentor, wait 2 years until it is adopted and then retry this PSR.
Is this better than what I am attempting now?
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/91936fad-f8ce-4631-a64b-5dcc5f71cde3%40googlegroups.com.