Skip to content

Commit

Permalink
Applied fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
jhdxr authored and StyleCIBot committed Apr 30, 2016
1 parent 4e6ad00 commit 43ea6ed
Show file tree
Hide file tree
Showing 100 changed files with 484 additions and 515 deletions.
10 changes: 2 additions & 8 deletions src/PhpBrew/AppStore.php
Expand Up @@ -3,7 +3,7 @@

class AppStore
{
public static function all()
public static function all()
{
$apps = array(
'composer' => array('url' => 'https://getcomposer.org/composer.phar', 'as' => 'composer'),
Expand All @@ -17,7 +17,7 @@ public static function all()
'onion' => array('url' => 'https://raw.githubusercontent.com/phpbrew/Onion/master/onion', 'as' => 'onion'),
'box-2.5' => array('url' => 'https://github.com/box-project/box2/releases/download/2.5.2/box-2.5.2.phar', 'as' => 'box'),
);
$phpunitapps = explode(' ','phpunit phpcov phpcpd phpdcd phptok phploc');
$phpunitapps = explode(' ', 'phpunit phpcov phpcpd phpdcd phptok phploc');
foreach ($phpunitapps as $phpunitapp) {
$apps[ $phpunitapp ] = array(
'url' => sprintf('https://phar.phpunit.de/%s.phar', $phpunitapp),
Expand All @@ -27,9 +27,3 @@ public static function all()
return $apps;
}
}






4 changes: 2 additions & 2 deletions src/PhpBrew/Build.php
@@ -1,5 +1,6 @@
<?php
namespace PhpBrew;

use Serializable;
use PhpBrew\BuildSettings\BuildSettings;
use PhpBrew\Types\ExistingDirectory;
Expand Down Expand Up @@ -236,7 +237,6 @@ public function getIdentifier()
$names[] = $str;
}
}

}

