@@ -30,7 +30,7 @@ function __construct(CommandLine $cli, Filesystem $files)
3030 */
3131 function installed ($ formula )
3232 {
33- return in_array ($ formula , explode (PHP_EOL , $ this ->cli ->run ('brew list | grep ' .$ formula )));
33+ return in_array ($ formula , explode (PHP_EOL , $ this ->cli ->runAsUser ('brew list | grep ' .$ formula )));
3434 }
3535
3636 /**
@@ -40,7 +40,8 @@ function installed($formula)
4040 */
4141 function hasInstalledPhp ()
4242 {
43- return $ this ->installed ('php70 ' )
43+ return $ this ->installed ('php71 ' )
44+ || $ this ->installed ('php70 ' )
4445 || $ this ->installed ('php56 ' )
4546 || $ this ->installed ('php55 ' );
4647 }
@@ -49,40 +50,42 @@ function hasInstalledPhp()
4950 * Ensure that the given formula is installed.
5051 *
5152 * @param string $formula
53+ * @param array $options
5254 * @param array $taps
5355 * @return void
5456 */
55- function ensureInstalled ($ formula , array $ taps = [])
57+ function ensureInstalled ($ formula , $ options = [], $ taps = [])
5658 {
5759 if (! $ this ->installed ($ formula )) {
58- $ this ->installOrFail ($ formula , $ taps );
60+ $ this ->installOrFail ($ formula , $ options , $ taps );
5961 }
6062 }
6163
6264 /**
6365 * Install the given formula and throw an exception on failure.
6466 *
6567 * @param string $formula
68+ * @param array $options
6669 * @param array $taps
6770 * @return void
6871 */
69- function installOrFail ($ formula , array $ taps = [])
72+ function installOrFail ($ formula , $ options = [], $ taps = [])
7073 {
7174 if (count ($ taps ) > 0 ) {
7275 $ this ->tap ($ taps );
7376 }
7477
7578 output ('<info>[ ' .$ formula .'] is not installed, installing it now via Brew...</info> 🍻 ' );
7679
77- $ this ->cli ->runAsUser ('brew install ' .$ formula , function ($ exitCode , $ errorOutput ) use ($ formula ) {
80+ $ this ->cli ->runAsUser (trim ( 'brew install ' .$ formula. ' ' . implode ( ' ' , $ options )) , function ($ exitCode , $ errorOutput ) use ($ formula ) {
7881 output ($ errorOutput );
7982
8083 throw new DomainException ('Brew was unable to install [ ' .$ formula .']. ' );
8184 });
8285 }
8386
8487 /**
85- * Tag the given formulas.
88+ * Tap the given formulas.
8689 *
8790 * @param dynamic[string] $formula
8891 * @return void
@@ -137,7 +140,9 @@ function linkedPhp()
137140
138141 $ resolvedPath = $ this ->files ->readLink ('/usr/local/bin/php ' );
139142
140- if (strpos ($ resolvedPath , 'php70 ' ) !== false ) {
143+ if (strpos ($ resolvedPath , 'php71 ' ) !== false ) {
144+ return 'php71 ' ;
145+ } elseif (strpos ($ resolvedPath , 'php70 ' ) !== false ) {
141146 return 'php70 ' ;
142147 } elseif (strpos ($ resolvedPath , 'php56 ' ) !== false ) {
143148 return 'php56 ' ;
0 commit comments