Skip to content

Commit 602cdee

Browse files
author
Benoit Leveque
committed
replace INF to PHP_INT_MAX inside Finder component.
bug issue introduced by 7c66dff
1 parent 02da7da commit 602cdee

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

src/Symfony/Component/Finder/Adapter/AbstractAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ abstract class AbstractAdapter implements AdapterInterface
2121
protected $followLinks = false;
2222
protected $mode = 0;
2323
protected $minDepth = 0;
24-
protected $maxDepth = INF;
24+
protected $maxDepth = PHP_INT_MAX;
2525
protected $exclude = array();
2626
protected $names = array();
2727
protected $notNames = array();
@@ -76,7 +76,7 @@ public function setMode($mode)
7676
public function setDepths(array $depths)
7777
{
7878
$this->minDepth = 0;
79-
$this->maxDepth = INF;
79+
$this->maxDepth = PHP_INT_MAX;
8080

8181
foreach ($depths as $comparator) {
8282
switch ($comparator->getOperator()) {

src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ public function searchInDirectory($dir)
6060
}
6161

6262
$find->add('-mindepth')->add($this->minDepth + 1);
63-
// warning! INF < INF => true ; INF == INF => false ; INF === INF => true
64-
// https://bugs.php.net/bug.php?id=9118
65-
if (INF !== $this->maxDepth) {
63+
64+
if (PHP_INT_MAX !== $this->maxDepth) {
6665
$find->add('-maxdepth')->add($this->maxDepth + 1);
6766
}
6867

src/Symfony/Component/Finder/Adapter/PhpAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function searchInDirectory($dir)
3636
\RecursiveIteratorIterator::SELF_FIRST
3737
);
3838

39-
if ($this->minDepth > 0 || $this->maxDepth < INF) {
39+
if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) {
4040
$iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth);
4141
}
4242

src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class DepthRangeFilterIterator extends FilterIterator
2727
* @param int $minDepth The min depth
2828
* @param int $maxDepth The max depth
2929
*/
30-
public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = INF)
30+
public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = PHP_INT_MAX)
3131
{
3232
$this->minDepth = $minDepth;
3333
$iterator->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);

src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public function getAcceptData()
7272
return array(
7373
array(0, 0, $this->toAbsolute($lessThan1)),
7474
array(0, 1, $this->toAbsolute($lessThanOrEqualTo1)),
75-
array(2, INF, array()),
76-
array(1, INF, $this->toAbsolute($graterThanOrEqualTo1)),
75+
array(2, PHP_INT_MAX, array()),
76+
array(1, PHP_INT_MAX, $this->toAbsolute($graterThanOrEqualTo1)),
7777
array(1, 1, $this->toAbsolute($equalTo1)),
7878
);
7979
}

0 commit comments

Comments
 (0)