diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 13ae07a..a2f6c2c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 diff --git a/composer.json b/composer.json index d13b165..caa34b8 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..43d5e33 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + ignoreErrors: + - + identifier: filesystemcall.unsafe + path: tests/FastSetTest.php diff --git a/phpunit.xml b/phpunit.xml index c2048ac..70f54b7 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -17,7 +17,7 @@ - + src diff --git a/src/FastSet.php b/src/FastSet.php index 2874dff..c4dbb33 100644 --- a/src/FastSet.php +++ b/src/FastSet.php @@ -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; diff --git a/tests/FastSetTest.php b/tests/FastSetTest.php index 6a522a5..3ef6a3d 100644 --- a/tests/FastSetTest.php +++ b/tests/FastSetTest.php @@ -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; @@ -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; } @@ -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); + } }