Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request zendframework/zendframework#2210 from weierophinne…
Browse files Browse the repository at this point in the history
…y/hotfix/remove-suppression-operator

Get rid of error suppression
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
}
},
"require": {
"php": ">=5.3.3"
"php": ">=5.3.3",
"zendframework/zend-stdlib": "self.version"
},
"homepage": "https://github.com/zendframework/zend-progress-bar",
"autoload-dev": {
Expand Down
25 changes: 15 additions & 10 deletions src/Adapter/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Zend\ProgressBar\Adapter;

use Zend\ProgressBar\Adapter\Exception;
use Zend\Stdlib\ErrorHandler;

/**
* Zend_ProgressBar_Adapter_Console offers a text-based progressbar for console
Expand Down Expand Up @@ -169,17 +170,19 @@ public function __destruct()
*/
public function setOutputStream($resource)
{
$stream = @fopen($resource, 'w');
ErrorHandler::start();
$stream = fopen($resource, 'w');
$error = ErrorHandler::stop();

if ($stream === false) {
throw new Exception\RuntimeException('Unable to open stream');
}
if ($stream === false) {
throw new Exception\RuntimeException('Unable to open stream', 0, $error);
}

if ($this->outputStream !== null) {
fclose($this->outputStream);
}
if ($this->outputStream !== null) {
fclose($this->outputStream);
}

$this->outputStream = $stream;
$this->outputStream = $stream;
}

/**
Expand Down Expand Up @@ -220,11 +223,13 @@ public function setWidth($width = null)
$this->width = 80;

// Try to determine the width through stty
if (preg_match('#\d+ (\d+)#', @shell_exec('stty size'), $match) === 1) {
ErrorHandler::start();
if (preg_match('#\d+ (\d+)#', shell_exec('stty size'), $match) === 1) {
$this->width = (int) $match[1];
} elseif (preg_match('#columns = (\d+);#', @shell_exec('stty'), $match) === 1) {
} elseif (preg_match('#columns = (\d+);#', shell_exec('stty'), $match) === 1) {
$this->width = (int) $match[1];
}
ErrorHandler::stop();
}
} else {
$this->width = (int) $width;
Expand Down

0 comments on commit ab30fab

Please # to comment.