Composer update

This commit is contained in:
Clemens Schwaighofer
2024-08-21 11:45:17 +09:00
parent a8d07634ff
commit 2d71e760e8
6 changed files with 51 additions and 20 deletions

12
www/composer.lock generated
View File

@@ -38,16 +38,16 @@
},
{
"name": "gullevek/dotenv",
"version": "v2.0.8",
"version": "v2.1.0",
"source": {
"type": "git",
"url": "https://github.com/gullevek/dotEnv.git",
"reference": "e29f9fcd8853a09bb89b0eb8ee555b754ecee36e"
"reference": "b9feacaded4e48effff9da7d1173752aef3dc27f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/gullevek/dotEnv/zipball/e29f9fcd8853a09bb89b0eb8ee555b754ecee36e",
"reference": "e29f9fcd8853a09bb89b0eb8ee555b754ecee36e",
"url": "https://api.github.com/repos/gullevek/dotEnv/zipball/b9feacaded4e48effff9da7d1173752aef3dc27f",
"reference": "b9feacaded4e48effff9da7d1173752aef3dc27f",
"shasum": ""
},
"require": {
@@ -86,9 +86,9 @@
],
"support": {
"issues": "https://github.com/gullevek/dotEnv/issues",
"source": "https://github.com/gullevek/dotEnv/tree/v2.0.8"
"source": "https://github.com/gullevek/dotEnv/tree/v2.1.0"
},
"time": "2023-03-03T00:32:02+00:00"
"time": "2024-08-21T02:41:15+00:00"
},
{
"name": "psr/log",

View File

@@ -203,7 +203,8 @@ class SmartyExtend extends \Smarty
_bind_textdomain_codeset($this->domain, $this->encoding);
// register smarty variable
$this->registerPlugin('modifier', 'getvar', [&$this, 'getTemplateVars']);
// $this->registerPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, 'getvar', [&$this, 'getTemplateVars']);
$this->registerPlugin(self::PLUGIN_MODIFIER, 'getvar', [&$this, 'getTemplateVars']);
$this->page_name = \CoreLibs\Get\System::getPageName();

View File

@@ -35,17 +35,17 @@
},
{
"name": "gullevek/dotenv",
"version": "v2.0.8",
"version_normalized": "2.0.8.0",
"version": "v2.1.0",
"version_normalized": "2.1.0.0",
"source": {
"type": "git",
"url": "https://github.com/gullevek/dotEnv.git",
"reference": "e29f9fcd8853a09bb89b0eb8ee555b754ecee36e"
"reference": "b9feacaded4e48effff9da7d1173752aef3dc27f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/gullevek/dotEnv/zipball/e29f9fcd8853a09bb89b0eb8ee555b754ecee36e",
"reference": "e29f9fcd8853a09bb89b0eb8ee555b754ecee36e",
"url": "https://api.github.com/repos/gullevek/dotEnv/zipball/b9feacaded4e48effff9da7d1173752aef3dc27f",
"reference": "b9feacaded4e48effff9da7d1173752aef3dc27f",
"shasum": ""
},
"require": {
@@ -56,7 +56,7 @@
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9"
},
"time": "2023-03-03T00:32:02+00:00",
"time": "2024-08-21T02:41:15+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -86,7 +86,7 @@
],
"support": {
"issues": "https://github.com/gullevek/dotEnv/issues",
"source": "https://github.com/gullevek/dotEnv/tree/v2.0.8"
"source": "https://github.com/gullevek/dotEnv/tree/v2.1.0"
},
"install-path": "../gullevek/dotenv"
},

View File

@@ -29,9 +29,9 @@
'dev_requirement' => false,
),
'gullevek/dotenv' => array(
'pretty_version' => 'v2.0.8',
'version' => '2.0.8.0',
'reference' => 'e29f9fcd8853a09bb89b0eb8ee555b754ecee36e',
'pretty_version' => 'v2.1.0',
'version' => '2.1.0.0',
'reference' => 'b9feacaded4e48effff9da7d1173752aef3dc27f',
'type' => 'library',
'install_path' => __DIR__ . '/../gullevek/dotenv',
'aliases' => array(),

View File

@@ -61,6 +61,29 @@ DOUBLE="I will be used"
DOUBLE="This will be ignored"
```
A prefix name can be set with `[PrefixName]`. Tne name rules are like for variables, but spaces
are allowed, but will be converted to "_".
The prefix is valid from the time set until the next prefix block appears or the file ends.
Example
```ini
FOO="bar"
FOOBAR="bar bar"
[SecitonA]
FOO="other bar"
FOOBAR="other bar bar"
```
Will have environmen variables as
```php
$_ENV["FOO"];
$_ENV["FOOBAR"];
$_ENV["SecitonA.FOO"];
$_ENV["SecitonA.FOOBAR"];
```
## Development
### Phan

View File

@@ -22,6 +22,9 @@ class DotEnv
* if there are two variables with the same name only the first is used
* variables are case sensitive
*
* [] Grouping Block Name as prefix until next or end if set,
* space replaced by _, all other var rules apply
*
* @param string $path Folder to file, default is __DIR__
* @param string $env_file What file to load, default is .env
* @return int -1 other error
@@ -56,10 +59,14 @@ class DotEnv
$status = 1;
$block = false;
$var = '';
$prefix_name = '';
while ($line = fgets($fp)) {
// main match for variable = value part
if (preg_match("/^\s*([\w_.]+)\s*=\s*((\"?).*)/", $line, $matches)) {
$var = $matches[1];
// [] block must be a single line, or it will be ignored
if (preg_match("/^\s*\[([\w_.\s]+)\]/", $line, $matches)) {
$prefix_name = preg_replace("/\s+/", "_", $matches[1]) . ".";
} elseif (preg_match("/^\s*([\w_.]+)\s*=\s*((\"?).*)/", $line, $matches)) {
// main match for variable = value part
$var = $prefix_name . $matches[1];
$value = $matches[2];
$quotes = $matches[3];
// write only if env is not set yet, and write only the first time