wp-config
wp-config copied to clipboard
Prevent using integers or numeric strings as keys
- [x] I've read the guidelines for Contributing to Roots Projects
- [x] This request isn't a duplicate of an existing issue
- [x] I've read the docs and followed them (if applicable)
- [x] This is not a personal support request that should be posted on the Roots Discourse community
Description
Unexpected behaviors when using integers or numeric strings as keys
Steps to reproduce
// Without declare(strict_types=1); !!
Config::define(999, 'nine nine nine');
Config::apply();
Expected behavior:
Warn (or throw exceptions) about using integers or numeric strings as keys is incorrect.
Actual behavior:
echo Config::get(999);
==> nine nine nine
echo constant(999);
==> nine nine nine
echo constant('999');
==> nine nine nine
echo 999;
==> 999
Possible Solution
- Bump PHP requirement
- Add
declare(strict_types=1); - Add type hints
@TangRufus I'm down for doing all this
- Bump PHP requirement
- Add declare(strict_types=1);
- Add type hints
Let's do it and tag a 2.0?