Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter support #88

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

TiMESPLiNTER
Copy link

@TiMESPLiNTER TiMESPLiNTER commented Nov 5, 2016

Proposal for #85

This is a first proposal to add parameter support. At the moment no recursive parameters are supported. This proposal is implemented to preserve backward compatibility.

Let's say we call the Config as follows:

$config = Config::load(
    ['some', 'config' ,'files'],
    ['parameters' => ['foo' => 'bar']]
);

we can use it in each of the config files like this:

config_key: "this is >%parameters.foo%<"

this will result in:

['config_key' => 'this is >bar<']

if you use a not existing parameter in a config value it will not be replaced and the configuration parsing will not fail:

config_key: "this is a %not.existing.parameter%"

will result in:

['config_key' => 'this is a %not.existing.parameter%']

Another idea would be to just merge the dynamic parameters into the config data and then allow using every config value as a parameter in another config value.

@gsouf
Copy link

gsouf commented Dec 14, 2016

That looks a good addition, @hassankhan would you like to merge it ?

@DavidePastore
Copy link
Collaborator

I'm really sorry for the delay. I would like to know how you can handle the case where you want to put in a property the string "%parameters.foo%", even if I have a property with the same key.

*
* @return Config
*/
public static function load($path)
public static function load($path, array $parameters = null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about let the optional $parameters be the empty array []?

*/
public function __construct($path)
public function __construct($path, array $parameters = null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has the same issue in the previous comment thread I mention.

peter279k pushed a commit to open-source-contributions/config that referenced this pull request May 8, 2021
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 0.12.75 to 0.12.76.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Commits](phpstan/phpstan@0.12.75...0.12.76)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants