From c8dbd2f0978a3eab14d6b9b725197d5cc5445d07 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Mon, 3 Oct 2022 13:15:47 -0600 Subject: [PATCH] Typofixes --- UPGRADING.md | 10 +++++----- src/Parser/Lines.php | 2 +- src/Repository/RepositoryBuilder.php | 2 +- src/Util/Regex.php | 2 +- tests/Dotenv/DotenvTest.php | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index f9e59dcc..757f666f 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -78,18 +78,18 @@ Release notes for 4.0.0 are available [here](https://github.com/vlucas/phpdotenv ### Details -V4 has again changed the way you initialize the `Dotenv` class. If you want immutable loading of environment variables, then replace `Dotenv::create` with `Dotenv::createImmutable`, and if you want mutable loading, replace `Dotenv::create` with `Dotenv::createMutable` and `->overload()` with `->load()`. The `overload` method has been removed in faviour of specifying mutability at object construction. +V4 has again changed the way you initialize the `Dotenv` class. If you want immutable loading of environment variables, then replace `Dotenv::create` with `Dotenv::createImmutable`, and if you want mutable loading, replace `Dotenv::create` with `Dotenv::createMutable` and `->overload()` with `->load()`. The `overload` method has been removed in favour of specifying mutability at object construction. -The behaviour when parsing single quoted strings has now changed, to mimic the behaviour of bash. It is no longer possible to escape characters in single quoted strings, and everything is treated literally. As soon as the first single quote character is read, after the initial one, then the variable is treated as ending immediately at that point. When parsing unquoted or double quoted strings, it is now possible to escape dollar signs, to forcefully avoid variable interpolation. Escaping dollars is not mandated, in the sense that if a dollar is present, and not following by variable interpolation sytnax, this is allowed, and the dollar will be treated as a literal dollar. Finally, interpolation of variables is now performed right to left, instead of left to right, so it is possible to nest interpolations to allow using the value of a variable as the name of another for further interpolation. +The behaviour when parsing single quoted strings has now changed, to mimic the behaviour of bash. It is no longer possible to escape characters in single quoted strings, and everything is treated literally. As soon as the first single quote character is read, after the initial one, then the variable is treated as ending immediately at that point. When parsing unquoted or double quoted strings, it is now possible to escape dollar signs, to forcefully avoid variable interpolation. Escaping dollars is not mandated, in the sense that if a dollar is present, and not following by variable interpolation syntax, this is allowed, and the dollar will be treated as a literal dollar. Finally, interpolation of variables is now performed right to left, instead of left to right, so it is possible to nest interpolations to allow using the value of a variable as the name of another for further interpolation. The `getEnvironmentVariableNames` method is no longer available. This is because calls to `load()` (since v3.0.0) return an associative array of what was loaded, so `$dotenv->getEnvironmentVariableNames()` can be replaced with `array_keys($dotenv->load())`. -There have been various internal refactorings. Appart from what has already been mentioned, the only other changes likely to affect developers is: +There have been various internal refactorings. Apart from what has already been mentioned, the only other changes likely to affect developers is: 1. The `Dotenv\Environment` namespace has been moved to `Dotenv\Repository`, the `Dotenv\Environment\Adapter\AdapterInterface` interface has been replaced by `Dotenv\Repository\Adapter\ReaderInterface` and `Dotenv\Repository\Adapter\WriterInterface`. 2. The `Dotenv\Environment\DotenvFactory` has been (roughly) replaced by `Dotenv\Repository\RepositoryBuilder`, and `Dotenv\Environment\FactoryInterface` has been deleted. 3. `Dotenv\Environment\AbstractVariables` has been replaced by `Dotenv\Repository\AbstractRepository`, `Dotenv\Environment\DotenvVariables` has been replaced by `Dotenv\Repository\AdapterRepository`, and `Dotenv\Environment\VariablesInterface` has been replaced by `Dotenv\Repository\RepositoryInterface`. -4. The `Dotenv\Loader` class has been moved to `Dotenv\Loader\Loader`, and now has a different public interface. It no longer expects any parameters at construction, and implements only the new interface `Dotenv\Loader\LoaderInterface`. Its reponsibility has changed to purely taking raw env file content, and handing it off to the parser, dealing with variable interpolation, and sending off instructions to the repository to set variables. No longer can it be used as a way to read the environment by callers, and nor does it track immutability. +4. The `Dotenv\Loader` class has been moved to `Dotenv\Loader\Loader`, and now has a different public interface. It no longer expects any parameters at construction, and implements only the new interface `Dotenv\Loader\LoaderInterface`. Its responsibility has changed to purely taking raw env file content, and handing it off to the parser, dealing with variable interpolation, and sending off instructions to the repository to set variables. No longer can it be used as a way to read the environment by callers, and nor does it track immutability. 5. The `Dotenv\Parser` and `Dotenv\Lines` classes have moved to `Dotenv\Loader\Parser` and `Dotenv\Loader\Lines`, respectively. `Dotenv\Loader\Parser::parse` now return has either `null` or `Dotenv\Loader\Value` objects as values, instead of `string`s. This is to support the new variable interpolation and dollar escaping features. 6. The `Dotenv\Validator` constructor has changed from `__construct(array $variables, Loader $loader, $required = true)` to `__construct(RepositoryInterface $repository, array $variables, $required = true)`. @@ -136,7 +136,7 @@ $repository = RepositoryBuilder::create() $variables = (new Loader())->load($repository, $content); ``` -Notice, that compared to v3, the loader no longer expects file paths in the constructor. Reading of the files is now managed by the `Dotenv\Dotenv` class. The loader is geuinely just loading the content into the repository. +Notice, that compared to v3, the loader no longer expects file paths in the constructor. Reading of the files is now managed by the `Dotenv\Dotenv` class. The loader is genuinely just loading the content into the repository. Finally, we note that the minimum supported version of PHP has increased to 5.5.9, up from 5.4.0 in V3 and 5.3.9 in V2. diff --git a/src/Parser/Lines.php b/src/Parser/Lines.php index 38397947..40dbeab7 100644 --- a/src/Parser/Lines.php +++ b/src/Parser/Lines.php @@ -104,7 +104,7 @@ private static function looksLikeMultilineStop(string $line, bool $started) return true; } - return Regex::occurences('/(?=([^\\\\]"))/', \str_replace('\\\\', '', $line))->map(static function (int $count) use ($started) { + return Regex::occurrences('/(?=([^\\\\]"))/', \str_replace('\\\\', '', $line))->map(static function (int $count) use ($started) { return $started ? $count > 1 : $count >= 1; })->success()->getOrElse(false); } diff --git a/src/Repository/RepositoryBuilder.php b/src/Repository/RepositoryBuilder.php index 92f65e99..a042f9a1 100644 --- a/src/Repository/RepositoryBuilder.php +++ b/src/Repository/RepositoryBuilder.php @@ -111,7 +111,7 @@ private static function defaultAdapters() } /** - * Determine if the given name if of an adapaterclass. + * Determine if the given name if of an adapterclass. * * @param string $name * diff --git a/src/Util/Regex.php b/src/Util/Regex.php index e558f407..a038ca0a 100644 --- a/src/Util/Regex.php +++ b/src/Util/Regex.php @@ -47,7 +47,7 @@ public static function matches(string $pattern, string $subject) * * @return \GrahamCampbell\ResultType\Result */ - public static function occurences(string $pattern, string $subject) + public static function occurrences(string $pattern, string $subject) { return self::pregAndWrap(static function (string $subject) use ($pattern) { return (int) @\preg_match_all($pattern, $subject); diff --git a/tests/Dotenv/DotenvTest.php b/tests/Dotenv/DotenvTest.php index dc778537..8baf5dd9 100644 --- a/tests/Dotenv/DotenvTest.php +++ b/tests/Dotenv/DotenvTest.php @@ -317,7 +317,7 @@ public function testDotenvAllowsSpecialCharacters() self::assertSame('secret!@#', \getenv('SPVAR8')); } - public function testMutlilineLoading() + public function testMultilineLoading() { $dotenv = Dotenv::createUnsafeMutable(self::$folder, 'multiline.env'); $dotenv->load();