Skip to content

Integer keys #91

@gregor-j

Description

@gregor-j

The function SimpleCacheTest::invalidKeys() line 58 lists (integer) 2 as invalid key, which leads to a problem:

  1. PHP will read ['0' => 'value0'] as ['value0'] making it impossible to determine whether 0 was an integer or a string at declaration time. Reference: PHP documentation on arrays, stating A key may be either an integer or a string. If a key is the standard representation of an integer, it will be interpreted as such (i.e. "8" will be interpreted as 8, while "08" will be interpreted as "08").
  2. Considering point 1, the test case SimpleCacheTest::testSetMultipleWithIntegerArrayKey() line 225 effectively considers 0 a valid key, contradicting SimpleCacheTest::invalidKeys().
  3. The problem already seems to have surfaced, because there is a fix in SimpleCacheTest::testSetMultipleInvalidKeys() on line 461. However, this does not solve the problem, because the tests using the SimpleCacheTest::invalidKeys() function still consider (integer) 2 an invalid key.

To solve the problem, either integers are considered keys, or the the test case SimpleCacheTest::testSetMultipleWithIntegerArrayKey() line 225 uses another key than '0'.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions