Skip to content

Commit

Permalink
Apply wdes/coding-standard
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Mar 24, 2021
1 parent 94f2ffe commit 08d91ae
Show file tree
Hide file tree
Showing 43 changed files with 345 additions and 181 deletions.
12 changes: 6 additions & 6 deletions src/AnalysisResult.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/*
* (c) Copyright (c) 2016-2020 Ondřej Mirtes <ondrej@mirtes.cz>
*
Expand All @@ -23,12 +25,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
declare(strict_types=1);

namespace CodeLts\CliTools;

use CodeLts\CliTools\Error;

class AnalysisResult
{

Expand Down Expand Up @@ -71,10 +70,10 @@ static function (Error $a, Error $b): int {
}
);

$this->fileSpecificErrors = $fileSpecificErrors;
$this->fileSpecificErrors = $fileSpecificErrors;
$this->notFileSpecificErrors = $notFileSpecificErrors;
$this->internalErrors = $internalErrors;
$this->warnings = $warnings;
$this->internalErrors = $internalErrors;
$this->warnings = $warnings;
}

public function hasErrors(): bool
Expand Down Expand Up @@ -128,4 +127,5 @@ public function hasInternalErrors(): bool
{
return count($this->internalErrors) > 0;
}

}
2 changes: 1 addition & 1 deletion src/AnsiEscapeSequences.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types=1);
declare(strict_types = 1);

namespace CodeLts\CliTools;

Expand Down
26 changes: 13 additions & 13 deletions src/Error.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types=1);
declare(strict_types = 1);

namespace CodeLts\CliTools;

Expand All @@ -18,14 +18,13 @@ class Error
protected $tip = null;

public const LEVEL_EMERGENCY = 0;
public const LEVEL_ALERT = 1;
public const LEVEL_CRITICAL = 2;
public const LEVEL_ERROR = 3;
public const LEVEL_WARNING = 4;
public const LEVEL_NOTICE = 5;
public const LEVEL_INFO = 6;
public const LEVEL_DEBUG = 7;

public const LEVEL_ALERT = 1;
public const LEVEL_CRITICAL = 2;
public const LEVEL_ERROR = 3;
public const LEVEL_WARNING = 4;
public const LEVEL_NOTICE = 5;
public const LEVEL_INFO = 6;
public const LEVEL_DEBUG = 7;

public function __construct(
string $message,
Expand All @@ -34,11 +33,11 @@ public function __construct(
int $severity = Error::LEVEL_ERROR,
?string $tip = null
) {
$this->message = $message;
$this->file = $file;
$this->line = $line;
$this->message = $message;
$this->file = $file;
$this->line = $line;
$this->severity = $severity;
$this->tip = $tip;
$this->tip = $tip;
}

public function getMessage(): string
Expand All @@ -65,4 +64,5 @@ public function getTip(): ?string
{
return $this->tip;
}

}
26 changes: 16 additions & 10 deletions src/ErrorFormatter/CheckstyleErrorFormatter.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/*
* (c) Copyright (c) 2016-2020 Ondřej Mirtes <ondrej@mirtes.cz>
*
Expand All @@ -23,7 +25,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
declare(strict_types=1);

namespace CodeLts\CliTools\ErrorFormatter;

Expand Down Expand Up @@ -54,18 +55,22 @@ public function formatErrors(
$output->writeLineFormatted('');

foreach ($this->groupByFile($analysisResult) as $relativeFilePath => $errors) {
$output->writeRaw(sprintf(
'<file name="%s">',
$this->escape($relativeFilePath)
));
$output->writeRaw(
sprintf(
'<file name="%s">',
$this->escape($relativeFilePath)
)
);
$output->writeLineFormatted('');

foreach ($errors as $error) {
$output->writeRaw(sprintf(
' <error line="%d" column="1" severity="error" message="%s" />',
$this->escape((string) $error->getLine()),
$this->escape((string) $error->getMessage())
));
$output->writeRaw(
sprintf(
' <error line="%d" column="1" severity="error" message="%s" />',
$this->escape((string) $error->getLine()),
$this->escape((string) $error->getMessage())
)
);
$output->writeLineFormatted('');
}
$output->writeRaw('</file>');
Expand Down Expand Up @@ -143,4 +148,5 @@ private function groupByFile(AnalysisResult $analysisResult): array

return $files;
}

}
4 changes: 3 additions & 1 deletion src/ErrorFormatter/ErrorFormatter.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/*
* (c) Copyright (c) 2016-2020 Ondřej Mirtes <ondrej@mirtes.cz>
*
Expand All @@ -23,7 +25,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
declare(strict_types=1);

namespace CodeLts\CliTools\ErrorFormatter;

Expand All @@ -44,4 +45,5 @@ public function formatErrors(
AnalysisResult $analysisResult,
Output $output
): int;

}
15 changes: 10 additions & 5 deletions src/ErrorFormatter/GithubErrorFormatter.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/*
* (c) Copyright (c) 2016-2020 Ondřej Mirtes <ondrej@mirtes.cz>
*
Expand All @@ -23,7 +25,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
declare(strict_types=1);

namespace CodeLts\CliTools\ErrorFormatter;

Expand Down Expand Up @@ -52,7 +53,7 @@ public function __construct(
RelativePathHelper $relativePathHelper,
TableErrorFormatter $tableErrorformatter
) {
$this->relativePathHelper = $relativePathHelper;
$this->relativePathHelper = $relativePathHelper;
$this->tableErrorformatter = $tableErrorformatter;
}

Expand All @@ -66,9 +67,12 @@ public function formatErrors(AnalysisResult $analysisResult, Output $output): in
'line' => $fileSpecificError->getLine(),
'col' => 0,
];
array_walk($metas, static function (&$value, string $key): void {
$value = sprintf('%s=%s', $key, (string) $value);
});
array_walk(
$metas,
static function (&$value, string $key): void {
$value = sprintf('%s=%s', $key, (string) $value);
}
);

$message = $fileSpecificError->getMessage();
// newlines need to be encoded
Expand Down Expand Up @@ -105,4 +109,5 @@ public function formatErrors(AnalysisResult $analysisResult, Output $output): in

return $analysisResult->hasErrors() ? 1 : 0;
}

}
4 changes: 3 additions & 1 deletion src/ErrorFormatter/GitlabErrorFormatter.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/*
* (c) Copyright (c) 2016-2020 Ondřej Mirtes <ondrej@mirtes.cz>
*
Expand All @@ -23,7 +25,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
declare(strict_types=1);

namespace CodeLts\CliTools\ErrorFormatter;

Expand Down Expand Up @@ -102,4 +103,5 @@ public function formatErrors(AnalysisResult $analysisResult, Output $output): in

return $analysisResult->hasErrors() ? 1 : 0;
}

}
4 changes: 3 additions & 1 deletion src/ErrorFormatter/JsonErrorFormatter.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/*
* (c) Copyright (c) 2016-2020 Ondřej Mirtes <ondrej@mirtes.cz>
*
Expand All @@ -23,7 +25,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
declare(strict_types=1);

namespace CodeLts\CliTools\ErrorFormatter;

Expand Down Expand Up @@ -84,4 +85,5 @@ public function formatErrors(AnalysisResult $analysisResult, Output $output): in

return $analysisResult->hasErrors() ? 1 : 0;
}

}
8 changes: 5 additions & 3 deletions src/ErrorFormatter/JunitErrorFormatter.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/*
* (c) Copyright (c) 2016-2020 Ondřej Mirtes <ondrej@mirtes.cz>
*
Expand All @@ -23,7 +25,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
declare(strict_types=1);

namespace CodeLts\CliTools\ErrorFormatter;

Expand All @@ -50,7 +51,7 @@ public function formatErrors(
AnalysisResult $analysisResult,
Output $output
): int {
$result = '<?xml version="1.0" encoding="UTF-8"?>';
$result = '<?xml version="1.0" encoding="UTF-8"?>';
$result .= sprintf(
'<testsuite failures="%d" name="cli-tools" tests="%d" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/junit-team/junit5/r5.5.1/platform-tests/src/test/resources/jenkins-junit.xsd">',
$analysisResult->getTotalErrorsCount(),
Expand All @@ -64,7 +65,7 @@ public function formatErrors(
}

$fileName = $this->relativePathHelper->getRelativePath($file);
$result .= $this->createTestCase(
$result .= $this->createTestCase(
sprintf('%s:%s', $fileName, (string) $fileSpecificError->getLine()),
'ERROR',
$this->escape($fileSpecificError->getMessage())
Expand Down Expand Up @@ -121,4 +122,5 @@ protected function escape(string $string): string
{
return htmlspecialchars($string, ENT_XML1 | ENT_COMPAT, 'UTF-8');
}

}
4 changes: 3 additions & 1 deletion src/ErrorFormatter/RawErrorFormatter.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/*
* (c) Copyright (c) 2016-2020 Ondřej Mirtes <ondrej@mirtes.cz>
*
Expand All @@ -23,7 +25,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
declare(strict_types=1);

namespace CodeLts\CliTools\ErrorFormatter;

Expand Down Expand Up @@ -61,4 +62,5 @@ public function formatErrors(

return $analysisResult->hasErrors() ? 1 : 0;
}

}
3 changes: 2 additions & 1 deletion src/ErrorFormatter/RawTextErrorFormatter.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types=1);
declare(strict_types = 1);

namespace CodeLts\CliTools\ErrorFormatter;

Expand Down Expand Up @@ -34,4 +34,5 @@ public function formatErrors(

return $analysisResult->hasErrors() ? 1 : 0;
}

}
Loading

0 comments on commit 08d91ae

Please sign in to comment.