1 | <?php |
||
13 | class Helper |
||
14 | { |
||
15 | /** |
||
16 | * @var \SplFileInfo |
||
17 | */ |
||
18 | protected $projectRoot; |
||
19 | |||
20 | /** |
||
21 | * @var ProjectConfig |
||
22 | */ |
||
23 | protected $magentoProjectConfig; |
||
24 | |||
25 | /** |
||
26 | * @param \SplFileInfo $projectRoot |
||
27 | */ |
||
28 | public function __construct(\SplFileInfo $projectRoot) |
||
42 | |||
43 | public function getVendorDirectory() |
||
44 | { |
||
45 | /* |
||
46 | $reader = new \Eloquent\Composer\Configuration\ConfigurationReader; |
||
47 | $composerJsonObject = $reader->read($this->projectRoot.'/composer.json'); |
||
48 | return $composerJsonObject->vendorName(); |
||
49 | */ |
||
50 | return new \SplFileInfo($this->projectRoot.'/vendor'); |
||
51 | } |
||
52 | |||
53 | public function getInstalledPackages() |
||
54 | { |
||
55 | |||
56 | $installedJsonObject = json_decode(file_get_contents( |
||
57 | $this->getVendorDirectory()->getPathname().'/composer/installed.json' |
||
58 | ), true); |
||
59 | return $installedJsonObject; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @return ProjectConfig |
||
64 | */ |
||
65 | public function getMagentoProjectConfig() |
||
66 | { |
||
67 | return $this->magentoProjectConfig; |
||
68 | } |
||
69 | |||
70 | public function getPackageByName($name) |
||
71 | { |
||
72 | $result = null; |
||
73 | foreach ($this->getInstalledPackages() as $package) { |
||
74 | if ($package['name'] == $name) { |
||
75 | $result = $package; |
||
76 | break; |
||
77 | } |
||
78 | } |
||
79 | return $result; |
||
80 | } |
||
81 | |||
82 | 3 | public static function initMagentoRootDir( |
|
113 | |||
114 | /** |
||
115 | * join 2 paths |
||
116 | * |
||
117 | * @param $path1 |
||
118 | * @param $path2 |
||
119 | * @param $delimiter |
||
120 | * @param bool $prependDelimiter |
||
121 | * @param string $additionalPrefix |
||
122 | * |
||
123 | * @internal param $url1 |
||
124 | * @internal param $url2 |
||
125 | * |
||
126 | * @return string |
||
127 | */ |
||
128 | public static function joinPath($path1, $path2, $delimiter, $prependDelimiter = false, $additionalPrefix = '') |
||
129 | { |
||
130 | $prefix = $additionalPrefix . $prependDelimiter ? $delimiter : ''; |
||
131 | |||
132 | return $prefix . join( |
||
133 | $delimiter, |
||
134 | array( |
||
135 | explode($path1, $delimiter), |
||
136 | explode($path2, $delimiter) |
||
137 | ) |
||
138 | ); |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * @param $path1 |
||
143 | * @param $path2 |
||
144 | * |
||
145 | * @return string |
||
146 | */ |
||
147 | public static function joinFilePath($path1, $path2) |
||
151 | } |
||
152 |
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.