1 | <?php |
||
12 | class GitBranches implements \IteratorAggregate |
||
13 | { |
||
14 | /** |
||
15 | * The working copy that branches are being collected from. |
||
16 | * |
||
17 | * @var \GitWrapper\GitWorkingCopy |
||
18 | */ |
||
19 | protected $git; |
||
20 | |||
21 | /** |
||
22 | * Constructs a GitBranches object. |
||
23 | * |
||
24 | * @param \GitWrapper\GitWorkingCopy $git |
||
25 | * The working copy that branches are being collected from. |
||
26 | * |
||
27 | * @throws \GitWrapper\GitException |
||
28 | */ |
||
29 | 24 | public function __construct(GitWorkingCopy $git) |
|
34 | |||
35 | /** |
||
36 | * Fetches the branches via the `git branch` command. |
||
37 | * |
||
38 | * @param boolean $onlyRemote |
||
39 | * Whether to fetch only remote branches, defaults to false which returns |
||
40 | * all branches. |
||
41 | * |
||
42 | * @return array |
||
43 | */ |
||
44 | 24 | public function fetchBranches($onlyRemote = false) |
|
52 | |||
53 | /** |
||
54 | * Strips unwanted characters from the branch. |
||
55 | * |
||
56 | * @param string $branch |
||
57 | * The raw branch returned in the output of the Git command. |
||
58 | * |
||
59 | * @return string |
||
60 | * The processed branch name. |
||
61 | */ |
||
62 | 24 | public function trimBranch($branch) |
|
66 | |||
67 | /** |
||
68 | * Implements \IteratorAggregate::getIterator(). |
||
69 | */ |
||
70 | public function getIterator() |
||
71 | { |
||
72 | $branches = $this->all(); |
||
73 | return new \ArrayIterator($branches); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Returns all branches. |
||
78 | * |
||
79 | * @return array |
||
80 | */ |
||
81 | public function all() |
||
82 | { |
||
83 | return $this->fetchBranches(); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Returns only remote branches. |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | 24 | public function remote() |
|
95 | |||
96 | /** |
||
97 | * Returns currently active branch (HEAD) of the working copy. |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | public function head() |
||
105 | } |
||
106 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.