From 4c1b00189190dc45db48920c93c5a3ffa3f5e0ad Mon Sep 17 00:00:00 2001 From: Craig Duncan Date: Tue, 11 Apr 2017 16:09:57 +0100 Subject: [PATCH] Allow terminal dimensions to be set to 0 (unbounded) --- src/Symfony/Component/Console/Terminal.php | 10 ++++++---- src/Symfony/Component/Console/Tests/TerminalTest.php | 11 +++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Console/Terminal.php b/src/Symfony/Component/Console/Terminal.php index 217e1f6e47170..927dfc4d76d71 100644 --- a/src/Symfony/Component/Console/Terminal.php +++ b/src/Symfony/Component/Console/Terminal.php @@ -23,8 +23,9 @@ class Terminal */ public function getWidth() { - if ($width = trim(getenv('COLUMNS'))) { - return (int) $width; + $width = getenv('COLUMNS'); + if (false !== $width) { + return (int) trim($width); } if (null === self::$width) { @@ -41,8 +42,9 @@ public function getWidth() */ public function getHeight() { - if ($height = trim(getenv('LINES'))) { - return (int) $height; + $height = getenv('LINES'); + if (false !== $height) { + return (int) trim($height); } if (null === self::$height) { diff --git a/src/Symfony/Component/Console/Tests/TerminalTest.php b/src/Symfony/Component/Console/Tests/TerminalTest.php index 7c39f439430e4..91af1d0ab459d 100644 --- a/src/Symfony/Component/Console/Tests/TerminalTest.php +++ b/src/Symfony/Component/Console/Tests/TerminalTest.php @@ -30,4 +30,15 @@ public function test() $this->assertSame(120, $terminal->getWidth()); $this->assertSame(60, $terminal->getHeight()); } + + public function test_zero_values() + { + putenv('COLUMNS=0'); + putenv('LINES=0'); + + $terminal = new Terminal(); + + $this->assertSame(0, $terminal->getWidth()); + $this->assertSame(0, $terminal->getHeight()); + } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy