From ea36aec2d227c87d5d054ebddad79777212e51a3 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 23 Jul 2021 15:20:36 +0200 Subject: [PATCH 01/14] perf optimize FileCacheStorage --- packages/Caching/ValueObject/Storage/FileCacheStorage.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/Caching/ValueObject/Storage/FileCacheStorage.php b/packages/Caching/ValueObject/Storage/FileCacheStorage.php index 6ecdcd1532f..ce1ca7f71fa 100644 --- a/packages/Caching/ValueObject/Storage/FileCacheStorage.php +++ b/packages/Caching/ValueObject/Storage/FileCacheStorage.php @@ -57,7 +57,6 @@ public function save(string $key, string $variableKey, $data): void $this->smartFileSystem->mkdir($cacheFilePaths->getFirstDirectory()); $this->smartFileSystem->mkdir($cacheFilePaths->getSecondDirectory()); - $tmpPath = sprintf('%s/%s.tmp', $this->directory, Random::generate()); $errorBefore = error_get_last(); $exported = @var_export(new CacheItem($variableKey, $data), true); $errorAfter = error_get_last(); @@ -73,10 +72,7 @@ public function save(string $key, string $variableKey, $data): void } $variableFileContent = sprintf("smartFileSystem->dumpFile($tmpPath, $variableFileContent); - - $this->smartFileSystem->rename($tmpPath, $cacheFilePaths->getFilePath(), true); - $this->smartFileSystem->remove($tmpPath); + $this->smartFileSystem->dumpFile($cacheFilePaths->getFilePath(), $variableFileContent); } public function clean(string $cacheKey): void From fa3b02ffb611358ab53762b0f3cd89ba8b94ffdc Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 26 Jul 2021 09:47:36 +0200 Subject: [PATCH 02/14] sync FIleCacheStorage impl with upstream phpstan --- .../ValueObject/Storage/FileCacheStorage.php | 124 ++++++++++-------- 1 file changed, 71 insertions(+), 53 deletions(-) diff --git a/packages/Caching/ValueObject/Storage/FileCacheStorage.php b/packages/Caching/ValueObject/Storage/FileCacheStorage.php index ce1ca7f71fa..fbc77904773 100644 --- a/packages/Caching/ValueObject/Storage/FileCacheStorage.php +++ b/packages/Caching/ValueObject/Storage/FileCacheStorage.php @@ -5,11 +5,9 @@ namespace Rector\Caching\ValueObject\Storage; use Nette\Utils\Random; -use Nette\Utils\Strings; -use Rector\Caching\ValueObject\CacheFilePaths; -use Rector\Caching\ValueObject\CacheItem; -use Symplify\EasyCodingStandard\Caching\Exception\CachingException; -use Symplify\SmartFileSystem\SmartFileSystem; +use PHPStan\Cache\CacheItem; +use PHPStan\File\FileWriter; +use PHPStan\ShouldNotHappenException; /** * Inspired by @@ -23,66 +21,83 @@ public function __construct( ) { } + private function makeDir(string $directory) : void + { + if (\is_dir($directory)) { + return; + } + $result = @\mkdir($directory, 0777); + if ($result === \false) { + \clearstatcache(); + if (\is_dir($directory)) { + return; + } + $error = \error_get_last(); + throw new \InvalidArgumentException(\sprintf('Failed to create directory "%s" (%s).', $this->directory, $error !== null ? $error['message'] : 'unknown cause')); + } + } + /** + * @param string $key + * @param string $variableKey * @return mixed|null */ public function load(string $key, string $variableKey) { - $cacheFilePaths = $this->getCacheFilePaths($key); - - $filePath = $cacheFilePaths->getFilePath(); - if (! is_file($filePath)) { - return null; - } - - $cacheItem = require $filePath; - if (! $cacheItem instanceof CacheItem) { - return null; - } - - if (! $cacheItem->isVariableKeyValid($variableKey)) { - return null; - } - - return $cacheItem->getData(); + return (function (string $key, string $variableKey) { + [, , $filePath] = $this->getFilePaths($key); + if (!\is_file($filePath)) { + return null; + } + $cacheItem = (require $filePath); + if (!$cacheItem instanceof CacheItem) { + return null; + } + if (!$cacheItem->isVariableKeyValid($variableKey)) { + return null; + } + return $cacheItem->getData(); + })($key, $variableKey); } /** + * @param string $key + * @param string $variableKey * @param mixed $data + * @return void */ - public function save(string $key, string $variableKey, $data): void + public function save(string $key, string $variableKey, $data) : void { - $cacheFilePaths = $this->getCacheFilePaths($key); - - $this->smartFileSystem->mkdir($cacheFilePaths->getFirstDirectory()); - $this->smartFileSystem->mkdir($cacheFilePaths->getSecondDirectory()); - - $errorBefore = error_get_last(); - $exported = @var_export(new CacheItem($variableKey, $data), true); - $errorAfter = error_get_last(); - + [$firstDirectory, $secondDirectory, $path] = $this->getFilePaths($key); + $this->makeDir($this->directory); + $this->makeDir($firstDirectory); + $this->makeDir($secondDirectory); + $tmpPath = \sprintf('%s/%s.tmp', $this->directory, Random::generate()); + $errorBefore = \error_get_last(); + $exported = @\var_export(new CacheItem($variableKey, $data), \true); + $errorAfter = \error_get_last(); if ($errorAfter !== null && $errorBefore !== $errorAfter) { - $errorMessage = sprintf( - 'Error occurred while saving item "%s" ("%s") to cache: "%s"', - $key, - $variableKey, - $errorAfter['message'] - ); - throw new CachingException($errorMessage); + throw new ShouldNotHappenException(\sprintf('Error occurred while saving item %s (%s) to cache: %s', $key, $variableKey, $errorAfter['message'])); + } + FileWriter::write($tmpPath, \sprintf("smartFileSystem->dumpFile($cacheFilePaths->getFilePath(), $variableFileContent); } public function clean(string $cacheKey): void { - $cacheFilePaths = $this->getCacheFilePaths($cacheKey); + [$firstDirectory, $secondDirectory, $path] = $this->getFilePaths($cacheKey); $this->smartFileSystem->remove([ - $cacheFilePaths->getFirstDirectory(), - $cacheFilePaths->getSecondDirectory(), - $cacheFilePaths->getFilePath(), + $firstDirectory, + $secondDirectory, + $path ]); } @@ -91,13 +106,16 @@ public function clear(): void $this->smartFileSystem->remove($this->directory); } - private function getCacheFilePaths(string $key): CacheFilePaths + /** + * @param string $key + * @return array{string, string, string} + */ + private function getFilePaths(string $key) : array { - $keyHash = sha1($key); - $firstDirectory = sprintf('%s/%s', $this->directory, Strings::substring($keyHash, 0, 2)); - $secondDirectory = sprintf('%s/%s', $firstDirectory, Strings::substring($keyHash, 2, 2)); - $filePath = sprintf('%s/%s.php', $secondDirectory, $keyHash); - - return new CacheFilePaths($firstDirectory, $secondDirectory, $filePath); + $keyHash = \sha1($key); + $firstDirectory = \sprintf('%s/%s', $this->directory, \substr($keyHash, 0, 2)); + $secondDirectory = \sprintf('%s/%s', $firstDirectory, \substr($keyHash, 2, 2)); + $filePath = \sprintf('%s/%s.php', $secondDirectory, $keyHash); + return [$firstDirectory, $secondDirectory, $filePath]; } } From 5edf306dd196c4f3f9856c062fb38c71d6d5a073 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 26 Jul 2021 09:47:58 +0200 Subject: [PATCH 03/14] update comment --- packages/Caching/ValueObject/Storage/FileCacheStorage.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/Caching/ValueObject/Storage/FileCacheStorage.php b/packages/Caching/ValueObject/Storage/FileCacheStorage.php index fbc77904773..1cd22231287 100644 --- a/packages/Caching/ValueObject/Storage/FileCacheStorage.php +++ b/packages/Caching/ValueObject/Storage/FileCacheStorage.php @@ -10,8 +10,7 @@ use PHPStan\ShouldNotHappenException; /** - * Inspired by - * https://github.com/phpstan/phpstan-src/commit/4df7342f3a0aaef4bcd85456dd20ca88d38dd90d#diff-6dc14f6222bf150e6840ca44a7126653052a1cedc6a149b4e5c1e1a2c80eacdc + * Inspired by https://github.com/phpstan/phpstan-src/blob/1e7ceae933f07e5a250b61ed94799e6c2ea8daa2/src/Cache/FileCacheStorage.php */ final class FileCacheStorage { From 8e848cce840289f99a5b0c776c2c56f5332ec1fc Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 26 Jul 2021 09:51:00 +0200 Subject: [PATCH 04/14] Update FileCacheStorage.php --- packages/Caching/ValueObject/Storage/FileCacheStorage.php | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/Caching/ValueObject/Storage/FileCacheStorage.php b/packages/Caching/ValueObject/Storage/FileCacheStorage.php index 1cd22231287..bea3ce70bef 100644 --- a/packages/Caching/ValueObject/Storage/FileCacheStorage.php +++ b/packages/Caching/ValueObject/Storage/FileCacheStorage.php @@ -8,6 +8,7 @@ use PHPStan\Cache\CacheItem; use PHPStan\File\FileWriter; use PHPStan\ShouldNotHappenException; +use Symplify\SmartFileSystem\SmartFileSystem; /** * Inspired by https://github.com/phpstan/phpstan-src/blob/1e7ceae933f07e5a250b61ed94799e6c2ea8daa2/src/Cache/FileCacheStorage.php From 6823d1a1edb6ce769f02ff72753534fdca4a0ef5 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 26 Jul 2021 09:54:59 +0200 Subject: [PATCH 05/14] use Rector\Caching\ValueObject\CacheItem --- packages/Caching/ValueObject/Storage/FileCacheStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/Caching/ValueObject/Storage/FileCacheStorage.php b/packages/Caching/ValueObject/Storage/FileCacheStorage.php index bea3ce70bef..721b778aaed 100644 --- a/packages/Caching/ValueObject/Storage/FileCacheStorage.php +++ b/packages/Caching/ValueObject/Storage/FileCacheStorage.php @@ -5,7 +5,7 @@ namespace Rector\Caching\ValueObject\Storage; use Nette\Utils\Random; -use PHPStan\Cache\CacheItem; +use Rector\Caching\ValueObject\CacheItem; use PHPStan\File\FileWriter; use PHPStan\ShouldNotHappenException; use Symplify\SmartFileSystem\SmartFileSystem; From e1d0fee47920a53d19b786ea3d2ca6aa28eeac5a Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 26 Jul 2021 13:23:42 +0200 Subject: [PATCH 06/14] fix phpstan: use CachingException --- packages/Caching/ValueObject/Storage/FileCacheStorage.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/Caching/ValueObject/Storage/FileCacheStorage.php b/packages/Caching/ValueObject/Storage/FileCacheStorage.php index 721b778aaed..33ff0a829bc 100644 --- a/packages/Caching/ValueObject/Storage/FileCacheStorage.php +++ b/packages/Caching/ValueObject/Storage/FileCacheStorage.php @@ -7,8 +7,8 @@ use Nette\Utils\Random; use Rector\Caching\ValueObject\CacheItem; use PHPStan\File\FileWriter; -use PHPStan\ShouldNotHappenException; use Symplify\SmartFileSystem\SmartFileSystem; +use Symplify\EasyCodingStandard\Caching\Exception\CachingException; /** * Inspired by https://github.com/phpstan/phpstan-src/blob/1e7ceae933f07e5a250b61ed94799e6c2ea8daa2/src/Cache/FileCacheStorage.php @@ -33,7 +33,7 @@ private function makeDir(string $directory) : void return; } $error = \error_get_last(); - throw new \InvalidArgumentException(\sprintf('Failed to create directory "%s" (%s).', $this->directory, $error !== null ? $error['message'] : 'unknown cause')); + throw new CachingException(\sprintf('Failed to create directory "%s" (%s).', $this->directory, $error !== null ? $error['message'] : 'unknown cause')); } } @@ -77,7 +77,7 @@ public function save(string $key, string $variableKey, $data) : void $exported = @\var_export(new CacheItem($variableKey, $data), \true); $errorAfter = \error_get_last(); if ($errorAfter !== null && $errorBefore !== $errorAfter) { - throw new ShouldNotHappenException(\sprintf('Error occurred while saving item %s (%s) to cache: %s', $key, $variableKey, $errorAfter['message'])); + throw new CachingException(\sprintf('Error occurred while saving item %s (%s) to cache: %s', $key, $variableKey, $errorAfter['message'])); } FileWriter::write($tmpPath, \sprintf(" Date: Mon, 26 Jul 2021 13:24:36 +0200 Subject: [PATCH 07/14] fix phpstan: use smartFileSystem --- .../ValueObject/Storage/FileCacheStorage.php | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/packages/Caching/ValueObject/Storage/FileCacheStorage.php b/packages/Caching/ValueObject/Storage/FileCacheStorage.php index 33ff0a829bc..4052516ecac 100644 --- a/packages/Caching/ValueObject/Storage/FileCacheStorage.php +++ b/packages/Caching/ValueObject/Storage/FileCacheStorage.php @@ -21,22 +21,6 @@ public function __construct( ) { } - private function makeDir(string $directory) : void - { - if (\is_dir($directory)) { - return; - } - $result = @\mkdir($directory, 0777); - if ($result === \false) { - \clearstatcache(); - if (\is_dir($directory)) { - return; - } - $error = \error_get_last(); - throw new CachingException(\sprintf('Failed to create directory "%s" (%s).', $this->directory, $error !== null ? $error['message'] : 'unknown cause')); - } - } - /** * @param string $key * @param string $variableKey @@ -69,9 +53,10 @@ public function load(string $key, string $variableKey) public function save(string $key, string $variableKey, $data) : void { [$firstDirectory, $secondDirectory, $path] = $this->getFilePaths($key); - $this->makeDir($this->directory); - $this->makeDir($firstDirectory); - $this->makeDir($secondDirectory); + + $this->smartFileSystem->mkdir($this->directory); + $this->smartFileSystem->mkdir($firstDirectory); + $this->smartFileSystem->mkdir($secondDirectory); $tmpPath = \sprintf('%s/%s.tmp', $this->directory, Random::generate()); $errorBefore = \error_get_last(); $exported = @\var_export(new CacheItem($variableKey, $data), \true); From 1eb741bffb9906997edd179aa40716c333c28561 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 26 Jul 2021 13:29:29 +0200 Subject: [PATCH 08/14] re-added nearly everything again --- .../ValueObject/Storage/FileCacheStorage.php | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/packages/Caching/ValueObject/Storage/FileCacheStorage.php b/packages/Caching/ValueObject/Storage/FileCacheStorage.php index 4052516ecac..8ce05bae2be 100644 --- a/packages/Caching/ValueObject/Storage/FileCacheStorage.php +++ b/packages/Caching/ValueObject/Storage/FileCacheStorage.php @@ -29,7 +29,9 @@ public function __construct( public function load(string $key, string $variableKey) { return (function (string $key, string $variableKey) { - [, , $filePath] = $this->getFilePaths($key); + $cacheFilePaths = $this->getCacheFilePaths($key); + + $filePath = $cacheFilePaths->getFilePath(); if (!\is_file($filePath)) { return null; } @@ -52,11 +54,11 @@ public function load(string $key, string $variableKey) */ public function save(string $key, string $variableKey, $data) : void { - [$firstDirectory, $secondDirectory, $path] = $this->getFilePaths($key); + $cacheFilePaths = $this->getCacheFilePaths($key); + $this->smartFileSystem->mkdir($cacheFilePaths->getFirstDirectory()); + $this->smartFileSystem->mkdir($cacheFilePaths->getSecondDirectory()); + $path = $cacheFilePaths->getFilePath(); - $this->smartFileSystem->mkdir($this->directory); - $this->smartFileSystem->mkdir($firstDirectory); - $this->smartFileSystem->mkdir($secondDirectory); $tmpPath = \sprintf('%s/%s.tmp', $this->directory, Random::generate()); $errorBefore = \error_get_last(); $exported = @\var_export(new CacheItem($variableKey, $data), \true); @@ -77,12 +79,12 @@ public function save(string $key, string $variableKey, $data) : void public function clean(string $cacheKey): void { - [$firstDirectory, $secondDirectory, $path] = $this->getFilePaths($cacheKey); + $cacheFilePaths = $this->getCacheFilePaths($cacheKey); $this->smartFileSystem->remove([ - $firstDirectory, - $secondDirectory, - $path + $cacheFilePaths->getFirstDirectory(), + $cacheFilePaths->getSecondDirectory(), + $cacheFilePaths->getFilePath(), ]); } @@ -91,16 +93,13 @@ public function clear(): void $this->smartFileSystem->remove($this->directory); } - /** - * @param string $key - * @return array{string, string, string} - */ - private function getFilePaths(string $key) : array + private function getCacheFilePaths(string $key): CacheFilePaths { - $keyHash = \sha1($key); - $firstDirectory = \sprintf('%s/%s', $this->directory, \substr($keyHash, 0, 2)); - $secondDirectory = \sprintf('%s/%s', $firstDirectory, \substr($keyHash, 2, 2)); - $filePath = \sprintf('%s/%s.php', $secondDirectory, $keyHash); - return [$firstDirectory, $secondDirectory, $filePath]; + $keyHash = sha1($key); + $firstDirectory = sprintf('%s/%s', $this->directory, Strings::substring($keyHash, 0, 2)); + $secondDirectory = sprintf('%s/%s', $firstDirectory, Strings::substring($keyHash, 2, 2)); + $filePath = sprintf('%s/%s.php', $secondDirectory, $keyHash); + + return new CacheFilePaths($firstDirectory, $secondDirectory, $filePath); } } From 97b01b6c9cf59ae5323a054be588f6835b573d71 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 26 Jul 2021 13:30:41 +0200 Subject: [PATCH 09/14] Update FileCacheStorage.php --- packages/Caching/ValueObject/Storage/FileCacheStorage.php | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/Caching/ValueObject/Storage/FileCacheStorage.php b/packages/Caching/ValueObject/Storage/FileCacheStorage.php index 8ce05bae2be..cca105560a4 100644 --- a/packages/Caching/ValueObject/Storage/FileCacheStorage.php +++ b/packages/Caching/ValueObject/Storage/FileCacheStorage.php @@ -66,6 +66,7 @@ public function save(string $key, string $variableKey, $data) : void if ($errorAfter !== null && $errorBefore !== $errorAfter) { throw new CachingException(\sprintf('Error occurred while saving item %s (%s) to cache: %s', $key, $variableKey, $errorAfter['message'])); } + // for performance reasons we don't use SmartFileSystem FileWriter::write($tmpPath, \sprintf(" Date: Mon, 26 Jul 2021 13:33:41 +0200 Subject: [PATCH 10/14] remove String::substring() --- packages/Caching/ValueObject/Storage/FileCacheStorage.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/Caching/ValueObject/Storage/FileCacheStorage.php b/packages/Caching/ValueObject/Storage/FileCacheStorage.php index cca105560a4..c1342d3efbd 100644 --- a/packages/Caching/ValueObject/Storage/FileCacheStorage.php +++ b/packages/Caching/ValueObject/Storage/FileCacheStorage.php @@ -97,8 +97,8 @@ public function clear(): void private function getCacheFilePaths(string $key): CacheFilePaths { $keyHash = sha1($key); - $firstDirectory = sprintf('%s/%s', $this->directory, Strings::substring($keyHash, 0, 2)); - $secondDirectory = sprintf('%s/%s', $firstDirectory, Strings::substring($keyHash, 2, 2)); + $firstDirectory = sprintf('%s/%s', $this->directory, substr($keyHash, 0, 2)); + $secondDirectory = sprintf('%s/%s', $firstDirectory, substr($keyHash, 2, 2)); $filePath = sprintf('%s/%s.php', $secondDirectory, $keyHash); return new CacheFilePaths($firstDirectory, $secondDirectory, $filePath); From b0be077c9c9d8be65841bc1a997c486e2ed8311d Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 26 Jul 2021 13:35:31 +0200 Subject: [PATCH 11/14] Update FileCacheStorage.php --- packages/Caching/ValueObject/Storage/FileCacheStorage.php | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/Caching/ValueObject/Storage/FileCacheStorage.php b/packages/Caching/ValueObject/Storage/FileCacheStorage.php index c1342d3efbd..4b1f3dcd584 100644 --- a/packages/Caching/ValueObject/Storage/FileCacheStorage.php +++ b/packages/Caching/ValueObject/Storage/FileCacheStorage.php @@ -5,6 +5,7 @@ namespace Rector\Caching\ValueObject\Storage; use Nette\Utils\Random; +use Rector\Caching\ValueObject\CacheFilePaths; use Rector\Caching\ValueObject\CacheItem; use PHPStan\File\FileWriter; use Symplify\SmartFileSystem\SmartFileSystem; From 38da1ee8ab3edf18ea980620c38a560983187591 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 26 Jul 2021 13:46:38 +0200 Subject: [PATCH 12/14] ignore phpstan errors --- .../ValueObject/Storage/FileCacheStorage.php | 2 +- phpstan.neon | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/Caching/ValueObject/Storage/FileCacheStorage.php b/packages/Caching/ValueObject/Storage/FileCacheStorage.php index 4b1f3dcd584..8bcf099d875 100644 --- a/packages/Caching/ValueObject/Storage/FileCacheStorage.php +++ b/packages/Caching/ValueObject/Storage/FileCacheStorage.php @@ -62,7 +62,7 @@ public function save(string $key, string $variableKey, $data) : void $tmpPath = \sprintf('%s/%s.tmp', $this->directory, Random::generate()); $errorBefore = \error_get_last(); - $exported = @\var_export(new CacheItem($variableKey, $data), \true); + $exported = @\var_export(new CacheItem($variableKey, $data), true); $errorAfter = \error_get_last(); if ($errorAfter !== null && $errorBefore !== $errorAfter) { throw new CachingException(\sprintf('Error occurred while saving item %s (%s) to cache: %s', $key, $variableKey, $errorAfter['message'])); diff --git a/phpstan.neon b/phpstan.neon index 1a7a0100b49..7eaf290a7d1 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -528,3 +528,23 @@ parameters: - '#Method "refactorParamType\(\)" returns bool type, so the name should start with is/has/was#' - '#Method "decorateReturnWithSpecificType\(\)" returns bool type, so the name should start with is/has/was#' - '#Method "resolveObjectType\(\)" returns bool type, so the name should start with is/has/was#' + + # resolve later + - + message: '#Use explicit names over dynamic ones#' + paths: + - path: packages/Caching/ValueObject/Storage/FileCacheStorage.php + + # native filesystem calls, required for performance reasons + - + message: '#"@\\unlink\(\$tmpPath\)" is forbidden to use#' + paths: + - path: packages/Caching/ValueObject/Storage/FileCacheStorage.php + - + message: '#"@\\rename\(\$tmpPath, \$path\)" is forbidden to use#' + paths: + - path: packages/Caching/ValueObject/Storage/FileCacheStorage.php + - + message: '#"%s" in sprintf\(\) format must be quoted#' + paths: + - path: packages/Caching/ValueObject/Storage/FileCacheStorage.php From cd54f0c8de88416ba7348703d61e94555776e5da Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 26 Jul 2021 13:48:05 +0200 Subject: [PATCH 13/14] fix path --- phpstan.neon | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 7eaf290a7d1..dd5f29d49ba 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -533,18 +533,18 @@ parameters: - message: '#Use explicit names over dynamic ones#' paths: - - path: packages/Caching/ValueObject/Storage/FileCacheStorage.php + - packages/Caching/ValueObject/Storage/FileCacheStorage.php # native filesystem calls, required for performance reasons - message: '#"@\\unlink\(\$tmpPath\)" is forbidden to use#' paths: - - path: packages/Caching/ValueObject/Storage/FileCacheStorage.php + - packages/Caching/ValueObject/Storage/FileCacheStorage.php - message: '#"@\\rename\(\$tmpPath, \$path\)" is forbidden to use#' paths: - - path: packages/Caching/ValueObject/Storage/FileCacheStorage.php + - packages/Caching/ValueObject/Storage/FileCacheStorage.php - message: '#"%s" in sprintf\(\) format must be quoted#' paths: - - path: packages/Caching/ValueObject/Storage/FileCacheStorage.php + - packages/Caching/ValueObject/Storage/FileCacheStorage.php From 3344e4a1699f96d1a0c9e38766fda83901e751e9 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 26 Jul 2021 13:52:02 +0200 Subject: [PATCH 14/14] Update phpstan.neon --- phpstan.neon | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index dd5f29d49ba..4a8e16e6551 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -459,8 +459,6 @@ parameters: message: '#Access to an undefined property PHPStan\\PhpDocParser\\Ast\\PhpDoc\\PhpDocChildNode\:\:\$value#' path: packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php #348 - - '#"@var_export\(new \\Rector\\Caching\\ValueObject\\CacheItem\(\$variableKey, \$data\), true\)" is forbidden to use#' - - message: '#Class with base "StaticTypeMapper" name is already used in "Rector\\PHPStanStaticTypeMapper\\TypeMapper\\StaticTypeMapper", "Rector\\StaticTypeMapper\\StaticTypeMapper"\. Use unique name to make classes easy to recognize#' path: packages/StaticTypeMapper/StaticTypeMapper.php #31 @@ -548,3 +546,7 @@ parameters: message: '#"%s" in sprintf\(\) format must be quoted#' paths: - packages/Caching/ValueObject/Storage/FileCacheStorage.php + - + message: '#"@\\var_export\(new \\Rector\\Caching\\ValueObject\\CacheItem\(\$variableKey, \$data\), true\)" is forbidden to use#' + paths: + - packages/Caching/ValueObject/Storage/FileCacheStorage.php