-
Notifications
You must be signed in to change notification settings - Fork 51
phpDoc annotation spacing #88
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
Conversation
if dpkg --compare-versions "$(composer show -n | grep squizlabs/php_codesniffer | tr -s ' ' | cut -d ' ' -f 2)" '>=' "3.3.2"; then | ||
xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd lib/Doctrine/ruleset.xml | ||
else | ||
echo "Validation skipped, PHPCS 3.3.2+ required" |
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.
Since this PR requires new property syntax for arrays, I put this conditional check in place. The ruleset is valid according to XML schema from 3.3.2-dev.
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.
Right now, we allow PHP_CodeSniffer ^3.1.1
. Given that the schema is invalid for versions <= 3.3.1
, will PHP_CodeSniffer 3.1.1 be able to process those rules?
Judging by the milestone of squizlabs/PHP_CodeSniffer#2154, the new schema will be available in 3.4.0, not in 3.3.2.
Why don't we just wait for a new release and bump the requirement? Otherwise, we may run into a PHP 6 situation.
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.
Yes it will, PHPCS itself doesn't validate the schema.
The referenced PR is not related to this part, we don't use the proposed extend
here.
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.
Addresses this problem: #84 (comment)
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.
So what is the 3.3.2 change which the XML validation depends on?
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.
squizlabs/PHP_CodeSniffer#2151
They forgot to update the schema to include the new <element>
syntax for arrays (available since 3.3.0).
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.
Gotcha. It'd be nice if they had validation internally as in PHPUnit (sebastianbergmann/phpunit#3048). Otherwise, the schema validity will have to be enforced by 3rd party's CI like ours.
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.
Possibly something for PHPCS 4.0. :)
From what I see in ODM we used to have no newline between |
I like this idea. Just for clarification: What exactly is a "annotation group"? Considering your example I would expect a newline between the |
@deeky666 My assumption was that you either:
But I may be wrong, I never worked with a hybrid application. |
@Majkl578 sure in this example it might not make much sense but if you have other annotation groups like from |
@deeky666 For annotations (or annotation namespaces) unspecied here, all unknown are put into a special group that is added at the end. Check the description here:
So for i.e. |
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.
🚢
Sniff to require a newline between between description and tags, a newline between annotation groups and no newline before/after phpDoc content.
Example:
This is based on spacing/format used in ORM, does this properly fit other projects (i.e. ODM) too?
Changes in ORM with this enabled are mostly (superfluous newlines) cosmetical: Majkl578/doctrine-orm@68920f1