Skip to content

Cache::has('key') response different from documentation #27630

@fitztrev

Description

@fitztrev
  • Laravel Version: 5.7.27
  • PHP Version: 7.2.15

Description:

Cache::has('key') returns true when its value is false, differing from the documentation:

screen shot 2019-02-22 at 11 40 20 am

Steps To Reproduce:

Copy + paste this code to a route, command, or test:

Cache::forever('foo_string', 'string');
Cache::forever('foo_0', 0);
Cache::forever('foo_1', 1);
Cache::forever('foo_true', true);
Cache::forever('foo_empty', '');

Cache::forever('foo_null', null);
Cache::forever('foo_false', false);

dd(
    'These should be true:',
        Cache::has('foo_string'),
        Cache::has('foo_0'),
        Cache::has('foo_1'),
        Cache::has('foo_true'),
        Cache::has('foo_empty'),

    'These should be false:',
        Cache::has('foo_null'),
        Cache::has('foo_false')  // <-- issue
);

I've tried the above with these cache drivers: file, redis, memcached, array. Same result with each.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions