Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vlucas/phpdotenv
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.1.0
Choose a base ref
...
head repository: vlucas/phpdotenv
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.2.0
Choose a head ref
  • 3 commits
  • 6 files changed
  • 3 contributors

Commits on Aug 4, 2020

  1. Fixed wording (#453)

    chapeupreto authored Aug 4, 2020

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    384e511 View commit details

Commits on Sep 14, 2020

  1. Bumped version

    GrahamCampbell committed Sep 14, 2020

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    3af4965 View commit details
  2. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    fba6413 View commit details
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ $s3_bucket = $_SERVER['S3_BUCKET'];

### Putenv and Getenv

Using `getenv()` and `putenv()` is strongly discurraged due to the fact that
Using `getenv()` and `putenv()` is strongly discouraged due to the fact that
these functions are not thread safe, however it is still possible to instruct
PHP dotenv to use these functions. Instead of calling
`Dotenv::createImmutable`, one can call `Dotenv::createUnsafeImmutable`, which
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "5.1-dev"
"dev-master": "5.2-dev"
}
}
}
17 changes: 14 additions & 3 deletions src/Repository/Adapter/EnvConstAdapter.php
Original file line number Diff line number Diff line change
@@ -40,9 +40,20 @@ public static function create()
public function read(string $name)
{
/** @var \PhpOption\Option<string> */
return Option::fromArraysValue($_ENV, $name)->filter(static function ($value) {
return \is_string($value);
});
return Option::fromArraysValue($_ENV, $name)
->map(static function ($value) {
if ($value === false) {
return 'false';
}

if ($value === true) {
return 'true';
}

return $value;
})->filter(static function ($value) {
return \is_string($value);
});
}

/**
17 changes: 14 additions & 3 deletions src/Repository/Adapter/ServerConstAdapter.php
Original file line number Diff line number Diff line change
@@ -40,9 +40,20 @@ public static function create()
public function read(string $name)
{
/** @var \PhpOption\Option<string> */
return Option::fromArraysValue($_SERVER, $name)->filter(static function ($value) {
return \is_string($value);
});
return Option::fromArraysValue($_SERVER, $name)
->map(static function ($value) {
if ($value === false) {
return 'false';
}

if ($value === true) {
return 'true';
}

return $value;
})->filter(static function ($value) {
return \is_string($value);
});
}

/**
16 changes: 16 additions & 0 deletions tests/Dotenv/Repository/Adapter/EnvConstAdapterTest.php
Original file line number Diff line number Diff line change
@@ -17,6 +17,22 @@ public function testGoodRead()
self::assertSame('foo bar baz', $value->get());
}

public function testFalseRead()
{
$_ENV['CONST_TEST'] = false;
$value = self::createAdapter()->read('CONST_TEST');
self::assertTrue($value->isDefined());
self::assertSame('false', $value->get());
}

public function testTrueRead()
{
$_ENV['CONST_TEST'] = true;
$value = self::createAdapter()->read('CONST_TEST');
self::assertTrue($value->isDefined());
self::assertSame('true', $value->get());
}

public function testBadTypeRead()
{
$_ENV['CONST_TEST'] = 123;
16 changes: 16 additions & 0 deletions tests/Dotenv/Repository/Adapter/ServerConstAdapterTest.php
Original file line number Diff line number Diff line change
@@ -17,6 +17,22 @@ public function testGoodRead()
self::assertSame('foo bar baz', $value->get());
}

public function testFalseRead()
{
$_SERVER['CONST_TEST'] = false;
$value = self::createAdapter()->read('CONST_TEST');
self::assertTrue($value->isDefined());
self::assertSame('false', $value->get());
}

public function testTrueRead()
{
$_SERVER['CONST_TEST'] = true;
$value = self::createAdapter()->read('CONST_TEST');
self::assertTrue($value->isDefined());
self::assertSame('true', $value->get());
}

public function testBadTypeRead()
{
$_SERVER['CONST_TEST'] = 123;