Skip to content

Commit 8a7d33d

Browse files
authored
Cast boolean env variables (#632)
1 parent 167c497 commit 8a7d33d

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/ProcessManager/ChromeManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,19 @@ private function getDefaultArguments(): array
9898
$args = [];
9999

100100
// Enable the headless mode unless PANTHER_NO_HEADLESS is defined
101-
if (!($_SERVER['PANTHER_NO_HEADLESS'] ?? false)) {
101+
if (!filter_var($_SERVER['PANTHER_NO_HEADLESS'] ?? false, \FILTER_VALIDATE_BOOLEAN)) {
102102
$args[] = '--headless';
103103
$args[] = '--window-size=1200,1100';
104104
$args[] = '--disable-gpu';
105105
}
106106

107107
// Enable devtools for debugging
108-
if ($_SERVER['PANTHER_DEVTOOLS'] ?? true) {
108+
if (filter_var($_SERVER['PANTHER_DEVTOOLS'] ?? true, \FILTER_VALIDATE_BOOLEAN)) {
109109
$args[] = '--auto-open-devtools-for-tabs';
110110
}
111111

112112
// Disable Chrome's sandbox if PANTHER_NO_SANDBOX is defined or if running in Travis
113-
if ($_SERVER['PANTHER_NO_SANDBOX'] ?? $_SERVER['HAS_JOSH_K_SEAL_OF_APPROVAL'] ?? false) {
113+
if (filter_var($_SERVER['PANTHER_NO_SANDBOX'] ?? $_SERVER['HAS_JOSH_K_SEAL_OF_APPROVAL'] ?? false, \FILTER_VALIDATE_BOOLEAN)) {
114114
// Running in Travis, disabling the sandbox mode
115115
$args[] = '--no-sandbox';
116116
}

src/ProcessManager/FirefoxManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ private function getDefaultArguments(): array
9393
$args = [];
9494

9595
// Enable the headless mode unless PANTHER_NO_HEADLESS is defined
96-
if (!($_SERVER['PANTHER_NO_HEADLESS'] ?? false)) {
96+
if (!filter_var($_SERVER['PANTHER_NO_HEADLESS'] ?? false, \FILTER_VALIDATE_BOOLEAN)) {
9797
$args[] = '--headless';
9898
}
9999

100100
// Enable devtools for debugging
101-
if ($_SERVER['PANTHER_DEVTOOLS'] ?? true) {
101+
if (filter_var($_SERVER['PANTHER_DEVTOOLS'] ?? true, \FILTER_VALIDATE_BOOLEAN)) {
102102
$args[] = '--devtools';
103103
}
104104

src/ServerTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private function stopWebServer(): void
3535
private function pause($message): void
3636
{
3737
if (\in_array('--debug', $_SERVER['argv'], true)
38-
&& ($_SERVER['PANTHER_NO_HEADLESS'] ?? false)
38+
&& filter_var($_SERVER['PANTHER_NO_HEADLESS'] ?? false, \FILTER_VALIDATE_BOOLEAN)
3939
) {
4040
echo "$message\n\nPress enter to continue...";
4141
if (!$this->testing) {

tests/ServerExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testPauseOnFailure(string $method, string $expected): void
4444

4545
// stores current state
4646
$argv = $_SERVER['argv'];
47-
$noHeadless = $_SERVER['PANTHER_NO_HEADLESS'] ?? false;
47+
$noHeadless = filter_var($_SERVER['PANTHER_NO_HEADLESS'] ?? false, \FILTER_VALIDATE_BOOLEAN);
4848

4949
self::startWebServer();
5050
$_SERVER['argv'][] = '--debug';

0 commit comments

Comments
 (0)