From c41ab549b4d1cfc591278fa31392bb548995a6cc Mon Sep 17 00:00:00 2001 From: "a.cianfarani" Date: Tue, 21 May 2013 17:57:24 +0200 Subject: [PATCH 01/11] Add format controls on url and email value during installation --- PHPCI/Command/InstallCommand.php | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/PHPCI/Command/InstallCommand.php b/PHPCI/Command/InstallCommand.php index 2549e5cc..8c38dc21 100644 --- a/PHPCI/Command/InstallCommand.php +++ b/PHPCI/Command/InstallCommand.php @@ -43,6 +43,11 @@ class InstallCommand extends Command $dbUser = $this->ask('Enter your MySQL username: '); $dbPass = $this->ask('Enter your MySQL password: ', true); $ciUrl = $this->ask('Your PHPCI URL (without trailing slash): '); + // verify url format and re-ask if wrong + while(! $this->controlFormat($ciUrl,array(FILTER_VALIDATE_URL,"/[^\/]$/i"),$status)) { + print $status; + $ciUrl = $this->ask('Your PHPCI URL (without trailing slash): '); + } $ghId = $this->ask('(Optional) Github Application ID: ', true); $ghSecret = $this->ask('(Optional) Github Application Secret: ', true); @@ -52,6 +57,7 @@ class InstallCommand extends Command shell_exec($cmd); + $str = "controlFormat($adminEmail,FILTER_VALIDATE_EMAIL,$status)) { + print $status; + $adminEmail = $this->ask('Enter your email address (leave blank if updating): '); + } + } $adminPass = $this->ask('Enter your desired admin password: '); $adminName = $this->ask('Enter your name: '); @@ -125,4 +138,39 @@ b8\Database::setReadServers(array('{$dbHost}')); return $rtn; } + protected function controlFormat($valueToInspect,$filter,&$statusMessage) + { + $filters = !(is_array($filter))? array($filter) : $filter; + $statusMessage = ''; + $status = true; + $options = array(); + + foreach ($filters as $filter) { + if (! is_int($filter)) { + $regexp = $filter; + $filter = FILTER_VALIDATE_REGEXP; + $options = array( + 'options' => array( + 'regexp' => $regexp, + ) + ); + } + if (! filter_var($valueToInspect,$filter,$options)) { + $status = false; + switch ($filter) + { + case FILTER_VALIDATE_URL : + $statusMessage = 'Incorrect url format.' . PHP_EOL; + break; + case FILTER_VALIDATE_EMAIL : + $statusMessage = 'Incorrect e-mail format.' . PHP_EOL; + break; + case FILTER_VALIDATE_REGEXP : + $statusMessage = 'Incorrect format.' . PHP_EOL; + break; + } + } + } + return $status; + } } From b8e932cb76daaf60836274600019f1ad6fa741fa Mon Sep 17 00:00:00 2001 From: "a.cianfarani" Date: Wed, 22 May 2013 09:58:04 +0200 Subject: [PATCH 02/11] Some coding style corrections --- PHPCI/Command/InstallCommand.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/PHPCI/Command/InstallCommand.php b/PHPCI/Command/InstallCommand.php index 8c38dc21..dea8f430 100644 --- a/PHPCI/Command/InstallCommand.php +++ b/PHPCI/Command/InstallCommand.php @@ -44,7 +44,7 @@ class InstallCommand extends Command $dbPass = $this->ask('Enter your MySQL password: ', true); $ciUrl = $this->ask('Your PHPCI URL (without trailing slash): '); // verify url format and re-ask if wrong - while(! $this->controlFormat($ciUrl,array(FILTER_VALIDATE_URL,"/[^\/]$/i"),$status)) { + while (! $this->controlFormat($ciUrl, array(FILTER_VALIDATE_URL,"/[^\/]$/i"), $status) ) { print $status; $ciUrl = $this->ask('Your PHPCI URL (without trailing slash): '); } @@ -92,15 +92,14 @@ b8\Database::setReadServers(array('{$dbHost}')); if (empty($adminEmail)) { return; - } - else { + } else { // verify e-mail format and re-ask if wrong - while (! $this->controlFormat($adminEmail,FILTER_VALIDATE_EMAIL,$status)) { + while (! $this->controlFormat($adminEmail, FILTER_VALIDATE_EMAIL, $status)) { print $status; $adminEmail = $this->ask('Enter your email address (leave blank if updating): '); } } - + $adminPass = $this->ask('Enter your desired admin password: '); $adminName = $this->ask('Enter your name: '); @@ -155,7 +154,7 @@ b8\Database::setReadServers(array('{$dbHost}')); ) ); } - if (! filter_var($valueToInspect,$filter,$options)) { + if (! filter_var($valueToInspect, $filter, $options)) { $status = false; switch ($filter) { @@ -171,6 +170,7 @@ b8\Database::setReadServers(array('{$dbHost}')); } } } + return $status; } } From 40afb58ff70d006005245a621e2663133fb87d67 Mon Sep 17 00:00:00 2001 From: Steve Kamerman Date: Wed, 22 May 2013 14:17:33 -0400 Subject: [PATCH 03/11] Added support for interpolation --- PHPCI/Builder.php | 61 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/PHPCI/Builder.php b/PHPCI/Builder.php index 5a26be8d..2043531f 100644 --- a/PHPCI/Builder.php +++ b/PHPCI/Builder.php @@ -73,6 +73,15 @@ class Builder * @var array */ protected $config; + + /** + * An array of key => value pairs that will be used for + * interpolation and environment variables + * @var array + * @see setInterpolationVars() + * @see getInterpolationVars() + */ + protected $interpolation_vars = array(); /** * Set up the builder. @@ -236,7 +245,46 @@ class Builder { $this->log("\033[0;31m" . $message . "\033[0m"); } + + /** + * Get an array key => value pairs that are used for interpolation + * @return array + */ + public function getInterpolationVars() + { + return $this->interpolation_vars; + } + + /** + * Replace every occurance of the interpolation vars in the given string + * Example: "This is build %PHPCI_BUILD%" => "This is build 182" + * @param string $input + * @return string + */ + public function interpolate($input) + { + $translations = array_walk($this->getInterpolationVars(), function($value, &$key) { + $key = '%'.$key.'%'; + }); + return strtr($input, $translations); + } + /** + * Sets the variables that will be used for interpolation. This must be run + * from setupBuild() because prior to that, we don't know the buildPath + */ + protected function setInterpolationVars() + { + $this->interpolation_vars = array( + 'PHPCI' => 1, + 'PHPCI_COMMIT' => $this->build->getCommitId(), + 'PHPCI_PROJECT' => $this->build->getProject()->getId(), + 'PHPCI_BUILD' => $this->build->getId(), + 'PHPCI_PROJECT_TITLE' => $this->build->getProject()->getTitle(), + 'PHPCI_BUILD_PATH' => $this->buildPath, + ); + } + /** * Set up a working copy of the project for building. */ @@ -247,14 +295,13 @@ class Builder $this->ciDir = realpath(dirname(__FILE__) . '/../') . '/'; $this->buildPath = $this->ciDir . 'build/' . $buildId . '/'; + $this->setInterpolationVars(); + // Setup environment vars that will be accessible during exec() - putenv("PHPCI=1"); - putenv("PHPCI_COMMIT=".$commitId); - putenv("PHPCI_PROJECT=".$this->build->getProject()->getId()); - putenv("PHPCI_BUILD=".$this->build->getId()); - putenv("PHPCI_PROJECT_TITLE=".$this->build->getProject()->getTitle()); - putenv("PHPCI_BUILD_PATH=".$this->buildPath); - + foreach ($this->getInterpolationVars() as $key => $value) { + putenv($key.'='.$value); + } + // Create a working copy of the project: if (!$this->build->createWorkingCopy($this, $this->buildPath)) { return false; From 095b7d7f14ecadf6a09e9112e44df117e3a97b9b Mon Sep 17 00:00:00 2001 From: Steve Kamerman Date: Wed, 22 May 2013 14:21:17 -0400 Subject: [PATCH 04/11] Added support for interpolation in MySQL host, user, database, queries and file imports --- PHPCI/Plugin/Mysql.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/PHPCI/Plugin/Mysql.php b/PHPCI/Plugin/Mysql.php index e67c31a4..5138116e 100644 --- a/PHPCI/Plugin/Mysql.php +++ b/PHPCI/Plugin/Mysql.php @@ -51,8 +51,8 @@ class Mysql implements \PHPCI\Plugin if (isset($buildSettings['mysql'])) { $sql = $buildSettings['mysql']; - $this->host = !empty($sql['host']) ? $sql['host'] : $this->host; - $this->user = !empty($sql['user']) ? $sql['user'] : $this->user; + $this->host = !empty($sql['host']) ? $sql['host'] : $this->phpci->interpolate($this->host); + $this->user = !empty($sql['user']) ? $sql['user'] : $this->phpci->interpolate($this->user); $this->pass = array_key_exists('pass', $sql) ? $sql['pass'] : $this->pass; } } @@ -71,10 +71,12 @@ class Mysql implements \PHPCI\Plugin foreach ($this->queries as $query) { if (!is_array($query)) { // Simple query - $this->pdo->query($query); + $this->pdo->query($this->phpci->interpolate($query)); } else if (isset($query['import'])) { // SQL file execution $this->executeFile($query['import']); + } else { + throw new \Exception("Invalid command"); } } } catch (\Exception $ex) { @@ -88,15 +90,15 @@ class Mysql implements \PHPCI\Plugin protected function executeFile($query) { if (!isset($query['file'])) { - throw new \Exception("Import statement must contiain an 'file' key"); + throw new \Exception("Import statement must contain a 'file' key"); } - $import_file = $this->phpci->buildPath . $query['file']; + $import_file = $this->phpci->buildPath . $this->phpci->interpolate($query['file']); if (!is_readable($import_file)) { throw new \Exception("Cannot open SQL import file: $import_file"); } - $database = isset($query['database'])? $query['database']: null; + $database = isset($query['database'])? $this->phpci->interpolate($query['database']): null; $import_command = $this->getImportCommand($import_file, $database); if (!$this->phpci->executeCommand($import_command)) { From 0a755cedaee148fdd81686b5e125d0db1843017c Mon Sep 17 00:00:00 2001 From: Steve Kamerman Date: Wed, 22 May 2013 15:17:54 -0400 Subject: [PATCH 05/11] array_walk doesn't alter keys, fixed --- PHPCI/Builder.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/PHPCI/Builder.php b/PHPCI/Builder.php index 2043531f..a7b60bc1 100644 --- a/PHPCI/Builder.php +++ b/PHPCI/Builder.php @@ -263,10 +263,11 @@ class Builder */ public function interpolate($input) { - $translations = array_walk($this->getInterpolationVars(), function($value, &$key) { - $key = '%'.$key.'%'; - }); - return strtr($input, $translations); + $trans_table = array(); + foreach ($this->getInterpolationVars() as $key => $value) { + $trans_table['%'.$key.'%'] = $value; + } + return strtr($input, $trans_table); } /** From d7c62f36092e62cad1e6ffb53ef6dc4e88fab6ff Mon Sep 17 00:00:00 2001 From: Steve Kamerman Date: Wed, 22 May 2013 15:54:18 -0400 Subject: [PATCH 06/11] Added interpolation support to Env plugin --- PHPCI/Plugin/Env.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PHPCI/Plugin/Env.php b/PHPCI/Plugin/Env.php index 1de016fb..e09d3dbf 100644 --- a/PHPCI/Plugin/Env.php +++ b/PHPCI/Plugin/Env.php @@ -41,7 +41,7 @@ class Env implements \PHPCI\Plugin $env_var = "$key=$value"; } - if (!putenv($env_var)) { + if (!putenv($this->phpci->interpolate($env_var))) { $success = false; $this->phpci->logFailure("Unable to set environment variable"); } From 81b2f89435dd54f5c2dee982223243cfc9576455 Mon Sep 17 00:00:00 2001 From: Gabriel Baker Date: Wed, 22 May 2013 21:43:19 +0100 Subject: [PATCH 07/11] PHP CS Fixer and indentation fix --- PHPCI/Plugin/PhpCsFixer.php | 89 +++++++++++++++++++++++++++++++++++++ composer.json | 35 ++++++++------- 2 files changed, 107 insertions(+), 17 deletions(-) create mode 100644 PHPCI/Plugin/PhpCsFixer.php diff --git a/PHPCI/Plugin/PhpCsFixer.php b/PHPCI/Plugin/PhpCsFixer.php new file mode 100644 index 00000000..571a7e8d --- /dev/null +++ b/PHPCI/Plugin/PhpCsFixer.php @@ -0,0 +1,89 @@ + +* @package PHPCI +* @subpackage Plugins +*/ +class PhpCsFixer implements \PHPCI\Plugin +{ + protected $phpci; + + protected $args = ''; + + protected $workingDir = ''; + protected $level = 'all'; + protected $dryRun = true; + protected $verbose = false; + protected $diff = false; + protected $levels = array('psr0', 'psr1', 'psr2', 'all'); + + public function __construct(\PHPCI\Builder $phpci, array $options = array()) + { + $this->phpci = $phpci; + $this->workingdir = $this->phpci->buildPath; + $this->buildArgs($options); + } + + public function execute() + { + $success = false; + + $curdir = getcwd(); + chdir($this->workingdir); + + $cmd = PHPCI_BIN_DIR . 'php-cs-fixer fix . %s'; + $success = $this->phpci->executeCommand($cmd, $this->args); + + chdir($curdir); + + return $success; + } + + public function buildArgs($options) + { + $argstring = ""; + + if ( array_key_exists('verbose', $options) && $options['verbose'] ) + { + $this->verbose = true; + $this->args .= ' --verbose'; + } + + if ( array_key_exists('diff', $options) && $options['diff'] ) + { + $this->diff = true; + $this->args .= ' --diff'; + } + + if ( array_key_exists('level', $options) && array_key_exists($options['level'], $this->levels) ) + { + $this->level = $options['level']; + $this->args .= ' --level='.$options['level']; + } + + if ( array_key_exists('dryrun', $options) && $options['dryrun'] ) + { + $this->dryRun = true; + $this->args .= ' --dry-run'; + } + + if ( array_key_exists('workingdir', $options) + && $options['workingdir'] + && is_dir($this->phpci->buildPath.$options['workingdir']) ) + { + $this->workingdir = $this->phpci->buildPath.$options['workingdir']; + } + + } +} \ No newline at end of file diff --git a/composer.json b/composer.json index 03e9ec38..7b8c37b3 100644 --- a/composer.json +++ b/composer.json @@ -1,36 +1,37 @@ { - "name": "block8/phpci", - "description": "Simple continuous integration for PHP projects.", + "name" : "block8/phpci", + "description" : "Simple continuous integration for PHP projects.", "minimum-stability": "dev", - "type": "library", - "keywords": ["php", "phpci", "ci", "continuous", "integration", "testing", "phpunit", "continuous integration", "jenkins", "travis"], - "homepage": "http://www.phptesting.org/", - "license": "BSD-2-Clause", + "type" : "library", + "keywords" : ["php", "phpci", "ci", "continuous", "integration", "testing", "phpunit", "continuous integration", "jenkins", "travis"], + "homepage" : "http://www.phptesting.org/", + "license" : "BSD-2-Clause", "authors": [ { - "name": "Dan Cryer", - "email": "dan.cryer@block8.co.uk", + "name" : "Dan Cryer", + "email" : "dan.cryer@block8.co.uk", "homepage": "http://www.block8.co.uk", - "role": "Developer" + "role" : "Developer" } ], "support": { - "email": "hello+phpci@block8.co.uk", + "email" : "hello+phpci@block8.co.uk", "issues": "https://github.com/Block8/PHPCI/issues", "source": "https://github.com/Block8/PHPCI" }, "require": { - "block8/b8framework": "dev-master", - "phpunit/phpunit": "3.*", - "phpmd/phpmd" : "1.*", - "sebastian/phpcpd": "1.*", + "block8/b8framework" : "dev-master", + "phpunit/phpunit" : "3.*", + "phpmd/phpmd" : "1.*", + "sebastian/phpcpd" : "1.*", "squizlabs/php_codesniffer": "1.*", "ircmaxell/password-compat": "1.x", - "phpspec/phpspec": "2.*", - "symfony/yaml": "2.2.x-dev", - "symfony/console": "2.2.*" + "phpspec/phpspec" : "2.*", + "symfony/yaml" : "2.2.x-dev", + "symfony/console" : "2.2.*", + "fabpot/php-cs-fixer" : "0.3.*@dev" } } From be13ec90eeb5c1f5690081f79d74f4a856cab7d2 Mon Sep 17 00:00:00 2001 From: Gabriel Baker Date: Wed, 22 May 2013 21:53:56 +0100 Subject: [PATCH 08/11] indentation --- PHPCI/Plugin/PhpCsFixer.php | 70 ++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/PHPCI/Plugin/PhpCsFixer.php b/PHPCI/Plugin/PhpCsFixer.php index 571a7e8d..b4d298e9 100644 --- a/PHPCI/Plugin/PhpCsFixer.php +++ b/PHPCI/Plugin/PhpCsFixer.php @@ -21,14 +21,14 @@ class PhpCsFixer implements \PHPCI\Plugin protected $args = ''; - protected $workingDir = ''; - protected $level = 'all'; - protected $dryRun = true; - protected $verbose = false; - protected $diff = false; - protected $levels = array('psr0', 'psr1', 'psr2', 'all'); + protected $workingDir = ''; + protected $level = 'all'; + protected $dryRun = true; + protected $verbose = false; + protected $diff = false; + protected $levels = array('psr0', 'psr1', 'psr2', 'all'); - public function __construct(\PHPCI\Builder $phpci, array $options = array()) + public function __construct(\PHPCI\Builder $phpci, array $options = array()) { $this->phpci = $phpci; $this->workingdir = $this->phpci->buildPath; @@ -39,7 +39,7 @@ class PhpCsFixer implements \PHPCI\Plugin { $success = false; - $curdir = getcwd(); + $curdir = getcwd(); chdir($this->workingdir); $cmd = PHPCI_BIN_DIR . 'php-cs-fixer fix . %s'; @@ -52,38 +52,38 @@ class PhpCsFixer implements \PHPCI\Plugin public function buildArgs($options) { - $argstring = ""; + $argstring = ""; - if ( array_key_exists('verbose', $options) && $options['verbose'] ) - { - $this->verbose = true; - $this->args .= ' --verbose'; - } + if ( array_key_exists('verbose', $options) && $options['verbose'] ) + { + $this->verbose = true; + $this->args .= ' --verbose'; + } - if ( array_key_exists('diff', $options) && $options['diff'] ) - { - $this->diff = true; - $this->args .= ' --diff'; - } + if ( array_key_exists('diff', $options) && $options['diff'] ) + { + $this->diff = true; + $this->args .= ' --diff'; + } - if ( array_key_exists('level', $options) && array_key_exists($options['level'], $this->levels) ) - { - $this->level = $options['level']; - $this->args .= ' --level='.$options['level']; - } + if ( array_key_exists('level', $options) && array_key_exists($options['level'], $this->levels) ) + { + $this->level = $options['level']; + $this->args .= ' --level='.$options['level']; + } - if ( array_key_exists('dryrun', $options) && $options['dryrun'] ) - { - $this->dryRun = true; - $this->args .= ' --dry-run'; - } + if ( array_key_exists('dryrun', $options) && $options['dryrun'] ) + { + $this->dryRun = true; + $this->args .= ' --dry-run'; + } - if ( array_key_exists('workingdir', $options) - && $options['workingdir'] - && is_dir($this->phpci->buildPath.$options['workingdir']) ) - { - $this->workingdir = $this->phpci->buildPath.$options['workingdir']; - } + if ( array_key_exists('workingdir', $options) + && $options['workingdir'] + && is_dir($this->phpci->buildPath.$options['workingdir']) ) + { + $this->workingdir = $this->phpci->buildPath.$options['workingdir']; + } } } \ No newline at end of file From e342483f03307687047f8410e9f97a7b3c52b78e Mon Sep 17 00:00:00 2001 From: Gabriel Baker Date: Thu, 23 May 2013 06:36:40 +0100 Subject: [PATCH 09/11] This should be checking the value not the key --- PHPCI/Plugin/PhpCsFixer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PHPCI/Plugin/PhpCsFixer.php b/PHPCI/Plugin/PhpCsFixer.php index b4d298e9..9aaa7536 100644 --- a/PHPCI/Plugin/PhpCsFixer.php +++ b/PHPCI/Plugin/PhpCsFixer.php @@ -66,7 +66,7 @@ class PhpCsFixer implements \PHPCI\Plugin $this->args .= ' --diff'; } - if ( array_key_exists('level', $options) && array_key_exists($options['level'], $this->levels) ) + if ( array_key_exists('level', $options) && in_array($options['level'], $this->levels) ) { $this->level = $options['level']; $this->args .= ' --level='.$options['level']; From ee4eab7a6cb9f7b7ec3705f7c2190be23aff1216 Mon Sep 17 00:00:00 2001 From: "a.cianfarani" Date: Thu, 23 May 2013 11:31:58 +0200 Subject: [PATCH 10/11] Move format controls into ask function --- PHPCI/Command/InstallCommand.php | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/PHPCI/Command/InstallCommand.php b/PHPCI/Command/InstallCommand.php index dea8f430..9c5472c6 100644 --- a/PHPCI/Command/InstallCommand.php +++ b/PHPCI/Command/InstallCommand.php @@ -42,12 +42,7 @@ class InstallCommand extends Command $dbName = $this->ask('Enter the database name PHPCI should use: '); $dbUser = $this->ask('Enter your MySQL username: '); $dbPass = $this->ask('Enter your MySQL password: ', true); - $ciUrl = $this->ask('Your PHPCI URL (without trailing slash): '); - // verify url format and re-ask if wrong - while (! $this->controlFormat($ciUrl, array(FILTER_VALIDATE_URL,"/[^\/]$/i"), $status) ) { - print $status; - $ciUrl = $this->ask('Your PHPCI URL (without trailing slash): '); - } + $ciUrl = $this->ask('Your PHPCI URL (without trailing slash): ', false, array(FILTER_VALIDATE_URL,"/[^\/]$/i")); $ghId = $this->ask('(Optional) Github Application ID: ', true); $ghSecret = $this->ask('(Optional) Github Application Secret: ', true); @@ -88,18 +83,11 @@ b8\Database::setReadServers(array('{$dbHost}')); $gen->generate(); // Try to create a user account: - $adminEmail = $this->ask('Enter your email address (leave blank if updating): ', true); + $adminEmail = $this->ask('Enter your email address (leave blank if updating): ', true, FILTER_VALIDATE_EMAIL); if (empty($adminEmail)) { return; - } else { - // verify e-mail format and re-ask if wrong - while (! $this->controlFormat($adminEmail, FILTER_VALIDATE_EMAIL, $status)) { - print $status; - $adminEmail = $this->ask('Enter your email address (leave blank if updating): '); - } } - $adminPass = $this->ask('Enter your desired admin password: '); $adminName = $this->ask('Enter your name: '); @@ -120,7 +108,7 @@ b8\Database::setReadServers(array('{$dbHost}')); } } - protected function ask($question, $emptyOk = false) + protected function ask($question, $emptyOk = false, $validationFilter = null) { print $question . ' '; @@ -132,9 +120,13 @@ b8\Database::setReadServers(array('{$dbHost}')); $rtn = trim($rtn); if (!$emptyOk && empty($rtn)) { - $rtn = $this->ask($question, $emptyOk); + $rtn = $this->ask($question, $emptyOk, $validationFilter); + } elseif ($validationFilter != null && ! empty($rtn)) { + if(! $this -> controlFormat($rtn, $validationFilter, $statusMessage)) { + print $statusMessage; + $rtn = $this->ask($question, $emptyOk, $validationFilter); + } } - return $rtn; } protected function controlFormat($valueToInspect,$filter,&$statusMessage) @@ -156,6 +148,7 @@ b8\Database::setReadServers(array('{$dbHost}')); } if (! filter_var($valueToInspect, $filter, $options)) { $status = false; + switch ($filter) { case FILTER_VALIDATE_URL : @@ -170,7 +163,6 @@ b8\Database::setReadServers(array('{$dbHost}')); } } } - return $status; } } From 857c14f0cd5fc43aeacab3aad567ff3aebb0bf30 Mon Sep 17 00:00:00 2001 From: "a.cianfarani" Date: Thu, 23 May 2013 12:14:42 +0200 Subject: [PATCH 11/11] Some coding style corrections --- PHPCI/Command/InstallCommand.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PHPCI/Command/InstallCommand.php b/PHPCI/Command/InstallCommand.php index b93249b3..f605833f 100644 --- a/PHPCI/Command/InstallCommand.php +++ b/PHPCI/Command/InstallCommand.php @@ -122,11 +122,12 @@ b8\Database::setReadServers(array('{$dbHost}')); if (!$emptyOk && empty($rtn)) { $rtn = $this->ask($question, $emptyOk, $validationFilter); } elseif ($validationFilter != null && ! empty($rtn)) { - if(! $this -> controlFormat($rtn, $validationFilter, $statusMessage)) { + if (! $this -> controlFormat($rtn, $validationFilter, $statusMessage)) { print $statusMessage; $rtn = $this->ask($question, $emptyOk, $validationFilter); } } + return $rtn; } protected function controlFormat($valueToInspect,$filter,&$statusMessage) @@ -148,7 +149,7 @@ b8\Database::setReadServers(array('{$dbHost}')); } if (! filter_var($valueToInspect, $filter, $options)) { $status = false; - + switch ($filter) { case FILTER_VALIDATE_URL : @@ -163,6 +164,7 @@ b8\Database::setReadServers(array('{$dbHost}')); } } } + return $status; } }