peteraba /
FooGrid
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types = 1); |
||
| 4 | |||
| 5 | namespace Foo\Grid; |
||
| 6 | |||
| 7 | use Foo\Grid\Collection\Actions; |
||
| 8 | use Foo\Grid\Collection\Filters; |
||
| 9 | use Foo\Grid\Component\Component; |
||
| 10 | use Foo\Grid\Helper\StringHelper; |
||
| 11 | use Foo\Grid\Table\ITable; |
||
| 12 | use Foo\Translate\ITranslator; |
||
| 13 | |||
| 14 | class Grid extends Component implements IGrid |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * %1$s - filter |
||
| 18 | * %2$s - actions |
||
| 19 | * %3$s - table |
||
| 20 | */ |
||
| 21 | const TEMPLATE_CONTENT = '%1$s%2$s%3$s'; |
||
| 22 | |||
| 23 | const TAG_GRID = 'div'; |
||
| 24 | const TAG_FILTER = 'div'; |
||
| 25 | const TAG_ACTIONS = 'div'; |
||
| 26 | const TAG_FORM = 'form'; |
||
| 27 | |||
| 28 | const ATTRIBUTE_GRID_CLASS = 'grid'; |
||
| 29 | const ATTRIBUTE_FILTER_CLASS = 'grid-filters'; |
||
| 30 | const ATTRIBUTE_ACTIONS_CLASS = 'grid-actions'; |
||
| 31 | |||
| 32 | const ATTRIBUTES_FORM = ['class' => 'grid-form']; |
||
| 33 | |||
| 34 | /** @var string */ |
||
| 35 | protected $containerClass = ''; |
||
| 36 | |||
| 37 | /** @var ITable */ |
||
| 38 | protected $table; |
||
| 39 | |||
| 40 | /** @var Filters */ |
||
| 41 | protected $filters; |
||
| 42 | |||
| 43 | /** @var Actions */ |
||
| 44 | protected $actions; |
||
| 45 | |||
| 46 | /** @var string */ |
||
| 47 | protected $whitespace; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @param ITable $rows |
||
|
0 ignored issues
–
show
|
|||
| 51 | * @param Filters|null $filters |
||
| 52 | * @param Actions|null $massActions |
||
|
0 ignored issues
–
show
There is no parameter named
$massActions. Did you maybe mean $actions?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit. Consider the following example. The parameter /**
* @param array $germany
* @param array $ireland
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was changed, but the annotation was not. Loading history...
|
|||
| 53 | * @param array $attributes |
||
| 54 | */ |
||
| 55 | 8 | public function __construct( |
|
| 56 | ITable $table, |
||
| 57 | Filters $filters = null, |
||
| 58 | Actions $actions = null, |
||
| 59 | array $attributes = [] |
||
| 60 | ) { |
||
| 61 | 8 | $this->table = $table; |
|
| 62 | |||
| 63 | 8 | parent::__construct('', static::TAG_GRID, $attributes); |
|
| 64 | |||
| 65 | 8 | $this->appendToAttribute(Component::ATTRIBUTE_CLASS, static::ATTRIBUTE_GRID_CLASS); |
|
| 66 | |||
| 67 | 8 | if ($actions) { |
|
| 68 | 3 | $this->actions = $actions; |
|
| 69 | 3 | $this->actions->appendToAttribute(Component::ATTRIBUTE_CLASS, static::ATTRIBUTE_ACTIONS_CLASS); |
|
| 70 | } |
||
| 71 | |||
| 72 | 8 | if ($filters) { |
|
| 73 | 4 | $this->filters = $filters; |
|
| 74 | 4 | $this->filters->appendToAttribute(Component::ATTRIBUTE_CLASS, static::ATTRIBUTE_FILTER_CLASS); |
|
| 75 | } |
||
| 76 | 8 | } |
|
| 77 | |||
| 78 | /** |
||
| 79 | * @param int $num |
||
| 80 | * @param string $whitespace |
||
| 81 | */ |
||
| 82 | 2 | public function setIndentation(int $num, string $whitespace = ' ') |
|
| 83 | { |
||
| 84 | 2 | $indentationStep = $this->filters || $this->actions ? 2 : 1; |
|
| 85 | |||
| 86 | 2 | $this->table->setIndentation($num + $indentationStep, $whitespace); |
|
| 87 | |||
| 88 | 2 | if ($this->filters) { |
|
| 89 | 2 | $this->filters->setIndentation($num + $indentationStep, $whitespace); |
|
| 90 | } |
||
| 91 | |||
| 92 | 2 | $this->indentation = str_repeat($whitespace, $num); |
|
| 93 | 2 | $this->whitespace = $whitespace; |
|
| 94 | 2 | } |
|
| 95 | |||
| 96 | /** |
||
| 97 | * @param ITranslator $translator |
||
| 98 | */ |
||
| 99 | 2 | public function setTranslator(ITranslator $translator) |
|
| 100 | { |
||
| 101 | 2 | $this->table->setTranslator($translator); |
|
| 102 | |||
| 103 | 2 | if ($this->filters) { |
|
| 104 | 1 | $this->filters->setTranslator($translator); |
|
| 105 | } |
||
| 106 | 2 | } |
|
| 107 | |||
| 108 | /** |
||
| 109 | * @return string |
||
| 110 | */ |
||
| 111 | 4 | public function __toString(): string |
|
| 112 | { |
||
| 113 | 4 | $filters = (string)$this->filters; |
|
| 114 | 4 | $actions = $this->actions ? (string)$this->actions : ''; |
|
| 115 | 4 | $table = (string)$this->table; |
|
| 116 | |||
| 117 | 4 | $this->content = sprintf(static::TEMPLATE_CONTENT, $filters, $actions, $table); |
|
| 118 | |||
| 119 | 4 | $this->wrapContentInForm(); |
|
| 120 | |||
| 121 | 4 | return parent::__toString(); |
|
| 122 | } |
||
| 123 | |||
| 124 | /** |
||
| 125 | * @return ITable |
||
| 126 | */ |
||
| 127 | public function getTable(): ITable |
||
| 128 | { |
||
| 129 | return $this->table; |
||
| 130 | } |
||
| 131 | |||
| 132 | /** |
||
| 133 | * @param Filters $filters |
||
| 134 | */ |
||
| 135 | public function setFilter(Filters $filters) |
||
| 136 | { |
||
| 137 | $this->filters = $filters; |
||
| 138 | } |
||
| 139 | |||
| 140 | 4 | protected function wrapContentInForm() |
|
| 141 | { |
||
| 142 | 4 | if (!$this->actions && !$this->filters) { |
|
| 143 | 3 | return; |
|
| 144 | } |
||
| 145 | |||
| 146 | 1 | $whitespace = $this->indentation . $this->whitespace; |
|
| 147 | |||
| 148 | 1 | $this->content = StringHelper::wrapInTag( |
|
| 149 | 1 | $this->content, |
|
| 150 | 1 | static::TAG_FORM, |
|
| 151 | 1 | static::ATTRIBUTES_FORM, |
|
| 152 | $whitespace |
||
| 153 | ); |
||
| 154 | 1 | } |
|
| 155 | } |
||
| 156 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.