1 | <?php |
||
2 | |||
3 | namespace Apps\Model\Admin\Comments; |
||
4 | |||
5 | use Apps\ActiveRecord\CommentAnswer; |
||
6 | use Apps\ActiveRecord\CommentPost; |
||
7 | use Ffcms\Core\Arch\Model; |
||
8 | use Illuminate\Support\Collection; |
||
9 | |||
10 | /** |
||
11 | * Class FormCommentDelete. Process comments and answers delete |
||
12 | * @package Apps\Model\Admin\Comments |
||
13 | */ |
||
14 | class FormCommentDelete extends Model |
||
15 | { |
||
16 | private $_record; |
||
17 | private $_type; |
||
18 | |||
19 | /** |
||
20 | * FormCommentDelete constructor. Pass active record and type of comment system inside. |
||
21 | * @param CommentPost[]|CommentAnswer[]|Collection $record |
||
22 | * @param string $type |
||
23 | */ |
||
24 | public function __construct($record, $type) |
||
25 | { |
||
26 | $this->_record = $record; |
||
27 | $this->_type = $type; |
||
28 | parent::__construct(); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * Make delete items after submit |
||
33 | */ |
||
34 | public function make() |
||
35 | { |
||
36 | // also delete all answers |
||
37 | if ($this->_type === 'comment') { |
||
38 | foreach ($this->getRecord() as $com) { |
||
39 | /** @var CommentPost $com */ |
||
40 | $com->answers()->delete(); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | $this->_record->delete(); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Get records to delete as object |
||
49 | * @return CommentAnswer[]|CommentPost[]|Collection |
||
50 | */ |
||
51 | public function getRecord() |
||
52 | { |
||
53 | return $this->_record->get(); |
||
0 ignored issues
–
show
|
|||
54 | } |
||
55 | } |
||
56 |
This check compares calls to functions or methods with their respective definitions. If the call has less 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. Please note the @ignore annotation hint above.