Skip to content

Psalm issue with the 3rd parameter of Psr16Adapter::set has to be null #768

@flecki89

Description

@flecki89

Configuration

  • PhpFastCache version: 8.0.2
  • PhpFastCache API version: 3.0.0
  • PHP version: PHP 7.4.11 (cli) (built: Sep 29 2020 13:18:06) ( ZTS Visual C++ 2017 x64 )
  • Operating system: Windows 10 Pro (Version: 10.0.18363 Build 18363)

Describe the bug

Not a functional bug, but psalm insists that the 3rd parameter in Phpfastcache\Helper\Psr16Adapter::set has to be null.

When I run psalm, it throws this error

ERROR: InvalidArgument - src\SFCache.php:88:38 - Argument 3 of Phpfastcache\Helper\Psr16Adapter::set expects null, int provided (see https://psalm.dev/004)
            $inst->set($key, $value, $ttl);

where $inst is my Cache instance

To Reproduce
Steps to reproduce the behavior:

  1. Use Psr16Adapter::set with 3rd parameter set
  2. Run psalm with default configuration
  3. Encounter the error above

Expected behavior
Psalm should not recognize this or similar errors.

Possible solution
Changing https://github.com/PHPSocialNetwork/phpfastcache/blob/99a345aae21f1c6d54955f8bbb622f3fba39a322/lib/Phpfastcache/Helper/Psr16Adapter.php#L93 to

     * @param int|null $ttl

solves this problem.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions