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: v3.6.1
Choose a base ref
...
head repository: vlucas/phpdotenv
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.6.2
Choose a head ref
  • 19 commits
  • 7 files changed
  • 2 contributors

Commits on Jan 28, 2019

  1. Updated branch alias

    GrahamCampbell committed Jan 28, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d7f715a View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    aa4be46 View commit details
  3. Unverified

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

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2a0c63f View commit details
  5. Fixed PHP 5.3 support

    GrahamCampbell committed Jan 28, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5f0fbb8 View commit details
  6. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    e53b2c3 View commit details
  7. Test both variants

    GrahamCampbell committed Jan 28, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e918eac View commit details
  8. Merge pull request #325 from vlucas/parser-backport

    [2.6] Backport parser fixes from 3.3.0
    GrahamCampbell authored Jan 28, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f3aae28 View commit details

Commits on Jan 29, 2019

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2a7dcf7 View commit details

Commits on Mar 27, 2020

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    31621bf View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0de6841 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    eea090d View commit details
  4. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e9a7fac View commit details
  5. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    4f3a400 View commit details
  6. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8bdc950 View commit details
  7. Copy the full SHA
    db354ca View commit details
  8. Copy the full SHA
    c4a653e View commit details
  9. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    884ab15 View commit details
  10. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    786a947 View commit details
Showing with 50 additions and 20 deletions.
  1. +28 −10 .travis.yml
  2. +3 −1 composer.json
  3. +3 −3 src/Environment/AbstractVariables.php
  4. +1 −1 src/Parser.php
  5. +6 −4 src/Validator.php
  6. +1 −1 tests/Dotenv/LinesTest.php
  7. +8 −0 tests/Dotenv/ValidatorTest.php
