Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
['8.1', '8.2', '8.3']
['8.1', '8.2', '8.3', '8.4']
2 changes: 1 addition & 1 deletion .github/workflows/composer-require-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.1', '8.2', '8.3']
['8.1', '8.2', '8.3', '8.4']
2 changes: 1 addition & 1 deletion .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.3']
['8.4']
secrets:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
2 changes: 1 addition & 1 deletion .github/workflows/rector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.3']
['8.4']
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.1', '8.2', '8.3']
['8.1', '8.2', '8.3', '8.4']
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## 3.2.1 under development

- Сhg #90: Bump minimal required PHP version to 8.1 and minor refactoring (@vjik)
- Chg #91: Change PHP constraint in `composer.json` to `~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0` (@vjik)
- Сhg #90, #91: Bump minimal required PHP version to 8.1 and minor refactoring (@vjik)

## 3.2.0 January 13, 2025

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This package implements file-based [PSR-16](https://www.php-fig.org/psr/psr-16/)

## Requirements

- PHP 8.0 or higher.
- PHP 8.1 or higher.

## Installation

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
}
],
"require": {
"php": "^8.1",
"psr/simple-cache": "^2.0|^3.0"
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
"psr/simple-cache": "^2.0 || ^3.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.7.1",
Expand All @@ -40,7 +40,7 @@
"rector/rector": "^2.0.9",
"roave/infection-static-analysis-plugin": "^1.35",
"spatie/phpunit-watcher": "^1.24",
"vimeo/psalm": "^5.26.1",
"vimeo/psalm": "^5.21 || ^6.5.1",
"yiisoft/aliases": "^3.0",
"yiisoft/di": "^1.3"
},
Expand Down
5 changes: 4 additions & 1 deletion src/FileCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
* @throws CacheException If failed to create cache directory.
*/
public function __construct(
private string $cachePath,
private readonly string $cachePath,
private int $directoryMode = 0775,
) {
}
Expand All @@ -106,6 +106,9 @@
}

flock($filePointer, LOCK_SH);
/**
* @var string $value We assume that we always can read content from `$filePointer` resource.
*/
$value = stream_get_contents($filePointer);
flock($filePointer, LOCK_UN);
fclose($filePointer);
Expand All @@ -128,7 +131,7 @@
// If ownership differs, the touch call will fail, so we try to
// rebuild the file from scratch by deleting it first
// https://github.com/yiisoft/yii2/pull/16120
if (function_exists('posix_geteuid') && is_file($file) && fileowner($file) !== posix_geteuid()) {

Check warning on line 134 in src/FileCache.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "NotIdentical": @@ @@ // If ownership differs, the touch call will fail, so we try to // rebuild the file from scratch by deleting it first // https://github.com/yiisoft/yii2/pull/16120 - if (function_exists('posix_geteuid') && is_file($file) && fileowner($file) !== posix_geteuid()) { + if (function_exists('posix_geteuid') && is_file($file) && fileowner($file) === posix_geteuid()) { @Unlink($file); } if (file_put_contents($file, serialize($value), LOCK_EX) === false) {

Check warning on line 134 in src/FileCache.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "LogicalAndAllSubExprNegation": @@ @@ // If ownership differs, the touch call will fail, so we try to // rebuild the file from scratch by deleting it first // https://github.com/yiisoft/yii2/pull/16120 - if (function_exists('posix_geteuid') && is_file($file) && fileowner($file) !== posix_geteuid()) { + if (!function_exists('posix_geteuid') && !is_file($file) && !(fileowner($file) !== posix_geteuid())) { @Unlink($file); } if (file_put_contents($file, serialize($value), LOCK_EX) === false) {

Check warning on line 134 in src/FileCache.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "LogicalAndSingleSubExprNegation": @@ @@ // If ownership differs, the touch call will fail, so we try to // rebuild the file from scratch by deleting it first // https://github.com/yiisoft/yii2/pull/16120 - if (function_exists('posix_geteuid') && is_file($file) && fileowner($file) !== posix_geteuid()) { + if (!function_exists('posix_geteuid') && is_file($file) && fileowner($file) !== posix_geteuid()) { @Unlink($file); } if (file_put_contents($file, serialize($value), LOCK_EX) === false) {
@unlink($file);
}

Expand Down Expand Up @@ -176,7 +179,7 @@
public function getMultiple(iterable $keys, mixed $default = null): iterable
{
$keys = $this->iterableToArray($keys);
$this->validateKeys($keys);

Check warning on line 182 in src/FileCache.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": @@ @@ public function getMultiple(iterable $keys, mixed $default = null): iterable { $keys = $this->iterableToArray($keys); - $this->validateKeys($keys); + $results = []; foreach ($keys as $key) { $results[$key] = $this->get($key, $default);
$results = [];

foreach ($keys as $key) {
Expand All @@ -189,7 +192,7 @@
public function setMultiple(iterable $values, null|int|DateInterval $ttl = null): bool
{
$values = $this->iterableToArray($values);
$this->validateKeys(array_map('\strval', array_keys($values)));

Check warning on line 195 in src/FileCache.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": @@ @@ public function setMultiple(iterable $values, null|int|DateInterval $ttl = null): bool { $values = $this->iterableToArray($values); - $this->validateKeys(array_map('\strval', array_keys($values))); + foreach ($values as $key => $value) { $this->set((string) $key, $value, $ttl); }

foreach ($values as $key => $value) {
$this->set((string) $key, $value, $ttl);
Expand Down
Loading