The PHP 8.0 update, introducing version 1.3.0.
All checks were successful
continuous-integration/drone/push Build is passing

Mostly a compatibility update, with some general beautification.

The following important changes have been made:
This commit is contained in:
Abel Hoogeveen 2021-11-24 20:22:35 +01:00
parent 0b5a867bc7
commit b08688ccb0
Signed by: abelhooge
GPG Key ID: C540221690CBFFBA
6 changed files with 46 additions and 21 deletions

View File

@ -12,7 +12,7 @@ steps:
commands:
- composer install
- name: dummyprovidertest
- name: dummyprovidertest74
image: registry.i15.nl/i15/fuzephp:7.4-alpine
commands:
- docker-php-ext-enable xdebug
@ -20,7 +20,7 @@ steps:
environment:
OBJECTSTORAGE_PROVIDER: DummyProvider
- name: fileprovidertest
- name: fileprovidertest74
image: registry.i15.nl/i15/fuzephp:7.4-alpine
commands:
- docker-php-ext-enable xdebug
@ -28,7 +28,7 @@ steps:
environment:
OBJECTSTORAGE_PROVIDER: FileProvider
- name: redisprovidertest
- name: redisprovidertest74
image: registry.i15.nl/i15/fuzephp:7.4-alpine
commands:
- docker-php-ext-enable xdebug
@ -37,5 +37,30 @@ steps:
OBJECTSTORAGE_PROVIDER: RedisProvider
OBJECTSTORAGE_REDIS_HOST: cache
- name: dummyprovidertest80
image: registry.i15.nl/i15/fuzephp:8.0-alpine
commands:
- docker-php-ext-enable xdebug
- vendor/bin/phpunit -c test/phpunit.xml
environment:
OBJECTSTORAGE_PROVIDER: DummyProvider
- name: fileprovidertest80
image: registry.i15.nl/i15/fuzephp:8.0-alpine
commands:
- docker-php-ext-enable xdebug
- vendor/bin/phpunit -c test/phpunit.xml
environment:
OBJECTSTORAGE_PROVIDER: FileProvider
- name: redisprovidertest80
image: registry.i15.nl/i15/fuzephp:8.0-alpine
commands:
- docker-php-ext-enable xdebug
- vendor/bin/phpunit -c test/phpunit.xml
environment:
OBJECTSTORAGE_PROVIDER: RedisProvider
OBJECTSTORAGE_REDIS_HOST: cache
image_pull_secrets:
- dockerconfig

View File

@ -1,16 +1,15 @@
{
"name": "fuzeworks/objectstorage",
"minimum-stability": "stable",
"license": ["MIT"],
"authors": [
{
"name": "Abel Hoogeveen",
"email": "abel@i15.nl"
"homepage": "https://i15.nl"
}
],
"require": {
"php": ">=7.4.0",
"fuzeworks/core": "~1.2",
"fuzeworks/core": "~1.3.0",
"psr/simple-cache": "1.0.1"
},
"suggest": {
@ -18,7 +17,7 @@
},
"require-dev": {
"phpunit/phpunit": "^9",
"fuzeworks/tracycomponent": "~1.2"
"fuzeworks/tracycomponent": "~1.3.0"
},
"autoload": {
"psr-4": {

View File

@ -35,6 +35,8 @@
namespace FuzeWorks\ObjectStorage\Exception;
class ObjectStorageException extends \FuzeWorks\Exception\CoreException
use FuzeWorks\Exception\CoreException;
class ObjectStorageException extends CoreException
{
}

View File

@ -65,7 +65,7 @@ class ObjectStorageCache implements CacheInterface
return is_null($res) ? $default : $res;
}
public function set($key, $value, $ttl = null)
public function set($key, $value, $ttl = null): bool
{
$meta = [
'time' => time(),
@ -75,12 +75,12 @@ class ObjectStorageCache implements CacheInterface
return $this->provider->save('fwcache_' . $key, $value, $meta);
}
public function delete($key)
public function delete($key): bool
{
return $this->provider->deleteItem('fwcache_' . $key);
}
public function clear()
public function clear(): bool
{
// Fetch the index set
$index = $this->provider->getIndex();
@ -93,7 +93,7 @@ class ObjectStorageCache implements CacheInterface
return true;
}
public function getMultiple($keys, $default = null)
public function getMultiple($keys, $default = null): array
{
$out = [];
foreach ($keys as $key)
@ -104,7 +104,7 @@ class ObjectStorageCache implements CacheInterface
return $out;
}
public function setMultiple($values, $ttl = null)
public function setMultiple($values, $ttl = null): bool
{
foreach ($values as $key => $value)
$this->set($key, $value, $ttl);
@ -112,7 +112,7 @@ class ObjectStorageCache implements CacheInterface
return true;
}
public function deleteMultiple($keys)
public function deleteMultiple($keys): bool
{
foreach ($keys as $key)
$this->delete($key);
@ -120,7 +120,7 @@ class ObjectStorageCache implements CacheInterface
return true;
}
public function has($key)
public function has($key): bool
{
$this->testTTL($key);
return $this->provider->hasItem('fwcache_' . $key);

View File

@ -37,7 +37,6 @@ namespace FuzeWorks\ObjectStorage\Provider;
use FuzeWorks\ObjectStorage\Exception\ObjectStorageException;
use FuzeWorks\ObjectStorage\iObjectStorageProvider;
use FuzeWorks\Core;
use Traversable;
/**
* FileProvider
@ -83,7 +82,7 @@ class FileProvider implements iObjectStorageProvider
public function init(array $providerConfig): bool
{
// First load the directory from the providerConfig
$directory = isset($providerConfig['storage_directory']) ? $providerConfig['storage_directory'] : null;
$directory = $providerConfig['storage_directory'] ?? null;
// Check if the directory exists
if (!file_exists($directory) || !is_dir($directory))
@ -236,12 +235,11 @@ class FileProvider implements iObjectStorageProvider
*
* @param string $path File path
* @param string $data Data to write
* @param string $mode fopen() mode (default: 'wb')
* @return bool
*/
private function write_file(string $path, string $data, string $mode = 'wb'): bool
private function write_file(string $path, string $data): bool
{
if ( ! $fp = @fopen($path, $mode))
if ( ! $fp = @fopen($path, 'wb'))
return false;
flock($fp, LOCK_EX);

View File

@ -36,6 +36,7 @@
require_once(dirname(__DIR__) . '/vendor/autoload.php');
use FuzeWorks\Configurator;
use FuzeWorks\ObjectStorage\ObjectStorageComponent;
use FuzeWorks\Priority;
$configurator = new Configurator();
@ -48,7 +49,7 @@ $configurator->setLogDirectory(__DIR__ . '/temp');
$configurator->setTimeZone('Europe/Amsterdam');
// And the star of the show: ObjectStorageComponent
$configurator->addComponent(new \FuzeWorks\ObjectStorage\ObjectStorageComponent());
$configurator->addComponent(new ObjectStorageComponent());
// Add the test config file
$configurator->addDirectory(dirname(__FILE__), 'config', Priority::HIGH);