-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DRAFT, WIP] PSR-5: PHPDoc Standard #169
Conversation
See phpDocumentor/phpDocumentor@0dbdbfa#docs/PSR.md for the original draft written by the same editor and contributors. This is a continuation of that version (hence the deeplink since the document will be removed from the repository).
Chuck's review
Fix indenting issues
Remove extraneous lines from null keyword example
Don't use single type notation for mixed type arrays
Fixing links to the Tags, which has been moved from section 7, and is now section 8. Also fixing @uses to be 8.23 instead of a second 8.22. (I also noticed there is a missing section that is in the index "Describing anonymous functions", but I didn't touch that).
Fixing internal links to the tags
@nikic has pointed out several shortcomings to the ABNF for types, his suggestion is a solid improvement to the BNF and has been used. One modification has been made; the 1*SP in the generic definition has been replaced with *SP to allow zero spaces as well.
Markdown wasn't seeing the unordered list as nested, so the list items were appearing as: 1. * * * 1. It now appears correctly as: 1. * * * 2.
There are several mentions of "File-Level" throughout the documentation, but one inconsistent reference to the previous term of "Page-Level".
6.3. Constant Or Property | ||
7. Describing hashes | ||
8. Describing anonymous functions | ||
8. Tags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are there two 8.
?
I can't find "Describing anonymous functions" anywhere in the document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are @access and @static not being added?
Why are there changes for PSR-4? |
Adding it as a new tag seems a bit much to me, mainly because it is more or less a specialisation for A DocBlock's strength is that it sits close to the code that it documents and by referring to, for example, a tutorial you are possibly negating that strength since it is no longer purely about the method. This is a bit of a unit test versus integration test situation where the DocBlock itself is equal to a unit test in scope and a tutorial more of a integration test. Also: by referencing an external location, especially a relative one, one will run a higher risk of referring to non-existing documentation |
|
||
> An exception to this principle is the File-level DocBlock which MUST be | ||
> placed at the top of a PHP source code file as the first DocBlock in a | ||
> file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this implying that every single file in a project must have a file-level docblock?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add an , if present
:
An exception to this principle is the File-level DocBlock which, if present, MUST be
placed at the top of a PHP source code file as the first DocBlock in a file.
For non-static methods (implemented via What about static methods (implemented via If otherwise |
@mlocati +1, I'm already using this with PhpStorm: https://github.com/ICanBoogie/ActiveRecord/blob/master/lib/ActiveRecord/Helpers.php#L17 Just a thought about @method, starting PHP7 the return type of a function may be defined as follows: function foo(): array {
return [];
} Maybe |
@mlocati Good point. |
Replace "ABFN" by "ABNF"
Fix typo in table of contents
Regarding docblock inheritance for methods: are docblocks inherited from trait methods? For example, if class Similarly, if method EDIT: I've made a ticket for this here [1], my apologies for disturbing the PR. |
@Gert-dev yes, traits should be considered in the way you described imo. |
(Moved my post to a separate ticket here [1].) |
I think that we should adopt the most restrictive approach. Think for instance at this example: /**
* @param string $name
*/
function printName($name)
{
if ($name === '') {
echo 'You belong to the Anonymous team ;)';
} else {
echo "Your name is $name";
}
} |
This should be merged anyway as proposed PSRs live in the main repo. |
callable is no longer pseudo
This PR represents the current state of affairs with the PHPDoc Standard. Until this description and subject is altered this PR is considered a Work in Progress and not ready for a final review.
All feedback is welcome, please direct this to the PHP-FIG mailing list to prevent noise in this PR. This PSR covers so many subjects that unless the discussions are separated by topic that it will probably be quite impossible to follow in this PR.
I would also request that people open a thread per issue they would like to discuss and not combine several issues in a single mail; this will help to keep noise-levels down in discussions and for me to loook back or filter important information.
TODO items are tracked in the issue tracker for this PSR: https://github.com/phpDocumentor/fig-standards/issues