Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tests/php-code-style/.php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

$APPROOT = dirname(__DIR__, 2);

echo $APPROOT;
$finder = PhpCsFixer\Finder::create()
->in($APPROOT)
->exclude(['oql', 'data', 'extensions'])
->notPath(['/env-*/', '/cache-*/', 'lib', 'vendor', 'node_modules'])
;

$config = new PhpCsFixer\Config();
return $config->setRiskyAllowed(true)
->setRules([
'@PSR12' => true,
'indentation_type' => true,
'no_extra_blank_lines' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => true,
'trailing_comma_in_multiline' => true,
])
->setIndent("\t")
->setLineEnding("\n")
->setFinder($finder)
;
17 changes: 17 additions & 0 deletions tests/php-code-style/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Code formatting tool used by iTop is PHP-CS-Fixer:
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/master


to check code style issues (no path provided means whole iTop code base):

```
cd tests/php-code-style/; composer install; cd -
tests/php-code-style/vendor/bin/php-cs-fixer check --config tests/php-code-style/.php-cs-fixer.dist.php [PATH]
```

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?


```
7 changes: 7 additions & 0 deletions tests/php-code-style/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"require-dev": {
"php": "^7.0 || ^8.0",
"friendsofphp/php-cs-fixer": "^3.89",
"phpstan/phpstan": "^2.1"
}
}
Loading