File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -90,11 +90,7 @@ foreach ($files as $file) {
90
90
91
91
function formatErrorMessage (PhpParser \Error $ e , $ code , $ withColumnInfo ) {
92
92
if ($ withColumnInfo && $ e ->hasColumnInfo ()) {
93
- $ startLine = $ e ->getStartLine ();
94
- $ endLine = $ e ->getEndLine ();
95
- $ startColumn = $ e ->getStartColumn ($ code );
96
- $ endColumn = $ e ->getEndColumn ($ code );
97
- return $ e ->getRawMessage () . " from $ startLine: $ startColumn to $ endLine: $ endColumn " ;
93
+ return $ e ->getMessageWithColumnInfo ($ code );
98
94
} else {
99
95
return $ e ->getMessage ();
100
96
}
Original file line number Diff line number Diff line change @@ -120,6 +120,14 @@ public function getEndColumn($code) {
120
120
return $ this ->toColumn ($ code , $ this ->attributes ['endFilePos ' ]);
121
121
}
122
122
123
+ public function getMessageWithColumnInfo ($ code ) {
124
+ return sprintf (
125
+ '%s from %d:%d to %d:%d ' , $ this ->getRawMessage (),
126
+ $ this ->getStartLine (), $ this ->getStartColumn ($ code ),
127
+ $ this ->getEndLine (), $ this ->getEndColumn ($ code )
128
+ );
129
+ }
130
+
123
131
private function toColumn ($ code , $ pos ) {
124
132
if ($ pos > strlen ($ code )) {
125
133
throw new \RuntimeException ('Invalid position information ' );
Original file line number Diff line number Diff line change @@ -60,8 +60,7 @@ public function provideTestParse() {
60
60
61
61
private function formatErrorMessage (Error $ e , $ code ) {
62
62
if ($ e ->hasColumnInfo ()) {
63
- return $ e ->getRawMessage () . ' from ' . $ e ->getStartLine () . ': ' . $ e ->getStartColumn ($ code )
64
- . ' to ' . $ e ->getEndLine () . ': ' . $ e ->getEndColumn ($ code );
63
+ return $ e ->getMessageWithColumnInfo ($ code );
65
64
} else {
66
65
return $ e ->getMessage ();
67
66
}
You can’t perform that action at this time.
0 commit comments