phpactor / path-finder
Utility for navigating to related source files
Installs: 41 888
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^7.3 || ^8.0
- webmozart/path-util: ^2.3
Requires (Dev)
- ergebnis/composer-normalize: ^2.0
- friendsofphp/php-cs-fixer: ^2.17
- phpstan/phpstan: ~0.12.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2022-03-20 11:51:53 UTC
README
Library to infer paths from a given path where paths share path segments.
For example, infer test paths for a given source file and vice-versa.
Usage
Path finder accepts a hash map of destinations and their schemas. The placeholders can be used to identify common parts of the path.
- The last placeholder is greedy it will match all path segments until the suffix.
- Preceding placeholders will only match until the first path separator.
Examples
Navigating between test files
$pathFinder = PathFinder::fromDestinations([ 'source' => 'lib/<kernel>.php', 'unit_test' => 'tests/Unit/<kernel>Test.php', 'benchmark' => 'benchmarks/<kernel>Bench.php', ]); $targets = $pathFinder->targetsFor('lib/Acme/Post.php'); // [ // 'unit_test' => 'tests/Unit/Acme/PostTest.php', // 'benchmark' => 'benchmarks/Acme/PostBench.php', // ]
Navigating between files organized by domain/module
$pathFinder = PathFinder::fromDestinations([ 'source' => 'lib/<module>/<kernel>.php', 'unit_test' => 'tests/<module>/Unit/<kernel>Test.php', 'benchmark' => 'benchmarks/<module>/<kernel>Bench.php', ]); $targets = $pathFinder->targetsFor('lib/MyModule/Acme/Post.php'); // [ // 'unit_test' => 'tests/MyModule/Unit/Acme/PostTest.php', // 'benchmark' => 'benchmarks/MyModule/Acme/PostBench.php', // ]
Contributing
This package is open source and welcomes contributions! Feel free to open a pull request on this repository.
Support
- Create an issue on the main Phpactor repository.
- Join the
#phpactor
channel on the Slack Symfony Devs channel.