Skip to content

Allow multiple array formats in config in addition to serialize(array()) #10

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SagePtr
Copy link
Contributor

@SagePtr SagePtr commented Mar 26, 2019

This change allows to use multiple array formats in config file.

Previously, the only one notation was this:
define('OPTION', serialize(array('value1', 'value2', 'value3')));
Now it's allowed to also define array directly (PHP 7.0+):
define('OPTION', ['value1', 'value2', 'value3']);
Or use JSON notation:
define('OPTION', "['value1', 'value2', 'value3']");
Or use comma-separated list:
define('OPTION', 'value1, value2, value3');
Or if array has the only one value, use it directly (if it doesn't contain comma):
define('OPTION', 'value');

Empty string is automatically converted to empty array:
define('OPTION', '');

Serialize(array()) is also allowed and checked first (if string is passed), so backward compatibility with older configs isn't broken.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant