File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
src/Symfony/Component/Console Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -23,8 +23,9 @@ class Terminal
23
23
*/
24
24
public function getWidth ()
25
25
{
26
- if ($ width = trim (getenv ('COLUMNS ' ))) {
27
- return (int ) $ width ;
26
+ $ width = getenv ('COLUMNS ' );
27
+ if (false !== $ width ) {
28
+ return (int ) trim ($ width );
28
29
}
29
30
30
31
if (null === self ::$ width ) {
@@ -41,8 +42,9 @@ public function getWidth()
41
42
*/
42
43
public function getHeight ()
43
44
{
44
- if ($ height = trim (getenv ('LINES ' ))) {
45
- return (int ) $ height ;
45
+ $ height = getenv ('LINES ' );
46
+ if (false !== $ height ) {
47
+ return (int ) trim ($ height );
46
48
}
47
49
48
50
if (null === self ::$ height ) {
Original file line number Diff line number Diff line change @@ -30,4 +30,15 @@ public function test()
30
30
$ this ->assertSame (120 , $ terminal ->getWidth ());
31
31
$ this ->assertSame (60 , $ terminal ->getHeight ());
32
32
}
33
+
34
+ public function test_zero_values ()
35
+ {
36
+ putenv ('COLUMNS=0 ' );
37
+ putenv ('LINES=0 ' );
38
+
39
+ $ terminal = new Terminal ();
40
+
41
+ $ this ->assertSame (0 , $ terminal ->getWidth ());
42
+ $ this ->assertSame (0 , $ terminal ->getHeight ());
43
+ }
33
44
}
You can’t perform that action at this time.
0 commit comments