if ($this->phpEnvironment === self::ENV_PRODUCTION) {
Expand Down Expand Up @@ -298,7 +298,7 @@ public static function findByName($name)
$prefix = Config::getVersionInstallPrefix($name);
if (file_exists($prefix)) {
// a installation exists
return new self($name, NULL, $prefix);
return new self($name, null, $prefix);
}

return null;
Expand Down
21 changes: 9 additions & 12 deletions src/PhpBrew/BuildFinder.php
@@ -1,20 +1,21 @@
<?php
namespace PhpBrew;

use PhpBrew\Config;

class BuildFinder
{
/**
* @return string[]
*/
static public function findInstalledBuilds($stripPrefix = true)
public static function findInstalledBuilds($stripPrefix = true)
{
$path = Config::getRoot() . DIRECTORY_SEPARATOR . 'php';
if (!file_exists($path)) {
throw new Exception($path . ' does not exist.');
}
$names = scandir($path);
$names = array_filter($names, function($name) use ($path) {
$names = array_filter($names, function ($name) use ($path) {
return $name != '.' && $name != '..' && file_exists($path . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'php');
});

Expand All @@ -23,7 +24,7 @@ static public function findInstalledBuilds($stripPrefix = true)
}

if ($stripPrefix) {
$names = array_map(function($name) { return preg_replace('/^php-(?=(\d+\.\d+\.\d+)$)/','', $name); }, $names);
$names = array_map(function ($name) { return preg_replace('/^php-(?=(\d+\.\d+\.\d+)$)/', '', $name); }, $names);
}
uasort($names, 'version_compare'); // ordering version name ascending... 5.5.17, 5.5.12
return array_reverse($names); // make it descending... since there is no sort function for user-define in reverse order.
Expand All @@ -33,18 +34,18 @@ static public function findInstalledBuilds($stripPrefix = true)
/**
* @return string[] build names
*/
static public function findMatchedBuilds($buildNameRE = '', $stripPrefix = true)
public static function findMatchedBuilds($buildNameRE = '', $stripPrefix = true)
{
$builds = self::findInstalledBuilds($stripPrefix);
return array_filter($builds, function($build) use ($buildNameRE) {
return array_filter($builds, function ($build) use ($buildNameRE) {
return preg_match("/^$buildNameRE/i", $build);
});
}

/**
* @return string[] build names
*/
static public function findFirstMatchedBuild($buildNameRE = '', $stripPrefix = true)
public static function findFirstMatchedBuild($buildNameRE = '', $stripPrefix = true)
{
$builds = self::findInstalledBuilds($stripPrefix);
foreach ($builds as $build) {
Expand All @@ -57,15 +58,11 @@ static public function findFirstMatchedBuild($buildNameRE = '', $stripPrefix = t
/**
* @return string[] build names
*/
static public function findLatestBuild($stripPrefix = true) {
public static function findLatestBuild($stripPrefix = true)
{
$builds = self::findInstalledBuilds($stripPrefix);
if (!empty($builds)) {
return $builds[0]; // latest
}
}


}



9 changes: 5 additions & 4 deletions src/PhpBrew/BuildRegister.php
@@ -1,5 +1,6 @@
<?php
namespace PhpBrew;

use PhpBrew\Build;
use PhpBrew\Config;

Expand All @@ -15,12 +16,14 @@ public function __construct()
$this->baseDir = $this->root . DIRECTORY_SEPARATOR . 'registry';
}

public function register(Build $build) {
public function register(Build $build)
{
$file = $this->baseDir . DIRECTORY_SEPARATOR . $build->getName();
$build->writeFile($file);
}

public function deregister(Build $build) {
public function deregister(Build $build)
{
$file = $this->baseDir . DIRECTORY_SEPARATOR . $build->getName();
if (file_exists($file)) {
unlink($file);
Expand All @@ -29,5 +32,3 @@ public function deregister(Build $build) {
return false;
}
}


21 changes: 8 additions & 13 deletions src/PhpBrew/BuildSettings/BuildSettings.php
Expand Up @@ -26,17 +26,18 @@ public function __construct(array $settings = array())
}
}

public function toArray() {
public function toArray()
{
return array(
'enabled_variants' => $this->variants,
'disabled_variants' => $this->disabledVariants,
'extra_options' => $this->extraOptions,
);
}

public function enableVariants(array $settings)
public function enableVariants(array $settings)
{
foreach($settings as $name => $value) {
foreach ($settings as $name => $value) {
$this->enableVariant($name, $value);
}
}
Expand All @@ -46,9 +47,9 @@ public function enableVariant($name, $value = null)
$this->variants[$name] = $value ?: true;
}

public function disableVariants(array $settings)
public function disableVariants(array $settings)
{
foreach($settings as $name => $value) {
foreach ($settings as $name => $value) {
$this->disableVariant($name);
}
}
Expand All @@ -65,7 +66,7 @@ public function disableVariant($name)


/**
* Remove the enabled the variants since we've disabled
* Remove the enabled the variants since we've disabled
* them.
*/
public function resolveVariants()
Expand Down Expand Up @@ -189,7 +190,7 @@ public function loadVariantInfoFile($variantFile)
}


public function writeVariantInfoFile($variantInfoFile)
public function writeVariantInfoFile($variantInfoFile)
{
return file_put_contents($variantInfoFile, serialize(array(
'enabled_variants' => $this->variants,
Expand Down Expand Up @@ -218,10 +219,4 @@ public function loadVariantInfo(array $variantInfo, $reset = false)
}
return $this->resolveVariants(); // Remove the enabled variants
}



}



9 changes: 4 additions & 5 deletions src/PhpBrew/Command/AppCommand.php
@@ -1,5 +1,6 @@
<?php
namespace PhpBrew\Command;

use PhpBrew\Config;
use CLIFramework\Command;

Expand All @@ -18,12 +19,12 @@ public function brief()
return 'php app store';
}

public function options($opts)
public function options($opts)
{
$opts->add('l|list','Show app list.');
$opts->add('l|list', 'Show app list.');
}

public function init()
public function init()
{
parent::init();
$this->command('get');
Expand All @@ -36,5 +37,3 @@ public function execute()
$listCommand->execute();
}
}


9 changes: 4 additions & 5 deletions src/PhpBrew/Command/AppCommand/GetCommand.php
@@ -1,5 +1,6 @@
<?php
namespace PhpBrew\Command\AppCommand;

use PhpBrew\Downloader\DownloadFactory;
use PhpBrew\Config;
use PhpBrew\AppStore;
Expand All @@ -24,12 +25,12 @@ public function arguments($args)
{
$apps = AppStore::all();
$args->add('app-name')
->validValues( array_keys($apps) )
->validValues(array_keys($apps))
;
}

public function execute($appName) {

public function execute($appName)
{
$apps = AppStore::all();

if (!isset($apps[$appName])) {
Expand All @@ -52,5 +53,3 @@ public function execute($appName) {
$this->logger->info("Downloaded at $target");
}
}


7 changes: 3 additions & 4 deletions src/PhpBrew/Command/AppCommand/ListCommand.php
@@ -1,5 +1,6 @@
<?php
namespace PhpBrew\Command\AppCommand;

use PhpBrew\Config;
use PhpBrew\AppStore;
use CLIFramework\Command;
Expand All @@ -12,13 +13,11 @@ public function brief()
return 'list php apps';
}

public function execute()
public function execute()
{
$apps = AppStore::all();
foreach ($apps as $name => $opt) {
$this->logger->writeln(sprintf('% -8s - %s', $name , $opt['url']));
$this->logger->writeln(sprintf('% -8s - %s', $name, $opt['url']));
}
}
}


4 changes: 3 additions & 1 deletion src/PhpBrew/Command/CdCommand.php
@@ -1,5 +1,6 @@
<?php
namespace PhpBrew\Command;

/**
* @codeCoverageIgnore
*/
Expand All @@ -13,7 +14,8 @@ public function brief()
return 'Change to directories';
}

public function arguments($args) {
public function arguments($args)
{
$args->add('directory')
->isa('string')
->validValues(explode('|', 'var|etc|build|dist'))
Expand Down
6 changes: 3 additions & 3 deletions src/PhpBrew/Command/CleanCommand.php
Expand Up @@ -5,7 +5,6 @@
use PhpBrew\Build;
use PhpBrew\Config;
use PhpBrew\Utils;

use CLIFramework\Command;

class CleanCommand extends Command
Expand All @@ -25,9 +24,10 @@ public function options($opts)
$opts->add('a|all', 'Remove all the files in the source directory of the PHP distribution.');
}

public function arguments($args) {
public function arguments($args)
{
$args->add('installed php')
->validValues(function() { return \PhpBrew\Config::getInstalledPhpVersions(); })
->validValues(function () { return \PhpBrew\Config::getInstalledPhpVersions(); })
;
}

Expand Down
3 changes: 2 additions & 1 deletion src/PhpBrew/Command/ConfigCommand.php
@@ -1,5 +1,6 @@
<?php
namespace PhpBrew\Command;

use CLIFramework\Command;
use PhpBrew\Utils;
use PhpBrew\Config;
Expand All @@ -14,7 +15,7 @@ public function brief()
public function execute()
{
$file = php_ini_loaded_file();
if(! file_exists($file)) {
if (! file_exists($file)) {
$php = Config::getCurrentPhpName();
$this->logger->warn("Sorry, I can't find the {$file} file for php {$php}.");
return;
Expand Down
7 changes: 4 additions & 3 deletions src/PhpBrew/Command/CtagsCommand.php
Expand Up @@ -11,13 +11,14 @@ public function brief()
return 'Run ctags at current php source dir for extension development.';
}

public function arguments($args) {
public function arguments($args)
{
$args->add('installed versions')
->validValues(function() { return \PhpBrew\Config::getInstalledPhpVersions(); })
->validValues(function () { return \PhpBrew\Config::getInstalledPhpVersions(); })
;
}

public function execute($versionName = NULL)
public function execute($versionName = null)
{
$args = func_get_args();
array_shift($args);
Expand Down

0 comments on commit 43ea6ed

Please sign in to comment.