-
-
Notifications
You must be signed in to change notification settings - Fork 108
Apply php-cs-fixer #112
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
Apply php-cs-fixer #112
Conversation
Current coverage is 99.70% (diff: 100%)@@ master #112 diff @@
==========================================
Files 53 53
Lines 3770 3777 +7
Methods 184 184
Messages 0 0
Branches 0 0
==========================================
- Hits 3767 3766 -1
- Misses 3 11 +8
Partials 0 0
|
2193f70
to
165e678
Compare
@@ -1,3 +1,5 @@ | |||
.php_cs.cache | |||
cs_fixer_tmp_* |
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.
I'm not terribly inclined to add these to .gitignore, but I'll wait to see what the others think about it.
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.
I've installed php-cs-fixer
as global vendor, normally I take this configuration in my global .gitignore,
but I thought for the other people who can run the tool, they can not have this configuration.
I've seen also, that you have .idea in your .gitignore, this line should be put in your global .gitignore configuration since .idea isn't realted to the project but to the ide used by programmer which can be different from person to person.
@@ -7,9 +7,8 @@ | |||
* There is a small difference between *Component and *Keyword classes: usually, | |||
* *Component parsers can be reused in multiple situations and *Keyword parsers | |||
* count on the *Component classes to do their job. | |||
* | |||
* @package SqlParser |
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.
I have to admit I'm a little stumped by this, I've looked at several styleguides and none of them mention this. The phpdoc documentation still mentions it, so it doesn't seem to be deprecated. I'm just confused about it.
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.
I think it makes less sense since namespaces were introduced, so it's probably okay to remove.
* @param Parser $parser The parser that serves as context. | ||
* @param TokensList $list The list of tokens that are being parsed. | ||
* @param array $options Parameters for parsing. | ||
* @param Parser $parser the parser that serves as context |
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.
This also doesn't quite make sense, and conflicts with the samples provided here. For me, it's much more readable to have the sentence (or phrase) start with a capital letter. The trailing period, I'm rather indifferent about; ideally I don't mind seeing it go away since these are often only phrases anyway.
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.
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.
This behavior is configurable
'UPGRADE' => array(1, 'var'), | ||
'COLLATE' => array(2, 'var'), | ||
'DEFAULT COLLATE' => array(2, 'var'), | ||
'CHARACTER SET' => array(1, 'var'), |
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.
I tend to prefer having everything lined up, but I'm not strictly tied to that.
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.
On the other side the lined up parts are harder to maintain (you need to reindent whole block when adding something longer).
); | ||
|
||
/** | ||
* All view options | ||
* All view options. |
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.
Now the tool seems to be making things up; earlier it was removing periods after full sentences and now it's adding them to a few words. I'm not sure what to make of this.
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.
Probably it's a sentence for it as it starts with capital letter :-)
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.
PhpDoc makes different summary
and description
sections. https://www.phpdoc.org/docs/latest/guides/docblocks.html#summary
Summay The summary is a short but effective overview of an element.
Description A description can be a long text with an elaborate explanation what the associated element does. The description is optional.
As I read, the texts after @var
and @param
are descriptions
https://www.phpdoc.org/docs/latest/references/phpdoc/tags/var.html#examples
|
||
/** | ||
* Counts brackets. | ||
* | ||
* @var int $brackets | ||
* @var int |
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.
This seems wrong to me; I don't think it should be removing the variable name from the 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.
The name is required only if you refer
https://www.phpdoc.org/docs/latest/references/phpdoc/tags/var.html
In this case the name of the property MAY be omitted
* | ||
* @return string | ||
*/ | ||
public static function build($component, array $options = array()) | ||
{ | ||
$ret = $component->options . ' '; | ||
$ret = $component->options.' '; |
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.
Looking at some comments on PSR-1 (not the standard itself, which doesn't seem to say anything), this seems opposite the intentions of the PSR. In all the discussion and examples around it, they use the spaces on both sides. I think the spaces make it much more readable, so I'd vote to keep the spaces, too.
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.
I also prefer to have spaces around docs.
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.
This behavior is configurable
* | ||
* @return AlterOperation | ||
*/ | ||
public static function parse(Parser $parser, TokensList $list, array $options = array()) | ||
{ | ||
$ret = new AlterOperation(); | ||
$ret = new self(); |
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.
This is an interesting change.
* | ||
* @return Expression | ||
*/ | ||
public static function parse(Parser $parser, TokensList $list, array $options = array()) | ||
{ | ||
$ret = new CaseExpression(); | ||
$ret = new self(); |
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.
This is also interesting.
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.
This will do the same
Hi @bigfoot90 and thanks for your submission. Some of the changes definitely look good, and some of them are not things I personally would change. I'd like to see some discussion from the rest of the team on these. For phpMyAdmin itself, we use our own hybrid (and loose) styleguide which mostly based on the PEAR styles. It might be good to enhance this and particularly to update it (for instance, PSR now makes recommendations about namespaces that weren't possible a few years ago). |
See phpmyadmin/sql-parser#112 Signed-off-by: Michal Čihař <michal@cihar.com>
See phpmyadmin/sql-parser#112 Signed-off-by: Michal Čihař <michal@cihar.com>
Anyway I think we should first agree on coding style and then enforce it, not the other way around :-). However I find this really useful, I've added it to motranslator and shapefile libs (with minor adjustments such as whitespace around
|
@@ -17,86 +15,84 @@ | |||
* Parses an alter operation. |
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.
Duplicated comment, see before namespace
19668cf
to
4f5cac4
Compare
Sorry, closed this wrong. My mistake. Please read my comments anyway. |
Apply php-cs-fixer
https://github.com/FriendsOfPHP/PHP-CS-Fixer