Skip to content

Commit

Permalink
Correct the value passed to check if the constant is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
duncan3dc committed Jan 23, 2022
1 parent f9d6801 commit 2224332
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Changelog

--------

## 3.8.1 - 2022-01-23

### Fixed

* [Linux] Avoid type issue when checking if \STDOUT is defined. [#185](/~https://github.com/thephpleague/climate/issues/185)

--------

## 3.8.0 - 2022-01-22

### Changed
Expand Down
2 changes: 1 addition & 1 deletion src/Util/System/Linux.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function systemHasAnsiSupport()
}

# If we're running in a web context then we can't use stdout
if (!defined(\STDOUT)) {
if (!defined('STDOUT')) {
return false;
}

Expand Down
18 changes: 18 additions & 0 deletions tests/AnsiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,22 @@ public function it_will_force_ansi_off_on_an_ansi_system()

$this->cli->out("<green>I am green</green>");
}


/**
* Ensure we can check if stdout is defined safely.
* /~https://github.com/thephpleague/climate/issues/185
*/
public function test6()
{
$system = new Linux();
$util = new UtilFactory($system);
$this->cli->setUtil($util);

$this->shouldWrite("\e[m\e[32mI am green\e[0m\e[0m");
$this->shouldHavePersisted();

$this->cli->out("<green>I am green</green>");
self::assertTrue(true);
}
}

0 comments on commit 2224332

Please sign in to comment.