From c3007e685c33ece91d2c5ec52ca172c7943d6a48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mor=C3=A1vek?= Date: Sun, 22 Nov 2020 16:53:24 +0100 Subject: [PATCH] Fix errors reported by PHPStan on PHP 8.0 --- phpstan.neon.dist | 1 + .../Storage/FileSystemStorageManager.php | 2 +- tests/PHPStan/conditional.config.php | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/PHPStan/conditional.config.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index c1e9c75..b0c6219 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -6,6 +6,7 @@ includes: - vendor/spaze/phpstan-disallowed-calls/extension.neon - vendor/spaze/phpstan-disallowed-calls/disallowed-dangerous-calls.neon - tests/PHPStan/disallowedCalls.neon + - tests/PHPStan/conditional.config.php parameters: level: max diff --git a/src/FileUploadControl/Storage/FileSystemStorageManager.php b/src/FileUploadControl/Storage/FileSystemStorageManager.php index 78e5ff2..f73b348 100644 --- a/src/FileUploadControl/Storage/FileSystemStorageManager.php +++ b/src/FileUploadControl/Storage/FileSystemStorageManager.php @@ -95,7 +95,7 @@ private function collectGarbage(): void $currentTimestamp = $this->dateTimeProvider->getNow()->getTimestamp(); /** @var \SplFileInfo $directory */ foreach ($this->finder->findDirectoriesInDirectory($this->directory, '*' . self::NAMESPACE_DIRECTORY_SUFFIX) as $directory) { - $age = $currentTimestamp - $directory->getMTime(); + $age = $currentTimestamp - (int) $directory->getMTime(); if ($age < $this->namespaceTtl) { continue; } diff --git a/tests/PHPStan/conditional.config.php b/tests/PHPStan/conditional.config.php new file mode 100644 index 0000000..3587fc0 --- /dev/null +++ b/tests/PHPStan/conditional.config.php @@ -0,0 +1,15 @@ + '~Casting to int something that\'s already int~', + 'path' => '../../src/FileUploadControl/Storage/FileSystemStorageManager.php', + 'count' => 1, + ]; +} + +return $config;