-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
don't be a dick |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# PHP CodeSniffer PhpStorm reporter | ||
|
||
prints additional PhpStorm editor url in PHPCS cli output. | ||
|
||
## installation | ||
```bash | ||
$ composer require --dev wickedone/phpcs-reporter | ||
``` | ||
|
||
### command line usage: | ||
specify this report on the command line: | ||
|
||
```bash | ||
$ php vendor/bin/phpcs --report='WickedOne\PHPCSReport\PhpStormReport' | ||
``` | ||
|
||
### phpcs xml configuration | ||
specify this report in your ``phpcs.xml.dist``: | ||
```xml | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"> | ||
|
||
<arg name="report" value="WickedOne\PHPCSReport\PhpStormReport" /> | ||
... | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "wickedone/phpcs-reporter", | ||
"description": "PHP Codesniffer output with phpstorm editor url", | ||
"type": "library", | ||
"keywords": [ | ||
"phpcs", | ||
"phpstorm", | ||
"testing" | ||
], | ||
"require": { | ||
"php": ">=7.3", | ||
"squizlabs/php_codesniffer": "^3.6" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "wickedOne", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"WickedOne\\PHPCSReport\\": "src/" | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of WickedOne\PHPCSReporter. | ||
* | ||
* (c) wicliff <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace WickedOne\PHPCSReport; | ||
|
||
use PHP_CodeSniffer\Files\File; | ||
use PHP_CodeSniffer\Reports\Full; | ||
|
||
/** | ||
* PhpStorm Report | ||
* | ||
* @author wicliff <[email protected]> | ||
*/ | ||
class PhpStormReport extends Full | ||
{ | ||
/** | ||
* {@inheritdoc | ||
*/ | ||
public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80): bool | ||
{ | ||
if ($report['errors'] === 0 && $report['warnings'] === 0) { | ||
return false; | ||
} | ||
|
||
parent::generateFileReport($report, $phpcsFile, $showSources, $width); | ||
|
||
if (count($report['messages']) > 1) { | ||
echo sprintf("✏️ phpstorm://open?file=%s", $phpcsFile->path).PHP_EOL; | ||
} else { | ||
echo sprintf("✏️ phpstorm://open?file=%s&line=%d", $phpcsFile->path, key($report['messages'])).PHP_EOL; | ||
} | ||
|
||
return true; | ||
} | ||
} |