1 | <?php |
||
53 | class BuildTypeFromSwVers implements BuildTypeFromFile |
||
54 | { |
||
55 | /** |
||
56 | * use the output of /usr/bin/sw_vers (if present) to determine which |
||
57 | * operating system we are using |
||
58 | * |
||
59 | * @param string $pathToBinary |
||
60 | * path to the binary to run |
||
61 | * @return null|OsType |
||
|
|||
62 | * OsType if we know which operating system we are using |
||
63 | * null otherwise |
||
64 | */ |
||
65 | public function __invoke($pathToBinary = "/usr/bin/sw_vers") |
||
69 | |||
70 | /** |
||
71 | * use the output of /usr/bin/sw_vers (if present) to determine which |
||
72 | * operating system we are using |
||
73 | * |
||
74 | * @return null|OsType |
||
75 | * OsType if we know which operating system we are using |
||
76 | * null otherwise |
||
77 | */ |
||
78 | public static function usingDefaultPath() |
||
82 | |||
83 | /** |
||
84 | * use the output of /usr/bin/sw_vers (if present) to determine which |
||
85 | * operating system we are using |
||
86 | * |
||
87 | * @param string $pathToBinary |
||
88 | * path to the binary to run |
||
89 | * @return null|OsType |
||
90 | * OsType if we know which operating system we are using |
||
91 | * null otherwise |
||
92 | */ |
||
93 | public static function usingPath($pathToBinary) |
||
108 | |||
109 | /** |
||
110 | * call /usr/bin/sw_vers to get details about this operating system |
||
111 | * |
||
112 | * @param string $pathToBinary |
||
113 | * path to the binary to run |
||
114 | * @return array |
||
115 | * [0] is the operating system name |
||
116 | * [1] is the operating system version |
||
117 | */ |
||
118 | private static function getOsDetails($pathToBinary) |
||
127 | |||
128 | /** |
||
129 | * call /usr/bin/sw_vers and return the output |
||
130 | * |
||
131 | * @param string $pathToBinary |
||
132 | * path to the binary to call |
||
133 | * @return string |
||
134 | * output from the binary |
||
135 | */ |
||
136 | private static function getOutputFromBinary($pathToBinary) |
||
152 | |||
153 | /** |
||
154 | * parse the output of /usr/bin/sw_vers to get details about |
||
155 | * this operating system |
||
156 | * |
||
157 | * @param string $output |
||
158 | * output from /usr/bin/sw_vers |
||
159 | * @return array |
||
160 | * [0] is the operating system name |
||
161 | * [1] is the operating system version |
||
162 | */ |
||
163 | private static function extractOsDetails($output) |
||
172 | |||
173 | /** |
||
174 | * extract a named field from the output of /usr/bin/sw_vers |
||
175 | * |
||
176 | * @param array $lines |
||
177 | * the output of /usr/bin/sw_vers |
||
178 | * @param string $fieldName |
||
179 | * the field that we are looking for |
||
180 | * @return string|null |
||
181 | * the value of the field (if found) |
||
182 | */ |
||
183 | private static function extractField($lines, $fieldName) |
||
191 | |||
192 | /** |
||
193 | * map of operating system names to OsTypes |
||
194 | * @var array |
||
195 | */ |
||
196 | private static $osTypes = [ |
||
197 | 'Mac OS X' => OSX::class, |
||
198 | ]; |
||
199 | } |
||
200 |
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.