-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[2.2] [WIP] [Finder] Adding native finders implementations #4061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
331e3ad
[Finder] Added adapter interface.
jfsimon a05f449
[Finder] Added abstract adapter.
jfsimon d340849
[Finder] Moved current implementation to php adapter.
jfsimon c3cdda3
[Finder] Moved min/max depth calculation to abstract adapter.
jfsimon 411cb8b
[Finder] Fixed depth iterator tests.
jfsimon c47c5de
[Finder] Moved glob/regex methods to new Expr class.
jfsimon 432a3fe
[Finder] Added Expr class tests.
jfsimon 524ebe9
[Finder] Added file paths iterator and its tests.
jfsimon f6acae0
[Finder] Added minimalist gnu find adapter.
jfsimon de2ae38
[Finder] Added adapter validity control.
jfsimon dc4bf1f
[Finder] Added adapter selection method.
jfsimon c23ebf9
[Finder] Updated tests to use all valid adapters.
jfsimon bf74c89
[Finder] Added native names/notNames support to gnu find adapter.
jfsimon 7b593ee
[Finder] Added native sizes support to gnu find adapter.
jfsimon 3b3ee8f
[Finder] Added native dates support to gnu find adapter.
jfsimon 530f229
[Finder] Performed some cleanup.
jfsimon 05897a4
[Finder] Improved command class.
jfsimon da79cc4
[Finder] Refactored command building.
jfsimon 19f055e
[Finder] Updated shell command test.
jfsimon daa9b31
[Finder] Added adapter registration method.
jfsimon cba5bca
[Finder] Cleaned code.
jfsimon f131e27
[Finder] Added possibility for adapter to fail.
8a3b2de
[Finder] Added adapters registration tests.
eefba16
[Finder] Added grep support for gnu find adapter.
924561c
[Finder] Fixed typo & removed debug output.
jfsimon f924d85
[Finder] Added native sorting support to gnu find adapter.
jfsimon 4229962
[Finder] Refactored expression (regex/glob) handling.
jfsimon e80e115
[Finder] Added expression tests & fixed related bugs.
jfsimon 8b9ffc6
[Finder] Moved Shell & Command classes to Shell namespace.
jfsimon 0e61db9
[Finder] Fixed regex escaped flag/joker bug.
jfsimon 60e69fe
[Finder] Fixed 'regex are not search' problem.
jfsimon 4e3b017
[Finder] Fixed master rebase.
jfsimon 144c61b
[Finder] Fixed search directory.
jfsimon aa84e2d
[Finder] Fixed typos, CS and small errors.
jfsimon 46cc2d4
[Finder] Fixed namespace.
jfsimon 5fc01f2
[Finder] Changed method name for gnu find adapter.
jfsimon ef0ebb8
[Finder] Fixed gnu find regex name filtering problems.
jfsimon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
174 changes: 174 additions & 0 deletions
174
src/Symfony/Component/Finder/Adapter/AbstractAdapter.php
This file contains hidden or 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,174 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Finder\Adapter; | ||
|
||
/** | ||
* Interface for finder engine implementations. | ||
* | ||
* @author Jean-François Simon <contact@jfsimon.fr> | ||
*/ | ||
abstract class AbstractAdapter implements AdapterInterface | ||
{ | ||
protected $followLinks = false; | ||
protected $mode = 0; | ||
protected $minDepth = 0; | ||
protected $maxDepth = INF; | ||
protected $exclude = array(); | ||
protected $names = array(); | ||
protected $notNames = array(); | ||
protected $contains = array(); | ||
protected $notContains = array(); | ||
protected $sizes = array(); | ||
protected $dates = array(); | ||
protected $filters = array(); | ||
protected $sort = false; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setFollowLinks($followLinks) | ||
{ | ||
$this->followLinks = $followLinks; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setMode($mode) | ||
{ | ||
$this->mode = $mode; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setDepths(array $depths) | ||
{ | ||
$this->minDepth = 0; | ||
$this->maxDepth = INF; | ||
|
||
foreach ($depths as $comparator) { | ||
switch ($comparator->getOperator()) { | ||
case '>': | ||
$this->minDepth = $comparator->getTarget() + 1; | ||
break; | ||
case '>=': | ||
$this->minDepth = $comparator->getTarget(); | ||
break; | ||
case '<': | ||
$this->maxDepth = $comparator->getTarget() - 1; | ||
break; | ||
case '<=': | ||
$this->maxDepth = $comparator->getTarget(); | ||
break; | ||
default: | ||
$this->minDepth = $this->maxDepth = $comparator->getTarget(); | ||
} | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setExclude(array $exclude) | ||
{ | ||
$this->exclude = $exclude; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setNames(array $names) | ||
{ | ||
$this->names = $names; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setNotNames(array $notNames) | ||
{ | ||
$this->notNames = $notNames; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setContains(array $contains) | ||
{ | ||
$this->contains = $contains; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setNotContains(array $notContains) | ||
{ | ||
$this->notContains = $notContains; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setSizes(array $sizes) | ||
{ | ||
$this->sizes = $sizes; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setDates(array $dates) | ||
{ | ||
$this->dates = $dates; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setFilters(array $filters) | ||
{ | ||
$this->filters = $filters; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setSort($sort) | ||
{ | ||
$this->sort = $sort; | ||
|
||
return $this; | ||
} | ||
} |
123 changes: 123 additions & 0 deletions
123
src/Symfony/Component/Finder/Adapter/AdapterInterface.php
This file contains hidden or 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,123 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Finder\Adapter; | ||
|
||
/** | ||
* @author Jean-François Simon <contact@jfsimon.fr> | ||
*/ | ||
interface AdapterInterface | ||
{ | ||
/** | ||
* @param bool $followLinks | ||
* | ||
* @return AdapterInterface Current instance | ||
*/ | ||
function setFollowLinks($followLinks); | ||
|
||
/** | ||
* @param int $mode | ||
* | ||
* @return AdapterInterface Current instance | ||
*/ | ||
function setMode($mode); | ||
|
||
/** | ||
* @param array $exclude | ||
* | ||
* @return AdapterInterface Current instance | ||
*/ | ||
function setExclude(array $exclude); | ||
|
||
/** | ||
* @param array $depths | ||
* | ||
* @return AdapterInterface Current instance | ||
*/ | ||
function setDepths(array $depths); | ||
|
||
/** | ||
* @param array $names | ||
* | ||
* @return AdapterInterface Current instance | ||
*/ | ||
function setNames(array $names); | ||
|
||
/** | ||
* @param array $notNames | ||
* | ||
* @return AdapterInterface Current instance | ||
*/ | ||
function setNotNames(array $notNames); | ||
|
||
/** | ||
* @param array $contains | ||
* | ||
* @return AdapterInterface Current instance | ||
*/ | ||
function setContains(array $contains); | ||
|
||
/** | ||
* @param array $notContains | ||
* | ||
* @return AdapterInterface Current instance | ||
*/ | ||
function setNotContains(array $notContains); | ||
|
||
/** | ||
* @param array $sizes | ||
* | ||
* @return AdapterInterface Current instance | ||
*/ | ||
function setSizes(array $sizes); | ||
|
||
/** | ||
* @param array $dates | ||
* | ||
* @return AdapterInterface Current instance | ||
*/ | ||
function setDates(array $dates); | ||
|
||
/** | ||
* @param array $filters | ||
* | ||
* @return AdapterInterface Current instance | ||
*/ | ||
function setFilters(array $filters); | ||
|
||
/** | ||
* @param \Closure|int $sort | ||
* | ||
* @return AdapterInterface Current instance | ||
*/ | ||
function setSort($sort); | ||
|
||
/** | ||
* @param string $dir | ||
* | ||
* @return \Iterator Result iterator | ||
*/ | ||
function searchInDirectory($dir); | ||
|
||
/** | ||
* Tests adapter support for current platform. | ||
* | ||
* @return bool | ||
*/ | ||
function isSupported(); | ||
|
||
/** | ||
* Returns adapter name. | ||
* | ||
* @return string | ||
*/ | ||
function getName(); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
properties should be initialized in the __construct method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hhamon I think no.
See the Request class for instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum not sure but I guess it should not be hardcoded in the property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These values act as default values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hhamon It's just like the finder himself https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Finder/Finder.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no pbe here.