1 | <?php |
||
54 | class BuildTypeFromSwVers implements BuildTypeFromFile |
||
55 | { |
||
56 | /** |
||
57 | * use the output of /usr/bin/sw_vers (if present) to determine which |
||
58 | * operating system we are using |
||
59 | * |
||
60 | * @param string $pathToBinary |
||
61 | * path to the binary to run |
||
62 | * @return null|OsType |
||
|
|||
63 | * OsType if we know which operating system we are using |
||
64 | * null otherwise |
||
65 | */ |
||
66 | public function __invoke($pathToBinary = "/usr/bin/sw_vers") |
||
70 | |||
71 | /** |
||
72 | * use the output of /usr/bin/sw_vers (if present) to determine which |
||
73 | * operating system we are using |
||
74 | * |
||
75 | * @return null|OsType |
||
76 | * OsType if we know which operating system we are using |
||
77 | * null otherwise |
||
78 | */ |
||
79 | public static function usingDefaultPath() |
||
83 | |||
84 | /** |
||
85 | * use the output of /usr/bin/sw_vers (if present) to determine which |
||
86 | * operating system we are using |
||
87 | * |
||
88 | * @param string $pathToBinary |
||
89 | * path to the binary to run |
||
90 | * @return null|OsType |
||
91 | * OsType if we know which operating system we are using |
||
92 | * null otherwise |
||
93 | */ |
||
94 | public static function usingPath($pathToBinary) |
||
110 | |||
111 | /** |
||
112 | * call /usr/bin/sw_vers to get details about this operating system |
||
113 | * |
||
114 | * @param string $pathToBinary |
||
115 | * path to the binary to run |
||
116 | * @return array |
||
117 | * [0] is the operating system name |
||
118 | * [1] is the operating system version |
||
119 | */ |
||
120 | private static function getOsDetails($pathToBinary) |
||
129 | |||
130 | /** |
||
131 | * call /usr/bin/sw_vers and return the output |
||
132 | * |
||
133 | * @param string $pathToBinary |
||
134 | * path to the binary to call |
||
135 | * @return string|null |
||
136 | * output from the binary |
||
137 | */ |
||
138 | private static function getOutputFromBinary($pathToBinary) |
||
154 | |||
155 | /** |
||
156 | * parse the output of /usr/bin/sw_vers to get details about |
||
157 | * this operating system |
||
158 | * |
||
159 | * @param string $output |
||
160 | * output from /usr/bin/sw_vers |
||
161 | * @return array |
||
162 | * [0] is the operating system name |
||
163 | * [1] is the operating system version |
||
164 | */ |
||
165 | private static function extractOsDetails($output) |
||
174 | |||
175 | /** |
||
176 | * extract a named field from the output of /usr/bin/sw_vers |
||
177 | * |
||
178 | * @param array $lines |
||
179 | * the output of /usr/bin/sw_vers |
||
180 | * @param string $fieldName |
||
181 | * the field that we are looking for |
||
182 | * @return string|null |
||
183 | * the value of the field (if found) |
||
184 | */ |
||
185 | private static function extractField($lines, $fieldName) |
||
193 | |||
194 | /** |
||
195 | * map of operating system names to OsTypes |
||
196 | * @var array |
||
197 | */ |
||
198 | private static $osTypes = [ |
||
199 | 'Mac OS X' => OSX::class, |
||
200 | ]; |
||
201 | } |
||
202 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.