wp-config icon indicating copy to clipboard operation
wp-config copied to clipboard

Prevent using integers or numeric strings as keys

Open tangrufus opened this issue 5 years ago • 1 comments

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 avatar Mar 11 '20 14:03 tangrufus

@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?

austinpray avatar Mar 11 '20 15:03 austinpray