Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
50
vendor/grasmash/expander/.gitignore
vendored
Normal file
50
vendor/grasmash/expander/.gitignore
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
# Cache and logs (Symfony2)
|
||||
/app/cache/*
|
||||
/app/logs/*
|
||||
!app/cache/.gitkeep
|
||||
!app/logs/.gitkeep
|
||||
|
||||
# Email spool folder
|
||||
/app/spool/*
|
||||
|
||||
# Cache, session files and logs (Symfony3)
|
||||
/var/cache/*
|
||||
/var/logs/*
|
||||
/var/sessions/*
|
||||
!var/cache/.gitkeep
|
||||
!var/logs/.gitkeep
|
||||
!var/sessions/.gitkeep
|
||||
|
||||
# Parameters
|
||||
/app/config/parameters.yml
|
||||
/app/config/parameters.ini
|
||||
|
||||
# Managed by Composer
|
||||
/app/bootstrap.php.cache
|
||||
/var/bootstrap.php.cache
|
||||
/bin/*
|
||||
!bin/console
|
||||
!bin/symfony_requirements
|
||||
/vendor/
|
||||
|
||||
# Assets and user uploads
|
||||
/web/bundles/
|
||||
/web/uploads/
|
||||
|
||||
# Assets managed by Bower
|
||||
/web/assets/vendor/
|
||||
|
||||
# PHPUnit
|
||||
/app/phpunit.xml
|
||||
/phpunit.xml
|
||||
|
||||
# Build data
|
||||
/build/
|
||||
|
||||
# Composer PHAR
|
||||
/composer.phar
|
||||
|
||||
# Backup entities generated with doctrine:generate:entities command
|
||||
*/Entity/*~
|
||||
|
||||
.idea
|
28
vendor/grasmash/expander/.travis.yml
vendored
Normal file
28
vendor/grasmash/expander/.travis.yml
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
language: php
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- php: 7.2
|
||||
- php: 7.1
|
||||
- php: 7.0.11
|
||||
- php: 5.6
|
||||
- php: 5.5
|
||||
- php: 5.4
|
||||
|
||||
sudo: false
|
||||
|
||||
cache:
|
||||
apt: true
|
||||
directories:
|
||||
- "$HOME/.composer/cache"
|
||||
- "vendor"
|
||||
|
||||
install:
|
||||
- composer install
|
||||
|
||||
script:
|
||||
- composer test
|
||||
|
||||
after_success:
|
||||
- travis_retry php vendor/bin/coveralls -v
|
0
vendor/grasmash/expander/CONTRIBUTING.md
vendored
Normal file
0
vendor/grasmash/expander/CONTRIBUTING.md
vendored
Normal file
21
vendor/grasmash/expander/LICENSE.md
vendored
Normal file
21
vendor/grasmash/expander/LICENSE.md
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Matthew Grasmick
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
149
vendor/grasmash/expander/README.md
vendored
Normal file
149
vendor/grasmash/expander/README.md
vendored
Normal file
|
@ -0,0 +1,149 @@
|
|||
[](https://travis-ci.org/grasmash/expander) [](https://packagist.org/packages/grasmash/expander)
|
||||
[](https://packagist.org/packages/grasmash/expander) [](https://coveralls.io/github/grasmash/expander?branch=master)
|
||||
|
||||
This tool expands property references in PHP arrays. For example implementation, see Yaml Expander.
|
||||
|
||||
### Installation
|
||||
|
||||
composer require grasmash/expander
|
||||
|
||||
### Example usage:
|
||||
|
||||
Property references use dot notation to indicate array keys, and must be wrapped in `${}`.
|
||||
|
||||
Expansion logic:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
$array = [
|
||||
'type' => 'book',
|
||||
'book' => [
|
||||
'title' => 'Dune',
|
||||
'author' => 'Frank Herbert',
|
||||
'copyright' => '${book.author} 1965',
|
||||
'protaganist' => '${characters.0.name}',
|
||||
'media' => [
|
||||
0 => 'hardcover',
|
||||
1 => 'paperback',
|
||||
],
|
||||
'nested-reference' => '${book.sequel}',
|
||||
],
|
||||
'characters' => [
|
||||
0 => [
|
||||
'name' => 'Paul Atreides',
|
||||
'occupation' => 'Kwisatz Haderach',
|
||||
'aliases' => [
|
||||
0 => 'Usul',
|
||||
1 => 'Muad\'Dib',
|
||||
2 => 'The Preacher',
|
||||
],
|
||||
],
|
||||
1 => [
|
||||
'name' => 'Duncan Idaho',
|
||||
'occupation' => 'Swordmaster',
|
||||
],
|
||||
],
|
||||
'summary' => '${book.title} by ${book.author}',
|
||||
'publisher' => '${not.real.property}',
|
||||
'sequels' => '${book.sequel}, and others.',
|
||||
'available-products' => '${book.media.1}, ${book.media.0}',
|
||||
'product-name' => '${${type}.title}',
|
||||
'boolean-value' => true,
|
||||
'null-value' => NULL,
|
||||
'inline-array' => [
|
||||
0 => 'one',
|
||||
1 => 'two',
|
||||
2 => 'three',
|
||||
],
|
||||
'expand-array' => '${inline-array}',
|
||||
'env-test' => '${env.test}',
|
||||
];
|
||||
|
||||
$expander = new Expander();
|
||||
// Optionally set a logger.
|
||||
$expander->setLogger(new Psr\Log\NullLogger());
|
||||
// Optionally set a Stringfier, used to convert array placeholders into strings. Defaults to using implode() with `,` delimeter.
|
||||
// @see StringifierInterface.
|
||||
$expander->setStringifier(new Grasmash\Expander\Stringifier());
|
||||
|
||||
// Parse an array, expanding internal property references.
|
||||
$expanded = $expander->expandArrayProperties($array);
|
||||
|
||||
// Parse an array, expanding references using both internal and supplementary values.
|
||||
$reference_properties = 'book' => ['sequel' => 'Dune Messiah'];
|
||||
// Set an environmental variable.
|
||||
putenv("test=gomjabbar");
|
||||
$expanded = $expander->expandArrayProperties($array, $reference_properties);
|
||||
|
||||
print_r($expanded);
|
||||
````
|
||||
|
||||
Resultant array:
|
||||
|
||||
```php
|
||||
Array
|
||||
(
|
||||
[type] => book
|
||||
[book] => Array
|
||||
(
|
||||
[title] => Dune
|
||||
[author] => Frank Herbert
|
||||
[copyright] => Frank Herbert 1965
|
||||
[protaganist] => Paul Atreides
|
||||
[media] => Array
|
||||
(
|
||||
[0] => hardcover
|
||||
[1] => paperback
|
||||
)
|
||||
|
||||
[nested-reference] => Dune Messiah
|
||||
)
|
||||
|
||||
[characters] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[name] => Paul Atreides
|
||||
[occupation] => Kwisatz Haderach
|
||||
[aliases] => Array
|
||||
(
|
||||
[0] => Usul
|
||||
[1] => Muad'Dib
|
||||
[2] => The Preacher
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[name] => Duncan Idaho
|
||||
[occupation] => Swordmaster
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[summary] => Dune by Frank Herbert
|
||||
[publisher] => ${not.real.property}
|
||||
[sequels] => Dune Messiah, and others.
|
||||
[available-products] => paperback, hardcover
|
||||
[product-name] => Dune
|
||||
[boolean-value] => 1
|
||||
[null-value] =>
|
||||
[inline-array] => Array
|
||||
(
|
||||
[0] => one
|
||||
[1] => two
|
||||
[2] => three
|
||||
)
|
||||
|
||||
[expand-array] => one,two,three
|
||||
[env-test] => gomjabbar
|
||||
[env] => Array
|
||||
(
|
||||
[test] => gomjabbar
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
```
|
11
vendor/grasmash/expander/RELEASE.md
vendored
Normal file
11
vendor/grasmash/expander/RELEASE.md
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Releasing
|
||||
|
||||
### Execute tests
|
||||
|
||||
./scripts/run-tests.sh
|
||||
|
||||
To quickly fix PHPCS issues:
|
||||
|
||||
./scripts/clean-code.sh
|
||||
|
||||
|
50
vendor/grasmash/expander/composer.json
vendored
Normal file
50
vendor/grasmash/expander/composer.json
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"name": "grasmash/expander",
|
||||
"description": "Expands internal property references in PHP arrays file.",
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": ">=5.4",
|
||||
"dflydev/dot-access-data": "^1.1.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Matthew Grasmick"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "stable",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Grasmash\\Expander\\": "src/"
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4|^5.5.4",
|
||||
"satooshi/php-coveralls": "^1.0.2|dev-master",
|
||||
"greg-1-anderson/composer-test-scenarios": "^1",
|
||||
"squizlabs/php_codesniffer": "^2.7"
|
||||
},
|
||||
"scripts": {
|
||||
"cs": "phpcs -n --standard=PSR2 src tests --exclude=Generic.Files.LineLength",
|
||||
"cbf": "phpcbf -n --standard=PSR2 src tests --exclude=Generic.Files.LineLength",
|
||||
"unit": "phpunit",
|
||||
"lint": [
|
||||
"find src -name '*.php' -print0 | xargs -0 -n1 php -l",
|
||||
"find tests -name '*.php' -print0 | xargs -0 -n1 php -l"
|
||||
],
|
||||
"test": [
|
||||
"@lint",
|
||||
"@unit",
|
||||
"@cs"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
1750
vendor/grasmash/expander/composer.lock
generated
vendored
Normal file
1750
vendor/grasmash/expander/composer.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
16
vendor/grasmash/expander/phpunit.xml.dist
vendored
Normal file
16
vendor/grasmash/expander/phpunit.xml.dist
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<!-- phpunit.xml.dist -->
|
||||
<phpunit>
|
||||
<testsuites>
|
||||
<testsuite name="Yaml Expander Test Suite">
|
||||
<directory>tests/phpunit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<logging>
|
||||
<log type="coverage-clover" target="build/logs/clover.xml"/>
|
||||
</logging>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
303
vendor/grasmash/expander/src/Expander.php
vendored
Normal file
303
vendor/grasmash/expander/src/Expander.php
vendored
Normal file
|
@ -0,0 +1,303 @@
|
|||
<?php
|
||||
|
||||
namespace Grasmash\Expander;
|
||||
|
||||
use Dflydev\DotAccessData\Data;
|
||||
use Psr\Log\LoggerAwareInterface;
|
||||
use Psr\Log\NullLogger;
|
||||
|
||||
/**
|
||||
* Class Expander
|
||||
* @package Grasmash\Expander
|
||||
*/
|
||||
class Expander implements LoggerAwareInterface
|
||||
{
|
||||
/**
|
||||
* @var \Grasmash\Expander\StringifierInterface
|
||||
*/
|
||||
protected $stringifier;
|
||||
/**
|
||||
* @var \Psr\Log\LoggerInterface
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setLogger(new NullLogger());
|
||||
$this->setStringifier(new Stringifier());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Grasmash\Expander\StringifierInterface
|
||||
*/
|
||||
public function getStringifier()
|
||||
{
|
||||
return $this->stringifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Grasmash\Expander\StringifierInterface $stringifier
|
||||
*/
|
||||
public function setStringifier(\Grasmash\Expander\StringifierInterface $stringifier)
|
||||
{
|
||||
$this->stringifier = $stringifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Log\LoggerInterface
|
||||
*/
|
||||
public function getLogger()
|
||||
{
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Psr\Log\LoggerInterface $logger
|
||||
*/
|
||||
public function setLogger(\Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands property placeholders in an array.
|
||||
*
|
||||
* Placeholders should formatted as ${parent.child}.
|
||||
*
|
||||
* @param array $array
|
||||
* An array containing properties to expand.
|
||||
*
|
||||
* @return array
|
||||
* The modified array in which placeholders have been replaced with
|
||||
* values.
|
||||
*/
|
||||
public function expandArrayProperties($array, $reference_array = [])
|
||||
{
|
||||
$data = new Data($array);
|
||||
if ($reference_array) {
|
||||
$reference_data = new Data($reference_array);
|
||||
$this->doExpandArrayProperties($data, $array, '', $reference_data);
|
||||
} else {
|
||||
$this->doExpandArrayProperties($data, $array);
|
||||
}
|
||||
|
||||
return $data->export();
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the actual property expansion.
|
||||
*
|
||||
* @param Data $data
|
||||
* A data object, containing the $array.
|
||||
* @param array $array
|
||||
* The original, unmodified array.
|
||||
* @param string $parent_keys
|
||||
* The parent keys of the current key in dot notation. This is used to
|
||||
* track the absolute path to the current key in recursive cases.
|
||||
* @param Data|null $reference_data
|
||||
* A reference data object. This is not operated upon but is used as a
|
||||
* reference to provide supplemental values for property expansion.
|
||||
*/
|
||||
protected function doExpandArrayProperties(
|
||||
$data,
|
||||
$array,
|
||||
$parent_keys = '',
|
||||
$reference_data = null
|
||||
) {
|
||||
foreach ($array as $key => $value) {
|
||||
// Boundary condition(s).
|
||||
if (is_null($value) || is_bool($value)) {
|
||||
continue;
|
||||
}
|
||||
// Recursive case.
|
||||
if (is_array($value)) {
|
||||
$this->doExpandArrayProperties($data, $value, $parent_keys . "$key.", $reference_data);
|
||||
} // Base case.
|
||||
else {
|
||||
$this->expandStringProperties($data, $parent_keys, $reference_data, $value, $key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand a single property.
|
||||
*
|
||||
* @param Data $data
|
||||
* A data object, containing the $array.
|
||||
* @param string $parent_keys
|
||||
* The parent keys of the current key in dot notation. This is used to
|
||||
* track the absolute path to the current key in recursive cases.
|
||||
* @param Data|null $reference_data
|
||||
* A reference data object. This is not operated upon but is used as a
|
||||
* reference to provide supplemental values for property expansion.
|
||||
* @param string $value
|
||||
* The unexpanded property value.
|
||||
* @param string $key
|
||||
* The immediate key of the property.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function expandStringProperties(
|
||||
$data,
|
||||
$parent_keys,
|
||||
$reference_data,
|
||||
$value,
|
||||
$key
|
||||
) {
|
||||
// We loop through all placeholders in a given string.
|
||||
// E.g., '${placeholder1} ${placeholder2}' requires two replacements.
|
||||
while (strpos($value, '${') !== false) {
|
||||
$original_value = $value;
|
||||
$value = preg_replace_callback(
|
||||
'/\$\{([^\$}]+)\}/',
|
||||
function ($matches) use ($data, $reference_data) {
|
||||
return $this->expandStringPropertiesCallback(
|
||||
$matches,
|
||||
$data,
|
||||
$reference_data
|
||||
);
|
||||
},
|
||||
$value
|
||||
);
|
||||
|
||||
// If no replacement occurred at all, break to prevent
|
||||
// infinite loop.
|
||||
if ($original_value == $value) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Set value on $data object.
|
||||
if ($parent_keys) {
|
||||
$full_key = $parent_keys . "$key";
|
||||
} else {
|
||||
$full_key = $key;
|
||||
}
|
||||
$data->set($full_key, $value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expansion callback used by preg_replace_callback() in expandProperty().
|
||||
*
|
||||
* @param array $matches
|
||||
* An array of matches created by preg_replace_callback().
|
||||
* @param Data $data
|
||||
* A data object containing the complete array being operated upon.
|
||||
* @param Data|null $reference_data
|
||||
* A reference data object. This is not operated upon but is used as a
|
||||
* reference to provide supplemental values for property expansion.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function expandStringPropertiesCallback(
|
||||
$matches,
|
||||
$data,
|
||||
$reference_data = null
|
||||
) {
|
||||
$property_name = $matches[1];
|
||||
$unexpanded_value = $matches[0];
|
||||
|
||||
// Use only values within the subject array's data.
|
||||
if (!$reference_data) {
|
||||
return $this->expandProperty($property_name, $unexpanded_value, $data);
|
||||
} // Search both the subject array's data and the reference data for a value.
|
||||
else {
|
||||
return $this->expandPropertyWithReferenceData(
|
||||
$property_name,
|
||||
$unexpanded_value,
|
||||
$data,
|
||||
$reference_data
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches both the subject data and the reference data for value.
|
||||
*
|
||||
* @param string $property_name
|
||||
* The name of the value for which to search.
|
||||
* @param string $unexpanded_value
|
||||
* The original, unexpanded value, containing the placeholder.
|
||||
* @param Data $data
|
||||
* A data object containing the complete array being operated upon.
|
||||
* @param Data|null $reference_data
|
||||
* A reference data object. This is not operated upon but is used as a
|
||||
* reference to provide supplemental values for property expansion.
|
||||
*
|
||||
* @return string
|
||||
* The expanded string.
|
||||
*/
|
||||
public function expandPropertyWithReferenceData(
|
||||
$property_name,
|
||||
$unexpanded_value,
|
||||
$data,
|
||||
$reference_data
|
||||
) {
|
||||
$expanded_value = $this->expandProperty(
|
||||
$property_name,
|
||||
$unexpanded_value,
|
||||
$data
|
||||
);
|
||||
// If the string was not changed using the subject data, try using
|
||||
// the reference data.
|
||||
if ($expanded_value == $unexpanded_value) {
|
||||
$expanded_value = $this->expandProperty(
|
||||
$property_name,
|
||||
$unexpanded_value,
|
||||
$reference_data
|
||||
);
|
||||
}
|
||||
|
||||
return $expanded_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches a data object for a value.
|
||||
*
|
||||
* @param string $property_name
|
||||
* The name of the value for which to search.
|
||||
* @param string $unexpanded_value
|
||||
* The original, unexpanded value, containing the placeholder.
|
||||
* @param Data $data
|
||||
* A data object containing possible replacement values.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function expandProperty($property_name, $unexpanded_value, $data)
|
||||
{
|
||||
if (strpos($property_name, "env.") === 0 &&
|
||||
!$data->has($property_name)) {
|
||||
$env_key = substr($property_name, 4);
|
||||
if (getenv($env_key)) {
|
||||
$data->set($property_name, getenv($env_key));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$data->has($property_name)) {
|
||||
$this->log("Property \${'$property_name'} could not be expanded.");
|
||||
return $unexpanded_value;
|
||||
} else {
|
||||
$expanded_value = $data->get($property_name);
|
||||
if (is_array($expanded_value)) {
|
||||
$expanded_value = $this->getStringifier()->stringifyArray($expanded_value);
|
||||
return $expanded_value;
|
||||
}
|
||||
$this->log("Expanding property \${'$property_name'} => $expanded_value.");
|
||||
return $expanded_value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a message using the logger.
|
||||
*
|
||||
* @param string $message
|
||||
* The message to log.
|
||||
*/
|
||||
public function log($message)
|
||||
{
|
||||
if ($this->getLogger()) {
|
||||
$this->getLogger()->debug($message);
|
||||
}
|
||||
}
|
||||
}
|
24
vendor/grasmash/expander/src/Stringifier.php
vendored
Normal file
24
vendor/grasmash/expander/src/Stringifier.php
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Grasmash\Expander;
|
||||
|
||||
/**
|
||||
* Class Stringifier
|
||||
* @package Grasmash\Expander
|
||||
*/
|
||||
class Stringifier implements StringifierInterface
|
||||
{
|
||||
/**
|
||||
* Converts array to string.
|
||||
*
|
||||
* @param array $array
|
||||
* The array to convert.
|
||||
*
|
||||
* @return string
|
||||
* The resultant string.
|
||||
*/
|
||||
public static function stringifyArray(array $array)
|
||||
{
|
||||
return implode(',', $array);
|
||||
}
|
||||
}
|
17
vendor/grasmash/expander/src/StringifierInterface.php
vendored
Normal file
17
vendor/grasmash/expander/src/StringifierInterface.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace Grasmash\Expander;
|
||||
|
||||
interface StringifierInterface
|
||||
{
|
||||
/**
|
||||
* Converts array to string.
|
||||
*
|
||||
* @param array $array
|
||||
* The array to convert.
|
||||
*
|
||||
* @return string
|
||||
* The resultant string.
|
||||
*/
|
||||
public static function stringifyArray(array $array);
|
||||
}
|
122
vendor/grasmash/expander/tests/phpunit/ExpanderTest.php
vendored
Normal file
122
vendor/grasmash/expander/tests/phpunit/ExpanderTest.php
vendored
Normal file
|
@ -0,0 +1,122 @@
|
|||
<?php
|
||||
|
||||
namespace Grasmash\Expander\Tests\Command;
|
||||
|
||||
use Dflydev\DotAccessData\Data;
|
||||
use Grasmash\Expander\Expander;
|
||||
use Grasmash\Expander\Stringifier;
|
||||
|
||||
class ExpanderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Tests Expander::expandArrayProperties().
|
||||
*
|
||||
* @param array $array
|
||||
* @param array $reference_array
|
||||
*
|
||||
* @dataProvider providerYaml
|
||||
*/
|
||||
public function testExpandArrayProperties(array $array, array $reference_array)
|
||||
{
|
||||
$expander = new Expander();
|
||||
|
||||
putenv("test=gomjabbar");
|
||||
$expanded = $expander->expandArrayProperties($array);
|
||||
$this->assertEquals('gomjabbar', $expanded['env-test']);
|
||||
$this->assertEquals('Frank Herbert 1965', $expanded['book']['copyright']);
|
||||
$this->assertEquals('Paul Atreides', $expanded['book']['protaganist']);
|
||||
$this->assertEquals('Dune by Frank Herbert', $expanded['summary']);
|
||||
$this->assertEquals('${book.media.1}, hardcover', $expanded['available-products']);
|
||||
$this->assertEquals('Dune', $expanded['product-name']);
|
||||
$this->assertEquals(Stringifier::stringifyArray($array['inline-array']), $expanded['expand-array']);
|
||||
|
||||
$expanded = $expander->expandArrayProperties($array, $reference_array);
|
||||
$this->assertEquals('Dune Messiah, and others.', $expanded['sequels']);
|
||||
$this->assertEquals('Dune Messiah', $expanded['book']['nested-reference']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* An array of values to test.
|
||||
*/
|
||||
public function providerYaml()
|
||||
{
|
||||
return [
|
||||
[
|
||||
[
|
||||
'type' => 'book',
|
||||
'book' => [
|
||||
'title' => 'Dune',
|
||||
'author' => 'Frank Herbert',
|
||||
'copyright' => '${book.author} 1965',
|
||||
'protaganist' => '${characters.0.name}',
|
||||
'media' => [
|
||||
0 => 'hardcover',
|
||||
],
|
||||
'nested-reference' => '${book.sequel}',
|
||||
],
|
||||
'characters' => [
|
||||
0 => [
|
||||
'name' => 'Paul Atreides',
|
||||
'occupation' => 'Kwisatz Haderach',
|
||||
'aliases' => [
|
||||
0 => 'Usul',
|
||||
1 => "Muad'Dib",
|
||||
2 => 'The Preacher',
|
||||
],
|
||||
],
|
||||
1 => [
|
||||
'name' => 'Duncan Idaho',
|
||||
'occupation' => 'Swordmaster',
|
||||
],
|
||||
],
|
||||
'summary' => '${book.title} by ${book.author}',
|
||||
'publisher' => '${not.real.property}',
|
||||
'sequels' => '${book.sequel}, and others.',
|
||||
'available-products' => '${book.media.1}, ${book.media.0}',
|
||||
'product-name' => '${${type}.title}',
|
||||
'boolean-value' => true,
|
||||
'null-value' => null,
|
||||
'inline-array' => [
|
||||
0 => 'one',
|
||||
1 => 'two',
|
||||
2 => 'three',
|
||||
],
|
||||
'expand-array' => '${inline-array}',
|
||||
'env-test' => '${env.test}',
|
||||
],
|
||||
[
|
||||
'book' => [
|
||||
'sequel' => 'Dune Messiah'
|
||||
]
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Expander::expandProperty().
|
||||
*
|
||||
* @dataProvider providerTestExpandProperty
|
||||
*/
|
||||
public function testExpandProperty(array $array, $property_name, $unexpanded_string, $expected)
|
||||
{
|
||||
$data = new Data($array);
|
||||
$expander = new Expander();
|
||||
$expanded_value = $expander->expandProperty($property_name, $unexpanded_string, $data);
|
||||
|
||||
$this->assertEquals($expected, $expanded_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function providerTestExpandProperty()
|
||||
{
|
||||
return [
|
||||
[ ['author' => 'Frank Herbert'], 'author', '${author}', 'Frank Herbert' ],
|
||||
[ ['book' => ['author' => 'Frank Herbert' ]], 'book.author', '${book.author}', 'Frank Herbert' ],
|
||||
];
|
||||
}
|
||||
}
|
50
vendor/grasmash/yaml-expander/.gitignore
vendored
Normal file
50
vendor/grasmash/yaml-expander/.gitignore
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
# Cache and logs (Symfony2)
|
||||
/app/cache/*
|
||||
/app/logs/*
|
||||
!app/cache/.gitkeep
|
||||
!app/logs/.gitkeep
|
||||
|
||||
# Email spool folder
|
||||
/app/spool/*
|
||||
|
||||
# Cache, session files and logs (Symfony3)
|
||||
/var/cache/*
|
||||
/var/logs/*
|
||||
/var/sessions/*
|
||||
!var/cache/.gitkeep
|
||||
!var/logs/.gitkeep
|
||||
!var/sessions/.gitkeep
|
||||
|
||||
# Parameters
|
||||
/app/config/parameters.yml
|
||||
/app/config/parameters.ini
|
||||
|
||||
# Managed by Composer
|
||||
/app/bootstrap.php.cache
|
||||
/var/bootstrap.php.cache
|
||||
/bin/*
|
||||
!bin/console
|
||||
!bin/symfony_requirements
|
||||
/vendor/
|
||||
|
||||
# Assets and user uploads
|
||||
/web/bundles/
|
||||
/web/uploads/
|
||||
|
||||
# Assets managed by Bower
|
||||
/web/assets/vendor/
|
||||
|
||||
# PHPUnit
|
||||
/app/phpunit.xml
|
||||
/phpunit.xml
|
||||
|
||||
# Build data
|
||||
/build/
|
||||
|
||||
# Composer PHAR
|
||||
/composer.phar
|
||||
|
||||
# Backup entities generated with doctrine:generate:entities command
|
||||
*/Entity/*~
|
||||
|
||||
.idea
|
39
vendor/grasmash/yaml-expander/.travis.yml
vendored
Normal file
39
vendor/grasmash/yaml-expander/.travis.yml
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
language: php
|
||||
|
||||
branches:
|
||||
# Only test the master branch and SemVer tags.
|
||||
only:
|
||||
- master
|
||||
- /^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+.*$/
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- php: 7.2
|
||||
env: 'SCENARIO=symfony4 HIGHEST_LOWEST="update"'
|
||||
- php: 7.1
|
||||
env: 'SCENARIO=symfony4'
|
||||
- php: 7.0.11
|
||||
env: 'HIGHEST_LOWEST="update"'
|
||||
- php: 7.0.11
|
||||
- php: 5.6
|
||||
- php: 5.5
|
||||
- php: 5.4
|
||||
env: 'SCENARIO=symfony2 HIGHEST_LOWEST="update --prefer-lowest'
|
||||
|
||||
sudo: false
|
||||
|
||||
cache:
|
||||
apt: true
|
||||
directories:
|
||||
- "$HOME/.composer/cache"
|
||||
- "vendor"
|
||||
|
||||
install:
|
||||
- 'composer scenario "${SCENARIO}" "${HIGHEST_LOWEST-install}"'
|
||||
|
||||
script:
|
||||
- composer test
|
||||
|
||||
after_success:
|
||||
- travis_retry php vendor/bin/coveralls -v
|
0
vendor/grasmash/yaml-expander/CONTRIBUTING.md
vendored
Normal file
0
vendor/grasmash/yaml-expander/CONTRIBUTING.md
vendored
Normal file
21
vendor/grasmash/yaml-expander/LICENSE.md
vendored
Normal file
21
vendor/grasmash/yaml-expander/LICENSE.md
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Matthew Grasmick
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
100
vendor/grasmash/yaml-expander/README.md
vendored
Normal file
100
vendor/grasmash/yaml-expander/README.md
vendored
Normal file
|
@ -0,0 +1,100 @@
|
|||
[](https://travis-ci.org/grasmash/yaml-expander) [](https://packagist.org/packages/grasmash/yaml-expander)
|
||||
[](https://packagist.org/packages/grasmash/yaml-expander) [](https://coveralls.io/github/grasmash/yaml-expander?branch=master)
|
||||
|
||||
This tool expands property references in YAML files.
|
||||
|
||||
### Installation
|
||||
|
||||
composer require grasmash/yaml-expander
|
||||
|
||||
### Example usage:
|
||||
|
||||
Example dune.yml:
|
||||
|
||||
```yaml
|
||||
type: book
|
||||
book:
|
||||
title: Dune
|
||||
author: Frank Herbert
|
||||
copyright: ${book.author} 1965
|
||||
protaganist: ${characters.0.name}
|
||||
media:
|
||||
- hardcover
|
||||
characters:
|
||||
- name: Paul Atreides
|
||||
occupation: Kwisatz Haderach
|
||||
aliases:
|
||||
- Usul
|
||||
- Muad'Dib
|
||||
- The Preacher
|
||||
- name: Duncan Idaho
|
||||
occupation: Swordmaster
|
||||
summary: ${book.title} by ${book.author}
|
||||
product-name: ${${type}.title}
|
||||
```
|
||||
|
||||
Property references use dot notation to indicate array keys, and must be wrapped in `${}`.
|
||||
|
||||
Expansion logic:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
// Parse a yaml string directly, expanding internal property references.
|
||||
$yaml_string = file_get_contents("dune.yml");
|
||||
$expanded = \Grasmash\YamlExpander\Expander::parse($yaml_string);
|
||||
print_r($expanded);
|
||||
|
||||
// Parse an array, expanding internal property references.
|
||||
$array = \Symfony\Component\Yaml\Yaml::parse(file_get_contents("dune.yml"));
|
||||
$expanded = \Grasmash\YamlExpander\Expander::expandArrayProperties($array);
|
||||
print_r($expanded);
|
||||
|
||||
// Parse an array, expanding references using both internal and supplementary values.
|
||||
$array = \Symfony\Component\Yaml\Yaml::parse(file_get_contents("dune.yml"));
|
||||
$reference_properties = ['book' => ['publication-year' => 1965]];
|
||||
$expanded = \Grasmash\YamlExpander\Expander::expandArrayProperties($array, $reference_properties);
|
||||
print_r($expanded);
|
||||
````
|
||||
|
||||
Resultant array:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
array (
|
||||
'type' => 'book',
|
||||
'book' =>
|
||||
array (
|
||||
'title' => 'Dune',
|
||||
'author' => 'Frank Herbert',
|
||||
'copyright' => 'Frank Herbert 1965',
|
||||
'protaganist' => 'Paul Atreides',
|
||||
'media' =>
|
||||
array (
|
||||
0 => 'hardcover',
|
||||
),
|
||||
),
|
||||
'characters' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'name' => 'Paul Atreides',
|
||||
'occupation' => 'Kwisatz Haderach',
|
||||
'aliases' =>
|
||||
array (
|
||||
0 => 'Usul',
|
||||
1 => 'Muad\'Dib',
|
||||
2 => 'The Preacher',
|
||||
),
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'name' => 'Duncan Idaho',
|
||||
'occupation' => 'Swordmaster',
|
||||
),
|
||||
),
|
||||
'summary' => 'Dune by Frank Herbert',
|
||||
'product-name' => 'Dune',
|
||||
);
|
||||
```
|
11
vendor/grasmash/yaml-expander/RELEASE.md
vendored
Normal file
11
vendor/grasmash/yaml-expander/RELEASE.md
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Releasing
|
||||
|
||||
### Execute tests
|
||||
|
||||
./scripts/run-tests.sh
|
||||
|
||||
To quickly fix PHPCS issues:
|
||||
|
||||
./scripts/clean-code.sh
|
||||
|
||||
|
59
vendor/grasmash/yaml-expander/composer.json
vendored
Normal file
59
vendor/grasmash/yaml-expander/composer.json
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
"name": "grasmash/yaml-expander",
|
||||
"description": "Expands internal property references in a yaml file.",
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": ">=5.4",
|
||||
"symfony/yaml": "^2.8.11|^3|^4",
|
||||
"dflydev/dot-access-data": "^1.1.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Matthew Grasmick"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "stable",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Grasmash\\YamlExpander\\": "src/"
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8|^5.5.4",
|
||||
"satooshi/php-coveralls": "^1.0.2|dev-master",
|
||||
"greg-1-anderson/composer-test-scenarios": "^1",
|
||||
"squizlabs/php_codesniffer": "^2.7"
|
||||
},
|
||||
"scripts": {
|
||||
"cs": "phpcs -n --standard=PSR2 src tests --exclude=Generic.Files.LineLength",
|
||||
"cbf": "phpcbf -n --standard=PSR2 src tests --exclude=Generic.Files.LineLength",
|
||||
"unit": "phpunit",
|
||||
"lint": [
|
||||
"find src -name '*.php' -print0 | xargs -0 -n1 php -l",
|
||||
"find tests -name '*.php' -print0 | xargs -0 -n1 php -l"
|
||||
],
|
||||
"test": [
|
||||
"@lint",
|
||||
"@unit",
|
||||
"@cs"
|
||||
],
|
||||
"scenario": "scenarios/install",
|
||||
"post-update-cmd": [
|
||||
"create-scenario symfony4 'symfony/console:^4.0'",
|
||||
"create-scenario symfony2 'symfony/console:^2.8' --platform-php '5.4' --no-lockfile"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true,
|
||||
"platform": {
|
||||
"php": "5.5.9"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
2019
vendor/grasmash/yaml-expander/composer.lock
generated
vendored
Normal file
2019
vendor/grasmash/yaml-expander/composer.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
16
vendor/grasmash/yaml-expander/phpunit.xml.dist
vendored
Normal file
16
vendor/grasmash/yaml-expander/phpunit.xml.dist
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<!-- phpunit.xml.dist -->
|
||||
<phpunit>
|
||||
<testsuites>
|
||||
<testsuite name="Yaml Expander Test Suite">
|
||||
<directory>tests/phpunit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<logging>
|
||||
<log type="coverage-clover" target="build/logs/clover.xml"/>
|
||||
</logging>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
23
vendor/grasmash/yaml-expander/scenarios/install
vendored
Executable file
23
vendor/grasmash/yaml-expander/scenarios/install
vendored
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
SCENARIO=$1
|
||||
ACTION=${2-install}
|
||||
|
||||
dir=scenarios/${SCENARIO}
|
||||
if [ -z "$SCENARIO" ] ; then
|
||||
SCENARIO=default
|
||||
dir=.
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -d "$dir" ] ; then
|
||||
echo "Requested scenario '${SCENARIO}' does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Switch to ${SCENARIO} scenario"
|
||||
|
||||
set -ex
|
||||
|
||||
composer -n --working-dir=$dir ${ACTION} --prefer-dist --no-scripts
|
||||
composer -n --working-dir=$dir info
|
2
vendor/grasmash/yaml-expander/scenarios/symfony2/.gitignore
vendored
Normal file
2
vendor/grasmash/yaml-expander/scenarios/symfony2/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
vendor
|
||||
composer.lock
|
61
vendor/grasmash/yaml-expander/scenarios/symfony2/composer.json
vendored
Normal file
61
vendor/grasmash/yaml-expander/scenarios/symfony2/composer.json
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"name": "grasmash/yaml-expander",
|
||||
"description": "Expands internal property references in a yaml file.",
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": ">=5.4",
|
||||
"symfony/yaml": "^2.8.11|^3|^4",
|
||||
"dflydev/dot-access-data": "^1.1.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Matthew Grasmick"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "stable",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Grasmash\\YamlExpander\\": "src/"
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"greg-1-anderson/composer-test-scenarios": "^1",
|
||||
"phpunit/phpunit": "^4.8|^5.5.4",
|
||||
"satooshi/php-coveralls": "^1.0.2|dev-master",
|
||||
"squizlabs/php_codesniffer": "^2.7",
|
||||
"symfony/console": "^2.8"
|
||||
},
|
||||
"scripts": {
|
||||
"cs": "phpcs -n --standard=PSR2 src tests --exclude=Generic.Files.LineLength",
|
||||
"cbf": "phpcbf -n --standard=PSR2 src tests --exclude=Generic.Files.LineLength",
|
||||
"unit": "phpunit",
|
||||
"lint": [
|
||||
"find src -name '*.php' -print0 | xargs -0 -n1 php -l",
|
||||
"find tests -name '*.php' -print0 | xargs -0 -n1 php -l"
|
||||
],
|
||||
"test": [
|
||||
"@lint",
|
||||
"@unit",
|
||||
"@cs"
|
||||
],
|
||||
"scenario": "scenarios/install",
|
||||
"post-update-cmd": [
|
||||
"create-scenario symfony4 'symfony/console:^4.0'",
|
||||
"create-scenario symfony2 'symfony/console:^2.8' --platform-php '5.4' --no-lockfile"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true,
|
||||
"platform": {
|
||||
"php": "5.4"
|
||||
},
|
||||
"vendor-dir": "../../vendor"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
1
vendor/grasmash/yaml-expander/scenarios/symfony2/src
vendored
Symbolic link
1
vendor/grasmash/yaml-expander/scenarios/symfony2/src
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../src
|
1
vendor/grasmash/yaml-expander/scenarios/symfony2/tests
vendored
Symbolic link
1
vendor/grasmash/yaml-expander/scenarios/symfony2/tests
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../tests
|
1
vendor/grasmash/yaml-expander/scenarios/symfony4/.gitignore
vendored
Normal file
1
vendor/grasmash/yaml-expander/scenarios/symfony4/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
vendor
|
61
vendor/grasmash/yaml-expander/scenarios/symfony4/composer.json
vendored
Normal file
61
vendor/grasmash/yaml-expander/scenarios/symfony4/composer.json
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"name": "grasmash/yaml-expander",
|
||||
"description": "Expands internal property references in a yaml file.",
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": ">=5.4",
|
||||
"symfony/yaml": "^2.8.11|^3|^4",
|
||||
"dflydev/dot-access-data": "^1.1.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Matthew Grasmick"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "stable",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Grasmash\\YamlExpander\\": "src/"
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"greg-1-anderson/composer-test-scenarios": "^1",
|
||||
"phpunit/phpunit": "^4.8|^5.5.4",
|
||||
"satooshi/php-coveralls": "^1.0.2|dev-master",
|
||||
"squizlabs/php_codesniffer": "^2.7",
|
||||
"symfony/console": "^4.0"
|
||||
},
|
||||
"scripts": {
|
||||
"cs": "phpcs -n --standard=PSR2 src tests --exclude=Generic.Files.LineLength",
|
||||
"cbf": "phpcbf -n --standard=PSR2 src tests --exclude=Generic.Files.LineLength",
|
||||
"unit": "phpunit",
|
||||
"lint": [
|
||||
"find src -name '*.php' -print0 | xargs -0 -n1 php -l",
|
||||
"find tests -name '*.php' -print0 | xargs -0 -n1 php -l"
|
||||
],
|
||||
"test": [
|
||||
"@lint",
|
||||
"@unit",
|
||||
"@cs"
|
||||
],
|
||||
"scenario": "scenarios/install",
|
||||
"post-update-cmd": [
|
||||
"create-scenario symfony4 'symfony/console:^4.0'",
|
||||
"create-scenario symfony2 'symfony/console:^2.8' --platform-php '5.4' --no-lockfile"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true,
|
||||
"platform": {
|
||||
|
||||
},
|
||||
"vendor-dir": "../../vendor"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
2163
vendor/grasmash/yaml-expander/scenarios/symfony4/composer.lock
generated
vendored
Normal file
2163
vendor/grasmash/yaml-expander/scenarios/symfony4/composer.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
vendor/grasmash/yaml-expander/scenarios/symfony4/src
vendored
Symbolic link
1
vendor/grasmash/yaml-expander/scenarios/symfony4/src
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../src
|
1
vendor/grasmash/yaml-expander/scenarios/symfony4/tests
vendored
Symbolic link
1
vendor/grasmash/yaml-expander/scenarios/symfony4/tests
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../tests
|
273
vendor/grasmash/yaml-expander/src/Expander.php
vendored
Normal file
273
vendor/grasmash/yaml-expander/src/Expander.php
vendored
Normal file
|
@ -0,0 +1,273 @@
|
|||
<?php
|
||||
|
||||
namespace Grasmash\YamlExpander;
|
||||
|
||||
use Dflydev\DotAccessData\Data;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* Class Expander
|
||||
* @package Grasmash\YamlExpander
|
||||
*/
|
||||
class Expander
|
||||
{
|
||||
|
||||
/**
|
||||
* Parses a YAML string and expands property placeholders.
|
||||
*
|
||||
* Placeholders should formatted as ${parent.child}.
|
||||
*
|
||||
* @param string $yaml_string
|
||||
* A string of YAML.
|
||||
* @param array $reference_array
|
||||
* Optional. An array of reference values. This is not operated upon but is used as a
|
||||
* reference to provide supplemental values for property expansion.
|
||||
*
|
||||
* @return array
|
||||
* The modified array in which placeholders have been replaced with
|
||||
* values.
|
||||
*/
|
||||
public static function parse($yaml_string, $reference_array = [])
|
||||
{
|
||||
$array = Yaml::parse($yaml_string);
|
||||
return self::expandArrayProperties($array, $reference_array);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Expands property placeholders in an array.
|
||||
*
|
||||
* Placeholders should formatted as ${parent.child}.
|
||||
*
|
||||
* @param array $array
|
||||
* An array containing properties to expand.
|
||||
*
|
||||
* @return array
|
||||
* The modified array in which placeholders have been replaced with
|
||||
* values.
|
||||
*/
|
||||
public static function expandArrayProperties($array, $reference_array = [])
|
||||
{
|
||||
$data = new Data($array);
|
||||
if ($reference_array) {
|
||||
$reference_data = new Data($reference_array);
|
||||
self::doExpandArrayProperties($data, $array, '', $reference_data);
|
||||
} else {
|
||||
self::doExpandArrayProperties($data, $array);
|
||||
}
|
||||
|
||||
return $data->export();
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the actual property expansion.
|
||||
*
|
||||
* @param Data $data
|
||||
* A data object, containing the $array.
|
||||
* @param array $array
|
||||
* The original, unmodified array.
|
||||
* @param string $parent_keys
|
||||
* The parent keys of the current key in dot notation. This is used to
|
||||
* track the absolute path to the current key in recursive cases.
|
||||
* @param Data|null $reference_data
|
||||
* A reference data object. This is not operated upon but is used as a
|
||||
* reference to provide supplemental values for property expansion.
|
||||
*/
|
||||
protected static function doExpandArrayProperties(
|
||||
$data,
|
||||
$array,
|
||||
$parent_keys = '',
|
||||
$reference_data = null
|
||||
) {
|
||||
foreach ($array as $key => $value) {
|
||||
// Boundary condition(s).
|
||||
if (is_null($value) || is_bool($value)) {
|
||||
continue;
|
||||
}
|
||||
// Recursive case.
|
||||
if (is_array($value)) {
|
||||
self::doExpandArrayProperties($data, $value, $parent_keys . "$key.", $reference_data);
|
||||
} // Base case.
|
||||
else {
|
||||
self::expandStringProperties($data, $parent_keys, $reference_data, $value, $key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand a single property.
|
||||
*
|
||||
* @param Data $data
|
||||
* A data object, containing the $array.
|
||||
* @param string $parent_keys
|
||||
* The parent keys of the current key in dot notation. This is used to
|
||||
* track the absolute path to the current key in recursive cases.
|
||||
* @param Data|null $reference_data
|
||||
* A reference data object. This is not operated upon but is used as a
|
||||
* reference to provide supplemental values for property expansion.
|
||||
* @param string $value
|
||||
* The unexpanded property value.
|
||||
* @param string $key
|
||||
* The immediate key of the property.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected static function expandStringProperties(
|
||||
$data,
|
||||
$parent_keys,
|
||||
$reference_data,
|
||||
$value,
|
||||
$key
|
||||
) {
|
||||
// We loop through all placeholders in a given string.
|
||||
// E.g., '${placeholder1} ${placeholder2}' requires two replacements.
|
||||
while (strpos($value, '${') !== false) {
|
||||
$original_value = $value;
|
||||
$value = preg_replace_callback(
|
||||
'/\$\{([^\$}]+)\}/',
|
||||
function ($matches) use ($data, $reference_data) {
|
||||
return self::expandStringPropertiesCallback(
|
||||
$matches,
|
||||
$data,
|
||||
$reference_data
|
||||
);
|
||||
},
|
||||
$value
|
||||
);
|
||||
|
||||
// If no replacement occurred at all, break to prevent
|
||||
// infinite loop.
|
||||
if ($original_value == $value) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Set value on $data object.
|
||||
if ($parent_keys) {
|
||||
$full_key = $parent_keys . "$key";
|
||||
} else {
|
||||
$full_key = $key;
|
||||
}
|
||||
$data->set($full_key, $value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expansion callback used by preg_replace_callback() in expandProperty().
|
||||
*
|
||||
* @param array $matches
|
||||
* An array of matches created by preg_replace_callback().
|
||||
* @param Data $data
|
||||
* A data object containing the complete array being operated upon.
|
||||
* @param Data|null $reference_data
|
||||
* A reference data object. This is not operated upon but is used as a
|
||||
* reference to provide supplemental values for property expansion.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function expandStringPropertiesCallback(
|
||||
$matches,
|
||||
$data,
|
||||
$reference_data = null
|
||||
) {
|
||||
$property_name = $matches[1];
|
||||
$unexpanded_value = $matches[0];
|
||||
|
||||
// Use only values within the subject array's data.
|
||||
if (!$reference_data) {
|
||||
return self::expandProperty($property_name, $unexpanded_value, $data);
|
||||
} // Search both the subject array's data and the reference data for a value.
|
||||
else {
|
||||
return self::expandPropertyWithReferenceData(
|
||||
$property_name,
|
||||
$unexpanded_value,
|
||||
$data,
|
||||
$reference_data
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches both the subject data and the reference data for value.
|
||||
*
|
||||
* @param string $property_name
|
||||
* The name of the value for which to search.
|
||||
* @param string $unexpanded_value
|
||||
* The original, unexpanded value, containing the placeholder.
|
||||
* @param Data $data
|
||||
* A data object containing the complete array being operated upon.
|
||||
* @param Data|null $reference_data
|
||||
* A reference data object. This is not operated upon but is used as a
|
||||
* reference to provide supplemental values for property expansion.
|
||||
*
|
||||
* @return string
|
||||
* The expanded string.
|
||||
*/
|
||||
public static function expandPropertyWithReferenceData(
|
||||
$property_name,
|
||||
$unexpanded_value,
|
||||
$data,
|
||||
$reference_data
|
||||
) {
|
||||
$expanded_value = self::expandProperty(
|
||||
$property_name,
|
||||
$unexpanded_value,
|
||||
$data
|
||||
);
|
||||
// If the string was not changed using the subject data, try using
|
||||
// the reference data.
|
||||
if ($expanded_value == $unexpanded_value) {
|
||||
$expanded_value = self::expandProperty(
|
||||
$property_name,
|
||||
$unexpanded_value,
|
||||
$reference_data
|
||||
);
|
||||
}
|
||||
|
||||
return $expanded_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches a data object for a value.
|
||||
*
|
||||
* @param string $property_name
|
||||
* The name of the value for which to search.
|
||||
* @param string $unexpanded_value
|
||||
* The original, unexpanded value, containing the placeholder.
|
||||
* @param Data $data
|
||||
* A data object containing possible replacement values.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function expandProperty($property_name, $unexpanded_value, $data)
|
||||
{
|
||||
if (strpos($property_name, "env.") === 0 &&
|
||||
!$data->has($property_name)) {
|
||||
$env_key = substr($property_name, 4);
|
||||
if (getenv($env_key)) {
|
||||
$data->set($property_name, getenv($env_key));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$data->has($property_name)) {
|
||||
self::log("Property \${'$property_name'} could not be expanded.");
|
||||
return $unexpanded_value;
|
||||
} else {
|
||||
$expanded_value = $data->get($property_name);
|
||||
if (is_array($expanded_value)) {
|
||||
$expanded_value = Yaml::dump($expanded_value, 0);
|
||||
return $expanded_value;
|
||||
}
|
||||
self::log("Expanding property \${'$property_name'} => $expanded_value.");
|
||||
return $expanded_value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $message
|
||||
*/
|
||||
public static function log($message)
|
||||
{
|
||||
// print "$message\n";
|
||||
}
|
||||
}
|
99
vendor/grasmash/yaml-expander/tests/phpunit/ExpanderTest.php
vendored
Normal file
99
vendor/grasmash/yaml-expander/tests/phpunit/ExpanderTest.php
vendored
Normal file
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
namespace Grasmash\YamlExpander\Tests\Command;
|
||||
|
||||
use Dflydev\DotAccessData\Data;
|
||||
use Grasmash\YamlExpander\Expander;
|
||||
use Grasmash\YamlExpander\Tests\TestBase;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class ExpanderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Tests Expander::expandArrayProperties().
|
||||
*
|
||||
* @param string $filename
|
||||
* @param array $reference_array
|
||||
*
|
||||
* @dataProvider providerYaml
|
||||
*/
|
||||
public function testExpandArrayProperties($filename, $reference_array)
|
||||
{
|
||||
$array = Yaml::parse(file_get_contents(__DIR__ . "/../resources/$filename"));
|
||||
putenv("test=gomjabbar");
|
||||
$expanded = Expander::expandArrayProperties($array);
|
||||
$this->assertEquals('gomjabbar', $expanded['env-test']);
|
||||
$this->assertEquals('Frank Herbert 1965', $expanded['book']['copyright']);
|
||||
$this->assertEquals('Paul Atreides', $expanded['book']['protaganist']);
|
||||
$this->assertEquals('Dune by Frank Herbert', $expanded['summary']);
|
||||
$this->assertEquals('${book.media.1}, hardcover', $expanded['available-products']);
|
||||
$this->assertEquals('Dune', $expanded['product-name']);
|
||||
$this->assertEquals(Yaml::dump($array['inline-array'], 0), $expanded['expand-array']);
|
||||
|
||||
$expanded = Expander::expandArrayProperties($array, $reference_array);
|
||||
$this->assertEquals('Dune Messiah, and others.', $expanded['sequels']);
|
||||
$this->assertEquals('Dune Messiah', $expanded['book']['nested-reference']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Expander::parse().
|
||||
*
|
||||
* @param string $filename
|
||||
* @param array $reference_array
|
||||
*
|
||||
* @dataProvider providerYaml
|
||||
*/
|
||||
public function testParse($filename, $reference_array)
|
||||
{
|
||||
$yaml_string = file_get_contents(__DIR__ . "/../resources/$filename");
|
||||
$expanded = Expander::parse($yaml_string);
|
||||
$this->assertEquals('Frank Herbert 1965', $expanded['book']['copyright']);
|
||||
$this->assertEquals('Paul Atreides', $expanded['book']['protaganist']);
|
||||
$this->assertEquals('Dune by Frank Herbert', $expanded['summary']);
|
||||
$this->assertEquals('${book.media.1}, hardcover', $expanded['available-products']);
|
||||
|
||||
$expanded = Expander::parse($yaml_string, $reference_array);
|
||||
$this->assertEquals('Dune Messiah, and others.', $expanded['sequels']);
|
||||
$this->assertEquals('Dune Messiah', $expanded['book']['nested-reference']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* An array of values to test.
|
||||
*/
|
||||
public function providerYaml()
|
||||
{
|
||||
return [
|
||||
['valid.yml', [
|
||||
'book' => [
|
||||
'sequel' => 'Dune Messiah'
|
||||
]
|
||||
]],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Expander::expandProperty().
|
||||
*
|
||||
* @dataProvider providerTestExpandProperty
|
||||
*/
|
||||
public function testExpandProperty($array, $property_name, $unexpanded_string, $expected)
|
||||
{
|
||||
$data = new Data($array);
|
||||
$expanded_value = Expander::expandProperty($property_name, $unexpanded_string, $data);
|
||||
|
||||
$this->assertEquals($expected, $expanded_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function providerTestExpandProperty()
|
||||
{
|
||||
return [
|
||||
[ ['author' => 'Frank Herbert'], 'author', '${author}', 'Frank Herbert' ],
|
||||
[ ['book' => ['author' => 'Frank Herbert' ]], 'book.author', '${book.author}', 'Frank Herbert' ],
|
||||
];
|
||||
}
|
||||
}
|
35
vendor/grasmash/yaml-expander/tests/resources/valid.yml
vendored
Normal file
35
vendor/grasmash/yaml-expander/tests/resources/valid.yml
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
# This file should contain only valid YAML.
|
||||
type: book
|
||||
book:
|
||||
title: Dune
|
||||
author: Frank Herbert
|
||||
copyright: ${book.author} 1965
|
||||
protaganist: ${characters.0.name}
|
||||
media:
|
||||
- hardcover
|
||||
# Use a nested key to reference an external value.
|
||||
nested-reference: ${book.sequel}
|
||||
characters:
|
||||
- name: Paul Atreides
|
||||
occupation: Kwisatz Haderach
|
||||
aliases:
|
||||
- Usul
|
||||
- Muad'Dib
|
||||
- The Preacher
|
||||
- name: Duncan Idaho
|
||||
occupation: Swordmaster
|
||||
summary: ${book.title} by ${book.author}
|
||||
# This is a complete fake property.
|
||||
publisher: ${not.real.property}
|
||||
# series.books is not defined in this YAML file, but is passed in to the parser by the application.
|
||||
sequels: ${book.sequel}, and others.
|
||||
# Reference one real value and one fake value.
|
||||
available-products: ${book.media.1}, ${book.media.0}
|
||||
# Nested property, should resolve to ${book.title} and then 'Dune'.
|
||||
product-name: ${${type}.title}
|
||||
# Represent a few more data types and formats.
|
||||
boolean-value: true
|
||||
null-value: null
|
||||
inline-array: [ one, two, three ]
|
||||
expand-array: ${inline-array}
|
||||
env-test: ${env.test}
|
Reference in a new issue