These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | declare(strict_types=1); |
||
3 | |||
4 | /** |
||
5 | * This file is part of phpDocumentor. |
||
6 | * |
||
7 | * For the full copyright and license information, please view the LICENSE |
||
8 | * file that was distributed with this source code. |
||
9 | * |
||
10 | * @author Mike van Riel <[email protected]> |
||
11 | * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com) |
||
12 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
||
13 | * @link http://phpdoc.org |
||
14 | */ |
||
15 | |||
16 | namespace phpDocumentor\Descriptor\Filter; |
||
17 | |||
18 | use phpDocumentor\Descriptor\ProjectDescriptorBuilder; |
||
19 | use Zend\Filter\FilterInterface; |
||
20 | |||
21 | /** |
||
22 | * Filter used to manipulate a descriptor after being build. |
||
23 | * |
||
24 | * This class is used during the building of descriptors. It passes the descriptor to each individual sub-filter, which |
||
25 | * may change data in the descriptor or even remove it from the building process by returning null. |
||
26 | */ |
||
27 | class Filter |
||
28 | { |
||
29 | /** @var int default priority for a filter in the series of filters. */ |
||
30 | const DEFAULT_PRIORITY = 1000; |
||
31 | |||
32 | /** @var ClassFactory */ |
||
33 | protected $factory; |
||
34 | |||
35 | /** |
||
36 | * Constructs the filter and attaches the factory to it. |
||
37 | */ |
||
38 | 1 | public function __construct(ClassFactory $factory) |
|
39 | { |
||
40 | 1 | $this->factory = $factory; |
|
41 | 1 | } |
|
42 | |||
43 | public function attachDefaults(ProjectDescriptorBuilder $descriptorBuilder): void |
||
44 | { |
||
45 | $stripOnVisibility = new StripOnVisibility($descriptorBuilder); |
||
46 | $filtersOnAllDescriptors = [ |
||
47 | new StripInternal($descriptorBuilder), |
||
48 | new StripIgnore($descriptorBuilder), |
||
49 | ]; |
||
50 | |||
51 | foreach ($filtersOnAllDescriptors as $filter) { |
||
52 | $this->attach('phpDocumentor\Descriptor\ConstantDescriptor', $filter); |
||
53 | $this->attach('phpDocumentor\Descriptor\FunctionDescriptor', $filter); |
||
54 | $this->attach('phpDocumentor\Descriptor\InterfaceDescriptor', $filter); |
||
55 | $this->attach('phpDocumentor\Descriptor\TraitDescriptor', $filter); |
||
56 | $this->attach('phpDocumentor\Descriptor\PropertyDescriptor', $filter); |
||
57 | $this->attach('phpDocumentor\Descriptor\MethodDescriptor', $filter); |
||
58 | } |
||
59 | |||
60 | $this->attach('phpDocumentor\Descriptor\PropertyDescriptor', $stripOnVisibility); |
||
61 | $this->attach('phpDocumentor\Descriptor\MethodDescriptor', $stripOnVisibility); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Attaches a filter to a specific FQCN. |
||
66 | */ |
||
67 | 1 | public function attach(string $fqcn, FilterInterface $filter, int $priority = self::DEFAULT_PRIORITY): void |
|
68 | { |
||
69 | 1 | $chain = $this->factory->getChainFor($fqcn); |
|
70 | 1 | $chain->attach($filter, $priority); |
|
0 ignored issues
–
show
|
|||
71 | 1 | } |
|
72 | |||
73 | /** |
||
74 | * Filters the given Descriptor and returns the altered object. |
||
75 | */ |
||
76 | 1 | public function filter(Filterable $descriptor): ?Filterable |
|
77 | { |
||
78 | 1 | $chain = $this->factory->getChainFor(get_class($descriptor)); |
|
79 | |||
80 | 1 | return $chain->filter($descriptor); |
|
81 | } |
||
82 | } |
||
83 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: