These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace ViewComponents\Grids\Component; |
||
4 | |||
5 | use ViewComponents\Grids\Grid; |
||
6 | use ViewComponents\ViewComponents\Base\Compound\PartInterface; |
||
7 | use ViewComponents\ViewComponents\Base\Compound\PartTrait; |
||
8 | use ViewComponents\ViewComponents\Component\Compound; |
||
9 | use ViewComponents\ViewComponents\Component\DataView; |
||
10 | use ViewComponents\ViewComponents\Component\Html\Tag; |
||
11 | |||
12 | /** |
||
13 | * This class is a component for rendering grid caption using 'caption' tag. |
||
14 | */ |
||
15 | class TableCaption extends Tag implements PartInterface |
||
16 | { |
||
17 | use PartTrait { |
||
18 | PartTrait::attachToCompound as private attachToCompoundInternal; |
||
19 | } |
||
20 | |||
21 | const ID = 'caption'; |
||
22 | |||
23 | /** @var DataView */ |
||
24 | private $text; |
||
25 | |||
26 | /** |
||
27 | * TableCaption constructor. |
||
28 | * |
||
29 | * @param null|string $text |
||
30 | * @param array $attributes caption tag attributes |
||
31 | */ |
||
32 | public function __construct($text, $attributes = []) |
||
33 | { |
||
34 | parent::__construct('caption', $attributes); |
||
35 | $this->setDestinationParentId(Grid::TABLE_ID); |
||
36 | $this->setId(static::ID); |
||
37 | $this->addChild($this->text = new DataView($text)); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * This method is overridden for adding caption to beginning |
||
42 | * of parent container instead of default appending. |
||
43 | * |
||
44 | * @param Compound $root |
||
45 | * @param bool $prepend |
||
46 | */ |
||
47 | public function attachToCompound(Compound $root, $prepend = true) |
||
48 | { |
||
49 | $this->attachToCompoundInternal($root, $prepend); |
||
0 ignored issues
–
show
|
|||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Returns caption text. |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | public function getText() |
||
58 | { |
||
59 | return $this->text; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Sets caption text. |
||
64 | * |
||
65 | * @param string $text |
||
66 | */ |
||
67 | public function setText($text) |
||
68 | { |
||
69 | $this->text->setData($text); |
||
70 | } |
||
71 | } |
||
72 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.