38 changes: 28 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,58 @@
matrix:
include:
- dist: trusty
- name: HHVM 3.18
dist: trusty
language: php
php: hhvm-3.18
before_install: travis_retry composer require "phpunit/phpunit:^5.7.27" --dev --no-update -n
install: travis_retry composer install --no-suggest --prefer-dist -n -o
script: vendor/bin/phpunit
- dist: trusty
- name: HHVM 3.30
dist: trusty
language: php
php: hhvm-3.30
before_install: travis_retry composer require "phpunit/phpunit:^5.7.27" --dev --no-update -n
install: travis_retry composer install --no-suggest --prefer-dist -n -o
script: vendor/bin/phpunit
- name: PHP 5.4
dist: trusty
language: php
php: 5.4
install: travis_retry composer install --no-suggest --prefer-dist -n -o
script: vendor/bin/phpunit
- dist: trusty
- name: PHP 5.5.9
dist: trusty
language: php
php: 5.5.9
install: travis_retry composer install --no-suggest --prefer-dist -n -o
script: vendor/bin/phpunit
- dist: trusty
- name: PHP 5.5
dist: trusty
language: php
php: 5.5
install: travis_retry composer install --no-suggest --prefer-dist -n -o
script: vendor/bin/phpunit
- dist: xenial
- name: PHP 5.6
dist: xenial
install: travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:5.6 install --no-suggest --prefer-dist -n -o
script: docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit registry.gitlab.com/grahamcampbell/php:5.6
- dist: xenial
- name: PHP 7.0
dist: xenial
install: travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:7.0 install --no-suggest --prefer-dist -n -o
script: docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit registry.gitlab.com/grahamcampbell/php:7.0
- dist: xenial
- name: PHP 7.1
dist: xenial
install: travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:7.1 install --no-suggest --prefer-dist -n -o
script: docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit registry.gitlab.com/grahamcampbell/php:7.1
- dist: xenial
- name: PHP 7.2
dist: xenial
install: travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:7.2 install --no-suggest --prefer-dist -n -o
script: docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit registry.gitlab.com/grahamcampbell/php:7.2
- dist: xenial
- name: PHP 7.3
dist: xenial
install: travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:7.3 install --no-suggest --prefer-dist -n -o
script: docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit registry.gitlab.com/grahamcampbell/php:7.3
- dist: xenial
- name: PHP 7.4
dist: xenial
install: travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:7.4 install --no-suggest --prefer-dist -n -o
script: docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit registry.gitlab.com/grahamcampbell/php:7.4
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
},
"require-dev": {
"ext-filter": "*",
"ext-pcre": "*",
"phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0"
},
"autoload": {
@@ -30,7 +31,8 @@
}
},
"suggest": {
"ext-filter": "Required to use the boolean validator."
"ext-filter": "Required to use the boolean validator.",
"ext-pcre": "Required to use most of the library."
},
"extra": {
"branch-alias": {
6 changes: 3 additions & 3 deletions src/Environment/AbstractVariables.php
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ public function get($name)
*
* @return string|null
*/
protected abstract function getInternal($name);
abstract protected function getInternal($name);

/**
* Set an environment variable.
@@ -100,7 +100,7 @@ public function set($name, $value = null)
*
* @return void
*/
protected abstract function setInternal($name, $value = null);
abstract protected function setInternal($name, $value = null);

/**
* Clear an environment variable.
@@ -132,7 +132,7 @@ public function clear($name)
*
* @return void
*/
protected abstract function clearInternal($name);
abstract protected function clearInternal($name);

/**
* Determine if the environment is immutable.
2 changes: 1 addition & 1 deletion src/Parser.php
Original file line number Diff line number Diff line change
@@ -135,7 +135,7 @@ private static function parseValue($value)
if ($char === $value[0] || $char === '\\') {
return [$data[0].$char, self::QUOTED_STATE];
} elseif (in_array($char, ['f', 'n', 'r', 't', 'v'], true)) {
return [$data[0].stripcslashes('\\' . $char), self::QUOTED_STATE];
return [$data[0].stripcslashes('\\'.$char), self::QUOTED_STATE];
} else {
throw new InvalidFileException(
self::getErrorMessage('an unexpected escape sequence', $value)
10 changes: 6 additions & 4 deletions src/Validator.php
Original file line number Diff line number Diff line change
@@ -50,7 +50,6 @@ function ($value) {
'is missing'
);
}

}

/**
@@ -133,6 +132,10 @@ public function allowedValues(array $choices)
{
return $this->assertCallback(
function ($value) use ($choices) {
if ($value === null) {
return true;
}

return in_array($value, $choices, true);
},
sprintf('is not one of [%s]', implode(', ', $choices))
@@ -151,15 +154,14 @@ function ($value) use ($choices) {
public function allowedRegexValues($regex)
{
return $this->assertCallback(
function ($value) use ($regex)
{
function ($value) use ($regex) {
if ($value === null) {
return true;
}

return Regex::match($regex, $value)->success()->getOrElse(0) === 1;
},
sprintf('does not match "%s"' , $regex)
sprintf('does not match "%s"', $regex)
);
}

2 changes: 1 addition & 1 deletion tests/Dotenv/LinesTest.php
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ public function testProcessQuotes()

$expected = [
"TEST=\"test\n test\\\"test\\\"\n test\"",
"TEST_ND=\"test\\ntest\"",
'TEST_ND="test\\ntest"',
'TEST_NS=\'test\\ntest\'',
'TEST_EQD="https://vision.googleapis.com/v1/images:annotate?key="',
'TEST_EQS=\'https://vision.googleapis.com/v1/images:annotate?key=\'',
8 changes: 8 additions & 0 deletions tests/Dotenv/ValidatorTest.php
Original file line number Diff line number Diff line change
@@ -39,6 +39,14 @@ public function testDotenvAllowedValuesIfPresent()
$this->assertTrue(true);
}

public function testDotenvAllowedValuesIfNotPresent()
{
$dotenv = Dotenv::create($this->fixturesFolder);
$dotenv->load();
$dotenv->ifPresent('FOOQWERTYOOOOOO')->allowedValues(['bar', 'baz']);
$this->assertTrue(true);
}

/**
* @expectedException \Dotenv\Exception\ValidationException
* @expectedExceptionMessage One or more environment variables failed assertions: FOO is not one of [buzz, buz].