Skip to content

feat: Fix phpstan array type #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/coding-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
coverage: none

- run: composer create-project nette/code-checker temp/code-checker ^3 --no-progress
Expand All @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
coverage: none

- run: composer create-project nette/coding-standard temp/coding-standard ^3 --no-progress
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
coverage: none

- run: composer install --no-progress --prefer-dist
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.0', '8.1', '8.2', '8.3', '8.4']
php: ['8.1', '8.2', '8.3', '8.4']

fail-fast: false

Expand Down Expand Up @@ -37,7 +37,7 @@ jobs:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
coverage: none

- run: composer update --no-progress --prefer-dist --prefer-lowest --prefer-stable
Expand All @@ -52,7 +52,7 @@ jobs:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
coverage: none

- run: composer install --no-progress --prefer-dist
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
}
],
"require": {
"php": "8.0 - 8.4",
"php": "8.1 - 8.4",
"nette/utils": "^4.0"
},
"require-dev": {
"nette/tester": "^2.4",
"nette/di": "^3.1 || ^4.0",
"latte/latte": "^2.11 || ^3.0.12",
"latte/latte": "^3.0.12",
"tracy/tracy": "^2.9",
"phpstan/phpstan": "^1.0",
"psr/simple-cache": "^2.0 || ^3.0"
},
"conflict": {
"latte/latte": ">=3.0.0 <3.0.12"
"latte/latte": "<3.0.12"
},
"suggest": {
"ext-pdo_sqlite": "to use SQLiteStorage or SQLiteJournal"
Expand All @@ -42,7 +42,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
"dev-master": "4.0-dev"
}
}
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Installation
composer require nette/caching
```

It requires PHP version 8.0 and supports PHP up to 8.4.
It requires PHP version 8.1 and supports PHP up to 8.4.


Basic Usage
Expand Down
8 changes: 0 additions & 8 deletions src/Bridges/CacheDI/CacheExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,5 @@ public function loadConfiguration(): void
$builder->addDefinition($this->prefix('storage'))
->setType(Nette\Caching\Storage::class)
->setFactory(Nette\Caching\Storages\FileStorage::class, [$this->tempDir]);

if ($this->name === 'cache') {
if (extension_loaded('pdo_sqlite')) {
$builder->addAlias('nette.cacheJournal', $this->prefix('journal'));
}

$builder->addAlias('cacheStorage', $this->prefix('storage'));
}
}
}
168 changes: 0 additions & 168 deletions src/Bridges/CacheLatte/CacheMacro.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Caching/BulkWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface BulkWriter
{
/**
* Writes to cache in bulk.
* @param array{string, mixed} $items
* @param array<string, mixed> $items
*/
function bulkWrite(array $items, array $dependencies): void;

Expand Down
7 changes: 3 additions & 4 deletions src/Caching/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ class Cache
public const ALL = self::All;

/** @internal */
public const
NamespaceSeparator = "\x00",
NAMESPACE_SEPARATOR = self::NamespaceSeparator;
public const NamespaceSeparator = "\x00";

private Storage $storage;
private string $namespace;
Expand Down Expand Up @@ -385,6 +383,7 @@ public function capture(mixed $key): ?OutputHelper
*/
public function start($key): ?OutputHelper
{
trigger_error(__METHOD__ . '() was renamed to capture()', E_USER_DEPRECATED);
return $this->capture($key);
}

Expand All @@ -394,7 +393,7 @@ public function start($key): ?OutputHelper
*/
protected function generateKey($key): string
{
return $this->namespace . md5(is_scalar($key) ? (string) $key : serialize($key));
return $this->namespace . hash('xxh128', is_scalar($key) ? (string) $key : serialize($key));
}


Expand Down
3 changes: 1 addition & 2 deletions src/Caching/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ interface Storage
{
/**
* Read from cache.
* @return mixed
*/
function read(string $key);
function read(string $key): mixed;

/**
* Prevents item reading and writing. Lock is released by write() or remove().
Expand Down
2 changes: 1 addition & 1 deletion src/Caching/Storages/MemcachedStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function bulkRead(array $keys): array
{
$prefixedKeys = array_map(fn($key) => urlencode($this->prefix . $key), $keys);
$keys = array_combine($prefixedKeys, $keys);
$metas = $this->memcached->getMulti($prefixedKeys);
$metas = $this->memcached->getMulti($prefixedKeys) ?: [];
$result = [];
$deleteKeys = [];
foreach ($metas as $prefixedKey => $meta) {
Expand Down
1 change: 0 additions & 1 deletion src/Caching/Storages/SQLiteJournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ private function open(): void
}

$this->pdo = new \PDO('sqlite:' . $this->path);
$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$this->pdo->exec('
PRAGMA foreign_keys = OFF;
PRAGMA journal_mode = WAL;
Expand Down
1 change: 0 additions & 1 deletion src/Caching/Storages/SQLiteStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function __construct(string $path)
}

$this->pdo = new \PDO('sqlite:' . $path);
$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$this->pdo->exec('
PRAGMA foreign_keys = ON;
CREATE TABLE IF NOT EXISTS cache (
Expand Down
4 changes: 0 additions & 4 deletions tests/Bridges.DI/CacheExtension.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,4 @@ test('', function () {

$storage = $container->getService('cache.storage');
Assert::type(Nette\Caching\Storages\FileStorage::class, $storage);

// aliases
Assert::same($journal, $container->getService('nette.cacheJournal'));
Assert::same($storage, $container->getService('cacheStorage'));
});
Loading