No Description

Finder.php 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Finder;
  11. use Symfony\Component\Finder\Adapter\AdapterInterface;
  12. use Symfony\Component\Finder\Adapter\GnuFindAdapter;
  13. use Symfony\Component\Finder\Adapter\BsdFindAdapter;
  14. use Symfony\Component\Finder\Adapter\PhpAdapter;
  15. use Symfony\Component\Finder\Comparator\DateComparator;
  16. use Symfony\Component\Finder\Comparator\NumberComparator;
  17. use Symfony\Component\Finder\Exception\ExceptionInterface;
  18. use Symfony\Component\Finder\Iterator\CustomFilterIterator;
  19. use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
  20. use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
  21. use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
  22. use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
  23. use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
  24. use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
  25. use Symfony\Component\Finder\Iterator\SortableIterator;
  26. /**
  27. * Finder allows to build rules to find files and directories.
  28. *
  29. * It is a thin wrapper around several specialized iterator classes.
  30. *
  31. * All rules may be invoked several times.
  32. *
  33. * All methods return the current Finder object to allow easy chaining:
  34. *
  35. * $finder = Finder::create()->files()->name('*.php')->in(__DIR__);
  36. *
  37. * @author Fabien Potencier <fabien@symfony.com>
  38. *
  39. * @api
  40. */
  41. class Finder implements \IteratorAggregate, \Countable
  42. {
  43. const IGNORE_VCS_FILES = 1;
  44. const IGNORE_DOT_FILES = 2;
  45. private $mode = 0;
  46. private $names = array();
  47. private $notNames = array();
  48. private $exclude = array();
  49. private $filters = array();
  50. private $depths = array();
  51. private $sizes = array();
  52. private $followLinks = false;
  53. private $sort = false;
  54. private $ignore = 0;
  55. private $dirs = array();
  56. private $dates = array();
  57. private $iterators = array();
  58. private $contains = array();
  59. private $notContains = array();
  60. private $adapters = array();
  61. private $paths = array();
  62. private $notPaths = array();
  63. private $ignoreUnreadableDirs = false;
  64. private static $vcsPatterns = array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg');
  65. /**
  66. * Constructor.
  67. */
  68. public function __construct()
  69. {
  70. $this->ignore = static::IGNORE_VCS_FILES | static::IGNORE_DOT_FILES;
  71. $this
  72. ->addAdapter(new GnuFindAdapter())
  73. ->addAdapter(new BsdFindAdapter())
  74. ->addAdapter(new PhpAdapter(), -50)
  75. ->setAdapter('php')
  76. ;
  77. }
  78. /**
  79. * Creates a new Finder.
  80. *
  81. * @return Finder A new Finder instance
  82. *
  83. * @api
  84. */
  85. public static function create()
  86. {
  87. return new static();
  88. }
  89. /**
  90. * Registers a finder engine implementation.
  91. *
  92. * @param AdapterInterface $adapter An adapter instance
  93. * @param int $priority Highest is selected first
  94. *
  95. * @return Finder The current Finder instance
  96. */
  97. public function addAdapter(AdapterInterface $adapter, $priority = 0)
  98. {
  99. $this->adapters[$adapter->getName()] = array(
  100. 'adapter' => $adapter,
  101. 'priority' => $priority,
  102. 'selected' => false,
  103. );
  104. return $this->sortAdapters();
  105. }
  106. /**
  107. * Sets the selected adapter to the best one according to the current platform the code is run on.
  108. *
  109. * @return Finder The current Finder instance
  110. */
  111. public function useBestAdapter()
  112. {
  113. $this->resetAdapterSelection();
  114. return $this->sortAdapters();
  115. }
  116. /**
  117. * Selects the adapter to use.
  118. *
  119. * @param string $name
  120. *
  121. * @throws \InvalidArgumentException
  122. *
  123. * @return Finder The current Finder instance
  124. */
  125. public function setAdapter($name)
  126. {
  127. if (!isset($this->adapters[$name])) {
  128. throw new \InvalidArgumentException(sprintf('Adapter "%s" does not exist.', $name));
  129. }
  130. $this->resetAdapterSelection();
  131. $this->adapters[$name]['selected'] = true;
  132. return $this->sortAdapters();
  133. }
  134. /**
  135. * Removes all adapters registered in the finder.
  136. *
  137. * @return Finder The current Finder instance
  138. */
  139. public function removeAdapters()
  140. {
  141. $this->adapters = array();
  142. return $this;
  143. }
  144. /**
  145. * Returns registered adapters ordered by priority without extra information.
  146. *
  147. * @return AdapterInterface[]
  148. */
  149. public function getAdapters()
  150. {
  151. return array_values(array_map(function (array $adapter) {
  152. return $adapter['adapter'];
  153. }, $this->adapters));
  154. }
  155. /**
  156. * Restricts the matching to directories only.
  157. *
  158. * @return Finder The current Finder instance
  159. *
  160. * @api
  161. */
  162. public function directories()
  163. {
  164. $this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES;
  165. return $this;
  166. }
  167. /**
  168. * Restricts the matching to files only.
  169. *
  170. * @return Finder The current Finder instance
  171. *
  172. * @api
  173. */
  174. public function files()
  175. {
  176. $this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES;
  177. return $this;
  178. }
  179. /**
  180. * Adds tests for the directory depth.
  181. *
  182. * Usage:
  183. *
  184. * $finder->depth('> 1') // the Finder will start matching at level 1.
  185. * $finder->depth('< 3') // the Finder will descend at most 3 levels of directories below the starting point.
  186. *
  187. * @param int $level The depth level expression
  188. *
  189. * @return Finder The current Finder instance
  190. *
  191. * @see DepthRangeFilterIterator
  192. * @see NumberComparator
  193. *
  194. * @api
  195. */
  196. public function depth($level)
  197. {
  198. $this->depths[] = new Comparator\NumberComparator($level);
  199. return $this;
  200. }
  201. /**
  202. * Adds tests for file dates (last modified).
  203. *
  204. * The date must be something that strtotime() is able to parse:
  205. *
  206. * $finder->date('since yesterday');
  207. * $finder->date('until 2 days ago');
  208. * $finder->date('> now - 2 hours');
  209. * $finder->date('>= 2005-10-15');
  210. *
  211. * @param string $date A date rage string
  212. *
  213. * @return Finder The current Finder instance
  214. *
  215. * @see strtotime
  216. * @see DateRangeFilterIterator
  217. * @see DateComparator
  218. *
  219. * @api
  220. */
  221. public function date($date)
  222. {
  223. $this->dates[] = new Comparator\DateComparator($date);
  224. return $this;
  225. }
  226. /**
  227. * Adds rules that files must match.
  228. *
  229. * You can use patterns (delimited with / sign), globs or simple strings.
  230. *
  231. * $finder->name('*.php')
  232. * $finder->name('/\.php$/') // same as above
  233. * $finder->name('test.php')
  234. *
  235. * @param string $pattern A pattern (a regexp, a glob, or a string)
  236. *
  237. * @return Finder The current Finder instance
  238. *
  239. * @see FilenameFilterIterator
  240. *
  241. * @api
  242. */
  243. public function name($pattern)
  244. {
  245. $this->names[] = $pattern;
  246. return $this;
  247. }
  248. /**
  249. * Adds rules that files must not match.
  250. *
  251. * @param string $pattern A pattern (a regexp, a glob, or a string)
  252. *
  253. * @return Finder The current Finder instance
  254. *
  255. * @see FilenameFilterIterator
  256. *
  257. * @api
  258. */
  259. public function notName($pattern)
  260. {
  261. $this->notNames[] = $pattern;
  262. return $this;
  263. }
  264. /**
  265. * Adds tests that file contents must match.
  266. *
  267. * Strings or PCRE patterns can be used:
  268. *
  269. * $finder->contains('Lorem ipsum')
  270. * $finder->contains('/Lorem ipsum/i')
  271. *
  272. * @param string $pattern A pattern (string or regexp)
  273. *
  274. * @return Finder The current Finder instance
  275. *
  276. * @see FilecontentFilterIterator
  277. */
  278. public function contains($pattern)
  279. {
  280. $this->contains[] = $pattern;
  281. return $this;
  282. }
  283. /**
  284. * Adds tests that file contents must not match.
  285. *
  286. * Strings or PCRE patterns can be used:
  287. *
  288. * $finder->notContains('Lorem ipsum')
  289. * $finder->notContains('/Lorem ipsum/i')
  290. *
  291. * @param string $pattern A pattern (string or regexp)
  292. *
  293. * @return Finder The current Finder instance
  294. *
  295. * @see FilecontentFilterIterator
  296. */
  297. public function notContains($pattern)
  298. {
  299. $this->notContains[] = $pattern;
  300. return $this;
  301. }
  302. /**
  303. * Adds rules that filenames must match.
  304. *
  305. * You can use patterns (delimited with / sign) or simple strings.
  306. *
  307. * $finder->path('some/special/dir')
  308. * $finder->path('/some\/special\/dir/') // same as above
  309. *
  310. * Use only / as dirname separator.
  311. *
  312. * @param string $pattern A pattern (a regexp or a string)
  313. *
  314. * @return Finder The current Finder instance
  315. *
  316. * @see FilenameFilterIterator
  317. */
  318. public function path($pattern)
  319. {
  320. $this->paths[] = $pattern;
  321. return $this;
  322. }
  323. /**
  324. * Adds rules that filenames must not match.
  325. *
  326. * You can use patterns (delimited with / sign) or simple strings.
  327. *
  328. * $finder->notPath('some/special/dir')
  329. * $finder->notPath('/some\/special\/dir/') // same as above
  330. *
  331. * Use only / as dirname separator.
  332. *
  333. * @param string $pattern A pattern (a regexp or a string)
  334. *
  335. * @return Finder The current Finder instance
  336. *
  337. * @see FilenameFilterIterator
  338. */
  339. public function notPath($pattern)
  340. {
  341. $this->notPaths[] = $pattern;
  342. return $this;
  343. }
  344. /**
  345. * Adds tests for file sizes.
  346. *
  347. * $finder->size('> 10K');
  348. * $finder->size('<= 1Ki');
  349. * $finder->size(4);
  350. *
  351. * @param string $size A size range string
  352. *
  353. * @return Finder The current Finder instance
  354. *
  355. * @see SizeRangeFilterIterator
  356. * @see NumberComparator
  357. *
  358. * @api
  359. */
  360. public function size($size)
  361. {
  362. $this->sizes[] = new Comparator\NumberComparator($size);
  363. return $this;
  364. }
  365. /**
  366. * Excludes directories.
  367. *
  368. * @param string|array $dirs A directory path or an array of directories
  369. *
  370. * @return Finder The current Finder instance
  371. *
  372. * @see ExcludeDirectoryFilterIterator
  373. *
  374. * @api
  375. */
  376. public function exclude($dirs)
  377. {
  378. $this->exclude = array_merge($this->exclude, (array) $dirs);
  379. return $this;
  380. }
  381. /**
  382. * Excludes "hidden" directories and files (starting with a dot).
  383. *
  384. * @param bool $ignoreDotFiles Whether to exclude "hidden" files or not
  385. *
  386. * @return Finder The current Finder instance
  387. *
  388. * @see ExcludeDirectoryFilterIterator
  389. *
  390. * @api
  391. */
  392. public function ignoreDotFiles($ignoreDotFiles)
  393. {
  394. if ($ignoreDotFiles) {
  395. $this->ignore = $this->ignore | static::IGNORE_DOT_FILES;
  396. } else {
  397. $this->ignore = $this->ignore & ~static::IGNORE_DOT_FILES;
  398. }
  399. return $this;
  400. }
  401. /**
  402. * Forces the finder to ignore version control directories.
  403. *
  404. * @param bool $ignoreVCS Whether to exclude VCS files or not
  405. *
  406. * @return Finder The current Finder instance
  407. *
  408. * @see ExcludeDirectoryFilterIterator
  409. *
  410. * @api
  411. */
  412. public function ignoreVCS($ignoreVCS)
  413. {
  414. if ($ignoreVCS) {
  415. $this->ignore = $this->ignore | static::IGNORE_VCS_FILES;
  416. } else {
  417. $this->ignore = $this->ignore & ~static::IGNORE_VCS_FILES;
  418. }
  419. return $this;
  420. }
  421. /**
  422. * Adds VCS patterns.
  423. *
  424. * @see ignoreVCS()
  425. *
  426. * @param string|string[] $pattern VCS patterns to ignore
  427. */
  428. public static function addVCSPattern($pattern)
  429. {
  430. foreach ((array) $pattern as $p) {
  431. self::$vcsPatterns[] = $p;
  432. }
  433. self::$vcsPatterns = array_unique(self::$vcsPatterns);
  434. }
  435. /**
  436. * Sorts files and directories by an anonymous function.
  437. *
  438. * The anonymous function receives two \SplFileInfo instances to compare.
  439. *
  440. * This can be slow as all the matching files and directories must be retrieved for comparison.
  441. *
  442. * @param \Closure $closure An anonymous function
  443. *
  444. * @return Finder The current Finder instance
  445. *
  446. * @see SortableIterator
  447. *
  448. * @api
  449. */
  450. public function sort(\Closure $closure)
  451. {
  452. $this->sort = $closure;
  453. return $this;
  454. }
  455. /**
  456. * Sorts files and directories by name.
  457. *
  458. * This can be slow as all the matching files and directories must be retrieved for comparison.
  459. *
  460. * @return Finder The current Finder instance
  461. *
  462. * @see SortableIterator
  463. *
  464. * @api
  465. */
  466. public function sortByName()
  467. {
  468. $this->sort = Iterator\SortableIterator::SORT_BY_NAME;
  469. return $this;
  470. }
  471. /**
  472. * Sorts files and directories by type (directories before files), then by name.
  473. *
  474. * This can be slow as all the matching files and directories must be retrieved for comparison.
  475. *
  476. * @return Finder The current Finder instance
  477. *
  478. * @see SortableIterator
  479. *
  480. * @api
  481. */
  482. public function sortByType()
  483. {
  484. $this->sort = Iterator\SortableIterator::SORT_BY_TYPE;
  485. return $this;
  486. }
  487. /**
  488. * Sorts files and directories by the last accessed time.
  489. *
  490. * This is the time that the file was last accessed, read or written to.
  491. *
  492. * This can be slow as all the matching files and directories must be retrieved for comparison.
  493. *
  494. * @return Finder The current Finder instance
  495. *
  496. * @see SortableIterator
  497. *
  498. * @api
  499. */
  500. public function sortByAccessedTime()
  501. {
  502. $this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME;
  503. return $this;
  504. }
  505. /**
  506. * Sorts files and directories by the last inode changed time.
  507. *
  508. * This is the time that the inode information was last modified (permissions, owner, group or other metadata).
  509. *
  510. * On Windows, since inode is not available, changed time is actually the file creation time.
  511. *
  512. * This can be slow as all the matching files and directories must be retrieved for comparison.
  513. *
  514. * @return Finder The current Finder instance
  515. *
  516. * @see SortableIterator
  517. *
  518. * @api
  519. */
  520. public function sortByChangedTime()
  521. {
  522. $this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME;
  523. return $this;
  524. }
  525. /**
  526. * Sorts files and directories by the last modified time.
  527. *
  528. * This is the last time the actual contents of the file were last modified.
  529. *
  530. * This can be slow as all the matching files and directories must be retrieved for comparison.
  531. *
  532. * @return Finder The current Finder instance
  533. *
  534. * @see SortableIterator
  535. *
  536. * @api
  537. */
  538. public function sortByModifiedTime()
  539. {
  540. $this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME;
  541. return $this;
  542. }
  543. /**
  544. * Filters the iterator with an anonymous function.
  545. *
  546. * The anonymous function receives a \SplFileInfo and must return false
  547. * to remove files.
  548. *
  549. * @param \Closure $closure An anonymous function
  550. *
  551. * @return Finder The current Finder instance
  552. *
  553. * @see CustomFilterIterator
  554. *
  555. * @api
  556. */
  557. public function filter(\Closure $closure)
  558. {
  559. $this->filters[] = $closure;
  560. return $this;
  561. }
  562. /**
  563. * Forces the following of symlinks.
  564. *
  565. * @return Finder The current Finder instance
  566. *
  567. * @api
  568. */
  569. public function followLinks()
  570. {
  571. $this->followLinks = true;
  572. return $this;
  573. }
  574. /**
  575. * Tells finder to ignore unreadable directories.
  576. *
  577. * By default, scanning unreadable directories content throws an AccessDeniedException.
  578. *
  579. * @param bool $ignore
  580. *
  581. * @return Finder The current Finder instance
  582. */
  583. public function ignoreUnreadableDirs($ignore = true)
  584. {
  585. $this->ignoreUnreadableDirs = (bool) $ignore;
  586. return $this;
  587. }
  588. /**
  589. * Searches files and directories which match defined rules.
  590. *
  591. * @param string|array $dirs A directory path or an array of directories
  592. *
  593. * @return Finder The current Finder instance
  594. *
  595. * @throws \InvalidArgumentException if one of the directories does not exist
  596. *
  597. * @api
  598. */
  599. public function in($dirs)
  600. {
  601. $resolvedDirs = array();
  602. foreach ((array) $dirs as $dir) {
  603. if (is_dir($dir)) {
  604. $resolvedDirs[] = $dir;
  605. } elseif ($glob = glob($dir, GLOB_BRACE | GLOB_ONLYDIR)) {
  606. $resolvedDirs = array_merge($resolvedDirs, $glob);
  607. } else {
  608. throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
  609. }
  610. }
  611. $this->dirs = array_merge($this->dirs, $resolvedDirs);
  612. return $this;
  613. }
  614. /**
  615. * Returns an Iterator for the current Finder configuration.
  616. *
  617. * This method implements the IteratorAggregate interface.
  618. *
  619. * @return \Iterator An iterator
  620. *
  621. * @throws \LogicException if the in() method has not been called
  622. */
  623. public function getIterator()
  624. {
  625. if (0 === count($this->dirs) && 0 === count($this->iterators)) {
  626. throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
  627. }
  628. if (1 === count($this->dirs) && 0 === count($this->iterators)) {
  629. return $this->searchInDirectory($this->dirs[0]);
  630. }
  631. $iterator = new \AppendIterator();
  632. foreach ($this->dirs as $dir) {
  633. $iterator->append($this->searchInDirectory($dir));
  634. }
  635. foreach ($this->iterators as $it) {
  636. $iterator->append($it);
  637. }
  638. return $iterator;
  639. }
  640. /**
  641. * Appends an existing set of files/directories to the finder.
  642. *
  643. * The set can be another Finder, an Iterator, an IteratorAggregate, or even a plain array.
  644. *
  645. * @param mixed $iterator
  646. *
  647. * @return Finder The finder
  648. *
  649. * @throws \InvalidArgumentException When the given argument is not iterable.
  650. */
  651. public function append($iterator)
  652. {
  653. if ($iterator instanceof \IteratorAggregate) {
  654. $this->iterators[] = $iterator->getIterator();
  655. } elseif ($iterator instanceof \Iterator) {
  656. $this->iterators[] = $iterator;
  657. } elseif ($iterator instanceof \Traversable || is_array($iterator)) {
  658. $it = new \ArrayIterator();
  659. foreach ($iterator as $file) {
  660. $it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file));
  661. }
  662. $this->iterators[] = $it;
  663. } else {
  664. throw new \InvalidArgumentException('Finder::append() method wrong argument type.');
  665. }
  666. return $this;
  667. }
  668. /**
  669. * Counts all the results collected by the iterators.
  670. *
  671. * @return int
  672. */
  673. public function count()
  674. {
  675. return iterator_count($this->getIterator());
  676. }
  677. /**
  678. * @return Finder The current Finder instance
  679. */
  680. private function sortAdapters()
  681. {
  682. uasort($this->adapters, function (array $a, array $b) {
  683. if ($a['selected'] || $b['selected']) {
  684. return $a['selected'] ? -1 : 1;
  685. }
  686. return $a['priority'] > $b['priority'] ? -1 : 1;
  687. });
  688. return $this;
  689. }
  690. /**
  691. * @param $dir
  692. *
  693. * @return \Iterator
  694. *
  695. * @throws \RuntimeException When none of the adapters are supported
  696. */
  697. private function searchInDirectory($dir)
  698. {
  699. if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
  700. $this->exclude = array_merge($this->exclude, self::$vcsPatterns);
  701. }
  702. if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
  703. $this->notPaths[] = '#(^|/)\..+(/|$)#';
  704. }
  705. foreach ($this->adapters as $adapter) {
  706. if ($adapter['adapter']->isSupported()) {
  707. try {
  708. return $this
  709. ->buildAdapter($adapter['adapter'])
  710. ->searchInDirectory($dir);
  711. } catch (ExceptionInterface $e) {
  712. }
  713. }
  714. }
  715. throw new \RuntimeException('No supported adapter found.');
  716. }
  717. /**
  718. * @param AdapterInterface $adapter
  719. *
  720. * @return AdapterInterface
  721. */
  722. private function buildAdapter(AdapterInterface $adapter)
  723. {
  724. return $adapter
  725. ->setFollowLinks($this->followLinks)
  726. ->setDepths($this->depths)
  727. ->setMode($this->mode)
  728. ->setExclude($this->exclude)
  729. ->setNames($this->names)
  730. ->setNotNames($this->notNames)
  731. ->setContains($this->contains)
  732. ->setNotContains($this->notContains)
  733. ->setSizes($this->sizes)
  734. ->setDates($this->dates)
  735. ->setFilters($this->filters)
  736. ->setSort($this->sort)
  737. ->setPath($this->paths)
  738. ->setNotPath($this->notPaths)
  739. ->ignoreUnreadableDirs($this->ignoreUnreadableDirs);
  740. }
  741. /**
  742. * Unselects all adapters.
  743. */
  744. private function resetAdapterSelection()
  745. {
  746. $this->adapters = array_map(function (array $properties) {
  747. $properties['selected'] = false;
  748. return $properties;
  749. }, $this->adapters);
  750. }
  751. }