1 | <?php |
||
20 | class BugsPlugin extends AbstractDatabaseCollectorPlugin |
||
21 | { |
||
22 | |||
23 | const STATISTIC_BUG_ADDED_TO_COMMIT = 'bug_added_to_commit'; |
||
24 | |||
25 | /** |
||
26 | * Repository url. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | private $_repositoryUrl; |
||
31 | |||
32 | /** |
||
33 | * Repository connector. |
||
34 | * |
||
35 | * @var Connector |
||
36 | */ |
||
37 | private $_repositoryConnector; |
||
38 | |||
39 | /** |
||
40 | * Log message parser factory. |
||
41 | * |
||
42 | * @var LogMessageParserFactory |
||
43 | */ |
||
44 | private $_logMessageParserFactory; |
||
45 | |||
46 | /** |
||
47 | * Create bugs revision log plugin. |
||
48 | * |
||
49 | * @param ExtendedPdoInterface $database Database. |
||
50 | * @param RepositoryFiller $repository_filler Repository filler. |
||
51 | * @param string $repository_url Repository url. |
||
52 | * @param Connector $repository_connector Repository connector. |
||
53 | * @param LogMessageParserFactory $log_message_parser_factory Log message parser. |
||
54 | */ |
||
55 | 19 | public function __construct( |
|
68 | |||
69 | /** |
||
70 | * Returns plugin name. |
||
71 | * |
||
72 | * @return string |
||
73 | */ |
||
74 | 13 | public function getName() |
|
78 | |||
79 | /** |
||
80 | * Defines parsing statistic types. |
||
81 | * |
||
82 | * @return array |
||
83 | */ |
||
84 | 19 | public function defineStatisticTypes() |
|
90 | |||
91 | /** |
||
92 | * Processes data. |
||
93 | * |
||
94 | * @param integer $from_revision From revision. |
||
95 | * @param integer $to_revision To revision. |
||
96 | * |
||
97 | * @return void |
||
98 | */ |
||
99 | 9 | public function doProcess($from_revision, $to_revision) |
|
110 | |||
111 | /** |
||
112 | * Populate "BugRegExp" column for projects without it. |
||
113 | * |
||
114 | * @return void |
||
115 | */ |
||
116 | 9 | protected function populateMissingBugRegExp() |
|
137 | |||
138 | /** |
||
139 | * Determines project bug tracking regular expression. |
||
140 | * |
||
141 | * @param string $project_path Project project_path. |
||
142 | * @param integer $revision Revision. |
||
143 | * @param boolean $project_deleted Project is deleted. |
||
144 | * |
||
145 | * @return string |
||
146 | */ |
||
147 | 4 | protected function detectProjectBugTraqRegEx($project_path, $revision, $project_deleted) |
|
162 | |||
163 | /** |
||
164 | * Returns last changed ref within given project. |
||
165 | * |
||
166 | * @param string $project_path Path. |
||
167 | * |
||
168 | * @return string|null |
||
169 | */ |
||
170 | 4 | protected function getLastChangedRefPath($project_path) |
|
205 | |||
206 | /** |
||
207 | * Detects if given project_path is known project root. |
||
208 | * |
||
209 | * @param string $path Path. |
||
210 | * |
||
211 | * @return boolean |
||
212 | */ |
||
213 | 3 | protected function isRef($path) |
|
229 | |||
230 | /** |
||
231 | * Detects bugs, associated with each commit from a given revision range. |
||
232 | * |
||
233 | * @param integer $from_revision From revision. |
||
234 | * @param integer $to_revision To revision. |
||
235 | * |
||
236 | * @return void |
||
237 | */ |
||
238 | 7 | protected function detectBugs($from_revision, $to_revision) |
|
259 | |||
260 | /** |
||
261 | * Returns "BugRegExp" field associated with every project. |
||
262 | * |
||
263 | * @return array |
||
264 | */ |
||
265 | 7 | protected function getProjectBugRegExps() |
|
281 | |||
282 | /** |
||
283 | * Detects bugs, associated with each commit from a given revision range. |
||
284 | * |
||
285 | * @param integer $from_revision From revision. |
||
286 | * @param integer $to_revision To revision. |
||
287 | * @param array $bug_regexp_mapping Mapping between project and it's "BugRegExp" field. |
||
288 | * |
||
289 | * @return void |
||
290 | */ |
||
291 | 4 | protected function doDetectBugs($from_revision, $to_revision, array $bug_regexp_mapping) |
|
314 | |||
315 | /** |
||
316 | * Returns commits grouped by project. |
||
317 | * |
||
318 | * @param integer $from_revision From revision. |
||
319 | * @param integer $to_revision To revision. |
||
320 | * |
||
321 | * @return array |
||
322 | */ |
||
323 | 4 | protected function getCommitsGroupedByProject($from_revision, $to_revision) |
|
357 | |||
358 | /** |
||
359 | * Find revisions by collected data. |
||
360 | * |
||
361 | * @param array $criteria Criteria. |
||
362 | * @param string $project_path Project path. |
||
363 | * |
||
364 | * @return array |
||
365 | */ |
||
366 | 5 | public function find(array $criteria, $project_path) |
|
384 | |||
385 | /** |
||
386 | * Returns information about revisions. |
||
387 | * |
||
388 | * @param array $revisions Revisions. |
||
389 | * |
||
390 | * @return array |
||
391 | */ |
||
392 | 1 | public function getRevisionsData(array $revisions) |
|
414 | |||
415 | } |
||
416 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.