From f04804d6a5421d2373200a2a6fb3ca7f72a9a5fb Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Sun, 17 Nov 2024 09:59:10 +0100 Subject: [PATCH] Increase PHPStan rule level to 10 --- phpstan.neon | 2 +- src/CodeUnit.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 3e639cd..9228327 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,4 @@ parameters: - level: 9 + level: 10 paths: - src diff --git a/src/CodeUnit.php b/src/CodeUnit.php index 87eaf71..e4e3b43 100644 --- a/src/CodeUnit.php +++ b/src/CodeUnit.php @@ -9,6 +9,7 @@ */ namespace SebastianBergmann\CodeUnit; +use function assert; use function count; use function file; use function file_exists; @@ -98,13 +99,16 @@ public static function forFileWithAbsolutePath(string $path): FileUnit { self::ensureFileExistsAndIsReadable($path); + $lines = file($path); + + assert($lines !== false); + return new FileUnit( $path, $path, range( 1, - // @phpstan-ignore argument.type - count(file($path)), + count($lines), ), ); }