Skip to content

Commit aa84e2d

Browse files
committed
[Finder] Fixed typos, CS and small errors.
1 parent 144c61b commit aa84e2d

File tree

9 files changed

+58
-49
lines changed

9 files changed

+58
-49
lines changed

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

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,11 @@ private function buildNamesCommand(Command $command, array $names, $not = false)
154154

155155
// Fixes 'not search' regex problem.
156156
if ($expr->isRegex()) {
157-
$expr->prepend($expr->hasStartFlag() ? '/' : '/.*')->setStartFlag(false)->setStartJoker(true);
157+
$regex = $expr->getRegex();
158+
$regex->prepend($regex->hasStartFlag() ? '/' : '/.*')->setStartFlag(false)->setStartJoker(true);
158159

159-
if (!$expr->hasEndFlag()) {
160-
$expr->setEndJoker(true);
160+
if (!$regex->hasEndFlag()) {
161+
$regex->setEndJoker(true);
161162
}
162163
}
163164

@@ -280,12 +281,23 @@ private function buildContainsCommand(Command $command, array $contains, $not =
280281
private function buildSortCommand(Command $command, $sort)
281282
{
282283
switch ($sort) {
283-
case SortableIterator::SORT_BY_NAME: $format = null; break;
284-
case SortableIterator::SORT_BY_TYPE: $format = '%y'; break;
285-
case SortableIterator::SORT_BY_ACCESSED_TIME: $format = '%A@'; break;
286-
case SortableIterator::SORT_BY_CHANGED_TIME: $format = '%C@'; break;
287-
case SortableIterator::SORT_BY_MODIFIED_TIME: $format = '%T@'; break;
288-
default: throw new \InvalidArgumentException('Unknown sort options: '.$sort.'.');
284+
case SortableIterator::SORT_BY_NAME:
285+
$format = null;
286+
break;
287+
case SortableIterator::SORT_BY_TYPE:
288+
$format = '%y';
289+
break;
290+
case SortableIterator::SORT_BY_ACCESSED_TIME:
291+
$format = '%A@';
292+
break;
293+
case SortableIterator::SORT_BY_CHANGED_TIME:
294+
$format = '%C@';
295+
break;
296+
case SortableIterator::SORT_BY_MODIFIED_TIME:
297+
$format = '%T@';
298+
break;
299+
default:
300+
throw new \InvalidArgumentException('Unknown sort options: '.$sort.'.');
289301
}
290302

291303
$command->get('find')->add('-printf')->arg($format.' %h/%f\\n');

src/Symfony/Component/Finder/Exception/AdapterFailureException.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
*
1919
* @author Jean-François Simon <contact@jfsimon.fr>
2020
*/
21-
class AdapterFailureException extends \RuntimeException
21+
class AdapterFailureException extends \RuntimeException implements ExceptionInterface
2222
{
2323
/**
2424
* @var \Symfony\Component\Finder\Adapter\AdapterInterface
2525
*/
2626
private $adapter;
2727

2828
/**
29-
* @param \Symfony\Component\Finder\Adapter\AdapterInterface $adapter
30-
* @param string|null $message
31-
* @param \Exception|null $previous
29+
* @param AdapterInterface $adapter
30+
* @param string|null $message
31+
* @param \Exception|null $previous
3232
*/
3333
public function __construct(AdapterInterface $adapter, $message = null, \Exception $previous = null)
3434
{
@@ -37,7 +37,7 @@ public function __construct(AdapterInterface $adapter, $message = null, \Excepti
3737
}
3838

3939
/**
40-
* @return \Symfony\Component\Finder\Adapter\AdapterInterface
40+
* {@inheritdoc}
4141
*/
4242
public function getAdapter()
4343
{
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Symfony\Component\Finder\Exception;
4+
5+
/**
6+
* @author Jean-François Simon <contact@jfsimon.fr>
7+
*/
8+
interface ExceptionInterface
9+
{
10+
/**
11+
* @return \Symfony\Component\Finder\Adapter\AdapterInterface
12+
*/
13+
function getAdapter();
14+
}

src/Symfony/Component/Finder/Expression/Expression.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,6 @@ public function __toString()
5454
return $this->render();
5555
}
5656

57-
/**
58-
* @param string $method
59-
* @param array $arguments
60-
*
61-
* @return mixed
62-
*/
63-
public function __call($method, array $arguments)
64-
{
65-
return call_user_func_array(array($this->value, $method), $arguments);
66-
}
67-
6857
/**
6958
* {@inheritdoc}
7059
*/

src/Symfony/Component/Finder/Finder.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\Finder;
1313

1414
use Symfony\Component\Finder\Adapter;
15-
use Symfony\Component\Finder\Exception\AdapterFailureException;
15+
use Symfony\Component\Finder\Exception\ExceptionInterface;
1616

1717
/**
1818
* Finder allows to build rules to find files and directories.
@@ -82,7 +82,7 @@ public static function create()
8282
* @param Adapter\AdapterInterface $adapter An adapter instance
8383
* @param int $priority Highest is selected first
8484
*
85-
* @return \Symfony\Component\Finder\Finder The current Finder instance
85+
* @return Finder The current Finder instance
8686
*/
8787
public function register(Adapter\AdapterInterface $adapter, $priority = 0)
8888
{
@@ -97,7 +97,7 @@ public function register(Adapter\AdapterInterface $adapter, $priority = 0)
9797
/**
9898
* Removes all adapters registered in the finder.
9999
*
100-
* @return \Symfony\Component\Finder\Finder The current Finder instance
100+
* @return Finder The current Finder instance
101101
*/
102102
public function removeAdapters()
103103
{
@@ -107,7 +107,7 @@ public function removeAdapters()
107107
}
108108

109109
/**
110-
* Returns reegistered adapters ordered by priority without extra informations.
110+
* Returns registered adapters ordered by priority without extra information.
111111
*
112112
* @return \Symfony\Component\Finder\Adapter\AdapterInterface[]
113113
*/
@@ -654,7 +654,7 @@ private function searchInDirectory($dir)
654654
return $this
655655
->buildAdapter($adapter['adapter'])
656656
->searchInDirectory($dir);
657-
} catch(AdapterFailureException $e) {
657+
} catch(ExceptionInterface $e) {
658658
continue;
659659
}
660660
}

src/Symfony/Component/Finder/Shell/Command.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __toString()
6060
*
6161
* @return Command New Command instance
6262
*/
63-
static public function create(Command $parent = null)
63+
public static function create(Command $parent = null)
6464
{
6565
return new self($parent);
6666
}
@@ -72,7 +72,7 @@ static public function create(Command $parent = null)
7272
*
7373
* @return string The escaped string
7474
*/
75-
static public function escape($input)
75+
public static function escape($input)
7676
{
7777
return escapeshellcmd($input);
7878
}
@@ -84,7 +84,7 @@ static public function escape($input)
8484
*
8585
* @return string The quoted string
8686
*/
87-
static public function quote($input)
87+
public static function quote($input)
8888
{
8989
return escapeshellarg($input);
9090
}

src/Symfony/Component/Finder/Tests/Expression/GlobTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313

1414
use Symfony\Component\Finder\Expression\Expression;
1515

16-
/**
17-
* @author Jean-François Simon <contact@jfsimon.fr>
18-
*/
1916
class GlobTest extends \PHPUnit_Framework_TestCase
2017
{
2118
/**

src/Symfony/Component/Finder/Tests/Expression/RegexTest.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313

1414
use Symfony\Component\Finder\Expression\Expression;
1515

16-
/**
17-
* @author Jean-François Simon <contact@jfsimon.fr>
18-
*/
1916
class RegexTest extends \PHPUnit_Framework_TestCase
2017
{
2118
/**
@@ -25,8 +22,8 @@ public function testHasFlags($regex, $start, $end)
2522
{
2623
$expr = new Expression($regex);
2724

28-
$this->assertEquals($start, $expr->hasStartFlag());
29-
$this->assertEquals($end, $expr->hasEndFlag());
25+
$this->assertEquals($start, $expr->getRegex()->hasStartFlag());
26+
$this->assertEquals($end, $expr->getRegex()->hasEndFlag());
3027
}
3128

3229
/**
@@ -36,8 +33,8 @@ public function testHasJokers($regex, $start, $end)
3633
{
3734
$expr = new Expression($regex);
3835

39-
$this->assertEquals($start, $expr->hasStartJoker());
40-
$this->assertEquals($end, $expr->hasEndJoker());
36+
$this->assertEquals($start, $expr->getRegex()->hasStartJoker());
37+
$this->assertEquals($end, $expr->getRegex()->hasEndJoker());
4138
}
4239

4340
/**
@@ -46,7 +43,7 @@ public function testHasJokers($regex, $start, $end)
4643
public function testSetFlags($regex, $start, $end, $expected)
4744
{
4845
$expr = new Expression($regex);
49-
$expr->setStartFlag($start)->setEndFlag($end);
46+
$expr->getRegex()->setStartFlag($start)->setEndFlag($end);
5047

5148
$this->assertEquals($expected, $expr->render());
5249
}
@@ -57,15 +54,15 @@ public function testSetFlags($regex, $start, $end, $expected)
5754
public function testSetJokers($regex, $start, $end, $expected)
5855
{
5956
$expr = new Expression($regex);
60-
$expr->setStartJoker($start)->setEndJoker($end);
57+
$expr->getRegex()->setStartJoker($start)->setEndJoker($end);
6158

6259
$this->assertEquals($expected, $expr->render());
6360
}
6461

6562
public function testOptions()
6663
{
6764
$expr = new Expression('~abc~is');
68-
$expr->removeOption('i')->addOption('m');
65+
$expr->getRegex()->removeOption('i')->addOption('m');
6966

7067
$this->assertEquals('~abc~sm', $expr->render());
7168
}
@@ -74,10 +71,10 @@ public function testMixFlagsAndJokers()
7471
{
7572
$expr = new Expression('~^.*abc.*$~is');
7673

77-
$expr->setStartFlag(false)->setEndFlag(false)->setStartJoker(false)->setEndJoker(false);
74+
$expr->getRegex()->setStartFlag(false)->setEndFlag(false)->setStartJoker(false)->setEndJoker(false);
7875
$this->assertEquals('~abc~is', $expr->render());
7976

80-
$expr->setStartFlag(true)->setEndFlag(true)->setStartJoker(true)->setEndJoker(true);
77+
$expr->getRegex()->setStartFlag(true)->setEndFlag(true)->setStartJoker(true)->setEndJoker(true);
8178
$this->assertEquals('~^.*abc.*$~is', $expr->render());
8279
}
8380

src/Symfony/Component/Finder/Tests/FakeAdapter/DummyAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function isSupported()
5151
/**
5252
* {@inheritdoc}
5353
*/
54-
function getName()
54+
public function getName()
5555
{
5656
return 'yes';
5757
}

0 commit comments

Comments
 (0)