diff --git a/.travis.yml b/.travis.yml index 0416daa..d80fdb6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,8 +17,6 @@ matrix: 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 diff --git a/composer.json b/composer.json index f671ee4..b18c09c 100644 --- a/composer.json +++ b/composer.json @@ -3,9 +3,10 @@ "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" + "php": ">=5.6", + "dflydev/dot-access-data": "^1.1.0", + "grasmash/expander": "^1.0.0", + "symfony/yaml": "^2.8.11|^3|^4" }, "license": "MIT", "authors": [ @@ -16,7 +17,7 @@ "minimum-stability": "stable", "autoload": { "psr-4": { - "Grasmash\\YamlExpander\\": "src/" + "Grasmash\\YamlExpander\\": "src/" } }, "require-dev": { @@ -48,12 +49,12 @@ "optimize-autoloader": true, "sort-packages": true, "platform": { - "php": "5.5.9" + "php": "7.1" } }, "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-master": "2.x-dev" } } } diff --git a/composer.lock b/composer.lock index 7f1268a..a9dfd33 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "ae81b9e7daa60d332450889eb23e80a9", + "content-hash": "7930cf3afdba0b8dc84256478b201fcb", "packages": [ { "name": "dflydev/dot-access-data", @@ -65,18 +65,65 @@ ], "time": "2017-01-20T21:14:22+00:00" }, + { + "name": "grasmash/expander", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/grasmash/expander.git", + "reference": "95d6037344a4be1dd5f8e0b0b2571a28c397578f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/grasmash/expander/zipball/95d6037344a4be1dd5f8e0b0b2571a28c397578f", + "reference": "95d6037344a4be1dd5f8e0b0b2571a28c397578f", + "shasum": "" + }, + "require": { + "dflydev/dot-access-data": "^1.1.0", + "php": ">=5.4" + }, + "require-dev": { + "greg-1-anderson/composer-test-scenarios": "^1", + "phpunit/phpunit": "^4|^5.5.4", + "satooshi/php-coveralls": "^1.0.2|dev-master", + "squizlabs/php_codesniffer": "^2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Grasmash\\Expander\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matthew Grasmick" + } + ], + "description": "Expands internal property references in PHP arrays file.", + "time": "2017-12-21T22:14:55+00:00" + }, { "name": "symfony/yaml", - "version": "v3.4.0", + "version": "v3.4.2", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "b3d0c9c11be3831b84825967dc6b52b5a7b84e04" + "reference": "afe0cd38486505c9703707707d91450cfc1bd536" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/b3d0c9c11be3831b84825967dc6b52b5a7b84e04", - "reference": "b3d0c9c11be3831b84825967dc6b52b5a7b84e04", + "url": "https://api.github.com/repos/symfony/yaml/zipball/afe0cd38486505c9703707707d91450cfc1bd536", + "reference": "afe0cd38486505c9703707707d91450cfc1bd536", "shasum": "" }, "require": { @@ -121,38 +168,38 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-11-29T13:28:14+00:00" + "time": "2017-12-11T20:38:23+00:00" } ], "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.0.5", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", "shasum": "" }, "require": { - "php": ">=5.3,<8.0-DEV" + "php": "^7.1" }, "require-dev": { "athletic/athletic": "~0.1.8", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" + "phpunit/phpunit": "^6.2.3", + "squizlabs/php_codesniffer": "^3.0.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -177,20 +224,20 @@ "constructor", "instantiate" ], - "time": "2015-06-14T21:17:01+00:00" + "time": "2017-07-22T11:58:36+00:00" }, { "name": "greg-1-anderson/composer-test-scenarios", - "version": "1.0.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/greg-1-anderson/composer-test-scenarios.git", - "reference": "00ff9f3af3132f0c6b2fb9e0906efee402f0c703" + "reference": "dc81660f44a8b126d7fa947156c98e34f45af3e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/greg-1-anderson/composer-test-scenarios/zipball/00ff9f3af3132f0c6b2fb9e0906efee402f0c703", - "reference": "00ff9f3af3132f0c6b2fb9e0906efee402f0c703", + "url": "https://api.github.com/repos/greg-1-anderson/composer-test-scenarios/zipball/dc81660f44a8b126d7fa947156c98e34f45af3e9", + "reference": "dc81660f44a8b126d7fa947156c98e34f45af3e9", "shasum": "" }, "bin": [ @@ -209,7 +256,7 @@ } ], "description": "Useful scripts for testing multiple sets of Composer dependencies.", - "time": "2017-12-01T21:34:53+00:00" + "time": "2017-12-13T18:41:24+00:00" }, { "name": "guzzlehttp/guzzle", @@ -392,6 +439,51 @@ ], "time": "2017-03-20T17:10:46+00:00" }, + { + "name": "myclabs/deep-copy", + "version": "1.7.0", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^4.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2017-10-19T19:58:43+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "1.0.1", @@ -448,29 +540,35 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.2.2", + "version": "4.2.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "4aada1f93c72c35e22fb1383b47fee43b8f1d157" + "reference": "66465776cfc249844bde6d117abff1d22e06c2da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/4aada1f93c72c35e22fb1383b47fee43b8f1d157", - "reference": "4aada1f93c72c35e22fb1383b47fee43b8f1d157", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/66465776cfc249844bde6d117abff1d22e06c2da", + "reference": "66465776cfc249844bde6d117abff1d22e06c2da", "shasum": "" }, "require": { - "php": ">=5.5", - "phpdocumentor/reflection-common": "^1.0@dev", - "phpdocumentor/type-resolver": "^0.3.0", + "php": "^7.0", + "phpdocumentor/reflection-common": "^1.0.0", + "phpdocumentor/type-resolver": "^0.4.0", "webmozart/assert": "^1.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.4" + "doctrine/instantiator": "~1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, "autoload": { "psr-4": { "phpDocumentor\\Reflection\\": [ @@ -489,20 +587,20 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-08-08T06:39:58+00:00" + "time": "2017-11-27T17:38:31+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.3.0", + "version": "0.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "fb3933512008d8162b3cdf9e18dba9309b7c3773" + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/fb3933512008d8162b3cdf9e18dba9309b7c3773", - "reference": "fb3933512008d8162b3cdf9e18dba9309b7c3773", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", "shasum": "" }, "require": { @@ -536,7 +634,7 @@ "email": "me@mikevanriel.com" } ], - "time": "2017-06-03T08:32:36+00:00" + "time": "2017-07-14T14:27:02+00:00" }, { "name": "phpspec/prophecy", @@ -603,39 +701,40 @@ }, { "name": "phpunit/php-code-coverage", - "version": "2.2.4", + "version": "4.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" + "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d", "shasum": "" }, "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "^1.3.2", - "sebastian/version": "~1.0" + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^5.6 || ^7.0", + "phpunit/php-file-iterator": "^1.3", + "phpunit/php-text-template": "^1.2", + "phpunit/php-token-stream": "^1.4.2 || ^2.0", + "sebastian/code-unit-reverse-lookup": "^1.0", + "sebastian/environment": "^1.3.2 || ^2.0", + "sebastian/version": "^1.0 || ^2.0" }, "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4" + "ext-xdebug": "^2.1.4", + "phpunit/phpunit": "^5.7" }, "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" + "ext-xdebug": "^2.5.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2.x-dev" + "dev-master": "4.0.x-dev" } }, "autoload": { @@ -661,7 +760,7 @@ "testing", "xunit" ], - "time": "2015-10-06T15:47:00+00:00" + "time": "2017-04-02T07:44:40+00:00" }, { "name": "phpunit/php-file-iterator", @@ -802,29 +901,29 @@ }, { "name": "phpunit/php-token-stream", - "version": "1.4.11", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" + "reference": "791198a2c6254db10131eecfe8c06670700904db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", + "reference": "791198a2c6254db10131eecfe8c06670700904db", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^6.2.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -847,44 +946,54 @@ "keywords": [ "tokenizer" ], - "time": "2017-02-27T10:12:30+00:00" + "time": "2017-11-27T05:48:46+00:00" }, { "name": "phpunit/phpunit", - "version": "4.8.36", + "version": "5.7.26", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "46023de9a91eec7dfb06cc56cb4e260017298517" + "reference": "7fbc25c13309de0c4c9bb48b7361f1eca34c7fbd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/46023de9a91eec7dfb06cc56cb4e260017298517", - "reference": "46023de9a91eec7dfb06cc56cb4e260017298517", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7fbc25c13309de0c4c9bb48b7361f1eca34c7fbd", + "reference": "7fbc25c13309de0c4c9bb48b7361f1eca34c7fbd", "shasum": "" }, "require": { "ext-dom": "*", "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpspec/prophecy": "^1.3.1", - "phpunit/php-code-coverage": "~2.1", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "myclabs/deep-copy": "~1.3", + "php": "^5.6 || ^7.0", + "phpspec/prophecy": "^1.6.2", + "phpunit/php-code-coverage": "^4.0.4", "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.2.2", - "sebastian/diff": "~1.2", - "sebastian/environment": "~1.3", - "sebastian/exporter": "~1.2", - "sebastian/global-state": "~1.0", - "sebastian/version": "~1.0", - "symfony/yaml": "~2.1|~3.0" + "phpunit/phpunit-mock-objects": "^3.2", + "sebastian/comparator": "^1.2.4", + "sebastian/diff": "^1.4.3", + "sebastian/environment": "^1.3.4 || ^2.0", + "sebastian/exporter": "~2.0", + "sebastian/global-state": "^1.1", + "sebastian/object-enumerator": "~2.0", + "sebastian/resource-operations": "~1.0", + "sebastian/version": "~1.0.3|~2.0", + "symfony/yaml": "~2.1|~3.0|~4.0" + }, + "conflict": { + "phpdocumentor/reflection-docblock": "3.0.2" + }, + "require-dev": { + "ext-pdo": "*" }, "suggest": { + "ext-xdebug": "*", "phpunit/php-invoker": "~1.1" }, "bin": [ @@ -893,7 +1002,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.8.x-dev" + "dev-master": "5.7.x-dev" } }, "autoload": { @@ -919,30 +1028,33 @@ "testing", "xunit" ], - "time": "2017-06-21T08:07:12+00:00" + "time": "2017-12-17T06:14:38+00:00" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.3.8", + "version": "3.4.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" + "reference": "a23b761686d50a560cc56233b9ecf49597cc9118" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/a23b761686d50a560cc56233b9ecf49597cc9118", + "reference": "a23b761686d50a560cc56233b9ecf49597cc9118", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2", - "sebastian/exporter": "~1.2" + "php": "^5.6 || ^7.0", + "phpunit/php-text-template": "^1.2", + "sebastian/exporter": "^1.2 || ^2.0" + }, + "conflict": { + "phpunit/phpunit": "<5.4.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^5.4" }, "suggest": { "ext-soap": "*" @@ -950,7 +1062,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3.x-dev" + "dev-master": "3.2.x-dev" } }, "autoload": { @@ -975,7 +1087,7 @@ "mock", "xunit" ], - "time": "2015-10-02T06:51:40+00:00" + "time": "2017-06-30T09:13:00+00:00" }, { "name": "psr/http-message", @@ -1080,12 +1192,12 @@ "source": { "type": "git", "url": "https://github.com/php-coveralls/php-coveralls.git", - "reference": "c9d3fe2327c8539f1105dc19954673ba993e4ad9" + "reference": "a9c356100c095e07b004d32942c9ff5731459b49" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-coveralls/php-coveralls/zipball/c9d3fe2327c8539f1105dc19954673ba993e4ad9", - "reference": "c9d3fe2327c8539f1105dc19954673ba993e4ad9", + "url": "https://api.github.com/repos/php-coveralls/php-coveralls/zipball/a9c356100c095e07b004d32942c9ff5731459b49", + "reference": "a9c356100c095e07b004d32942c9ff5731459b49", "shasum": "" }, "require": { @@ -1155,7 +1267,52 @@ "github", "test" ], - "time": "2017-10-14T23:16:28+00:00" + "time": "2017-12-08T13:59:48+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "time": "2017-03-04T06:30:41+00:00" }, { "name": "sebastian/comparator", @@ -1275,28 +1432,28 @@ }, { "name": "sebastian/environment", - "version": "1.3.8", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" + "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^5.6 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.0" + "phpunit/phpunit": "^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -1321,25 +1478,25 @@ "environment", "hhvm" ], - "time": "2016-08-18T05:49:44+00:00" + "time": "2016-11-26T07:53:53+00:00" }, { "name": "sebastian/exporter", - "version": "1.2.2", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" + "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", "shasum": "" }, "require": { "php": ">=5.3.3", - "sebastian/recursion-context": "~1.0" + "sebastian/recursion-context": "~2.0" }, "require-dev": { "ext-mbstring": "*", @@ -1348,7 +1505,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -1388,7 +1545,7 @@ "export", "exporter" ], - "time": "2016-06-17T09:04:28+00:00" + "time": "2016-11-19T08:54:04+00:00" }, { "name": "sebastian/global-state", @@ -1441,18 +1598,64 @@ ], "time": "2015-10-12T03:26:01+00:00" }, + { + "name": "sebastian/object-enumerator", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", + "shasum": "" + }, + "require": { + "php": ">=5.6", + "sebastian/recursion-context": "~2.0" + }, + "require-dev": { + "phpunit/phpunit": "~5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "time": "2017-02-18T15:18:39+00:00" + }, { "name": "sebastian/recursion-context", - "version": "1.0.5", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7" + "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b19cc3298482a335a95f3016d2f8a6950f0fbcd7", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", "shasum": "" }, "require": { @@ -1464,7 +1667,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -1492,23 +1695,73 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2016-10-03T07:41:43+00:00" + "time": "2016-11-19T07:33:16+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "time": "2015-07-28T20:34:47+00:00" }, { "name": "sebastian/version", - "version": "1.0.6", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", "shasum": "" }, + "require": { + "php": ">=5.6" + }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -1527,7 +1780,7 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-06-21T13:59:46+00:00" + "time": "2016-10-03T07:35:21+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -1609,16 +1862,16 @@ }, { "name": "symfony/config", - "version": "v3.4.0", + "version": "v3.4.2", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "1de51a6c76359897ab32c309934b93d036bccb60" + "reference": "e57211b88aa889fefac1cb36866db04100b0f21c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/1de51a6c76359897ab32c309934b93d036bccb60", - "reference": "1de51a6c76359897ab32c309934b93d036bccb60", + "url": "https://api.github.com/repos/symfony/config/zipball/e57211b88aa889fefac1cb36866db04100b0f21c", + "reference": "e57211b88aa889fefac1cb36866db04100b0f21c", "shasum": "" }, "require": { @@ -1667,20 +1920,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2017-11-19T20:09:36+00:00" + "time": "2017-12-14T19:40:10+00:00" }, { "name": "symfony/console", - "version": "v3.4.0", + "version": "v3.4.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "9468ad3fba3a5e1f0dc12a96e50e84cddb923cf0" + "reference": "9f21adfb92a9315b73ae2ed43138988ee4913d4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/9468ad3fba3a5e1f0dc12a96e50e84cddb923cf0", - "reference": "9468ad3fba3a5e1f0dc12a96e50e84cddb923cf0", + "url": "https://api.github.com/repos/symfony/console/zipball/9f21adfb92a9315b73ae2ed43138988ee4913d4e", + "reference": "9f21adfb92a9315b73ae2ed43138988ee4913d4e", "shasum": "" }, "require": { @@ -1736,20 +1989,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-11-29T13:28:14+00:00" + "time": "2017-12-14T19:40:10+00:00" }, { "name": "symfony/debug", - "version": "v3.4.0", + "version": "v3.4.2", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "fb2001e5d85f95d8b6ab94ae3be5d2672df128fd" + "reference": "543deab3ffff94402440b326fc94153bae2dfa7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/fb2001e5d85f95d8b6ab94ae3be5d2672df128fd", - "reference": "fb2001e5d85f95d8b6ab94ae3be5d2672df128fd", + "url": "https://api.github.com/repos/symfony/debug/zipball/543deab3ffff94402440b326fc94153bae2dfa7a", + "reference": "543deab3ffff94402440b326fc94153bae2dfa7a", "shasum": "" }, "require": { @@ -1792,20 +2045,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2017-11-21T09:01:46+00:00" + "time": "2017-12-12T08:27:14+00:00" }, { "name": "symfony/filesystem", - "version": "v3.4.0", + "version": "v3.4.2", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "de56eee71e0a128d8c54ccc1909cdefd574bad0f" + "reference": "25b135bea251829e3db6a77d773643408b575ed4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/de56eee71e0a128d8c54ccc1909cdefd574bad0f", - "reference": "de56eee71e0a128d8c54ccc1909cdefd574bad0f", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/25b135bea251829e3db6a77d773643408b575ed4", + "reference": "25b135bea251829e3db6a77d773643408b575ed4", "shasum": "" }, "require": { @@ -1841,7 +2094,7 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2017-11-19T18:59:05+00:00" + "time": "2017-12-14T19:40:10+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -1904,7 +2157,7 @@ }, { "name": "symfony/stopwatch", - "version": "v3.4.0", + "version": "v3.4.2", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", @@ -2014,6 +2267,6 @@ }, "platform-dev": [], "platform-overrides": { - "php": "5.5.9" + "php": "7.1" } } diff --git a/scenarios/install b/scenarios/install index 5bc73b7..e921ec0 100755 --- a/scenarios/install +++ b/scenarios/install @@ -15,9 +15,14 @@ if [ ! -d "$dir" ] ; then exit 1 fi -echo "Switch to ${SCENARIO} scenario" +echo +echo "::" +echo ":: Switch to ${SCENARIO} scenario" +echo "::" +echo set -ex +composer -n validate --working-dir=$dir --no-check-all --ansi composer -n --working-dir=$dir ${ACTION} --prefer-dist --no-scripts composer -n --working-dir=$dir info diff --git a/scenarios/symfony2/composer.json b/scenarios/symfony2/composer.json index 43e4e96..356a3ac 100644 --- a/scenarios/symfony2/composer.json +++ b/scenarios/symfony2/composer.json @@ -4,8 +4,9 @@ "type": "library", "require": { "php": ">=5.4", - "symfony/yaml": "^2.8.11|^3|^4", - "dflydev/dot-access-data": "^1.1.0" + "dflydev/dot-access-data": "^1.1.0", + "grasmash/expander": "^1.0.0", + "symfony/yaml": "^2.8.11|^3|^4" }, "license": "MIT", "authors": [ @@ -16,7 +17,7 @@ "minimum-stability": "stable", "autoload": { "psr-4": { - "Grasmash\\YamlExpander\\": "src/" + "Grasmash\\YamlExpander\\": "src/" } }, "require-dev": { @@ -55,7 +56,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-master": "2.x-dev" } } } diff --git a/scenarios/symfony4/composer.json b/scenarios/symfony4/composer.json index 3052d4e..96f70bf 100644 --- a/scenarios/symfony4/composer.json +++ b/scenarios/symfony4/composer.json @@ -4,8 +4,9 @@ "type": "library", "require": { "php": ">=5.4", - "symfony/yaml": "^2.8.11|^3|^4", - "dflydev/dot-access-data": "^1.1.0" + "dflydev/dot-access-data": "^1.1.0", + "grasmash/expander": "^1.0.0", + "symfony/yaml": "^2.8.11|^3|^4" }, "license": "MIT", "authors": [ @@ -16,7 +17,7 @@ "minimum-stability": "stable", "autoload": { "psr-4": { - "Grasmash\\YamlExpander\\": "src/" + "Grasmash\\YamlExpander\\": "src/" } }, "require-dev": { @@ -55,7 +56,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-master": "2.x-dev" } } } diff --git a/scenarios/symfony4/composer.lock b/scenarios/symfony4/composer.lock index d0fe611..df03b4b 100644 --- a/scenarios/symfony4/composer.lock +++ b/scenarios/symfony4/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "d2caa274a8dbc1766b1756b440be19a0", + "content-hash": "bc5e8004383b21b8ff51fb59bc6dcf67", "packages": [ { "name": "dflydev/dot-access-data", @@ -65,18 +65,65 @@ ], "time": "2017-01-20T21:14:22+00:00" }, + { + "name": "grasmash/expander", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/grasmash/expander.git", + "reference": "95d6037344a4be1dd5f8e0b0b2571a28c397578f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/grasmash/expander/zipball/95d6037344a4be1dd5f8e0b0b2571a28c397578f", + "reference": "95d6037344a4be1dd5f8e0b0b2571a28c397578f", + "shasum": "" + }, + "require": { + "dflydev/dot-access-data": "^1.1.0", + "php": ">=5.4" + }, + "require-dev": { + "greg-1-anderson/composer-test-scenarios": "^1", + "phpunit/phpunit": "^4|^5.5.4", + "satooshi/php-coveralls": "^1.0.2|dev-master", + "squizlabs/php_codesniffer": "^2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Grasmash\\Expander\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matthew Grasmick" + } + ], + "description": "Expands internal property references in PHP arrays file.", + "time": "2017-12-21T22:14:55+00:00" + }, { "name": "symfony/yaml", - "version": "v4.0.0", + "version": "v4.0.2", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "7be8741ce5dce9943f41a9269f6828b66e726776" + "reference": "a5ee52d155f06ad23b19eb63c31228ff56ad1116" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/7be8741ce5dce9943f41a9269f6828b66e726776", - "reference": "7be8741ce5dce9943f41a9269f6828b66e726776", + "url": "https://api.github.com/repos/symfony/yaml/zipball/a5ee52d155f06ad23b19eb63c31228ff56ad1116", + "reference": "a5ee52d155f06ad23b19eb63c31228ff56ad1116", "shasum": "" }, "require": { @@ -121,7 +168,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-11-29T13:42:03+00:00" + "time": "2017-12-12T08:41:51+00:00" } ], "packages-dev": [ @@ -181,16 +228,16 @@ }, { "name": "greg-1-anderson/composer-test-scenarios", - "version": "1.0.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/greg-1-anderson/composer-test-scenarios.git", - "reference": "00ff9f3af3132f0c6b2fb9e0906efee402f0c703" + "reference": "dc81660f44a8b126d7fa947156c98e34f45af3e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/greg-1-anderson/composer-test-scenarios/zipball/00ff9f3af3132f0c6b2fb9e0906efee402f0c703", - "reference": "00ff9f3af3132f0c6b2fb9e0906efee402f0c703", + "url": "https://api.github.com/repos/greg-1-anderson/composer-test-scenarios/zipball/dc81660f44a8b126d7fa947156c98e34f45af3e9", + "reference": "dc81660f44a8b126d7fa947156c98e34f45af3e9", "shasum": "" }, "bin": [ @@ -209,7 +256,7 @@ } ], "description": "Useful scripts for testing multiple sets of Composer dependencies.", - "time": "2017-12-01T21:34:53+00:00" + "time": "2017-12-13T18:41:24+00:00" }, { "name": "guzzlehttp/guzzle", @@ -903,16 +950,16 @@ }, { "name": "phpunit/phpunit", - "version": "5.7.25", + "version": "5.7.26", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "4b1c822a68ae6577df38a59eb49b046712ec0f6a" + "reference": "7fbc25c13309de0c4c9bb48b7361f1eca34c7fbd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4b1c822a68ae6577df38a59eb49b046712ec0f6a", - "reference": "4b1c822a68ae6577df38a59eb49b046712ec0f6a", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7fbc25c13309de0c4c9bb48b7361f1eca34c7fbd", + "reference": "7fbc25c13309de0c4c9bb48b7361f1eca34c7fbd", "shasum": "" }, "require": { @@ -981,7 +1028,7 @@ "testing", "xunit" ], - "time": "2017-11-14T14:50:51+00:00" + "time": "2017-12-17T06:14:38+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -1145,12 +1192,12 @@ "source": { "type": "git", "url": "https://github.com/php-coveralls/php-coveralls.git", - "reference": "c9d3fe2327c8539f1105dc19954673ba993e4ad9" + "reference": "a9c356100c095e07b004d32942c9ff5731459b49" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-coveralls/php-coveralls/zipball/c9d3fe2327c8539f1105dc19954673ba993e4ad9", - "reference": "c9d3fe2327c8539f1105dc19954673ba993e4ad9", + "url": "https://api.github.com/repos/php-coveralls/php-coveralls/zipball/a9c356100c095e07b004d32942c9ff5731459b49", + "reference": "a9c356100c095e07b004d32942c9ff5731459b49", "shasum": "" }, "require": { @@ -1220,7 +1267,7 @@ "github", "test" ], - "time": "2017-10-14T23:16:28+00:00" + "time": "2017-12-08T13:59:48+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -1815,16 +1862,16 @@ }, { "name": "symfony/config", - "version": "v4.0.0", + "version": "v4.0.2", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "6e6dbc6d2beff8117b974d74274bff02e43c32a6" + "reference": "0356e6d5298e9e72212c0bad65c2f1b49e42d622" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/6e6dbc6d2beff8117b974d74274bff02e43c32a6", - "reference": "6e6dbc6d2beff8117b974d74274bff02e43c32a6", + "url": "https://api.github.com/repos/symfony/config/zipball/0356e6d5298e9e72212c0bad65c2f1b49e42d622", + "reference": "0356e6d5298e9e72212c0bad65c2f1b49e42d622", "shasum": "" }, "require": { @@ -1871,20 +1918,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2017-11-20T18:22:57+00:00" + "time": "2017-12-14T19:48:22+00:00" }, { "name": "symfony/console", - "version": "v4.0.0", + "version": "v4.0.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "5cd0dd461dfc72f59c8405cac32d31e82c7348e8" + "reference": "de8cf039eacdec59d83f7def67e3b8ff5ed46714" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/5cd0dd461dfc72f59c8405cac32d31e82c7348e8", - "reference": "5cd0dd461dfc72f59c8405cac32d31e82c7348e8", + "url": "https://api.github.com/repos/symfony/console/zipball/de8cf039eacdec59d83f7def67e3b8ff5ed46714", + "reference": "de8cf039eacdec59d83f7def67e3b8ff5ed46714", "shasum": "" }, "require": { @@ -1939,20 +1986,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-11-29T13:42:03+00:00" + "time": "2017-12-14T19:48:22+00:00" }, { "name": "symfony/filesystem", - "version": "v4.0.0", + "version": "v4.0.2", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "c9d4a26759ff75a077e4e334315cb632739b661a" + "reference": "8c2868641d0c4885eee9c12a89c2b695eb1985cd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/c9d4a26759ff75a077e4e334315cb632739b661a", - "reference": "c9d4a26759ff75a077e4e334315cb632739b661a", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/8c2868641d0c4885eee9c12a89c2b695eb1985cd", + "reference": "8c2868641d0c4885eee9c12a89c2b695eb1985cd", "shasum": "" }, "require": { @@ -1988,7 +2035,7 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2017-11-21T14:14:53+00:00" + "time": "2017-12-14T19:48:22+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -2051,7 +2098,7 @@ }, { "name": "symfony/stopwatch", - "version": "v4.0.0", + "version": "v4.0.2", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", diff --git a/src/Expander.php b/src/Expander.php index d922db5..c94ae83 100644 --- a/src/Expander.php +++ b/src/Expander.php @@ -2,8 +2,10 @@ namespace Grasmash\YamlExpander; -use Dflydev\DotAccessData\Data; +use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; use Symfony\Component\Yaml\Yaml; +use Grasmash\Expander\Expander as GrasmashExpander; /** * Class Expander @@ -11,6 +13,28 @@ */ class Expander { + /** + * @var \Psr\Log\LoggerInterface + */ + protected $logger; + + /** + * @var \Grasmash\Expander\Expander + */ + protected $expander; + + /** + * Expander constructor. + * + * @param \Psr\Log\LoggerInterface $logger + */ + public function __construct(LoggerInterface $logger) + { + $this->logger = $logger; + $this->expander = new GrasmashExpander(); + $this->expander->setLogger($logger); + $this->expander->setStringifier(new Stringifier()); + } /** * Parses a YAML string and expands property placeholders. @@ -27,13 +51,12 @@ class Expander * The modified array in which placeholders have been replaced with * values. */ - public static function parse($yaml_string, $reference_array = []) + public function parse($yaml_string, $reference_array = []) { $array = Yaml::parse($yaml_string); - return self::expandArrayProperties($array, $reference_array); + return $this->expander->expandArrayProperties($array, $reference_array); } - /** * Expands property placeholders in an array. * @@ -46,228 +69,8 @@ public static function parse($yaml_string, $reference_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) + public function expandArrayProperties($array, $reference_array = []) { - // print "$message\n"; + return $this->expander->expandArrayProperties($array, $reference_array); } } diff --git a/src/Stringifier.php b/src/Stringifier.php new file mode 100644 index 0000000..a420999 --- /dev/null +++ b/src/Stringifier.php @@ -0,0 +1,23 @@ +expandArrayProperties($array); $this->assertEquals('gomjabbar', $expanded['env-test']); $this->assertEquals('Frank Herbert 1965', $expanded['book']['copyright']); $this->assertEquals('Paul Atreides', $expanded['book']['protaganist']); @@ -31,7 +34,7 @@ public function testExpandArrayProperties($filename, $reference_array) $this->assertEquals('Dune', $expanded['product-name']); $this->assertEquals(Yaml::dump($array['inline-array'], 0), $expanded['expand-array']); - $expanded = Expander::expandArrayProperties($array, $reference_array); + $expanded = $expander->expandArrayProperties($array, $reference_array); $this->assertEquals('Dune Messiah, and others.', $expanded['sequels']); $this->assertEquals('Dune Messiah', $expanded['book']['nested-reference']); } @@ -47,13 +50,14 @@ public function testExpandArrayProperties($filename, $reference_array) public function testParse($filename, $reference_array) { $yaml_string = file_get_contents(__DIR__ . "/../resources/$filename"); - $expanded = Expander::parse($yaml_string); + $expander = new Expander(new NullLogger()); + $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); + $expanded = $expander->parse($yaml_string, $reference_array); $this->assertEquals('Dune Messiah, and others.', $expanded['sequels']); $this->assertEquals('Dune Messiah', $expanded['book']['nested-reference']); } @@ -75,25 +79,15 @@ public function providerYaml() /** * Tests Expander::expandProperty(). - * - * @dataProvider providerTestExpandProperty */ - public function testExpandProperty($array, $property_name, $unexpanded_string, $expected) + public function testStringifyArray() { - $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' ], + $array = [ + 0 => 'one', + 1 => 'two', + 2 => 'three', ]; + $string = Stringifier::stringifyArray($array); + $this->assertEquals('[one, two, three]', $string); } }