Skip to content

Commit

Permalink
Fixed evals for true / false
Browse files Browse the repository at this point in the history
  • Loading branch information
andrevanzuydam committed Aug 7, 2021
1 parent f5fb54f commit 4dc170b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[TEST]
VERSION=1.0.0
SWAGGER_TITLE = "Tina4 Project"
TINA4_DEBUG=true
TINA4_DEBUG_LEVEL=[]
8 changes: 5 additions & 3 deletions Tina4/Env.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@ private function parseLine($line): void
if (isset($variables[0], $variables[1]) && !defined(trim($variables[0]))) {
Debug::message("Defining {$variables[0]} = $variables[1]", TINA4_LOG_DEBUG);
$variable = trim($variables[0]);
if ($variables[1][0] === "[" || $variables[1][0] === "\"")

if (trim($variables[1]) === "false" || trim($variables[1]) === "true" || trim($variables[1])[0] === "[" || trim($variables[1])[0] === "\"" || trim($variables[1])[0] === '"' || trim($variables[1])[0] === '"')
{
eval("\${$variable} = {$variables[1]};");
} else {
extract([$variable => $variables[1]], EXTR_OVERWRITE);
extract([$variable => trim($variables[1])], EXTR_OVERWRITE);
}

define(trim($variables[0]), ${$variable});

}


}

/**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"scripts": {
"start": "php -S localhost:7147 index.php",
"test": "./vendor/bin/phpunit tests --color --log-junit=tests/junit.xml",
"test": "./vendor/bin/phpunit tests -vvv --color --log-junit=tests/junit.xml",
"phpmetrics": "phpmetrics --report-html=phpmetrics --junit=tests/junit.xml ./Tina4"
},
"require-dev": {
Expand Down
1 change: 1 addition & 0 deletions tests/EnvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ function testEnvValue (): void
$this->assertEquals("1.0.0", VERSION);
$this->assertEquals("Tina4 Project", SWAGGER_TITLE);
$this->assertIsArray( TINA4_DEBUG_LEVEL);
$this->assertEquals(true, TINA4_DEBUG);
}
}

0 comments on commit 4dc170b

Please sign in to comment.