Skip to content

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

Closed
wants to merge 0 commits into from
Closed

Conversation

bigfoot90
Copy link
Contributor

@codecov-io
Copy link

codecov-io commented Jan 3, 2017

Current coverage is 99.70% (diff: 100%)

Merging #112 into master will decrease coverage by 0.21%

@@             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          

Powered by Codecov. Last update 082a1fa...165e678

@bigfoot90 bigfoot90 force-pushed the php-cs-fixer branch 2 times, most recently from 2193f70 to 165e678 Compare January 3, 2017 00:10
@@ -1,3 +1,5 @@
.php_cs.cache
cs_fixer_tmp_*
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor

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
Copy link
Member

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO it looks better in the documentation as sentences, but I'm quite okay with both choices.

class_sqlparser_component_-_2017-01-03_10 08 33

Copy link
Contributor Author

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'),
Copy link
Member

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.

Copy link
Contributor

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.
Copy link
Member

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.

Copy link
Contributor

@nijel nijel Jan 3, 2017

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 :-)

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

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.' ';
Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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();
Copy link
Member

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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also interesting.

Copy link
Contributor Author

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

@ibennetch
Copy link
Member

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).

nijel added a commit to phpmyadmin/motranslator that referenced this pull request Jan 3, 2017
See phpmyadmin/sql-parser#112

Signed-off-by: Michal Čihař <michal@cihar.com>
nijel added a commit to phpmyadmin/shapefile that referenced this pull request Jan 3, 2017
See phpmyadmin/sql-parser#112

Signed-off-by: Michal Čihař <michal@cihar.com>
@nijel
Copy link
Contributor

nijel commented Jan 3, 2017

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 . operator) right now as the outcome is less problematic there:

@@ -17,86 +15,84 @@
* Parses an alter operation.
Copy link
Contributor Author

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

@bigfoot90 bigfoot90 closed this Jan 3, 2017
@bigfoot90 bigfoot90 deleted the php-cs-fixer branch January 3, 2017 21:03
@bigfoot90 bigfoot90 restored the php-cs-fixer branch January 3, 2017 21:04
@bigfoot90
Copy link
Contributor Author

bigfoot90 commented Jan 3, 2017

Sorry, closed this wrong. My mistake.
Why there are 0 commints and 0 file changed?

Please read my comments anyway.

@bigfoot90 bigfoot90 mentioned this pull request Jan 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants