File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,13 @@ class Config
89
89
*/
90
90
const STABILITY = 'stable ' ;
91
91
92
+ /**
93
+ * Default report width when no report width is provided and 'auto' does not yield a valid width.
94
+ *
95
+ * @var int
96
+ */
97
+ const DEFAULT_REPORT_WIDTH = 80 ;
98
+
92
99
/**
93
100
* An array of settings that PHPCS and PHPCBF accept.
94
101
*
@@ -223,13 +230,20 @@ public function __set($name, $value)
223
230
switch ($ name ) {
224
231
case 'reportWidth ' :
225
232
// Support auto terminal width.
226
- if ($ value === 'auto '
227
- && function_exists ('shell_exec ' ) === true
228
- && preg_match ('|\d+ (\d+)| ' , shell_exec ('stty size 2>&1 ' ), $ matches ) === 1
229
- ) {
230
- $ value = (int ) $ matches [1 ];
231
- } else {
233
+ if ($ value === 'auto ' && function_exists ('shell_exec ' ) === true ) {
234
+ $ dimensions = shell_exec ('stty size 2>&1 ' );
235
+ if (is_string ($ dimensions ) === true && preg_match ('|\d+ (\d+)| ' , $ dimensions , $ matches ) === 1 ) {
236
+ $ value = (int ) $ matches [1 ];
237
+ break ;
238
+ }
239
+ }
240
+
241
+ if (is_int ($ value ) === true ) {
242
+ $ value = abs ($ value );
243
+ } else if (is_string ($ value ) === true && preg_match ('`^\d+$` ' , $ value ) === 1 ) {
232
244
$ value = (int ) $ value ;
245
+ } else {
246
+ $ value = self ::DEFAULT_REPORT_WIDTH ;
233
247
}
234
248
break ;
235
249
case 'standards ' :
You can’t perform that action at this time.
0 commit comments