doctrine / cache

Doctrine Cache component

Home Page:https://www.doctrine-project.org/projects/cache.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

should lifeTime have int type declaration ?

serbancatalin opened this issue · comments

public function save($id, $data, $lifeTime = 0);

Since it is used with null in

https://github.com/doctrine/common/blob/a61bfddd39b887265117806e81cc6ca8da242fe1/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php#L200-L203

and adding a test for null lifeTime fails CouchbaseBucketCacheTest and PhpFileCacheTest

     /**
     * @dataProvider provideDataToCache
     */
    public function testLifeTimeNull($value) : void
    {
        $cache = $this->_getCacheDriver();

        // Test saving a value, checking if it exists, and fetching it back
        self::assertTrue($cache->save('key', $value, null));
        self::assertTrue($cache->contains('key'));
    }

https://travis-ci.org/serbancatalin/cache/builds/352894953

Yeah, it should, but adding a type declaration can only be done if we enforce PHP 7.2, as otherwise it counts as a BC break.

I believe int type declaration was added in PHP 7.0

CouchbaseBucketCache usses it

private function normalizeExpiry(int $expiry) : int

Closing as we're sunsetting this library. Please see #354 for more details.