Skip to content

Commit 82822c4

Browse files
committed
:octocat:
1 parent fca6963 commit 82822c4

11 files changed

+92
-59
lines changed

.gitattributes

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/.build export-ignore
2+
/.github export-ignore
3+
/.phan export-ignore
4+
/.phpdoc export-ignore
5+
/docs export-ignore
6+
/examples export-ignore
7+
/tests export-ignore
8+
/.editorconfig export-ignore
9+
/.gitattributes export-ignore
10+
/.gitignore export-ignore
11+
/.readthedocs.yml export-ignore
12+
/phpcs.xml.dist export-ignore
13+
/phpdoc.xml.dist export-ignore
14+
/phpmd.xml.dist export-ignore
15+
/phpunit.xml.dist export-ignore
16+
17+
*.php diff=php

.github/workflows/ci.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
php-version:
2424
- "8.1"
2525
- "8.2"
26+
- "8.3"
2627

2728
env:
2829
PHAN_ALLOW_XDEBUG: 0
@@ -59,13 +60,13 @@ jobs:
5960
- name: "Install PHP"
6061
uses: shivammathur/setup-php@v2
6162
with:
62-
php-version: "7.4"
63+
php-version: "8.1"
6364
coverage: none
6465
tools: phpDocumentor
6566
extensions: apcu, memcached, redis
6667

6768
- name: "Build Docs"
68-
run: phpdoc --config=phpdoc.xml
69+
run: phpdoc --config=phpdoc.xml.dist
6970

7071
- name: "Publish Docs to gh-pages"
7172
uses: JamesIves/github-pages-deploy-action@v4
@@ -86,6 +87,7 @@ jobs:
8687
php-version:
8788
- "8.1"
8889
- "8.2"
90+
- "8.3"
8991

9092
steps:
9193
- name: "Checkout"
@@ -111,7 +113,7 @@ jobs:
111113
uses: ramsey/composer-install@v2
112114

113115
- name: "Run tests with phpunit"
114-
run: php vendor/phpunit/phpunit/phpunit --configuration=phpunit.xml
116+
run: php vendor/phpunit/phpunit/phpunit --configuration=phpunit.xml.dist
115117

116118
- name: "Send code coverage report to Codecov.io"
117119
uses: codecov/codecov-action@v3

.scrutinizer.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ A psr/simple-cache implementation for PHP 8.1+.
66
[![version][packagist-badge]][packagist]
77
[![license][license-badge]][license]
88
[![Coverage][coverage-badge]][coverage]
9-
[![Scrunitizer][scrutinizer-badge]][scrutinizer]
109
[![Packagist downloads][downloads-badge]][downloads]<br/>
1110
[![Continuous Integration][gh-action-badge]][gh-action]
1211

