Skip to content
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

Developer Guide: php-cs-fixer #295

Closed
1 of 2 tasks
mmattel opened this issue Apr 20, 2018 · 20 comments
Closed
1 of 2 tasks

Developer Guide: php-cs-fixer #295

mmattel opened this issue Apr 20, 2018 · 20 comments
Assignees

Comments

@mmattel
Copy link
Contributor

mmattel commented Apr 20, 2018

This is a reminder that this needs to be documented in the developer guide when the referenced PR gets merged: owncloud/core#31198 (php-cs-fixer fix . --rules=native_function_invocation)

@DeepDiver1975
Copy link
Member

THX @mmattel for taking care!

@mmattel
Copy link
Contributor Author

mmattel commented Apr 20, 2018

@mmattel
Copy link
Contributor Author

mmattel commented Apr 21, 2018

@settermjd referenced PR got merged. Removing Wait for PR.

@DeepDiver1975 pls help creating the doc. You can just paste your text here and we will setup it properly.

@mmattel
Copy link
Contributor Author

mmattel commented Apr 26, 2018

@mmattel mmattel changed the title Developer Guide: php functions should be called with their full namespace Developer Guide: php-cs-fixer Apr 27, 2018
@settermjd
Copy link
Contributor

Thanks @mmattel. I'll have this finalised this week.

@mmattel
Copy link
Contributor Author

mmattel commented May 1, 2018

Adding https://github.com/owncloud/core/blob/master/.php_cs as reference for the current parameters. Maybe useful to others when documented.

And https://veewee.github.io/blog/optimizing-php-performance-by-fq-function-calls/ as reference of the background and possible performance gains. (was in the core PR a link, just easier to doc it here too)

@patrickjahns
Copy link
Contributor

Later on the code style references will be available here: https://github.com/owncloud/coding-standard

We then need to see how much information needs to stay in the documentation - or if a link to a repository for further information makes more sense

@phil-davis
Copy link
Contributor

PR owncloud/core#31484 selects a (hopefully) better udiff format for the diff output. If any of that sort of detail is documented (diff sample...) then make sure to use udiff in the doc.

@settermjd settermjd removed their assignment Jul 2, 2018
@mmattel
Copy link
Contributor Author

mmattel commented Aug 10, 2018

I just stumbled while writing a PR over a complaint of drone/php-cs-fixer. The code itself was fine.
I got some time ago a tip from @phil-davis how to fix that on the command line which I now cant find anymore. Remembering that I filed this issue, I looked what progress has been made and saw no changes. It would be really good to have some documentation for developers to support code writing and ease debugging with respect of php-cs-fixer related topics.

@phil-davis
Copy link
Contributor

When you do:

make test-php-style

It spits out output that includes the actual command line it is running:

lib/composer/bin/php-cs-fixer fix -v --diff --diff-format udiff --dry-run --allow-risky yes

To make it fix the things it finds, just take off the --dry-run

lib/composer/bin/php-cs-fixer fix -v --diff --diff-format udiff --allow-risky yes

Then when you make test-php-style again, it will be happy.

When someone documents this thing, this can be included as a handy hint.

@mmattel
Copy link
Contributor Author

mmattel commented Aug 20, 2018

The path given above lib/composer/bin/ may be dependent of how the repro is setup and must be used according the actual paths used. In files_primary_s3 it is vendor/bin/.

@mmattel
Copy link
Contributor Author

mmattel commented Aug 20, 2018

Additional note made by experience:
if you use a namespace and extend the class, the extending class name MUST NOT have a php reserved name. I case you have that, you may get a "linting" error of php-cs-fixer and no checks are made.

@settermjd
Copy link
Contributor

@mmattel, is this addressed now?

@patrickjahns
Copy link
Contributor

We are trying to establish two make-file targets for the time being:

  • test-php-style -> check for errors and exit with failure ( used in CI or pre-commit hooks )
  • test-php-style-fix -> fix detected errors

Example:
https://github.com/owncloud/password_policy/blob/master/Makefile#L114-L122

@patrickjahns
Copy link
Contributor

Also note:

We are moving towards segregating cli tool dependencies into vendor-bin folders - example also in
https://github.com/owncloud/password_policy/blob/master/Makefile

This has the benefit, that tools can fetch their dependencies independently from the ownCloud app. As the CLI tool can have any dependency and not affect the app itself.

@mmattel
Copy link
Contributor Author

mmattel commented Sep 7, 2018

@patrickjahns it would be great to start documenting these things, even not 100% ready or final. Currently there is nothing. I am lacking knowledge to write the text...

@settermjd
Copy link
Contributor

@patrickjahns, when more concrete information's available, can you provide the core text for the docs, pls?

@phil-davis
Copy link
Contributor

One question is what to document. make test-php-style-fix can "just fix it" for you. So you can "shut your eyes" and write "randomly-formatted" code. Then let the fixer fix it for you :) If you do that, then you do not need to know what the standard is!

I guess we should document some links to the standard that is chosen (e.g. PSR-0, PSR-42, whatever) so that people have some idea what the style fixer is going to require/do.
But if we try to write much detail, then we will have to keep it up-to-date when the required style settings are changed.

@patrickjahns
Copy link
Contributor

patrickjahns commented Sep 24, 2018

The coding standard is open and has its own repository - https://github.com/owncloud/coding-standard/

Latest cs-fixer configuration is to be found in the repository
https://github.com/owncloud/coding-standard/blob/master/src/Config.php

And yes - we shall not write more details then the configuration provides by default. Running the make test-php-style will provide reasonable details of what is wrong

I do not see the point of updating a documentation for a changing part that will be clearly documented in code. 🤷‍♂️

@settermjd settermjd transferred this issue from owncloud-archive/documentation Nov 19, 2018
settermjd added a commit that referenced this issue Oct 22, 2019
This fixes #295, by adding a small, concise section on php-cs-fixer to
the developer docs. Specifically, it shows how to review and fix coding
standard violations using `make test-php-style` and `make
test-php-style-fix` respectively.
@phil-davis phil-davis self-assigned this Oct 22, 2019
@phil-davis
Copy link
Contributor

phil-davis commented Oct 22, 2019

Re-opening and assigning myself to write a few words about squizlabs/php_codesniffer

See PR #1976

@phil-davis phil-davis reopened this Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants