From 602cdeeaed888660bb1cee72917f0537812b22a1 Mon Sep 17 00:00:00 2001 From: Benoit Leveque Date: Tue, 12 Mar 2013 12:39:20 +0100 Subject: [PATCH] replace INF to PHP_INT_MAX inside Finder component. bug issue introduced by 7c66dffa6b --- src/Symfony/Component/Finder/Adapter/AbstractAdapter.php | 4 ++-- src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php | 5 ++--- src/Symfony/Component/Finder/Adapter/PhpAdapter.php | 2 +- .../Component/Finder/Iterator/DepthRangeFilterIterator.php | 2 +- .../Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php | 4 ++-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/Finder/Adapter/AbstractAdapter.php b/src/Symfony/Component/Finder/Adapter/AbstractAdapter.php index 839a601638265..477a58a073296 100644 --- a/src/Symfony/Component/Finder/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Finder/Adapter/AbstractAdapter.php @@ -21,7 +21,7 @@ abstract class AbstractAdapter implements AdapterInterface protected $followLinks = false; protected $mode = 0; protected $minDepth = 0; - protected $maxDepth = INF; + protected $maxDepth = PHP_INT_MAX; protected $exclude = array(); protected $names = array(); protected $notNames = array(); @@ -76,7 +76,7 @@ public function setMode($mode) public function setDepths(array $depths) { $this->minDepth = 0; - $this->maxDepth = INF; + $this->maxDepth = PHP_INT_MAX; foreach ($depths as $comparator) { switch ($comparator->getOperator()) { diff --git a/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php b/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php index b0aef4d0cf334..d521a55bbc04c 100644 --- a/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php +++ b/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php @@ -60,9 +60,8 @@ public function searchInDirectory($dir) } $find->add('-mindepth')->add($this->minDepth + 1); - // warning! INF < INF => true ; INF == INF => false ; INF === INF => true - // https://bugs.php.net/bug.php?id=9118 - if (INF !== $this->maxDepth) { + + if (PHP_INT_MAX !== $this->maxDepth) { $find->add('-maxdepth')->add($this->maxDepth + 1); } diff --git a/src/Symfony/Component/Finder/Adapter/PhpAdapter.php b/src/Symfony/Component/Finder/Adapter/PhpAdapter.php index dfc842f6b5502..7abdcdad52472 100644 --- a/src/Symfony/Component/Finder/Adapter/PhpAdapter.php +++ b/src/Symfony/Component/Finder/Adapter/PhpAdapter.php @@ -36,7 +36,7 @@ public function searchInDirectory($dir) \RecursiveIteratorIterator::SELF_FIRST ); - if ($this->minDepth > 0 || $this->maxDepth < INF) { + if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) { $iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth); } diff --git a/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php b/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php index 97f18cb0997f5..67cf5ded0e357 100644 --- a/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php @@ -27,7 +27,7 @@ class DepthRangeFilterIterator extends FilterIterator * @param int $minDepth The min depth * @param int $maxDepth The max depth */ - public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = INF) + public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = PHP_INT_MAX) { $this->minDepth = $minDepth; $iterator->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth); diff --git a/src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php index bb4508861e62b..be06f1cdd34cd 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php @@ -72,8 +72,8 @@ public function getAcceptData() return array( array(0, 0, $this->toAbsolute($lessThan1)), array(0, 1, $this->toAbsolute($lessThanOrEqualTo1)), - array(2, INF, array()), - array(1, INF, $this->toAbsolute($graterThanOrEqualTo1)), + array(2, PHP_INT_MAX, array()), + array(1, PHP_INT_MAX, $this->toAbsolute($graterThanOrEqualTo1)), array(1, 1, $this->toAbsolute($equalTo1)), ); }