-
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* trying to fix * Remove symfony finder
- Loading branch information
Showing
7 changed files
with
85 additions
and
19 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Phpactor\Indexer\Adapter\Php; | ||
|
||
use Generator; | ||
use Phpactor\Indexer\Model\IndexInfo; | ||
use Phpactor\Indexer\Model\IndexLister; | ||
use SplFileInfo; | ||
use Symfony\Component\Filesystem\Path; | ||
|
||
class PhpIndexerLister implements IndexLister | ||
{ | ||
public function __construct(private string $indexDirectory) | ||
{ | ||
} | ||
public function list(): Generator | ||
{ | ||
$indexes = array_filter(array_map( | ||
fn (string|false $name) => $name ? Path::join($this->indexDirectory, $name) : '', | ||
array_filter( | ||
(array)scandir($this->indexDirectory), | ||
fn (string|false $name) => !in_array($name, ['.', '..']) | ||
), | ||
), fn (string $indexPath) => is_dir($indexPath)); | ||
|
||
foreach ($indexes as $indexPath) { | ||
$info = IndexInfo::fromSplFileInfo(new SplFileInfo($indexPath)); | ||
// warmup the size | ||
$info->size(); | ||
yield $info; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Phpactor\Indexer\Model; | ||
|
||
use Generator; | ||
|
||
interface IndexLister | ||
{ | ||
/** | ||
* @return Generator<IndexInfo> | ||
*/ | ||
public function list(): Generator; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Phpactor\Indexer\Tests\Adapter\Php; | ||
|
||
use Phpactor\Indexer\Adapter\Php\PhpIndexerLister; | ||
use Phpactor\Indexer\Tests\IntegrationTestCase; | ||
|
||
class PhpIndexListerTest extends IntegrationTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
$this->workspace()->reset(); | ||
} | ||
|
||
public function testListsIndexes(): void | ||
{ | ||
$this->workspace()->mkdir('index1'); | ||
$this->workspace()->mkdir('index2'); | ||
$this->workspace()->put('file1.txt', ''); | ||
|
||
$lister = $this->lister(); | ||
|
||
$infos = iterator_to_array($lister->list()); | ||
self::assertCount(2, $infos); | ||
} | ||
|
||
private function lister(): PhpIndexerLister | ||
{ | ||
return (new PhpIndexerLister($this->workspace()->path())); | ||
} | ||
} |