Skip to content

Commit

Permalink
kw_cache - bump versions, dependency analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-kalanis committed Mar 31, 2024
1 parent f04746f commit 2509c03
Show file tree
Hide file tree
Showing 23 changed files with 113 additions and 86 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/code_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ '7.4', '8.0', '8.1' ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
name: PHP ${{ matrix.php }} tests
steps:
- uses: actions/checkout@v2
Expand All @@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ '7.4', '8.1' ]
php: [ '8.1' ]
name: PHP ${{ matrix.php }} code style
steps:
- uses: actions/checkout@v2
Expand All @@ -43,7 +43,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ '7.4', '8.1' ]
php: [ '8.1' ]
name: PHP ${{ matrix.php }} phpstan
steps:
- uses: actions/checkout@v2
Expand All @@ -53,3 +53,18 @@ jobs:
coverage: none
- run: composer install --no-progress
- run: vendor/bin/phpstan analyse -c phpstan.neon

composer_dependencies:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ '8.1' ]
name: PHP ${{ matrix.php }} problematic dependencies
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
- run: composer install --no-progress
- run: vendor/bin/composer-dependency-analyser --config=composer-dependency-analyser.php
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# kw_cache

[![Build Status](https://app.travis-ci.com/alex-kalanis/kw_cache.svg?branch=master)](https://app.travis-ci.com/github/alex-kalanis/kw_cache)
![Build Status](https://github.com/alex-kalanis/kw_cache/actions/workflows/code_checks.yml/badge.svg)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/alex-kalanis/kw_cache/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/alex-kalanis/kw_cache/?branch=master)
[![Latest Stable Version](https://poser.pugx.org/alex-kalanis/kw_cache/v/stable.svg?v=1)](https://packagist.org/packages/alex-kalanis/kw_cache)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.3-8892BF.svg)](https://php.net/)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.4-8892BF.svg)](https://php.net/)
[![Downloads](https://img.shields.io/packagist/dt/alex-kalanis/kw_cache.svg?v1)](https://packagist.org/packages/alex-kalanis/kw_cache)
[![License](https://poser.pugx.org/alex-kalanis/kw_cache/license.svg?v=1)](https://packagist.org/packages/alex-kalanis/kw_cache)
[![Code Coverage](https://scrutinizer-ci.com/g/alex-kalanis/kw_cache/badges/coverage.png?b=master&v=1)](https://scrutinizer-ci.com/g/alex-kalanis/kw_cache/?branch=master)
Expand All @@ -13,12 +13,8 @@ for semaphores as remote flags for cache re-generating.

## PHP Installation

```
{
"require": {
"alex-kalanis/kw_cache": "2.0"
}
}
```bash
composer.phar require alex-kalanis/kw_cache
```

(Refer to [Composer Documentation](https://github.com/composer/composer/blob/master/doc/00-intro.md#introduction) if you are not
Expand Down
21 changes: 21 additions & 0 deletions composer-dependency-analyser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/**
* Dependency analyzer configuration
* @link https://github.com/shipmonk-rnd/composer-dependency-analyser
*/

use ShipMonk\ComposerDependencyAnalyser\Config\Configuration;
use ShipMonk\ComposerDependencyAnalyser\Config\ErrorType;

$config = new Configuration();

return $config
// ignore errors on specific packages and paths
->ignoreErrorsOnPackageAndPath('alex-kalanis/kw_files', __DIR__ . '/php-src/Files/Basic.php', [ErrorType::DEV_DEPENDENCY_IN_PROD])
->ignoreErrorsOnPackageAndPath('alex-kalanis/kw_files', __DIR__ . '/php-src/Files/Dual.php', [ErrorType::DEV_DEPENDENCY_IN_PROD])
->ignoreErrorsOnPackageAndPath('alex-kalanis/kw_files', __DIR__ . '/php-src/Files/Semaphore.php', [ErrorType::DEV_DEPENDENCY_IN_PROD])
->ignoreErrorsOnPackageAndPath('alex-kalanis/kw_storage', __DIR__ . '/php-src/Storage/Basic.php', [ErrorType::DEV_DEPENDENCY_IN_PROD])
->ignoreErrorsOnPackageAndPath('alex-kalanis/kw_storage', __DIR__ . '/php-src/Storage/Dual.php', [ErrorType::DEV_DEPENDENCY_IN_PROD])
->ignoreErrorsOnPackageAndPath('alex-kalanis/kw_storage', __DIR__ . '/php-src/Storage/Semaphore.php', [ErrorType::DEV_DEPENDENCY_IN_PROD])
;
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
"license": "BSD-3-Clause",
"type": "library",
"require": {
"alex-kalanis/kw_paths": ">=3.0 <4",
"alex-kalanis/kw_semaphore": ">=1.0 <2",
"alex-kalanis/kw_paths": ">=4.0 <5",
"alex-kalanis/kw_semaphore": ">=2.0 <3",
"ext-json": "*",
"php": ">=7.3"
"php": ">=7.4"
},
"require-dev": {
"alex-kalanis/kw_storage": ">=4.0 <5",
"alex-kalanis/kw_files": ">=3.3 <4",
"alex-kalanis/kw_storage": ">=5.0 <6",
"alex-kalanis/kw_files": ">=4.0 <5",
"shipmonk/composer-dependency-analyser": "^1.4",
"friendsofphp/php-cs-fixer": "^3.0",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": ">=7.2 <=9"
"phpunit/phpunit": ">=8.0 <=9"
},
"suggest": {
},
Expand Down
2 changes: 1 addition & 1 deletion kwcms.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"require": {
"alex-kalanis/kw_paths": "dev-master",
"alex-kalanis/kw_semaphore": "dev-master",
"php": ">=7.2.0"
"php": ">=7.4.0"
},
"suggest": {
},
Expand Down
6 changes: 2 additions & 4 deletions php-src/Cache/Dual.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
*/
class Dual implements ICache
{
/** @var ICache */
protected $storageCache = null;
/** @var ICache */
protected $reloadCache = null;
protected ICache $storageCache;
protected ICache $reloadCache;

public function __construct(ICache $storageCache, ?ICache $reloadCache = null)
{
Expand Down
6 changes: 2 additions & 4 deletions php-src/Cache/Formatted.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
*/
class Formatted
{
/** @var Interfaces\ICache */
protected $cache = null;
/** @var Interfaces\IFormat */
protected $format = null;
protected Interfaces\ICache $cache;
protected Interfaces\IFormat $format;

public function __construct(Interfaces\ICache $cache, Interfaces\IFormat $format)
{
Expand Down
6 changes: 2 additions & 4 deletions php-src/Cache/Semaphore.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
*/
class Semaphore implements ICache
{
/** @var ICache */
protected $cache = null;
/** @var ISemaphore */
protected $reloadSemaphore = null;
protected ICache $cache;
protected ISemaphore $reloadSemaphore;

public function __construct(ICache $cache, ISemaphore $reloadSemaphore)
{
Expand Down
5 changes: 2 additions & 3 deletions php-src/Files/Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ class Basic implements ICache
{
use TToString;

/** @var CompositeAdapter */
protected $cacheStorage = null;
protected CompositeAdapter $cacheStorage;
/** @var string[] */
protected $cachePath = [];
protected array $cachePath = [];

public function __construct(CompositeAdapter $cacheStorage)
{
Expand Down
10 changes: 4 additions & 6 deletions php-src/Files/Dual.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ class Dual implements ICache
{
use TToString;

/** @var CompositeAdapter */
protected $cacheLib = null;
/** @var CompositeAdapter */
protected $reloadLib = null;
protected CompositeAdapter $cacheLib;
protected CompositeAdapter $reloadLib;
/** @var string[] */
protected $cachePath = [];
protected array $cachePath = [];
/** @var string[] */
protected $reloadPath = [];
protected array $reloadPath = [];

public function __construct(CompositeAdapter $cacheLib, ?CompositeAdapter $reloadLib = null)
{
Expand Down
8 changes: 3 additions & 5 deletions php-src/Files/Semaphore.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ class Semaphore implements ICache
{
use TToString;

/** @var CompositeAdapter */
protected $lib = null;
/** @var ISemaphore */
protected $reloadSemaphore = null;
protected CompositeAdapter $lib;
protected ISemaphore $reloadSemaphore;
/** @var string[] */
protected $cachePath = [ICache::EXT_CACHE];
protected array $cachePath = [ICache::EXT_CACHE];

public function __construct(CompositeAdapter $lib, ISemaphore $reloadSemaphore)
{
Expand Down
4 changes: 2 additions & 2 deletions php-src/Interfaces/ICache.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/
interface ICache
{
const EXT_CACHE = '.cache'; # cache itself file ext
const EXT_RELOAD = '.reload'; # reload file ext
public const EXT_CACHE = '.cache'; # cache itself file ext
public const EXT_RELOAD = '.reload'; # reload file ext

/**
* @param string[] $what
Expand Down
3 changes: 1 addition & 2 deletions php-src/Simple/Variable.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
*/
class Variable implements ICache
{
/** @var string|null */
protected $content = null;
protected ?string $content = null;

public function init(array $what): void
{
Expand Down
5 changes: 2 additions & 3 deletions php-src/Storage/Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
*/
class Basic implements ICache
{
/** @var IStorage */
protected $cacheStorage = null;
protected IStorage $cacheStorage;
/** @var string[] */
protected $cachePath = [ICache::EXT_CACHE];
protected array $cachePath = [ICache::EXT_CACHE];

public function __construct(IStorage $cacheStorage)
{
Expand Down
10 changes: 4 additions & 6 deletions php-src/Storage/Dual.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
*/
class Dual implements ICache
{
/** @var IStorage */
protected $cacheStorage = null;
/** @var IStorage */
protected $reloadStorage = null;
protected IStorage $cacheStorage;
protected IStorage $reloadStorage;
/** @var string[] */
protected $cachePath = [ICache::EXT_CACHE];
protected array $cachePath = [ICache::EXT_CACHE];
/** @var string[] */
protected $reloadPath = [ICache::EXT_RELOAD];
protected array $reloadPath = [ICache::EXT_RELOAD];

public function __construct(IStorage $cacheStorage, ?IStorage $reloadStorage = null)
{
Expand Down
8 changes: 3 additions & 5 deletions php-src/Storage/Semaphore.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
*/
class Semaphore implements ICache
{
/** @var IStorage */
protected $storage = null;
/** @var ISemaphore */
protected $reloadSemaphore = null;
protected IStorage $storage;
protected ISemaphore $reloadSemaphore;
/** @var string[] */
protected $cachePath = [ICache::EXT_CACHE];
protected array $cachePath = [ICache::EXT_CACHE];

public function __construct(IStorage $cacheStorage, ISemaphore $reloadSemaphore)
{
Expand Down
10 changes: 5 additions & 5 deletions php-tests/CommonTestClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public function exists(string $key): bool
return isset($this->data[$key]);
}

public function load(string $key)
public function load(string $key): string
{
return $this->exists($key) ? $this->data[$key] : null ;
return $this->exists($key) ? $this->data[$key] : '';
}

public function save(string $key, $data, ?int $timeout = null): bool
Expand Down Expand Up @@ -89,9 +89,9 @@ public function exists(string $key): bool
return false;
}

public function load(string $key)
public function load(string $key): string
{
return null;
return '';
}

public function save(string $key, $data, ?int $timeout = null): bool
Expand Down Expand Up @@ -144,7 +144,7 @@ public function exists(string $key): bool
throw new SemaphoreException('mock fail');
}

public function load(string $key)
public function load(string $key): string
{
throw new StorageException('mock fail');
}
Expand Down
2 changes: 2 additions & 0 deletions php-tests/FilesTests/AFilesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use kalanis\kw_paths\PathsException;
use kalanis\kw_storage\Interfaces\ITarget;
use kalanis\kw_storage\Storage as XStorage;
use kalanis\kw_storage\StorageException;


abstract class AFilesTest extends \CommonTestClass
Expand All @@ -16,6 +17,7 @@ abstract class AFilesTest extends \CommonTestClass
* @param ITarget|string $mockStorage
* @throws FilesException
* @throws PathsException
* @throws StorageException
* @return Access\CompositeAdapter
*/
protected function getStorage($mockStorage): Access\CompositeAdapter
Expand Down

0 comments on commit 2509c03

Please sign in to comment.