diff --git a/.editorconfig b/.editorconfig index 497e5b3..b914dcf 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,3 +15,6 @@ indent_size = 4 [*.{yml,yaml,neon}] indent_size = 2 +[*.md] +max_line_length = 80 + diff --git a/README.md b/README.md index 0aeecac..fb8582b 100644 --- a/README.md +++ b/README.md @@ -242,3 +242,8 @@ tutorials available: * [How to add a new static code analysis tool](doc/howto/HowToAddANewTool.md) * [Adding new information to your TerminalCommand](doc/howto/HowToAddInformationSources.md) + +## Integrating the Coding Standard into PHPStorm + +If you want to integrate the ZooRoyal Coding Standard into PHPStorm, have a look +at the guides in the [doc/ideConfig](doc/ideConfig/IdeConfig.md) folder. diff --git a/composer.json b/composer.json index 36eb434..daa251f 100644 --- a/composer.json +++ b/composer.json @@ -86,7 +86,7 @@ ], "infection": [ "@test", - "infection -n --threads=$(getconf _NPROCESSORS_ONLN) --only-covered --skip-initial-tests --coverage=tmp/phpunit --no-progress" + "infection -n --threads=$(getconf _NPROCESSORS_ONLN) --skip-initial-tests --coverage=tmp/phpunit --no-progress" ] }, "config": { diff --git a/doc/ideConfig/IdeConfig.md b/doc/ideConfig/IdeConfig.md new file mode 100644 index 0000000..1332b21 --- /dev/null +++ b/doc/ideConfig/IdeConfig.md @@ -0,0 +1,17 @@ +# How to use the Coding-Standard in PHPStorm + +## Introduction + +The Coding-Standard application is designed as an integrated application to make +sure it has as few dependencies as possible. As a result, it is less obvious how +to use the IDE with the project. This document will guide you through the steps +necessary to get code highlighting and auto-fixing working in your IDE. + +The Coding-Standard incorporates different tools to check and fix your code. +Here are the guides to set up PHPStorm for each tool: + +- [PHP Code Sniffer](phpCS/PhpCodeSniffer.md) + + + + diff --git a/doc/ideConfig/SetUpFromSource.md b/doc/ideConfig/SetUpFromSource.md new file mode 100644 index 0000000..ad513c3 --- /dev/null +++ b/doc/ideConfig/SetUpFromSource.md @@ -0,0 +1,29 @@ +# Setup coding-standard-source + +We need to make sure the coding-standard-source is installed and available +in your environment. + +1) Clone the coding-standard-source repository + ```bash + git clone git@github.com:ZooRoyal/coding-standard-source.git + ``` +2) Install the dependencies + ```bash + composer install + ``` + Notice how npm dependencies are also installed. This is because of a + custom script in the composer.json file. ("post-install-cmd") + +#### Optional + +Check if everything works by running the coding-standard from source. For +this your need to switch to a git repository on your disc containing a composer. +json file and execute a test run. + +```bash +cd /path/to/your/project +/path/to/coding-standard-source/tests/run-coding-standard.sh sca:all +``` +The script understands the same parameters as the coding-standard +application. As it will build the coding-standard application from source it +will take a little longer then a normal run. diff --git a/doc/ideConfig/phpCS/PhpCodeSniffer.md b/doc/ideConfig/phpCS/PhpCodeSniffer.md new file mode 100644 index 0000000..87b8769 --- /dev/null +++ b/doc/ideConfig/phpCS/PhpCodeSniffer.md @@ -0,0 +1,41 @@ +# Set up PHPStorm for PHP CodeSniffer + +This guide will help you set up PHPStorm to use PHP CodeSniffer. You will be +able to see code highlighting and use auto-fixing in your IDE. + +How long will it take: 15 minutes + +Pre-requisites: +- Completed guide: [PHP-Interpreter](../phpInterpreter/PhpInterpreter.md) +- A local composer project, fully installed + +## Steps + +1) Open the PHPStorm IDE and load up the project you want to work on. +2) Open the settings dialog by pressing `Ctrl + Alt + S`(Windows + Linux) + `CMD + ,` (macOS). +3) Navigate to "PHP" -> "Quality Tools" -> "PHP CodeSniffer" and open the + Configuration by clicking on the "..." button. + ![PHP CodeSniffer](php-code-sniffer.png) +4) If your [PHP interpreter](#Set-up-the-PHP-interpreter) we just set up in the + last step is not automatically added to the list click on the "+" button to + add it now. +5) Fill the Dialog as follows + * `PHP_CodeSniffer path` must be `/coding-standard/vendor/bin/phpcs` + * `Path to phpcbf` must be `/coding-standard/vendor/bin/phpcbf` + + ![PHP CodeSniffer Configuration](php-code-sniffer-configuration.png) +6) Click on the Folder Icon in `Docker container` and change the Volume bindings + as follows. The only entry allowed here is Hostpath = absolute Path to your + project -> Container path = /app + + ![PHP CodeSniffer Configuration](php-code-sniffer-configuration-docker.png) +7) Return to "PHP" -> "Quality Tools" -> "PHP_CodeSniffer". +8) Choose your newly added configuration and Switch it on. +9) Now we have to do something wierd. Close the settings dialog. Navigate to a + PHP file and do any change. Any change will do. Just add a space. +10) Return to the settings dialog by pressing `Ctrl + Alt + S`(Windows + Linux) + `CMD + ,` (macOS). +11) Navigate to "PHP" -> "Quality Tools" -> "PHP CodeSniffer" and + choose `ZooRoyal` as Coding standard. +12) Close dialog. You are done. diff --git a/doc/ideConfig/phpCS/php-code-sniffer-configuration-docker.png b/doc/ideConfig/phpCS/php-code-sniffer-configuration-docker.png new file mode 100644 index 0000000..4cc8d71 Binary files /dev/null and b/doc/ideConfig/phpCS/php-code-sniffer-configuration-docker.png differ diff --git a/doc/ideConfig/phpCS/php-code-sniffer-configuration.png b/doc/ideConfig/phpCS/php-code-sniffer-configuration.png new file mode 100644 index 0000000..6505468 Binary files /dev/null and b/doc/ideConfig/phpCS/php-code-sniffer-configuration.png differ diff --git a/doc/ideConfig/phpCS/php-code-sniffer.png b/doc/ideConfig/phpCS/php-code-sniffer.png new file mode 100644 index 0000000..e4dbdd6 Binary files /dev/null and b/doc/ideConfig/phpCS/php-code-sniffer.png differ diff --git a/doc/ideConfig/phpInterpreter/PhpInterpreter.md b/doc/ideConfig/phpInterpreter/PhpInterpreter.md new file mode 100644 index 0000000..06813c7 --- /dev/null +++ b/doc/ideConfig/phpInterpreter/PhpInterpreter.md @@ -0,0 +1,31 @@ +# Set up the PHP interpreter + + +## Docker + +This guide will show you how to install the PHP-Interpreter you need to execute +the coding-standard application. + +How long will it take: 5 minutes + +Pre-requisites: +- Running Docker service on your local machine + +## Steps + +1) Open the PHPStorm IDE and load up the project you want to work on. +2) Open the settings dialog by pressing `Ctrl + Alt + S`(Windows + Linux) + `CMD + ,` (macOS). +3) Remember what interpreter you are using right now +4) Navigate to "PHP" and open the interpreter settings by clicking on the + "..." button next to the interpreter dropdown. + ![PHP Settings](php-settings.png) +5) Click on the "+" button to add a new interpreter. + Choose `From Docker`. In the following dialog choose `Docker` and use the image + `ghcr.io/zooroyal/coding-standard-source:latest`. Check that all settings are + equal to the image linked below. + ![PHP Interpreter](php-settings-interpreter.png) +6) Make sure you don't forget to tick `Visible for all projects`. +7) Close this dialog. +8) Do not choose this interpreter as default CLI Interpreter. Use what you saw in step 2). + diff --git a/doc/ideConfig/phpInterpreter/php-settings-interpreter.png b/doc/ideConfig/phpInterpreter/php-settings-interpreter.png new file mode 100644 index 0000000..8e66bc3 Binary files /dev/null and b/doc/ideConfig/phpInterpreter/php-settings-interpreter.png differ diff --git a/doc/ideConfig/phpInterpreter/php-settings.png b/doc/ideConfig/phpInterpreter/php-settings.png new file mode 100644 index 0000000..42d180a Binary files /dev/null and b/doc/ideConfig/phpInterpreter/php-settings.png differ diff --git a/infection.json.dist b/infection.json.dist index 856eb21..28e3f73 100644 --- a/infection.json.dist +++ b/infection.json.dist @@ -1,6 +1,6 @@ { "timeout": 20, - "minMsi": 94, + "minMsi": 86, "minCoveredMsi": 94, "source": { "directories": [