These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Changelog keeper |
||
4 | * |
||
5 | * @link https://github.com/hiqdev/chkipper |
||
6 | * @package chkipper |
||
7 | * @license BSD-3-Clause |
||
8 | * @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/) |
||
9 | */ |
||
10 | |||
11 | namespace hiqdev\chkipper\lib\modifiers; |
||
12 | |||
13 | use hiqdev\chkipper\lib\History; |
||
14 | |||
15 | /** |
||
16 | * Modifier that adds links for tags. |
||
17 | * |
||
18 | * @author Andrii Vasyliev <[email protected]> |
||
19 | */ |
||
20 | class AddTagLinks extends AbstractModifier |
||
21 | { |
||
22 | /** |
||
23 | * {@inheritdoc} |
||
24 | */ |
||
25 | 2 | public function run(History $history) |
|
26 | { |
||
27 | 2 | $prev = null; |
|
28 | 2 | foreach ($history->getTags() as $tag) { |
|
29 | 2 | $tag = $tag->getName(); |
|
30 | 2 | if ($prev && ($history->isLastTag($prev) || !$history->hasLink($prev))) { |
|
31 | 2 | $history->addLink($prev, static::generateTagHref($history, $prev, $tag)); |
|
32 | 2 | } |
|
33 | 2 | $prev = $tag; |
|
34 | 2 | } |
|
35 | 2 | } |
|
36 | |||
37 | /** |
||
38 | * Generate href to a version tag. |
||
39 | * @param History $history history object |
||
40 | * @param string $prev previous tag |
||
41 | * @param string $curr current tag |
||
42 | * @return string |
||
43 | */ |
||
44 | 2 | public function generateTagHref(History $history, $prev, $curr) |
|
45 | { |
||
46 | 2 | $project = $history->getProject(); |
|
47 | 2 | $rmsSite = $history->getConfig()->rmsSite; |
|
0 ignored issues
–
show
|
|||
48 | |||
49 | 2 | if ($history->isInitTag($curr)) { |
|
50 | 2 | if ($history->isLastTag($prev)) { |
|
51 | 1 | return "https://$rmsSite/$project/releases"; |
|
52 | } |
||
53 | |||
54 | 1 | return "https://$rmsSite/$project/releases/tag/$prev"; |
|
55 | } |
||
56 | 1 | if ($history->isLastTag($prev)) { |
|
57 | 1 | $prev = 'HEAD'; |
|
58 | 1 | } |
|
59 | |||
60 | 1 | return "https://$rmsSite/$project/compare/$curr...$prev"; |
|
61 | } |
||
62 | } |
||
63 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: