Skip to content

Commit f5be730

Browse files
committed
Apply a coding standard
1 parent 9d6d540 commit f5be730

39 files changed

+1907
-1963
lines changed

src/AnalysisResult.php

+97-99
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2424
* SOFTWARE.
2525
*/
26-
declare(strict_types = 1);
26+
declare(strict_types=1);
2727

2828
namespace CodeLts\CliTools;
2929

@@ -32,102 +32,100 @@
3232
class AnalysisResult
3333
{
3434

35-
/** @var \CodeLts\CliTools\Error[] sorted by their file name, line number and message */
36-
private $fileSpecificErrors;
37-
38-
/** @var string[] */
39-
private $notFileSpecificErrors;
40-
41-
/** @var string[] */
42-
private $internalErrors;
43-
44-
/** @var string[] */
45-
private $warnings;
46-
47-
/**
48-
* @param \CodeLts\CliTools\Error[] $fileSpecificErrors
49-
* @param string[] $notFileSpecificErrors
50-
* @param string[] $internalErrors
51-
* @param string[] $warnings
52-
*/
53-
public function __construct(
54-
array $fileSpecificErrors,
55-
array $notFileSpecificErrors,
56-
array $internalErrors,
57-
array $warnings
58-
)
59-
{
60-
usort(
61-
$fileSpecificErrors,
62-
static function (Error $a, Error $b): int {
63-
return [
64-
$a->getFile(),
65-
$a->getLine(),
66-
$a->getMessage(),
67-
] <=> [
68-
$b->getFile(),
69-
$b->getLine(),
70-
$b->getMessage(),
71-
];
72-
}
73-
);
74-
75-
$this->fileSpecificErrors = $fileSpecificErrors;
76-
$this->notFileSpecificErrors = $notFileSpecificErrors;
77-
$this->internalErrors = $internalErrors;
78-
$this->warnings = $warnings;
79-
}
80-
81-
public function hasErrors(): bool
82-
{
83-
return $this->getTotalErrorsCount() > 0;
84-
}
85-
86-
public function getTotalErrorsCount(): int
87-
{
88-
return count($this->fileSpecificErrors) + count($this->notFileSpecificErrors);
89-
}
90-
91-
/**
92-
* @return \CodeLts\CliTools\Error[] sorted by their file name, line number and message
93-
*/
94-
public function getFileSpecificErrors(): array
95-
{
96-
return $this->fileSpecificErrors;
97-
}
98-
99-
/**
100-
* @return string[]
101-
*/
102-
public function getNotFileSpecificErrors(): array
103-
{
104-
return $this->notFileSpecificErrors;
105-
}
106-
107-
/**
108-
* @return string[]
109-
*/
110-
public function getInternalErrors(): array
111-
{
112-
return $this->internalErrors;
113-
}
114-
115-
/**
116-
* @return string[]
117-
*/
118-
public function getWarnings(): array
119-
{
120-
return $this->warnings;
121-
}
122-
123-
public function hasWarnings(): bool
124-
{
125-
return count($this->warnings) > 0;
126-
}
127-
128-
public function hasInternalErrors(): bool
129-
{
130-
return count($this->internalErrors) > 0;
131-
}
132-
35+
/** @var \CodeLts\CliTools\Error[] sorted by their file name, line number and message */
36+
private $fileSpecificErrors;
37+
38+
/** @var string[] */
39+
private $notFileSpecificErrors;
40+
41+
/** @var string[] */
42+
private $internalErrors;
43+
44+
/** @var string[] */
45+
private $warnings;
46+
47+
/**
48+
* @param \CodeLts\CliTools\Error[] $fileSpecificErrors
49+
* @param string[] $notFileSpecificErrors
50+
* @param string[] $internalErrors
51+
* @param string[] $warnings
52+
*/
53+
public function __construct(
54+
array $fileSpecificErrors,
55+
array $notFileSpecificErrors,
56+
array $internalErrors,
57+
array $warnings
58+
) {
59+
usort(
60+
$fileSpecificErrors,
61+
static function (Error $a, Error $b): int {
62+
return [
63+
$a->getFile(),
64+
$a->getLine(),
65+
$a->getMessage(),
66+
] <=> [
67+
$b->getFile(),
68+
$b->getLine(),
69+
$b->getMessage(),
70+
];
71+
}
72+
);
73+
74+
$this->fileSpecificErrors = $fileSpecificErrors;
75+
$this->notFileSpecificErrors = $notFileSpecificErrors;
76+
$this->internalErrors = $internalErrors;
77+
$this->warnings = $warnings;
78+
}
79+
80+
public function hasErrors(): bool
81+
{
82+
return $this->getTotalErrorsCount() > 0;
83+
}
84+
85+
public function getTotalErrorsCount(): int
86+
{
87+
return count($this->fileSpecificErrors) + count($this->notFileSpecificErrors);
88+
}
89+
90+
/**
91+
* @return \CodeLts\CliTools\Error[] sorted by their file name, line number and message
92+
*/
93+
public function getFileSpecificErrors(): array
94+
{
95+
return $this->fileSpecificErrors;
96+
}
97+
98+
/**
99+
* @return string[]
100+
*/
101+
public function getNotFileSpecificErrors(): array
102+
{
103+
return $this->notFileSpecificErrors;
104+
}
105+
106+
/**
107+
* @return string[]
108+
*/
109+
public function getInternalErrors(): array
110+
{
111+
return $this->internalErrors;
112+
}
113+
114+
/**
115+
* @return string[]
116+
*/
117+
public function getWarnings(): array
118+
{
119+
return $this->warnings;
120+
}
121+
122+
public function hasWarnings(): bool
123+
{
124+
return count($this->warnings) > 0;
125+
}
126+
127+
public function hasInternalErrors(): bool
128+
{
129+
return count($this->internalErrors) > 0;
130+
}
133131
}

src/Error.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace CodeLts\CliTools;
66

@@ -28,9 +28,12 @@ class Error
2828

2929

3030
public function __construct(
31-
string $message, ?string $file, int $line,
32-
int $severity = Error::LEVEL_ERROR, ?string $tip = null)
33-
{
31+
string $message,
32+
?string $file,
33+
int $line,
34+
int $severity = Error::LEVEL_ERROR,
35+
?string $tip = null
36+
) {
3437
$this->message = $message;
3538
$this->file = $file;
3639
$this->line = $line;
@@ -62,5 +65,4 @@ public function getTip(): ?string
6265
{
6366
return $this->tip;
6467
}
65-
6668
}

0 commit comments

Comments
 (0)