Skip to content

Commit

Permalink
Cast boolean env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
SeyamMs committed Oct 3, 2024
1 parent 6a9f089 commit e706dc9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/ProcessManager/ChromeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,19 @@ private function getDefaultArguments(): array
$args = [];

// Enable the headless mode unless PANTHER_NO_HEADLESS is defined
if (!($_SERVER['PANTHER_NO_HEADLESS'] ?? false)) {
if (!(filter_var($_SERVER['PANTHER_NO_HEADLESS'] ?? false, FILTER_VALIDATE_BOOLEAN))) {
$args[] = '--headless';
$args[] = '--window-size=1200,1100';
$args[] = '--disable-gpu';
}

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

// Disable Chrome's sandbox if PANTHER_NO_SANDBOX is defined or if running in Travis
if ($_SERVER['PANTHER_NO_SANDBOX'] ?? $_SERVER['HAS_JOSH_K_SEAL_OF_APPROVAL'] ?? false) {
if (filter_var($_SERVER['PANTHER_NO_SANDBOX'] ?? $_SERVER['HAS_JOSH_K_SEAL_OF_APPROVAL'] ?? false, FILTER_VALIDATE_BOOLEAN)) {
// Running in Travis, disabling the sandbox mode
$args[] = '--no-sandbox';
}
Expand Down
4 changes: 2 additions & 2 deletions src/ProcessManager/FirefoxManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ private function getDefaultArguments(): array
$args = [];

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

// Enable devtools for debugging
if ($_SERVER['PANTHER_DEVTOOLS'] ?? true) {
if (filter_var($_SERVER['PANTHER_DEVTOOLS'] ?? true, FILTER_VALIDATE_BOOLEAN)) {
$args[] = '--devtools';
}

Expand Down
2 changes: 1 addition & 1 deletion src/ServerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private function stopWebServer(): void
private function pause($message): void
{
if (\in_array('--debug', $_SERVER['argv'], true)
&& ($_SERVER['PANTHER_NO_HEADLESS'] ?? false)
&& (filter_var($_SERVER['PANTHER_NO_HEADLESS'] ?? false, FILTER_VALIDATE_BOOLEAN))
) {
echo "$message\n\nPress enter to continue...";
if (!$this->testing) {
Expand Down
2 changes: 1 addition & 1 deletion tests/ServerExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testPauseOnFailure(string $method, string $expected): void

// stores current state
$argv = $_SERVER['argv'];
$noHeadless = $_SERVER['PANTHER_NO_HEADLESS'] ?? false;
$noHeadless = filter_var($_SERVER['PANTHER_NO_HEADLESS'] ?? false, FILTER_VALIDATE_BOOLEAN);

self::startWebServer();
$_SERVER['argv'][] = '--debug';
Expand Down

0 comments on commit e706dc9

Please sign in to comment.