1
1
<?php
2
+
2
3
declare (strict_types=1 );
3
4
4
5
namespace noximo ;
5
6
6
7
use Nette \IOException ;
8
+ use Nette \Neon \Neon ;
7
9
use Nette \Utils \FileSystem ;
8
10
use Nette \Utils \RegexpException ;
9
11
use Nette \Utils \Strings ;
14
16
15
17
class FileOutput implements ErrorFormatter
16
18
{
19
+ /** @var string */
17
20
public const ERROR = 'error ' ;
18
21
22
+ /** @var string */
19
23
public const LINK = 'link ' ;
20
24
25
+ /** @var string */
21
26
public const LINE = 'line ' ;
22
27
28
+ /** @var string */
23
29
public const FILES = 'files ' ;
24
30
31
+ /** @var string */
25
32
public const UNKNOWN = 'unknown ' ;
26
33
34
+ /** @var string */
35
+ public const IGNORE = 'ignore ' ;
36
+
27
37
/** @var string */
28
38
private $ link = 'editor://open/?file=%file&line=%line ' ;
29
39
@@ -51,7 +61,7 @@ public function __construct(string $outputFile, ?ErrorFormatter $defaultFormatte
51
61
$ this ->defaultFormatter = $ defaultFormatterClass ;
52
62
$ cwd = \Safe \getcwd () . DIRECTORY_SEPARATOR ;
53
63
try {
54
- $ outputFile = Strings::replace ($ outputFile , '{time} ' , (string )time ());
64
+ $ outputFile = Strings::replace ($ outputFile , '{time} ' , (string ) time ());
55
65
} catch (RegexpException $ e ) {
56
66
}
57
67
@@ -114,9 +124,10 @@ private function generateFile(AnalysisResult $analysisResult): void
114
124
$ line = $ fileSpecificError ->getLine () ?? 1 ;
115
125
$ link = strtr ($ this ->link , ['%file ' => $ file , '%line ' => $ line ]);
116
126
$ output [self ::FILES ][$ file ][] = [
117
- self ::ERROR => $ this -> formatMessage ($ fileSpecificError ->getMessage ()),
127
+ self ::ERROR => self :: formatMessage ($ fileSpecificError ->getMessage ()),
118
128
self ::LINK => $ link ,
119
129
self ::LINE => $ line ,
130
+ self ::IGNORE => Neon::encode ($ fileSpecificError ->getMessage ()),
120
131
];
121
132
}
122
133
@@ -126,13 +137,12 @@ private function generateFile(AnalysisResult $analysisResult): void
126
137
});
127
138
}
128
139
unset($ file );
129
-
130
140
}
131
141
132
142
FileSystem::write ($ this ->outputFile , $ this ->getTable ($ output ));
133
143
}
134
144
135
- private function formatMessage (string $ message ): string
145
+ private static function formatMessage (string $ message ): string
136
146
{
137
147
$ words = explode (' ' , $ message );
138
148
$ words = array_map (function ($ word ) {
0 commit comments