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 | namespace PHPDaemon\Clients\IRC; |
||
3 | |||
4 | use PHPDaemon\Structures\ObjectStorage; |
||
5 | use PHPDaemon\Utils\IRC; |
||
6 | |||
7 | /** |
||
8 | * @package NetworkClients |
||
9 | * @subpackage IRCClient |
||
10 | * @author Vasily Zorin <[email protected]> |
||
11 | */ |
||
12 | class Channel extends ObjectStorage |
||
13 | { |
||
14 | use \PHPDaemon\Traits\EventHandlers; |
||
15 | |||
16 | /** |
||
17 | * @var Connection |
||
18 | */ |
||
19 | public $irc; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | public $name; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | public $nicknames = []; |
||
30 | |||
31 | /** |
||
32 | * @var |
||
33 | */ |
||
34 | public $self; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | public $type; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | public $topic; |
||
45 | |||
46 | /** |
||
47 | * @param Connection $irc |
||
48 | * @param string $name |
||
49 | */ |
||
50 | public function __construct($irc, $name) |
||
51 | { |
||
52 | $this->irc = $irc; |
||
53 | $this->name = $name; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @TODO DESCR |
||
58 | */ |
||
59 | public function who() |
||
60 | { |
||
61 | $this->irc->command('WHO', $this->name); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @TODO DESCR |
||
66 | * @param array|string $mask |
||
67 | * @param mixed $msg |
||
68 | */ |
||
69 | public function onPart($mask, $msg = null) |
||
0 ignored issues
–
show
|
|||
70 | { |
||
71 | if (is_string($mask)) { |
||
72 | $mask = IRC::parseUsermask($mask); |
||
73 | } |
||
74 | if (($mask['nick'] === $this->irc->nick) && ($mask['user'] === $this->irc->user)) { |
||
0 ignored issues
–
show
The property
$user is declared protected in PHPDaemon\Clients\IRC\Connection . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
75 | $this->destroy(); |
||
76 | } else { |
||
77 | unset($this->nicknames[$mask['nick']]); |
||
78 | } |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * @TODO DESCR |
||
83 | */ |
||
84 | public function destroy() |
||
85 | { |
||
86 | unset($this->irc->channels[$this->name]); |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * @TODO DESCR |
||
91 | * @param string $type |
||
92 | */ |
||
93 | public function setChanType($type) |
||
94 | { |
||
95 | $this->type = $type; |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * @TODO DESCR |
||
100 | * @return array |
||
101 | */ |
||
102 | public function exportNicksArray() |
||
103 | { |
||
104 | $nicks = []; |
||
105 | foreach ($this as $participant) { |
||
106 | $nicks[] = $participant->flag . $participant->nick; |
||
107 | } |
||
108 | return $nicks; |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * @TODO DESCR |
||
113 | * @param string $msg |
||
114 | */ |
||
115 | public function setTopic($msg) |
||
116 | { |
||
117 | $this->topic = $msg; |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * @TODO DESCR |
||
122 | * @param string $nick |
||
123 | * @param string $mode |
||
124 | */ |
||
125 | View Code Duplication | public function addMode($nick, $mode) |
|
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. ![]() |
|||
126 | { |
||
127 | if (!isset($this->nicknames[$nick])) { |
||
128 | return; |
||
129 | } |
||
130 | $participant = $this->nicknames[$nick]; |
||
131 | if (mb_orig_strpos($participant->mode, $mode) === false) { |
||
132 | $participant->mode .= $mode; |
||
133 | } |
||
134 | $participant->onModeUpdate(); |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * @TODO DESCR |
||
139 | * @param string $target |
||
140 | * @param string $mode |
||
141 | */ |
||
142 | View Code Duplication | public function removeMode($target, $mode) |
|
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. ![]() |
|||
143 | { |
||
144 | if (!isset($this->nicknames[$target])) { |
||
145 | return; |
||
146 | } |
||
147 | $participant = $this->nicknames[$target]; |
||
148 | $participant->mode = str_replace($mode, '', $participant->mode); |
||
149 | $participant->onModeUpdate(); |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * @TODO DESCR |
||
154 | */ |
||
155 | public function join() |
||
156 | { |
||
157 | $this->irc->join($this->name); |
||
0 ignored issues
–
show
$this->name is of type string , but the function expects a array .
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: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
158 | } |
||
159 | |||
160 | /** |
||
161 | * @TODO DESCR |
||
162 | * @param mixed $msg |
||
163 | */ |
||
164 | public function part($msg = null) |
||
165 | { |
||
166 | $this->irc->part($this->name, $msg); |
||
0 ignored issues
–
show
$this->name is of type string , but the function expects a array .
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: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
167 | } |
||
168 | |||
169 | /** |
||
170 | * @TODO DESCR |
||
171 | * @param string $type |
||
172 | * @return $this |
||
173 | */ |
||
174 | public function setType($type) |
||
175 | { |
||
176 | $this->type = $type; |
||
177 | return $this; |
||
178 | } |
||
179 | |||
180 | /** |
||
181 | * @TODO DESCR |
||
182 | * @param object $obj |
||
183 | */ |
||
184 | public function detach($obj) |
||
185 | { |
||
186 | parent::detach($obj); |
||
187 | unset($this->nicknames[$obj->nick]); |
||
188 | } |
||
189 | } |
||
190 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.