Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@odain-cbd
Copy link
Contributor

@odain-cbd odain-cbd commented Oct 6, 2025

Nice tool to automatically parse code and find out code style issues.
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/master

cd tools; composer install
tools/vendor/bin/php-cs-fixer check 
tools/vendor/bin/php-cs-fixer fix

In a future we could even reformat whole code base. and then be notified by CI when code style is not respected....

@odain-cbd odain-cbd self-assigned this Oct 6, 2025
@odain-cbd odain-cbd added the internal Work made by Combodo label Oct 6, 2025
@Molkobain
Copy link
Contributor

Great initiative! 🙌

Two things we should discuss as a team:

  • Put it in a dedicated folder under tools/ (e.g. tools/php-code-standards-fixer) so if if we add another one (e.g. for JS), its already structured correctly (to avoid the issue we add with tests).
  • Ensure it follows our code standards as described in the wiki or accept that our new coding standard should be PSR-2 or PSR-12.

Extras to check afterwards (did you already take a look?):

  • Add something to the iTop / modules projects so it runs automatically on pre-commit on the dev environment.

@Hipska
Copy link
Contributor

Hipska commented Oct 7, 2025

A nice to have would also be to have this as an action on GitHub pull requests, so contributors (internal and external) would immediately see if te changes are conform the defined coding standards.

@odain-cbd odain-cbd changed the base branch from develop to support/3.2 October 9, 2025 14:46
@odain-cbd odain-cbd force-pushed the feature/php-cs-fixer branch from 0a03706 to 3040963 Compare October 9, 2025 15:09
@Molkobain
Copy link
Contributor

I've take a look at the rules described by Symfony. From my POV what you set is already a great start to propose to the team.

@odain-cbd odain-cbd closed this Oct 15, 2025
@odain-cbd odain-cbd reopened this Oct 15, 2025
Copy link
Contributor

@Hipska Hipska left a comment

Choose a reason for hiding this comment

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

The formatting changes on the files in /webservices (why only there?) seem to have changed indentation from tabs to spaces. Please revert.

https://www.itophub.io/wiki/page?id=3_2_0:customization:coding_standards#white_spaces_and_indentation

to respect iTop code standards and re-format (no path provided means whole iTop code base):

```
tests/php-code-style/vendor/bin/php-cs-fixer fix --config tests/php-code-style/.php-cs-fixer.dist.php [PATH]
Copy link
Contributor

@Hipska Hipska Oct 17, 2025

Choose a reason for hiding this comment

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

Maybe just move the .php-cs-fixer.dist.php to the root directory and add this in the main README?

When also moving composer, the command would then just become vendor/bin/php-cs-fixer fix [PATH], which is much easier/friendly to use.

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 agree with you. CLI would be shorter and that's what I started with.

but we prefer to keep such stuff apart. ie phpstan/phpunit/php-cs-fixer are gathered in tests folder to package iTop community easily without them. zip is heavy enough. packaging tools are simpler to maintain.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should not impact .zip size when putting in require-dev section of composer?

If that's the case, then why not using tests/composer.json instead?

@odain-cbd
Copy link
Contributor Author

The formatting changes on the files in /webservices (why only there?) seem to have changed indentation from tabs to spaces. Please revert.

https://www.itophub.io/wiki/page?id=3_2_0:customization:coding_standards#white_spaces_and_indentation

we will apply code style to whole code base. for now I did it partially to share future effects with the team/community.

@Hipska
Copy link
Contributor

Hipska commented Oct 17, 2025

The effect is now apparently to change tabs into spaces? That doesn't seem right?

@odain-cbd
Copy link
Contributor Author

The effect is now apparently to change tabs into spaces? That doesn't seem right?

side effect fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants