diff --git a/.gitattributes b/.gitattributes index d995ab8db..e6ef3db5b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,5 @@ /tests export-ignore +/docs/examples export-ignore /bin/ci export-ignore /bin/stubs export-ignore /.github export-ignore @@ -14,4 +15,4 @@ CODING_GUIDELINE.md export-ignore phpunit.xml.dist export-ignore phpcs.xml.dist export-ignore composer.lock export-ignore -CNAME export-ignore \ No newline at end of file +CNAME export-ignore diff --git a/.travis.yml b/.travis.yml index ddbee2d86..ca572bd8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,18 +21,6 @@ services: - riak - mongodb -before_script: - - | - if [[ $TRAVIS_PHP_VERSION = "hhv"* ]]; then - cat bin/ci/hhvm_phpfastcache.ini >> /etc/hhvm/php.ini - else - phpenv config-add bin/ci/php_phpfastcache.ini - pecl channel-update pecl.php.net - pecl install -f mongodb-stable - fi - - sleep 15 - - mongo pfc_test --eval 'db.createUser({user:"travis",pwd:"test",roles:["readWrite"]});' - php: # - 5.3 # - 5.4 @@ -52,6 +40,18 @@ matrix: - php: nightly - php: hhvm +before_install: + - | + if [[ $TRAVIS_PHP_VERSION = "hhv"* ]]; then + cat bin/ci/hhvm_phpfastcache.ini >> /etc/hhvm/php.ini + else + phpenv config-add bin/ci/php_phpfastcache.ini + pecl channel-update pecl.php.net + pecl install -f mongodb-1.9.2 + fi + - sleep 15 + - mongo pfc_test --eval 'db.createUser({user:"travis",pwd:"test",roles:["readWrite"]});' + install: - ./bin/ci/install_dependencies.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index cf30ed1ec..d6d5a15da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,27 @@ +## 7.1.2 +#### _"Rust-weak"_ +##### 12 august 2021 +- __Global__ + - Improved PHP 7.4 support + - Fixed #768 // Psalm issue with the 3rd parameter of Psr16Adapter::set has to be null (@geolim4) + - Fixed #781 // Type issue (@geolim4) +- __Docs__ + - Fixed vulnerability issue that cause exposed phpinfo() in some situations (@geolim4) +- __Drivers__ + - Fixed #759 // Memcached Bytes Replaced with Version (@geolim4) + +## 7.1.1 +#### _"Rust-out"_ +##### 24 april 2020 +- __Drivers__ + - Fixed #716 // TypeError in lib/Phpfastcache/Drivers/Cookie/Driver.php (@motikan2010) + - Fixed #733 // Removing path check in Redis driver before auth. (@gillytech) +- __Helpers__ + - Fixed #717 // Deprecate "ActOnAll" to remove it in v8 (@geolim4) +- __Misc__ + - Added v8 mention in Readme (@geolim4) + - Added Github Funding option (@geolim4) + ## 7.1.0 #### _"Wake the rust"_ ##### 15 september 2019 @@ -293,4 +317,4 @@ ## 7.0.0-dev ##### 01 october 2017 -- Initialized v7 development \ No newline at end of file +- Initialized v7 development diff --git a/README.md b/README.md index 4c2add5da..136d6c9df 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ [![Total Downloads](https://img.shields.io/packagist/dt/phpfastcache/phpfastcache.svg?maxAge=86400)](https://packagist.org/packages/phpfastcache/phpfastcache) [![Latest Stable Version](https://img.shields.io/packagist/v/phpfastcache/phpfastcache.svg?maxAge=86400)](https://packagist.org/packages/phpfastcache/phpfastcache) [![License](https://img.shields.io/packagist/l/phpfastcache/phpfastcache.svg?maxAge=86400)](https://packagist.org/packages/phpfastcache/phpfastcache) [![Coding Standards](https://img.shields.io/badge/CI-PSR6-orange.svg?maxAge=86400)](https://github.com/php-fig/cache) [![Coding Standards](https://img.shields.io/badge/CS-PSR16-orange.svg?maxAge=86400)](https://github.com/php-fig/simple-cache) -[![Code Climate](https://codeclimate.com/github/PHPSocialNetwork/phpfastcache/badges/gpa.svg)](https://codeclimate.com/github/PHPSocialNetwork/phpfastcache) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/PHPSocialNetwork/phpfastcache/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/PHPSocialNetwork/phpfastcache/?branch=master) [![Build Status](https://travis-ci.org/PHPSocialNetwork/phpfastcache.svg?branch=master)](https://travis-ci.org/PHPSocialNetwork/phpfastcache) [![Semver compliant](https://img.shields.io/badge/Semver-2.0.0-yellow.svg?maxAge=86400)](https://semver.org/spec/v2.0.0.html) [![Patreon](https://img.shields.io/badge/Support%20us%20on-Patreon-f96854.svg?maxAge=86400)](https://www.patreon.com/geolim4) +[![Code Climate](https://codeclimate.com/github/PHPSocialNetwork/phpfastcache/badges/gpa.svg)](https://codeclimate.com/github/PHPSocialNetwork/phpfastcache) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/PHPSocialNetwork/phpfastcache/badges/quality-score.png?b=v7)](https://scrutinizer-ci.com/g/PHPSocialNetwork/phpfastcache/?branch=v7) [![Build Status](https://travis-ci.com/PHPSocialNetwork/phpfastcache.svg?branch=v7)](https://travis-ci.com/PHPSocialNetwork/phpfastcache) [![Semver compliant](https://img.shields.io/badge/Semver-2.0.0-yellow.svg?maxAge=86400)](https://semver.org/spec/v2.0.0.html) [![Patreon](https://img.shields.io/badge/Support%20us%20on-Patreon-f96854.svg?maxAge=86400)](https://www.patreon.com/geolim4) #### :warning: Please note that the V7 is a major (BC breaking) update of PhpFastCache ! > As the V7 is **absolutely** not compatible with previous versions, please read carefully the [migration guide](./docs/migration/MigratingFromV6ToV7.md) to ensure you the smoothest migration possible. One of the biggest change is the configuration system which is now an object that replace the primitive array that we used to implement back then. Also please note that the V7 requires at least PHP7 or higher to work properly. +>:new: The V8 is now released, upgrade Phpfastcache by following our migration guide in `docs/migration` --------------------------- Simple Yet Powerful PHP Caching Class --------------------------- diff --git a/bin/ci/install_dependencies.sh b/bin/ci/install_dependencies.sh index 6b0b87005..d370b40f8 100755 --- a/bin/ci/install_dependencies.sh +++ b/bin/ci/install_dependencies.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash composer self-update; -composer install --ignore-platform-reqs; -composer require "phpfastcache/couchdb:~1.0.0" "phpfastcache/phpssdb:~1.0.0" "predis/predis:~1.1.0" "mongodb/mongodb:^1.1" "phpfastcache/riak-client:^1.4.4" --ignore-platform-reqs; +composer install; +composer require "phpfastcache/couchdb:~1.0.0" "phpfastcache/phpssdb:~1.0.0" "predis/predis:~1.1.0" "mongodb/mongodb:^1.1" "phpfastcache/riak-client:^1.4.4"; diff --git a/docs/examples/phpinfo.php b/docs/examples/phpinfo.php deleted file mode 100644 index cf6086080..000000000 --- a/docs/examples/phpinfo.php +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/lib/Phpfastcache/Config/ConfigurationOption.php b/lib/Phpfastcache/Config/ConfigurationOption.php index 2392f747b..cecfdd5d2 100644 --- a/lib/Phpfastcache/Config/ConfigurationOption.php +++ b/lib/Phpfastcache/Config/ConfigurationOption.php @@ -142,14 +142,24 @@ public function __construct(...$args) $typeHintGot = \is_object($value) ? \get_class($value) : \gettype($value); $reflectionMethod = new \ReflectionMethod($this, $method); $parameter = $reflectionMethod->getParameters()[0] ?? null; - $typeHintExpected = ($parameter instanceof \ReflectionParameter ? ($parameter->getType() === 'object' ? $parameter->getClass() : $parameter->getType()) : 'Unknown type'); - - throw new PhpfastcacheInvalidConfigurationException(\sprintf( - 'Invalid type hint found for "%s", expected "%s" got "%s"', - \lcfirst(\substr($method, 3)), - $typeHintExpected, - $typeHintGot - )); + $paraReflectionType = $parameter->getType(); + if(method_exists($paraReflectionType, "getName")) { + $typeHintExpected = ($parameter instanceof \ReflectionParameter ? ($paraReflectionType->getName() === 'object' ? $parameter->getClass() : $paraReflectionType->getName()) : 'Unknown type'); + throw new PhpfastcacheInvalidConfigurationException(\sprintf( + 'Invalid type hint found for "%s", expected "%s" got "%s"', + \lcfirst(\substr($method, 3)), + $typeHintExpected, + $typeHintGot + )); + } else { + $typeHintExpected = ($parameter instanceof \ReflectionParameter ? ($paraReflectionType === 'object' ? $parameter->getClass() : $paraReflectionType) : 'Unknown type'); + throw new PhpfastcacheInvalidConfigurationException(\sprintf( + 'Invalid type hint found for "%s", expected "%s" got "%s"', + \lcfirst(\substr($method, 3)), + $typeHintExpected, + $typeHintGot + )); + } } } } @@ -447,4 +457,4 @@ public function setCacheSlamsTimeout(int $cacheSlamsTimeout): self $this->cacheSlamsTimeout = $cacheSlamsTimeout; return $this; } -} \ No newline at end of file +} diff --git a/lib/Phpfastcache/Drivers/Memcached/Driver.php b/lib/Phpfastcache/Drivers/Memcached/Driver.php index a7e1c74b9..140ceca9f 100644 --- a/lib/Phpfastcache/Drivers/Memcached/Driver.php +++ b/lib/Phpfastcache/Drivers/Memcached/Driver.php @@ -194,9 +194,9 @@ protected function driverClear(): bool public function getStats(): DriverStatistic { $stats = current($this->instance->getStats()); - $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); - $stats['version'] = (isset($stats['version']) ? $stats['version'] : $this->instance->getVersion()); - $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); + $stats['uptime'] = $stats['uptime'] ?? 0; + $stats['version'] = $stats['version'] ?? $this->instance->getVersion(); + $stats['bytes'] = $stats['bytes'] ?? 0; $date = (new \DateTime())->setTimestamp(\time() - $stats['uptime']); diff --git a/lib/Phpfastcache/Drivers/Redis/Driver.php b/lib/Phpfastcache/Drivers/Redis/Driver.php index 311e86026..ed21d71c8 100644 --- a/lib/Phpfastcache/Drivers/Redis/Driver.php +++ b/lib/Phpfastcache/Drivers/Redis/Driver.php @@ -85,10 +85,9 @@ protected function driverConnect(): bool $this->instance->setOption(RedisClient::OPT_PREFIX, $this->getConfig()->getOptPrefix()); } - if (!$this->getConfig()->getPath()) { - if ($this->getConfig()->getPassword() && !$this->instance->auth($this->getConfig()->getPassword())) { - return false; - } + + if ($this->getConfig()->getPassword() && !$this->instance->auth($this->getConfig()->getPassword())) { + return false; } if ($this->getConfig()->getDatabase() !== null) { diff --git a/lib/Phpfastcache/Drivers/Riak/Driver.php b/lib/Phpfastcache/Drivers/Riak/Driver.php index 2c15a62c8..00f5c76af 100644 --- a/lib/Phpfastcache/Drivers/Riak/Driver.php +++ b/lib/Phpfastcache/Drivers/Riak/Driver.php @@ -145,7 +145,7 @@ public function getStats(): DriverStatistic return (new DriverStatistic()) ->setData(\implode(', ', \array_keys($this->itemInstances))) ->setRawData($info) - ->setSize(false) + ->setSize(0) ->setInfo('Riak does not provide size/date information att all :('); } -} \ No newline at end of file +} diff --git a/lib/Phpfastcache/Helper/Psr16Adapter.php b/lib/Phpfastcache/Helper/Psr16Adapter.php index 0f7679bbf..e2fa5a7a0 100644 --- a/lib/Phpfastcache/Helper/Psr16Adapter.php +++ b/lib/Phpfastcache/Helper/Psr16Adapter.php @@ -76,7 +76,7 @@ public function get($key, $default = null) /** * @param string $key * @param mixed $value - * @param null $ttl + * @param null|int|\DateInterval $ttl * @return bool * @throws \Phpfastcache\Exceptions\PhpfastcacheSimpleCacheException */