From 8fdb7ff2840fee629acb159ac266a7718bbf1beb Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Sat, 23 Dec 2023 14:29:46 +0100 Subject: [PATCH] Remove deprecated functionality --- .psalm/baseline.xml | 7 ------- ChangeLog-11.0.md | 1 + src/Filter.php | 35 ----------------------------------- tests/tests/FilterTest.php | 31 ------------------------------- 4 files changed, 1 insertion(+), 73 deletions(-) diff --git a/.psalm/baseline.xml b/.psalm/baseline.xml index 59acf9a9e..863797919 100644 --- a/.psalm/baseline.xml +++ b/.psalm/baseline.xml @@ -55,13 +55,6 @@ - - $directory - $directory - - - excludeFile - $files diff --git a/ChangeLog-11.0.md b/ChangeLog-11.0.md index d6b490a30..4935920ed 100644 --- a/ChangeLog-11.0.md +++ b/ChangeLog-11.0.md @@ -6,6 +6,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt ### Removed +* The `SebastianBergmann\CodeCoverage\Filter::includeDirectory()`, `SebastianBergmann\CodeCoverage\Filter::excludeDirectory()`, and `SebastianBergmann\CodeCoverage\Filter::excludeFile()` methods have been removed * This component now requires PHP-Parser 5 * This component is no longer supported on PHP 8.1 diff --git a/src/Filter.php b/src/Filter.php index f51eb3e1f..975b28f1d 100644 --- a/src/Filter.php +++ b/src/Filter.php @@ -14,7 +14,6 @@ use function realpath; use function str_contains; use function str_starts_with; -use SebastianBergmann\FileIterator\Facade as FileIteratorFacade; final class Filter { @@ -28,16 +27,6 @@ final class Filter */ private array $isFileCache = []; - /** - * @deprecated - */ - public function includeDirectory(string $directory, string $suffix = '.php', string $prefix = ''): void - { - foreach ((new FileIteratorFacade)->getFilesAsArray($directory, $suffix, $prefix) as $file) { - $this->includeFile($file); - } - } - /** * @psalm-param list $files */ @@ -59,30 +48,6 @@ public function includeFile(string $filename): void $this->files[$filename] = true; } - /** - * @deprecated - */ - public function excludeDirectory(string $directory, string $suffix = '.php', string $prefix = ''): void - { - foreach ((new FileIteratorFacade)->getFilesAsArray($directory, $suffix, $prefix) as $file) { - $this->excludeFile($file); - } - } - - /** - * @deprecated - */ - public function excludeFile(string $filename): void - { - $filename = realpath($filename); - - if (!$filename || !isset($this->files[$filename])) { - return; - } - - unset($this->files[$filename]); - } - public function isFile(string $filename): bool { if (isset($this->isFileCache[$filename])) { diff --git a/tests/tests/FilterTest.php b/tests/tests/FilterTest.php index adea607a8..143cc1840 100644 --- a/tests/tests/FilterTest.php +++ b/tests/tests/FilterTest.php @@ -57,37 +57,6 @@ public function testMultipleFilesCanBeAdded(): void $this->assertSame($files, $this->filter->files()); } - public function testDirectoryCanBeAdded(): void - { - $this->filter->includeDirectory(__DIR__ . '/../_files/filter'); - - $this->assertSame( - [ - realpath(__DIR__ . '/../_files/filter/a.php'), - realpath(__DIR__ . '/../_files/filter/b.php'), - ], - $this->filter->files() - ); - } - - public function testSingleFileCanBeRemoved(): void - { - $this->filter->includeFile(realpath(__DIR__ . '/../_files/filter/a.php')); - $this->filter->excludeFile(realpath(__DIR__ . '/../_files/filter/a.php')); - - $this->assertTrue($this->filter->isEmpty()); - $this->assertSame([], $this->filter->files()); - } - - public function testDirectoryCanBeRemoved(): void - { - $this->filter->includeDirectory(__DIR__ . '/../_files/filter'); - $this->filter->excludeDirectory(__DIR__ . '/../_files/filter'); - - $this->assertTrue($this->filter->isEmpty()); - $this->assertSame([], $this->filter->files()); - } - public function testDeterminesWhetherStringContainsNameOfRealFileThatExists(): void { $this->assertFalse($this->filter->isFile('vfs://root/a/path'));