@@ -18,8 +17,6 @@ A psr/simple-cache implementation for PHP 8.1+.
1817
[license]: https://github.com/chillerlan/php-cache/blob/master/LICENSE
1918
[coverage-badge]: https://img.shields.io/codecov/c/github/chillerlan/php-cache.svg?logo=codecov
2019
[coverage]: https://codecov.io/github/chillerlan/php-cache
21-
[scrutinizer-badge]: https://img.shields.io/scrutinizer/g/chillerlan/php-cache.svg?logo=scrutinizer
22-
[scrutinizer]: https://scrutinizer-ci.com/g/chillerlan/php-cache
2320
[downloads-badge]: https://img.shields.io/packagist/dt/chillerlan/php-cache.svg?logo=packagist
2421
[downloads]: https://packagist.org/packages/chillerlan/php-cache/stats
2522
[gh-action-badge]: https://github.com/chillerlan/php-cache/workflows/Continuous%20Integration/badge.svg

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chillerlan/php-cache",
3-
"description": "A psr/simple-cache implementation. PHP 7.4+",
3+
"description": "A psr/simple-cache implementation. PHP 8.1+",
44
"homepage": "https://github.com/chillerlan/php-cache",
55
"license": "MIT",
66
"type": "library",
@@ -23,11 +23,11 @@
2323
"php": "^8.1",
2424
"psr/log": "^1.1 || ^2.0 || ^3.0",
2525
"psr/simple-cache": "^1.0",
26-
"chillerlan/php-settings-container": "^3.0"
26+
"chillerlan/php-settings-container": "^3.1"
2727
},
2828
"require-dev": {
2929
"phan/phan": "^5.4",
30-
"phpunit/phpunit": "^10.0"
30+
"phpunit/phpunit": "^10.5"
3131
},
3232
"autoload": {
3333
"psr-4": {

phpdoc.xml

Lines changed: 0 additions & 20 deletions
This file was deleted.

phpdoc.xml.dist

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<phpdocumentor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="https://www.phpdoc.org"
4+
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/phpDocumentor/phpDocumentor/master/data/xsd/phpdoc.xsd"
5+
configVersion="3"
6+
>
7+
<!-- https://docs.phpdoc.org/3.0/guide/references/configuration.html#configuration -->
8+
<paths>
9+
<output>.build/phpdocs</output>
10+
<cache>.build/phpdocs-cache</cache>
11+
</paths>
12+
<version number="3.0.0">
13+
<api>
14+
<source dsn=".">
15+
<path>src</path>
16+
<path>tests</path>
17+
</source>
18+
<extensions>
19+
<extension>php</extension>
20+
</extensions>
21+
</api>
22+
</version>
23+
<setting name="template.color" value="deep-purple"/>
24+
<template name="default" />
25+
</phpdocumentor>

phpunit.xml renamed to phpunit.xml.dist

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<?xml version="1.0"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
5-
cacheResultFile=".build/phpunit.result.cache"
5+
cacheDirectory=".build/phpunit-cache"
66
colors="true"
77
>
88
<testsuites>
99
<testsuite name="php-cache test suite">
10-
<directory suffix=".php">./tests</directory>
11-
<exclude>tests/NonpersistentTestAbstract.php</exclude>
12-
<exclude>tests/SimpleCacheTestAbstract.php</exclude>
10+
<directory>./tests</directory>
1311
</testsuite>
1412
</testsuites>
15-
<coverage>
13+
<source>
1614
<include>
17-
<directory suffix=".php">./src</directory>
15+
<directory>src</directory>
1816
</include>
17+
</source>
18+
<coverage>
1919
<report>
2020
<clover outputFile=".build/coverage/clover.xml"/>
2121
<xml outputDirectory=".build/coverage/coverage-xml"/>

src/APCUCache.php

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace chillerlan\SimpleCache;
1414

15-
use function apcu_clear_cache, apcu_delete, apcu_fetch, apcu_store;
15+
use function apcu_clear_cache, apcu_delete, apcu_fetch, apcu_store, implode, is_array, is_bool, sprintf;
1616

1717
class APCUCache extends CacheDriverAbstract{
1818

@@ -27,14 +27,40 @@ public function get($key, $default = null){
2727
return $default;
2828
}
2929

30-
/** @inheritdoc */
30+
/**
31+
* @inheritdoc
32+
* @throws \Psr\SimpleCache\CacheException
33+
*/
3134
public function set($key, $value, $ttl = null):bool{
32-
return (bool)apcu_store($this->checkKey($key), $value, $this->getTTL($ttl) ?? 0);
35+
$ret = apcu_store($this->checkKey($key), $value, $this->getTTL($ttl) ?? 0);
36+
37+
if(is_bool($ret)){
38+
return $ret;
39+
}
40+
41+
if(is_array($ret)){
42+
throw new CacheException(sprintf('error keys: %s', implode(', ', $ret)));
43+
}
44+
45+
throw new CacheException('unknown apcu_store() error');
3346
}
3447

35-
/** @inheritdoc */
48+
/**
49+
* @inheritdoc
50+
* @throws \chillerlan\SimpleCache\CacheException
51+
*/
3652
public function delete($key):bool{
37-
return (bool)apcu_delete($this->checkKey($key));
53+
$ret = apcu_delete($this->checkKey($key));
54+
55+
if(is_bool($ret)){
56+
return $ret;
57+
}
58+
59+
if(is_array($ret)){
60+
throw new CacheException(sprintf('error keys: %s', implode(', ', $ret)));
61+
}
62+
63+
throw new CacheException('unknown apcu_delete() error');
3864
}
3965

4066
/** @inheritdoc */

tests/APCUTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
class APCUTest extends SimpleCacheTestAbstract{
1818

1919
protected function setUp():void{
20-
parent::setUp();
2120

2221
if(!extension_loaded('apcu')){
2322
$this->markTestSkipped('APCU not installed/enabled');
2423
}
2524

25+
parent::setUp();
26+
2627
$this->cache = new APCUCache;
2728
}
2829

tests/MemcachedTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
class MemcachedTest extends SimpleCacheTestAbstract{
2121

2222
protected function setUp():void{
23-
parent::setUp();
2423

2524
if(!extension_loaded('memcached')){
2625
$this->markTestSkipped('Memcached not installed/enabled');
2726
}
2827

28+
parent::setUp();
29+
2930
$memcached = new Memcached('test');
3031
$memcached->addServer('localhost', 11211);
3132

0 commit comments

Comments
 (0)