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 | * @author Joas Schilling <[email protected]> |
||
4 | * |
||
5 | * @copyright Copyright (c) 2016, ownCloud, Inc. |
||
6 | * @license AGPL-3.0 |
||
7 | * |
||
8 | * This code is free software: you can redistribute it and/or modify |
||
9 | * it under the terms of the GNU Affero General Public License, version 3, |
||
10 | * as published by the Free Software Foundation. |
||
11 | * |
||
12 | * This program is distributed in the hope that it will be useful, |
||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
15 | * GNU Affero General Public License for more details. |
||
16 | * |
||
17 | * You should have received a copy of the GNU Affero General Public License, version 3, |
||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/> |
||
19 | * |
||
20 | */ |
||
21 | |||
22 | namespace OCA\Activity\Parameter; |
||
23 | |||
24 | use OCA\Activity\Formatter\BaseFormatter; |
||
25 | use OCA\Activity\Formatter\GroupFormatter; |
||
26 | use OCA\Activity\Formatter\IFormatter; |
||
27 | use OCA\Activity\Formatter\CloudIDFormatter; |
||
28 | use OCA\Activity\Formatter\FileFormatter; |
||
29 | use OCA\Activity\Formatter\UserFormatter; |
||
30 | use OCA\Activity\ViewInfoCache; |
||
31 | use OCP\Activity\IEvent; |
||
32 | use OCP\Activity\IManager; |
||
33 | use OCP\Contacts\IManager as IContactsManager; |
||
34 | use OCP\IConfig; |
||
35 | use OCP\IGroupManager; |
||
36 | use OCP\IL10N; |
||
37 | use OCP\IURLGenerator; |
||
38 | use OCP\IUserManager; |
||
39 | |||
40 | class Factory { |
||
41 | /** @var IManager */ |
||
42 | protected $activityManager; |
||
43 | |||
44 | /** @var IUserManager */ |
||
45 | protected $userManager; |
||
46 | |||
47 | /** @var IContactsManager */ |
||
48 | protected $contactsManager; |
||
49 | |||
50 | /** @var IL10N */ |
||
51 | protected $l; |
||
52 | |||
53 | /** @var IGroupManager */ |
||
54 | protected $groupManager; |
||
55 | |||
56 | /** @var ViewInfoCache */ |
||
57 | protected $infoCache; |
||
58 | |||
59 | /** @var string */ |
||
60 | protected $user; |
||
61 | |||
62 | /** @var IURLGenerator */ |
||
63 | protected $urlGenerator; |
||
64 | |||
65 | /** |
||
66 | * @param IManager $activityManager |
||
67 | * @param IUserManager $userManager |
||
68 | * @param IURLGenerator $urlGenerator |
||
69 | * @param IContactsManager $contactsManager |
||
70 | * @param ViewInfoCache $infoCache, |
||
0 ignored issues
–
show
|
|||
71 | * @param IL10N $l |
||
72 | * @param string $user |
||
73 | */ |
||
74 | 21 | View Code Duplication | public function __construct(IManager $activityManager, |
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
75 | IUserManager $userManager, |
||
76 | IURLGenerator $urlGenerator, |
||
77 | IContactsManager $contactsManager, |
||
78 | ViewInfoCache $infoCache, |
||
79 | IL10N $l, |
||
80 | IGroupManager $groupManager, |
||
81 | $user) { |
||
82 | 21 | $this->activityManager = $activityManager; |
|
83 | 21 | $this->userManager = $userManager; |
|
84 | 21 | $this->urlGenerator = $urlGenerator; |
|
85 | 21 | $this->contactsManager = $contactsManager; |
|
86 | 21 | $this->infoCache = $infoCache; |
|
87 | 21 | $this->l = $l; |
|
88 | 21 | $this->groupManager = $groupManager; |
|
89 | 21 | $this->user = $user; |
|
90 | 21 | } |
|
91 | |||
92 | /** |
||
93 | * @param string $user |
||
94 | */ |
||
95 | 7 | public function setUser($user) { |
|
96 | 7 | $this->user = (string) $user; |
|
97 | 7 | } |
|
98 | |||
99 | /** |
||
100 | * @param IL10N $l |
||
101 | */ |
||
102 | 1 | public function setL10n(IL10N $l) { |
|
103 | 1 | $this->l = $l; |
|
104 | 1 | } |
|
105 | |||
106 | /** |
||
107 | * @param string $parameter |
||
108 | * @param IEvent $event |
||
109 | * @param string $formatter |
||
110 | * @return IParameter |
||
111 | */ |
||
112 | 6 | public function get($parameter, IEvent $event, $formatter) { |
|
113 | 6 | return new Parameter( |
|
114 | 6 | $parameter, |
|
115 | 6 | $event, |
|
116 | 6 | $this->getFormatter($formatter), |
|
117 | 6 | $formatter |
|
118 | ); |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * @return Collection |
||
123 | */ |
||
124 | 1 | public function createCollection() { |
|
125 | 1 | return new Collection($this->l, \sha1(\microtime() . \mt_rand())); |
|
126 | } |
||
127 | |||
128 | /** |
||
129 | * @param string $formatter |
||
130 | * @return IFormatter |
||
131 | */ |
||
132 | 9 | protected function getFormatter($formatter) { |
|
133 | 9 | if ($formatter === 'file') { |
|
134 | 5 | return new FileFormatter($this->infoCache, $this->urlGenerator, $this->l, $this->user); |
|
135 | 7 | } elseif ($formatter === 'username') { |
|
136 | 4 | return new UserFormatter($this->userManager, $this->l); |
|
137 | 3 | } elseif ($formatter === 'federated_cloud_id') { |
|
138 | 1 | return new CloudIDFormatter($this->contactsManager); |
|
139 | 2 | } elseif ($formatter === 'group') { |
|
140 | 1 | return new GroupFormatter($this->groupManager); |
|
141 | } else { |
||
142 | 1 | return new BaseFormatter(); |
|
143 | } |
||
144 | } |
||
145 | } |
||
146 |
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
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.