Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.3', '8.4', '8.5']
php: ['8.1', '8.2', '8.3', '8.4', '8.5']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
"keywords": ["dictionary", "set", "lookup", "binary", "hash", "memory", "fingerprint"],
"type": "library",
"require": {
"php": "^8.3"
"php": "^8.1"
},
"require-dev": {
"phpunit/phpunit": "^12.5",
"symfony/filesystem": "^7.4 || ^8.0",
"phpunit/phpunit": "^10.5 || ^11.0 || ^12.5",
"terminal42/contao-build-tools": "@dev"
},
"license": "MIT",
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
ignoreErrors:
-
identifier: filesystemcall.unsafe
path: tests/FastSetTest.php
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</testsuite>
</testsuites>

<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
<source restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
Expand Down
2 changes: 1 addition & 1 deletion src/FastSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class FastSet
* With a 16-bit prefix, a lot of datasets end up with tiny buckets most of the time,
* so avoiding the extra branching of binary search wins in practice.
*/
private const int LINEAR_SCAN_THRESHOLD = 8;
private const LINEAR_SCAN_THRESHOLD = 8;

private readonly string $hashesPath;

Expand Down
24 changes: 20 additions & 4 deletions tests/FastSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use PHPUnit\Framework\Attributes\TestWith;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Filesystem\Filesystem;
use Toflar\FastSet\FastSet;
use Toflar\FastSet\SetBuilder;

Expand All @@ -17,9 +16,8 @@ final class FastSetTest extends TestCase
protected function setUp(): void
{
$testDir = __DIR__.'/../var';
$fs = new Filesystem();
$fs->remove($testDir);
$fs->mkdir($testDir);
$this->removeDirectory($testDir);
mkdir($testDir, 0777, true);
$this->testDirectory = $testDir;
}

Expand Down Expand Up @@ -76,4 +74,22 @@ private function assertFastSetContents(FastSet $fastSet): void
$this->assertTrue($fastSet->has('aab'));
$this->assertFalse($fastSet->has('foobar'));
}

private function removeDirectory(string $directory): void
{
if (!is_dir($directory)) {
return;
}

$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS),
\RecursiveIteratorIterator::CHILD_FIRST,
);

foreach ($iterator as $file) {
$file->isDir() ? rmdir($file->getPathname()) : unlink($file->getPathname());
}

rmdir($directory);
}
}
Loading