Skip to content

Commit

Permalink
Remove deprecated functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Dec 23, 2023
1 parent bf33b01 commit 8fdb7ff
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 73 deletions.
7 changes: 0 additions & 7 deletions .psalm/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@
</UndefinedConstant>
</file>
<file src="src/Filter.php">
<ArgumentTypeCoercion>
<code>$directory</code>
<code>$directory</code>
</ArgumentTypeCoercion>
<DeprecatedMethod>
<code>excludeFile</code>
</DeprecatedMethod>
<InvalidDocblockParamName>
<code>$files</code>
</InvalidDocblockParamName>
Expand Down
1 change: 1 addition & 0 deletions ChangeLog-11.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
35 changes: 0 additions & 35 deletions src/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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<string> $files
*/
Expand All @@ -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])) {
Expand Down
31 changes: 0 additions & 31 deletions tests/tests/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down

0 comments on commit 8fdb7ff

Please sign in to comment.