@@ -125,7 +125,7 @@ |
||
125 | 125 | * @param string $name |
126 | 126 | * @param string $path |
127 | 127 | * |
128 | - * @return boolean |
|
128 | + * @return boolean|null |
|
129 | 129 | */ |
130 | 130 | public function addSite($name, $path) |
131 | 131 | { |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | } |
22 | 22 | |
23 | 23 | public function sitePathExists($path) { |
24 | - foreach($this->sites as $site){ |
|
25 | - if(dirname($path) === dirname($site->path)){ |
|
24 | + foreach ($this->sites as $site) { |
|
25 | + if (dirname($path) === dirname($site->path)) { |
|
26 | 26 | return true; |
27 | 27 | } |
28 | 28 | } |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | $request = Request::createFromGlobals(); |
39 | 39 | $server = $request->server; |
40 | 40 | $selim_foldername = "/.selim/"; |
41 | - if($server->get("HOME")){ |
|
41 | + if ($server->get("HOME")) { |
|
42 | 42 | $conf_dir = $server->get("HOME").$selim_foldername; |
43 | - }else if($server->get("HOMEDRIVE")){ |
|
43 | + } else if ($server->get("HOMEDRIVE")) { |
|
44 | 44 | $conf_dir = "{$server->get("HOMEDRIVE")}{$server->get("HOMEPATH")}{$selim_foldername}"; |
45 | - }else{ |
|
45 | + } else { |
|
46 | 46 | Util::reportError("Can't find Homedir. Aborting..."); |
47 | 47 | return; |
48 | 48 | } |
49 | 49 | |
50 | - if(!file_exists($conf_dir)){ |
|
50 | + if (!file_exists($conf_dir)) { |
|
51 | 51 | mkdir($conf_dir); |
52 | 52 | } |
53 | 53 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | public function removeSite($name) |
136 | 136 | { |
137 | 137 | $size = count($this->sites); |
138 | - for ($i = 0; $i < $size;$i++) { |
|
138 | + for ($i = 0; $i < $size; $i++) { |
|
139 | 139 | $s = $this->sites[$i]; |
140 | 140 | if ($s->name === $name) { |
141 | 141 | array_splice($this->sites, $i, 1); |
@@ -144,21 +144,21 @@ discard block |
||
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - public function setPath($config_path = "",$is_cli = true) { |
|
147 | + public function setPath($config_path = "", $is_cli = true) { |
|
148 | 148 | $dir = dirname($config_path); |
149 | - if(file_exists($dir)) { |
|
150 | - if(!file_exists($config_path) && $is_cli){ |
|
149 | + if (file_exists($dir)) { |
|
150 | + if (!file_exists($config_path) && $is_cli) { |
|
151 | 151 | echo "The file $config_path doesn't exist. Do you want to create it? yes/[no]"; |
152 | 152 | $line = fgets(STDIN); |
153 | - if(preg_match("/^y|yes/", $line)) { |
|
153 | + if (preg_match("/^y|yes/", $line)) { |
|
154 | 154 | file_put_contents($config_path, '{"sites":{}}'); |
155 | - }else{ |
|
155 | + } else { |
|
156 | 156 | Util::reportError("Aborting..."); |
157 | 157 | } |
158 | 158 | } |
159 | 159 | $this->path_config = $config_path; |
160 | 160 | $this->load(); |
161 | - }else{ |
|
161 | + } else { |
|
162 | 162 | Util::reportError("The directory \"$dir\" doesnt exist."); |
163 | 163 | } |
164 | 164 | } |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | $selim_foldername = "/.selim/"; |
41 | 41 | if($server->get("HOME")){ |
42 | 42 | $conf_dir = $server->get("HOME").$selim_foldername; |
43 | - }else if($server->get("HOMEDRIVE")){ |
|
43 | + } else if($server->get("HOMEDRIVE")){ |
|
44 | 44 | $conf_dir = "{$server->get("HOMEDRIVE")}{$server->get("HOMEPATH")}{$selim_foldername}"; |
45 | - }else{ |
|
45 | + } else{ |
|
46 | 46 | Util::reportError("Can't find Homedir. Aborting..."); |
47 | 47 | return; |
48 | 48 | } |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | $line = fgets(STDIN); |
153 | 153 | if(preg_match("/^y|yes/", $line)) { |
154 | 154 | file_put_contents($config_path, '{"sites":{}}'); |
155 | - }else{ |
|
155 | + } else{ |
|
156 | 156 | Util::reportError("Aborting..."); |
157 | 157 | } |
158 | 158 | } |
159 | 159 | $this->path_config = $config_path; |
160 | 160 | $this->load(); |
161 | - }else{ |
|
161 | + } else{ |
|
162 | 162 | Util::reportError("The directory \"$dir\" doesnt exist."); |
163 | 163 | } |
164 | 164 | } |
@@ -39,7 +39,7 @@ |
||
39 | 39 | * |
40 | 40 | * @param string $path |
41 | 41 | * |
42 | - * @return boolean |
|
42 | + * @return boolean|null |
|
43 | 43 | */ |
44 | 44 | public function setupPaths($path) |
45 | 45 | { |
@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Selim; |
4 | 4 | |
5 | -use Exception; |
|
6 | -use Symfony\Component\Yaml\Exception\ParseException; |
|
5 | +use Exception; |
|
6 | +use Symfony\Component\Yaml\Exception\ParseException; |
|
7 | 7 | use Symfony\Component\Yaml\Yaml; |
8 | 8 | |
9 | 9 | class SilverstripePage |
@@ -127,7 +127,7 @@ |
||
127 | 127 | echo $e->getMessage().PHP_EOL; |
128 | 128 | } |
129 | 129 | } |
130 | - }else{ |
|
130 | + } else { |
|
131 | 131 | $this->envtype = "live"; |
132 | 132 | } |
133 | 133 | } |
@@ -127,7 +127,7 @@ |
||
127 | 127 | echo $e->getMessage().PHP_EOL; |
128 | 128 | } |
129 | 129 | } |
130 | - }else{ |
|
130 | + } else{ |
|
131 | 131 | $this->envtype = "live"; |
132 | 132 | } |
133 | 133 | } |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use Symfony\Component\Console\Input\InputInterface; |
7 | 7 | |
8 | 8 | class SelimApplication extends Application { |
9 | - public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN'){ |
|
10 | - parent::__construct($name,$version); |
|
9 | + public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') { |
|
10 | + parent::__construct($name, $version); |
|
11 | 11 | $this->selim_config = SelimConfig::getInstance(); |
12 | 12 | } |
13 | 13 | |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | * @param InputInterface $input |
16 | 16 | * @return SelimConfig |
17 | 17 | */ |
18 | - public function getSelimConfig(InputInterface $input){ |
|
18 | + public function getSelimConfig(InputInterface $input) { |
|
19 | 19 | $config_path = $input->getOption('config'); |
20 | - if($config_path) { |
|
20 | + if ($config_path) { |
|
21 | 21 | $this->selim_config->setPath($config_path); |
22 | 22 | } |
23 | 23 | return $this->selim_config; |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use Symfony\Component\Console\Input\InputInterface; |
10 | 10 | use Symfony\Component\Console\Output\OutputInterface; |
11 | 11 | |
12 | -class SecurityCommand extends SelimCommand{ |
|
12 | +class SecurityCommand extends SelimCommand { |
|
13 | 13 | protected function configure() |
14 | 14 | { |
15 | 15 | parent::configure(); |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | $sc = SecurityChecker::getInstance(); |
35 | 35 | $issues = $sc->findIssues(new SilverstripePage($site), true); |
36 | 36 | |
37 | - if(count($issues)) { |
|
37 | + if (count($issues)) { |
|
38 | 38 | foreach ($issues as $iss) { |
39 | 39 | echo $iss; |
40 | 40 | } |
41 | - }else{ |
|
41 | + } else { |
|
42 | 42 | echo "No security issues found."; |
43 | 43 | } |
44 | 44 | } else { |
@@ -38,7 +38,7 @@ |
||
38 | 38 | foreach ($issues as $iss) { |
39 | 39 | echo $iss; |
40 | 40 | } |
41 | - }else{ |
|
41 | + } else{ |
|
42 | 42 | echo "No security issues found."; |
43 | 43 | } |
44 | 44 | } else { |
@@ -7,7 +7,7 @@ |
||
7 | 7 | use Symfony\Component\Console\Input\InputInterface; |
8 | 8 | use Symfony\Component\Console\Output\OutputInterface; |
9 | 9 | |
10 | -class RemoveSiteCommand extends SelimCommand{ |
|
10 | +class RemoveSiteCommand extends SelimCommand { |
|
11 | 11 | protected function configure() |
12 | 12 | { |
13 | 13 | parent::configure(); |
@@ -11,7 +11,7 @@ |
||
11 | 11 | use Symfony\Component\Console\Input\InputOption; |
12 | 12 | use Symfony\Component\Console\Output\OutputInterface; |
13 | 13 | |
14 | -class DefaultCommand extends SelimCommand{ |
|
14 | +class DefaultCommand extends SelimCommand { |
|
15 | 15 | protected function configure() |
16 | 16 | { |
17 | 17 | parent::configure(); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | use Symfony\Component\Console\Output\OutputInterface; |
11 | 11 | use Symfony\Component\Console\Question\Question; |
12 | 12 | |
13 | -class FindSitesCommand extends SelimCommand{ |
|
13 | +class FindSitesCommand extends SelimCommand { |
|
14 | 14 | protected function configure() |
15 | 15 | { |
16 | 16 | parent::configure(); |
@@ -35,40 +35,40 @@ discard block |
||
35 | 35 | $skippaths = $input->getOption("skip-known-paths") ? true : false; |
36 | 36 | $path = realpath($input->getArgument("path")); |
37 | 37 | $projects = array(); |
38 | - $question_helper = $this->getHelper("question"); |
|
38 | + $question_helper = $this->getHelper("question"); |
|
39 | 39 | |
40 | 40 | $output->write("Start searching _config.php files..."); |
41 | 41 | $fact = new File_Iterator_Factory(); |
42 | - $iterator = $fact->getFileIterator($path,"php","_config"); |
|
42 | + $iterator = $fact->getFileIterator($path, "php", "_config"); |
|
43 | 43 | $output->writeln("OK"); |
44 | 44 | |
45 | 45 | $output->write("Filter for project paths..."); |
46 | - while($file = $iterator->current()){ |
|
46 | + while ($file = $iterator->current()) { |
|
47 | 47 | $content = Util::stripPhpComments(file_get_contents($file)); |
48 | - if(preg_match("/\\\$project\\s=/",$content)){ |
|
49 | - array_push($projects,dirname($file)); |
|
48 | + if (preg_match("/\\\$project\\s=/", $content)) { |
|
49 | + array_push($projects, dirname($file)); |
|
50 | 50 | } |
51 | 51 | $iterator->next(); |
52 | 52 | } |
53 | 53 | $output->writeln("OK"); |
54 | 54 | |
55 | - if(count($projects)){ |
|
55 | + if (count($projects)) { |
|
56 | 56 | $sites_added = false; |
57 | 57 | $output->writeln("found ".count($projects)." possible sites"); |
58 | - foreach($projects as $p){ |
|
59 | - if($skippaths && $cfg->sitePathExists($p)) continue; |
|
58 | + foreach ($projects as $p) { |
|
59 | + if ($skippaths && $cfg->sitePathExists($p)) continue; |
|
60 | 60 | |
61 | 61 | $question = new Question("Please enter name for '$p' (leave empty to skip)"); |
62 | 62 | do { |
63 | 63 | $name = $question_helper->ask($input, $output, $question); |
64 | - }while($cfg->siteExists($name)); |
|
64 | + }while ($cfg->siteExists($name)); |
|
65 | 65 | |
66 | - if($name){ |
|
66 | + if ($name) { |
|
67 | 67 | $sites_added = true; |
68 | - $cfg->addSite($name,$p); |
|
68 | + $cfg->addSite($name, $p); |
|
69 | 69 | } |
70 | 70 | } |
71 | - if($sites_added) { |
|
71 | + if ($sites_added) { |
|
72 | 72 | $output->write("Writing config.json ..."); |
73 | 73 | $cfg->write(); |
74 | 74 | $output->writeln("OK"); |
@@ -56,7 +56,9 @@ |
||
56 | 56 | $sites_added = false; |
57 | 57 | $output->writeln("found ".count($projects)." possible sites"); |
58 | 58 | foreach($projects as $p){ |
59 | - if($skippaths && $cfg->sitePathExists($p)) continue; |
|
59 | + if($skippaths && $cfg->sitePathExists($p)) { |
|
60 | + continue; |
|
61 | + } |
|
60 | 62 | |
61 | 63 | $question = new Question("Please enter name for '$p' (leave empty to skip)"); |
62 | 64 | do { |
@@ -6,7 +6,7 @@ |
||
6 | 6 | use Symfony\Component\Console\Input\InputInterface; |
7 | 7 | use Symfony\Component\Console\Output\OutputInterface; |
8 | 8 | |
9 | -class AddSiteCommand extends SelimCommand{ |
|
9 | +class AddSiteCommand extends SelimCommand { |
|
10 | 10 | protected function configure() |
11 | 11 | { |
12 | 12 | parent::configure(); |
@@ -7,20 +7,20 @@ |
||
7 | 7 | use Symfony\Component\Console\Command\Command; |
8 | 8 | use Symfony\Component\Console\Input\InputInterface; |
9 | 9 | |
10 | -abstract class SelimCommand extends Command{ |
|
10 | +abstract class SelimCommand extends Command { |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * @param InputInterface $input |
14 | 14 | * @return SelimConfig |
15 | 15 | */ |
16 | - protected function getSelimConfig(InputInterface $input){ |
|
16 | + protected function getSelimConfig(InputInterface $input) { |
|
17 | 17 | return $this->getApplication()->getSelimConfig($input); |
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @return SelimApplication |
22 | 22 | */ |
23 | - public function getApplication(){ |
|
23 | + public function getApplication() { |
|
24 | 24 | return parent::getApplication(); |
25 | 25 | } |
26 | 26 | } |
27 | 27 | \ No newline at end of file |