First of all, let me list some versions so you know the setup.
OS: Windows 10
php: 7.2.7 NTS with xDebug 2.6.1 active
PhpStorm: 2016.2.2
PHP_CodeSniffer: version 3.4.0 (stable) by Squiz (http://www.squiz.net)
PEAR: 1.10.7
Now let me describe the problem:
The code sniffer was installed via pear. I'm using the following bat script for starting the sniffer.
@echo off
set folder=C:\Program Files\php
set phpcs=%folder%\phpcs
php "%phpcs%" %*
If I start the code sniffer via the PowerShell with the following command:
phpcs.bat index.php --standard=PSR2 --encoding=utf-8 --report=xml
I'm getting a valid output:
xml version="1.0" encoding="UTF-8"?>
<file name="C:\Users\simon\Documents\Repositories\mm-BIT\CatalogGenerator\index.php" errors="3" warnings="0" fixable="3">
<error line="1" column="1" source="Generic.Files.LineEndings.InvalidEOLChar" severity="5" fixable="1">End of line character is invalid; expected "\n" but found "\r\n"</error>
<error line="124" column="1" source="PSR2.Methods.FunctionCallSignature.SpaceBeforeOpenBracket" severity="5" fixable="1">Space before opening parenthesis of function call prohibited</error>
<error line="129" column="1" source="PSR2.Methods.FunctionCallSignature.SpaceBeforeOpenBracket" severity="5" fixable="1">Space before opening parenthesis of function call prohibited</error>
</file>
</phpcs>
In PhpStorm the setting looks like this:
If I validate the installation PhpStorm tells me everything is fine:
The data for the coding standards on the Inspections page was loaded automatically, so this seems to work as well.
If PhpStorm is running the script I'm getting the following error:
PHP Code Sniffer
phpcs: xml version="1.0" encoding="UTF-8"?>
I was exposing some data via the script which is getting called:
PHP Code Sniffer
phpcs: C:/temp/___1.tmp/Core/DataContainers/Language.php --standard=PSR2 --encoding=utf-8 --report=xml
command: php "C:\Program Files\php\phpcs" C:/temp/___1.tmp/Core/DataContainers/Language.php --standard=PSR2 --encoding=utf-8 --report=xml
xml version="1.0" encoding="UTF-8"?>
I did check the temp folder for writing permissions and was checking if the file is created correctly on the path mentioned above. I did copy the folder as soon as it was created and did run the command line by hand in the PowerShell successfully.
php "C:\Program Files\php\phpcs"
C:/temp/___.tmp/Core/DataContainers/Modules/SimpleTableModule.php --
standard=PSR2 --encoding=utf-8 --report=xml
which delivers the following output:
<?xml version="1.0" encoding="UTF-8"?>
<phpcs version="3.4.0">
xml version="1.0" encoding="UTF-8"?>
<file name="C:\temp\___.tmp\Core\DataContainers\Modules\SimpleTableModule.php" errors="1" warnings="1" fixable="1">
<warning line="82" column="114" source="Generic.Files.LineLength.TooLong" severity="5" fixable="0">Line exceeds 120 characters; contains 123 characters</warning>
<error line="106" column="1" source="PSR2.Files.EndFileNewline.NoneFound" severity="5" fixable="1">Expected 1 newline at end of file; 0 found</error>
</file>
</phpcs>
I don't know how to fix this if you could provide me with some ideas I would be really happy.