xp-framework / core

The XP Framework is an all-purpose, object oriented PHP framework.
Other
19 stars 6 forks source link

Pass NULL to Properties::expanding() to ignore expansion #271

Closed thekid closed 3 years ago

thekid commented 3 years ago

When working with injection files used in web applications outside of these applications, a property expansion named app needs to be registered for them to parse, even when values are not accessed!

An example is the following inject.ini:

string[sessions]=${app.tempdir}

To read these files, the following code is necessary:

$config= (new Properties('inject.ini'))->expanding('app', fn($n) => '*'));

This pull request adds the ability to ignore any expansions as follows:

$config= (new Properties('inject.ini'))->expanding('app', null);
thekid commented 3 years ago

Another idea could be to defer expansion until read time, which would be a bigger refactoring on the one hand and lead to typos in expansions being recognized very late on.