Skip to content

Commit c6b7b24

Browse files
committedNov 13, 2014
Replace Zend\Filter with a custom SimpleFilter
1 parent da580dc commit c6b7b24

File tree

10 files changed

+70
-122
lines changed

10 files changed

+70
-122
lines changed
 

‎composer.json

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"nikic/php-parser": "~1.0",
1616
"phpdocumentor/reflection-docblock": "~2.0",
1717
"symfony/validator": "~2.2",
18-
"zendframework/zend-filter": "~2.1",
1918
"symfony/filesystem": "~2.3"
2019
},
2120
"suggests": {

‎composer.lock

+45-96
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/phpDocumentor/Descriptor/Filter/ClassFactory.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@
1111

1212
namespace phpDocumentor\Descriptor\Filter;
1313

14-
use Zend\Filter\FilterChain;
14+
use phpDocumentor\SimpleFilter\Chain;
1515

1616
/**
1717
* Retrieves a series of filters to manipulate a specific Descriptor with during building.
1818
*/
1919
class ClassFactory
2020
{
21-
/** @var FilterChain[] */
21+
/** @var Chain[] */
2222
protected $chains = array();
2323

2424
/**
2525
* Retrieves the filters for a class with a given FQCN.
2626
*
2727
* @param string $fqcn
2828
*
29-
* @return FilterChain
29+
* @return Chain
3030
*/
3131
public function getChainFor($fqcn)
3232
{
3333
if (!isset($this->chains[$fqcn])) {
34-
$this->chains[$fqcn] = new FilterChain();
34+
$this->chains[$fqcn] = new Chain();
3535
}
3636

3737
return $this->chains[$fqcn];

‎src/phpDocumentor/Descriptor/Filter/Filter.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
*/
1111

1212
namespace phpDocumentor\Descriptor\Filter;
13-
14-
use Zend\Filter\FilterInterface;
13+
use phpDocumentor\SimpleFilter\FilterInterface;
1514

1615
/**
1716
* Filter used to manipulate a descriptor after being build.
@@ -46,7 +45,7 @@ public function __construct($factory)
4645
*
4746
* @return void
4847
*/
49-
public function attach($fqcn, $filter, $priority = self::DEFAULT_PRIORITY)
48+
public function attach($fqcn, FilterInterface $filter, $priority = self::DEFAULT_PRIORITY)
5049
{
5150
$chain = $this->factory->getChainFor($fqcn);
5251
$chain->attach($filter, $priority);

‎src/phpDocumentor/Descriptor/Filter/StripIgnore.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313

1414
use phpDocumentor\Descriptor\DescriptorAbstract;
1515
use phpDocumentor\Descriptor\Analyzer;
16-
use Zend\Filter\AbstractFilter;
16+
use phpDocumentor\SimpleFilter\FilterInterface;
1717

1818
/**
1919
* Strips any Descriptor if the ignore tag is present with that element.
2020
*/
21-
class StripIgnore extends AbstractFilter
21+
class StripIgnore implements FilterInterface
2222
{
2323
/** @var Analyzer $analyzer */
2424
protected $analyzer;

‎src/phpDocumentor/Descriptor/Filter/StripInternal.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use phpDocumentor\Descriptor\DescriptorAbstract;
1515
use phpDocumentor\Descriptor\ProjectDescriptor\Settings;
1616
use phpDocumentor\Descriptor\Analyzer;
17-
use Zend\Filter\AbstractFilter;
17+
use phpDocumentor\SimpleFilter\FilterInterface;
1818

1919
/**
2020
* Filters a Descriptor when the @internal inline tag, or normal tag, is used.
@@ -27,7 +27,7 @@
2727
*
2828
* @link http://www.phpdoc.org/docs/latest/for-users/phpdoc/tags/internal.html
2929
*/
30-
class StripInternal extends AbstractFilter
30+
class StripInternal implements FilterInterface
3131
{
3232
/** @var Analyzer $analyzer */
3333
protected $analyzer;

‎src/phpDocumentor/Descriptor/Filter/StripOnVisibility.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
use phpDocumentor\Descriptor\DescriptorAbstract;
1515
use phpDocumentor\Descriptor\Interfaces\VisibilityInterface;
1616
use phpDocumentor\Descriptor\Analyzer;
17-
use Zend\Filter\AbstractFilter;
17+
use phpDocumentor\SimpleFilter\FilterInterface;
1818

1919
/**
2020
* Strips any Descriptor if their visibility is allowed according to the Analyzer.
2121
*/
22-
class StripOnVisibility extends AbstractFilter
22+
class StripOnVisibility implements FilterInterface
2323
{
2424
/** @var Analyzer $analyzer */
2525
protected $analyzer;

‎src/phpDocumentor/SimpleFilter/Chain.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
final class Chain implements FilterInterface, \Countable, \IteratorAggregate
1818
{
19+
const DEFAULT_PRIORITY = 1000;
20+
1921
/** @var \SplPriorityQueue */
2022
private $innerQueue;
2123

@@ -38,7 +40,7 @@ public function __construct()
3840
*
3941
* @return $this
4042
*/
41-
public function attach($filter, $priority = 1000)
43+
public function attach($filter, $priority = self::DEFAULT_PRIORITY)
4244
{
4345
if ($filter instanceof FilterInterface) {
4446
$filter = array($filter, 'filter');

‎tests/unit/phpDocumentor/Descriptor/Filter/ClassFactoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ public function testGetChainForReturnsInstanceOfFilterChain()
3434
{
3535
$filterChain = $this->fixture->getChainFor('foo');
3636

37-
$this->assertInstanceOf('Zend\Filter\FilterChain', $filterChain);
37+
$this->assertInstanceOf('phpDocumentor\SimpleFilter\Chain', $filterChain);
3838
}
3939
}

‎tests/unit/phpDocumentor/Descriptor/Filter/FilterTest.php

+9-10
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
namespace phpDocumentor\Descriptor\Filter;
1313

1414
use \Mockery as m;
15-
use \Zend\Filter\FilterChain;
15+
use phpDocumentor\SimpleFilter\Chain;
1616

1717
/**
1818
* Tests the functionality for the Filter class.
19-
* @group broken
2019
*/
2120
class FilterTest extends \PHPUnit_Framework_TestCase
2221
{
@@ -25,8 +24,8 @@ class FilterTest extends \PHPUnit_Framework_TestCase
2524
/** @var ClassFactory|m\Mock */
2625
protected $classFactoryMock;
2726

28-
/** @var FilterChain|m\Mock */
29-
protected $filterChainMock;
27+
/** @var Chain|m\Mock */
28+
protected $chainMock;
3029

3130
/** @var Filter $fixture */
3231
protected $fixture;
@@ -37,7 +36,7 @@ class FilterTest extends \PHPUnit_Framework_TestCase
3736
protected function setUp()
3837
{
3938
$this->classFactoryMock = m::mock('phpDocumentor\Descriptor\Filter\ClassFactory');
40-
$this->filterChainMock = m::mock('Zend\Filter\FilterChain');
39+
$this->chainMock = m::mock(new Chain());
4140
$this->fixture = new Filter($this->classFactoryMock);
4241
}
4342

@@ -54,10 +53,10 @@ public function testClassFactoryIsSetUponConstruction()
5453
*/
5554
public function testAttach()
5655
{
57-
$filterMock = m::mock('Zend\Filter\FilterInterface');
56+
$filterMock = m::mock('phpDocumentor\SimpleFilter\FilterInterface');
5857

59-
$this->filterChainMock->shouldReceive('attach')->with($filterMock, FilterChain::DEFAULT_PRIORITY);
60-
$this->classFactoryMock->shouldReceive('getChainFor')->with(self::FQCN)->andReturn($this->filterChainMock);
58+
$this->chainMock->shouldReceive('attach')->with($filterMock, Chain::DEFAULT_PRIORITY);
59+
$this->classFactoryMock->shouldReceive('getChainFor')->with(self::FQCN)->andReturn($this->chainMock);
6160

6261
$this->fixture->attach(self::FQCN, $filterMock);
6362
}
@@ -69,9 +68,9 @@ public function testFilter()
6968
{
7069
$filterableMock = m::mock('phpDocumentor\Descriptor\Filter\Filterable');
7170

72-
$this->filterChainMock->shouldReceive('filter')->with($filterableMock)->andReturn($filterableMock);
71+
$this->chainMock->shouldReceive('filter')->with($filterableMock)->andReturn($filterableMock);
7372
$this->classFactoryMock
74-
->shouldReceive('getChainFor')->with(get_class($filterableMock))->andReturn($this->filterChainMock);
73+
->shouldReceive('getChainFor')->with(get_class($filterableMock))->andReturn($this->chainMock);
7574

7675
$this->assertSame($filterableMock, $this->fixture->filter($filterableMock));
7776
}

0 commit comments

Comments
 (0)
Please sign in to comment.