Skip to content

Commit b83a45e

Browse files
committed
Fixed phpmd + phpstan
1 parent 568de49 commit b83a45e

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

lib/Phpfastcache/Drivers/Solr/Driver.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ protected function driverWrite(ExtendedCacheItemInterface $item): bool
8989
$update = $this->instance->createUpdate();
9090

9191
$doc = $update->createDocument();
92-
$doc->{'id'} = $item->getEncodedKey();
92+
/** @SuppressWarnings(PHPMD.UndefinedVariable) */
93+
$doc->id = $item->getEncodedKey();
9394
$doc->{$this->getSolrField(self::DRIVER_KEY_WRAPPER_INDEX)} = $item->getKey();
9495
$doc->{$this->getSolrField(self::DRIVER_DATA_WRAPPER_INDEX)} = $this->encode($item->getRawValue());
9596
$doc->{$this->getSolrField(self::DRIVER_TAGS_WRAPPER_INDEX)} = $item->getTags();

lib/Phpfastcache/Drivers/Sqlite/Driver.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Driver implements ExtendedCacheItemPoolInterface, AggregatablePoolInterfac
4242

4343
protected int $currentDB = 1;
4444

45-
protected string $SqliteDir = '';
45+
protected string $sqliteDir = '';
4646

4747
protected ?PDO $indexing;
4848

@@ -62,7 +62,7 @@ public function driverCheck(): bool
6262
*/
6363
public function getSqliteDir(): string
6464
{
65-
return $this->SqliteDir ?: $this->getPath();
65+
return $this->sqliteDir ?: $this->getPath();
6666
}
6767

6868
/**
@@ -83,7 +83,7 @@ protected function driverConnect(): bool
8383
throw new PhpfastcacheIOException(sprintf('Sqlite cannot write in "%s", aborting...', $this->getPath()));
8484
}
8585

86-
$this->SqliteDir = $this->getPath();
86+
$this->sqliteDir = $this->getPath();
8787

8888
return true;
8989
}
@@ -143,10 +143,10 @@ public function getDb(string $keyword, bool $reset = false): PDO
143143
if (!isset($this->instance[$instant])) {
144144
// check DB Files ready or not
145145
$tableCreated = false;
146-
if ($reset || !file_exists($this->SqliteDir . '/db' . $instant)) {
146+
if ($reset || !file_exists($this->sqliteDir . '/db' . $instant)) {
147147
$tableCreated = true;
148148
}
149-
$pdo = new PDO('sqlite:' . $this->SqliteDir . '/db' . $instant);
149+
$pdo = new PDO('sqlite:' . $this->sqliteDir . '/db' . $instant);
150150
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
151151

152152
if ($tableCreated) {
@@ -169,11 +169,11 @@ public function getDbIndex($keyword)
169169
{
170170
if (!isset($this->indexing)) {
171171
$tableCreated = false;
172-
if (!file_exists($this->SqliteDir . '/indexing')) {
172+
if (!file_exists($this->sqliteDir . '/indexing')) {
173173
$tableCreated = true;
174174
}
175175

176-
$pdo = new PDO("sqlite:" . $this->SqliteDir . '/' . self::INDEXING_FILE);
176+
$pdo = new PDO("sqlite:" . $this->sqliteDir . '/' . self::INDEXING_FILE);
177177
$pdo->setAttribute(
178178
PDO::ATTR_ERRMODE,
179179
PDO::ERRMODE_EXCEPTION
@@ -198,7 +198,7 @@ public function getDbIndex($keyword)
198198

199199
// check file size
200200

201-
$size = file_exists($this->SqliteDir . '/db' . $db) ? filesize($this->SqliteDir . '/db' . $db) : 1;
201+
$size = file_exists($this->sqliteDir . '/db' . $db) ? filesize($this->sqliteDir . '/db' . $db) : 1;
202202
$size = round($size / 1024 / 1024, 1);
203203

204204

@@ -242,10 +242,10 @@ public function getDbIndex($keyword)
242242
public function initIndexing(PDO $db)
243243
{
244244
// delete everything before reset indexing
245-
$dir = opendir($this->SqliteDir);
245+
$dir = opendir($this->sqliteDir);
246246
while ($file = readdir($dir)) {
247247
if ($file !== '.' && $file !== '..' && $file !== 'indexing' && $file !== 'dbfastcache') {
248-
unlink($this->SqliteDir . '/' . $file);
248+
unlink($this->sqliteDir . '/' . $file);
249249
}
250250
}
251251

phpstan.neon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ parameters:
1111
-
1212
message: '#Cannot call method getPayload\(\) on int#' # Issue in predis/predis => https://github.com/predis/predis/pull/710
1313
path: lib/Phpfastcache/Drivers/Predis/Driver.php
14+
-
15+
message: '#Access to an undefined property Solarium\\Core\\Query\\DocumentInterface#' # Issue in predis/predis => https://github.com/predis/predis/pull/710
16+
path: lib/Phpfastcache/Drivers/Solr/Driver.php

0 commit comments

Comments
 (0)