Skip to content

Commit 2d18000

Browse files
authored
Merge pull request #55 from rulatir/master
Flysystem v3 port
2 parents 4c0fa89 + b708dc9 commit 2d18000

27 files changed

+277
-237
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ phpstan:
2121

2222
.PHONY: psaml
2323
psalm:
24-
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 tools/psalm
24+
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.2 tools/psalm
2525

2626
.PHONY: test
2727
test:
28-
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.2 tools/phpunit
28+
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.2 tools/phpunit
2929

3030
.PHONY: pre-commit-test
3131
pre-commit-test: test phpcs phpstan psalm

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
FlyFinder
99
=========
1010

11-
FlyFinder is a plugin for [Flysystem](http://flysystem.thephpleague.com/) that will enable you to find files
11+
FlyFinder is a utility class for [Flysystem](http://flysystem.thephpleague.com/) that will enable you to find files
1212
based on certain criteria.
1313

1414
FlyFinder can search for files that are hidden (either because they are hidden files themselves, or because they are
@@ -33,14 +33,14 @@ In order to use the FlyFinder plugin you first need a Flyfinder filesystem with
3333
for instance the local adapter.
3434

3535
use League\Flysystem\Filesystem;
36-
use League\Flysystem\Adapter;
36+
use League\Flysystem\Local\LocalFilesystemAdapter as LocalAdapter;
3737
use Flyfinder\Finder;
3838

39-
$filesystem = new Filesystem(new Adapter\Local(__DIR__.'/path/to/files/'));
39+
$filesystem = new Filesystem(new LocalAdapter(__DIR__.'/path/to/files/'));
4040

41-
Now you can add the plugin as follows:
41+
Now you can create the `Finder` instance:
4242

43-
$filesystem->addPlugin(new Finder());
43+
$finder = new Finder($filesystem);
4444

4545
FlyFinder will need specifications to know what to look for. The following specifications are available:
4646

@@ -74,6 +74,6 @@ extension.
7474

7575
You can also make longer chains like this:
7676

77-
` $specification = $inPath->andSpecification($hasExtension)->andSpecification($isHidden->notSpecification());`
77+
`$specification = $inPath->andSpecification($hasExtension)->andSpecification($isHidden->notSpecification());`
7878

7979
This will find all files in the given path, that have the given extension and are not hidden.

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
}
1919
},
2020
"require": {
21-
"php": "^7.2||^8.0",
22-
"league/flysystem": "^1.0"
21+
"php": "^8.0||^8.1||8.2",
22+
"league/flysystem": "^3.0"
2323
},
2424
"minimum-stability": "stable",
2525
"require-dev": {
2626
"mockery/mockery": "^1.3",
27-
"league/flysystem-memory": "~1"
27+
"league/flysystem-memory": "~3"
2828
},
2929
"extra": {
3030
"branch-alias": {

composer.lock

Lines changed: 73 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/01-find-hidden-files.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require_once(__DIR__ . '/../vendor/autoload.php');
33

44
use League\Flysystem\Filesystem;
5-
use League\Flysystem\Memory\MemoryAdapter as Adapter;
5+
use League\Flysystem\InMemory\InMemoryFilesystemAdapter as Adapter;
66
use Flyfinder\Finder;
77
use Flyfinder\Specification\IsHidden;
88

@@ -11,7 +11,8 @@
1111
* In this example we are using a filesystem with the memory adapter
1212
*/
1313
$filesystem = new Filesystem(new Adapter());
14-
$filesystem->addPlugin(new Finder());
14+
$finder = new Finder();
15+
$finder->setFilesystem($filesystem);
1516

1617
// Create some demo files
1718
$filesystem->write('test.txt', 'test');
@@ -22,7 +23,7 @@
2223
$specification = new IsHidden();
2324

2425
//FlyFinder will yield a generator object with the files that are found
25-
$generator = $filesystem->find($specification);
26+
$generator = $finder->find($specification);
2627

2728
$result = [];
2829

examples/02-find-on-multiple-criteria.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
require_once(__DIR__ . '/../vendor/autoload.php');
33

44
use League\Flysystem\Filesystem;
5-
use League\Flysystem\Memory\MemoryAdapter as Adapter;
5+
use League\Flysystem\InMemory\InMemoryFilesystemAdapter as Adapter;
66
use Flyfinder\Finder;
77
use Flyfinder\Path;
88
use Flyfinder\Specification\IsHidden;
99
use Flyfinder\Specification\HasExtension;
10-
use Flyfinder\Specification\InPath;
10+
use Flyfinder\Specification\InPath;use League\Flysystem\InMemory\InMemoryFilesystemAdapter;
1111

1212
/*
1313
* First create a new Filesystem and add the FlySystem plugin
1414
* In this example we are using a filesystem with the memory adapter
1515
*/
1616
$filesystem = new Filesystem(new Adapter());
17-
$filesystem->addPlugin(new Finder());
17+
$finder = new Finder();
18+
$finder->setFilesystem($filesystem);
1819

1920
// Create some demo files
2021
$filesystem->write('test.txt', 'test');
@@ -33,7 +34,7 @@
3334
$specification = $inPath->andSpecification($hasExtension)->andSpecification($isHidden->notSpecification());
3435

3536
//FlyFinder will yield a generator object with the files that are found
36-
$generator = $filesystem->find($specification);
37+
$generator = $finder->find($specification);
3738

3839
$result = [];
3940

examples/03-sample-phpdoc-layout.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require_once(__DIR__ . '/../vendor/autoload.php');
33

44
use League\Flysystem\Filesystem;
5-
use League\Flysystem\Adapter\Local;
5+
use League\Flysystem\Local\LocalFilesystemAdapter as Local;
66
use Flyfinder\Finder;
77
use Flyfinder\Path;
88
use Flyfinder\Specification\IsHidden;
@@ -12,7 +12,8 @@
1212

1313
// (03-sample-files based on some phpDocumentor2 src files)
1414
$filesystem = new Filesystem(new Local(__DIR__ . '/03-sample-files'));
15-
$filesystem->addPlugin(new Finder());
15+
$finder = new Finder();
16+
$finder->setFilesystem($filesystem);
1617

1718
/*
1819
* "phpdoc -d src -i src/phpDocumentor/DomainModel"
@@ -27,7 +28,7 @@
2728
$spec->andSpecification($isHidden->notSpecification());
2829
$spec->andSpecification($isPhpFile);
2930

30-
$generator = $filesystem->find($spec);
31+
$generator = $finder->find($spec);
3132
$result = [];
3233
foreach($generator as $value) {
3334
$result[] = $value;

0 commit comments

Comments
 (0)