Skip to content

Commit

Permalink
php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
wickedOne committed Dec 29, 2022
1 parent 54baea4 commit 9273c7d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
36 changes: 36 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

$header = <<<'EOF'
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.
EOF;

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules(array(
'@Symfony' => true,
'@Symfony:risky' => true,
'combine_consecutive_unsets' => true,
'array_syntax' => array('syntax' => 'short'),
'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
'header_comment' => array('header' => $header),
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'php_unit_strict' => true,
'phpdoc_add_missing_param_annotation' => true,
'psr_autoloading' => true,
'strict_comparison' => true,
'strict_param' => true,
'fopen_flags' => array('b_mode' => true),
))
->setFinder(
(new PhpCsFixer\Finder())
->in([__DIR__ . '/src/'])
->name('*.php')
);
12 changes: 6 additions & 6 deletions src/PhpStormReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@
use PHP_CodeSniffer\Reports\Full;

/**
* PhpStorm Report
* PhpStorm Report.
*
* @author wicliff <[email protected]>
*/
class PhpStormReport extends Full
{
/**
* {@inheritdoc
* {@inheritdoc.
*/
public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80): bool
{
if ($report['errors'] === 0 && $report['warnings'] === 0) {
if (0 === $report['errors'] && 0 === $report['warnings']) {
return false;
}

parent::generateFileReport($report, $phpcsFile, $showSources, $width);

if (count($report['messages']) > 1) {
echo sprintf("✏️ phpstorm://open?file=%s", $phpcsFile->path).PHP_EOL;
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;
echo sprintf('✏️ phpstorm://open?file=%s&line=%d', $phpcsFile->path, key($report['messages'])).\PHP_EOL;
}

return true;
Expand Down

0 comments on commit 9273c7d

Please sign in to comment.