@@ -26,6 +26,10 @@ |
||
26 | 26 | chmod('cli', 0755); |
27 | 27 | } |
28 | 28 | |
29 | + /** |
|
30 | + * @param string $src |
|
31 | + * @param string $dst |
|
32 | + */ |
|
29 | 33 | private static function copy($src, $dst) |
30 | 34 | { |
31 | 35 | $success = copy($src, $dst); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | { |
31 | 31 | $success = copy($src, $dst); |
32 | 32 | if ($success) { |
33 | - echo 'copied: ' . $dst . PHP_EOL; |
|
33 | + echo 'copied: '.$dst.PHP_EOL; |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | |
52 | 52 | foreach ($iterator as $file) { |
53 | 53 | if ($file->isDir()) { |
54 | - @mkdir($dst . '/' . $iterator->getSubPathName()); |
|
54 | + @mkdir($dst.'/'.$iterator->getSubPathName()); |
|
55 | 55 | } else { |
56 | - $success = copy($file, $dst . '/' . $iterator->getSubPathName()); |
|
56 | + $success = copy($file, $dst.'/'.$iterator->getSubPathName()); |
|
57 | 57 | if ($success) { |
58 | - echo 'copied: ' . $dst . '/' . $iterator->getSubPathName() . PHP_EOL; |
|
58 | + echo 'copied: '.$dst.'/'.$iterator->getSubPathName().PHP_EOL; |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | } |
@@ -12,7 +12,6 @@ |
||
12 | 12 | |
13 | 13 | use Aura\Cli\Stdio; |
14 | 14 | use Aura\Cli\Context; |
15 | -use Aura\Cli\Status; |
|
16 | 15 | use CI_Controller; |
17 | 16 | |
18 | 17 | class Seed extends Command |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function __invoke($class = null) |
39 | 39 | { |
40 | - $options =[ |
|
41 | - 'l', // short flag -l, parameter is not allowed |
|
40 | + $options = [ |
|
41 | + 'l', // short flag -l, parameter is not allowed |
|
42 | 42 | 'list', // long option --list, parameter is not allowed |
43 | 43 | ]; |
44 | 44 | $getopt = $this->context->getopt($options); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | if ($class === null) { |
53 | 53 | $seeder_list = $this->findSeeder(); |
54 | 54 | } else { |
55 | - $seeder_list = [$this->seeder_path . $class . '.php']; |
|
55 | + $seeder_list = [$this->seeder_path.$class.'.php']; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | $this->runSeederList($seeder_list); |
@@ -65,30 +65,30 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function call($class) |
67 | 67 | { |
68 | - $seeder_list = [$this->seeder_path . $class . '.php']; |
|
68 | + $seeder_list = [$this->seeder_path.$class.'.php']; |
|
69 | 69 | $this->runSeederList($seeder_list); |
70 | 70 | } |
71 | 71 | |
72 | 72 | private function runSeederList($seeder_list) |
73 | 73 | { |
74 | 74 | foreach ($seeder_list as $file) { |
75 | - if (! is_readable($file)) { |
|
76 | - $this->stdio->errln('<<red>>Can\'t read: ' . $file . '<<reset>>'); |
|
75 | + if (!is_readable($file)) { |
|
76 | + $this->stdio->errln('<<red>>Can\'t read: '.$file.'<<reset>>'); |
|
77 | 77 | break; |
78 | 78 | } |
79 | 79 | require_once $file; |
80 | 80 | $classname = basename($file, '.php'); |
81 | - if (! class_exists($classname)) { |
|
81 | + if (!class_exists($classname)) { |
|
82 | 82 | $this->stdio->errln( |
83 | - '<<red>>No such class: ' . $classname . ' in ' . $file . '<<reset>>' |
|
84 | - . ' [' . __METHOD__ . ': line ' . __LINE__ . ']' |
|
83 | + '<<red>>No such class: '.$classname.' in '.$file.'<<reset>>' |
|
84 | + . ' ['.__METHOD__.': line '.__LINE__.']' |
|
85 | 85 | ); |
86 | 86 | break; |
87 | 87 | } |
88 | 88 | $seeder = new $classname($this->context, $this->stdio, $this->ci); |
89 | 89 | $seeder->setSeederPath($this->seeder_path); |
90 | 90 | $this->runSeed($seeder); |
91 | - $this->stdio->outln('<<green>>Seeded: ' . $classname . '<<reset>>'); |
|
91 | + $this->stdio->outln('<<green>>Seeded: '.$classname.'<<reset>>'); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $seeder_list = $this->findSeeder(); |
98 | 98 | foreach ($seeder_list as $file) { |
99 | 99 | if (is_readable($file)) { |
100 | - $this->stdio->outln(' <<green>>' . $file . '<<reset>>'); |
|
100 | + $this->stdio->outln(' <<green>>'.$file.'<<reset>>'); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | private function findSeeder() |
111 | 111 | { |
112 | 112 | $seeders = []; |
113 | - foreach (glob($this->seeder_path . '*.php') as $file) { |
|
113 | + foreach (glob($this->seeder_path.'*.php') as $file) { |
|
114 | 114 | $seeders[] = $file; |
115 | 115 | } |
116 | 116 | return $seeders; |
@@ -21,21 +21,21 @@ discard block |
||
21 | 21 | $doc_root = 'public'; |
22 | 22 | |
23 | 23 | if (realpath($system_path) !== false) { |
24 | - $system_path = realpath($system_path) . '/'; |
|
24 | + $system_path = realpath($system_path).'/'; |
|
25 | 25 | } |
26 | -$system_path = rtrim($system_path, '/') . '/'; |
|
26 | +$system_path = rtrim($system_path, '/').'/'; |
|
27 | 27 | |
28 | 28 | define('BASEPATH', str_replace("\\", "/", $system_path)); |
29 | -define('FCPATH', $doc_root . '/'); |
|
30 | -define('APPPATH', $application_folder . '/'); |
|
31 | -define('VIEWPATH', $application_folder . '/views/'); |
|
29 | +define('FCPATH', $doc_root.'/'); |
|
30 | +define('APPPATH', $application_folder.'/'); |
|
31 | +define('VIEWPATH', $application_folder.'/views/'); |
|
32 | 32 | |
33 | -require(BASEPATH . 'core/Common.php'); |
|
33 | +require(BASEPATH.'core/Common.php'); |
|
34 | 34 | |
35 | -if (file_exists(APPPATH . 'config/' . ENVIRONMENT . '/constants.php')) { |
|
36 | - require(APPPATH . 'config/' . ENVIRONMENT . '/constants.php'); |
|
35 | +if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php')) { |
|
36 | + require(APPPATH.'config/'.ENVIRONMENT.'/constants.php'); |
|
37 | 37 | } else { |
38 | - require(APPPATH . 'config/constants.php'); |
|
38 | + require(APPPATH.'config/constants.php'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | $charset = strtoupper(config_item('charset')); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | load_class('Input', 'core'); |
74 | 74 | load_class('Lang', 'core'); |
75 | 75 | |
76 | -require(BASEPATH . 'core/Controller.php'); |
|
76 | +require(BASEPATH.'core/Controller.php'); |
|
77 | 77 | |
78 | 78 | function &get_instance() |
79 | 79 | { |
@@ -27,6 +27,6 @@ |
||
27 | 27 | |
28 | 28 | // set the mode here only if it is not already set. |
29 | 29 | // this allows for setting via shell variables, integration testing, etc. |
30 | -if (! isset($_ENV['AURA_CONFIG_MODE'])) { |
|
30 | +if (!isset($_ENV['AURA_CONFIG_MODE'])) { |
|
31 | 31 | $_ENV['AURA_CONFIG_MODE'] = 'dev'; |
32 | 32 | } |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | $di->set('aura/project-kernel:logger', $di->newInstance('Monolog\Logger')); |
31 | 31 | |
32 | 32 | /* @var $ci \CI_Controller */ |
33 | - $ci =& get_instance(); |
|
33 | + $ci = & get_instance(); |
|
34 | 34 | |
35 | 35 | // register built-in command classes |
36 | 36 | foreach ($this->commands as $command) { |
37 | - $class = 'Kenjis\CodeIgniter_Cli\Command\\' . $command; |
|
37 | + $class = 'Kenjis\CodeIgniter_Cli\Command\\'.$command; |
|
38 | 38 | $di->params[$class] = [ |
39 | 39 | 'context' => $di->lazyGet('aura/cli-kernel:context'), |
40 | 40 | 'stdio' => $di->lazyGet('aura/cli-kernel:stdio'), |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | ]; |
43 | 43 | } |
44 | 44 | |
45 | - $seeder_path = APPPATH . 'database/seeds/'; |
|
45 | + $seeder_path = APPPATH.'database/seeds/'; |
|
46 | 46 | $di->setter['Kenjis\CodeIgniter_Cli\Command\Seed']['setSeederPath'] |
47 | 47 | = $seeder_path; |
48 | 48 | |
49 | - $this->user_command_paths = [ APPPATH . 'commands/' ]; |
|
49 | + $this->user_command_paths = [APPPATH.'commands/']; |
|
50 | 50 | // register user command classes |
51 | 51 | UserConfig::registerCommandClasses($di, $ci, $this->user_command_paths); |
52 | 52 | } |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | |
83 | 83 | // register built-in commands |
84 | 84 | foreach ($this->commands as $command) { |
85 | - $class = 'Kenjis\CodeIgniter_Cli\Command\\' . $command; |
|
85 | + $class = 'Kenjis\CodeIgniter_Cli\Command\\'.$command; |
|
86 | 86 | $command_name = strtolower($command); |
87 | 87 | $dispatcher->setObject( |
88 | 88 | $command_name, |
89 | 89 | $di->lazyNew($class) |
90 | 90 | ); |
91 | 91 | |
92 | - $help_class = 'Kenjis\CodeIgniter_Cli\Command\\' . $command . 'Help'; |
|
92 | + $help_class = 'Kenjis\CodeIgniter_Cli\Command\\'.$command.'Help'; |
|
93 | 93 | $help_service->set( |
94 | 94 | $command_name, |
95 | 95 | $di->lazyNew($help_class) |
@@ -2,38 +2,38 @@ discard block |
||
2 | 2 | |
3 | 3 | error_reporting(E_ALL); |
4 | 4 | |
5 | -$autoloader = __DIR__ . '/vendor/autoload.php'; |
|
6 | -if (! file_exists($autoloader)) { |
|
7 | - echo "Composer autoloader not found: $autoloader" . PHP_EOL; |
|
8 | - echo "Please issue 'composer install' and try again." . PHP_EOL; |
|
5 | +$autoloader = __DIR__.'/vendor/autoload.php'; |
|
6 | +if (!file_exists($autoloader)) { |
|
7 | + echo "Composer autoloader not found: $autoloader".PHP_EOL; |
|
8 | + echo "Please issue 'composer install' and try again.".PHP_EOL; |
|
9 | 9 | exit(1); |
10 | 10 | } |
11 | 11 | require $autoloader; |
12 | 12 | |
13 | 13 | /** @const ROOTPATH CodeIgniter project root directory */ |
14 | -define('ROOTPATH', realpath(__DIR__ . '/../../..') . '/'); |
|
14 | +define('ROOTPATH', realpath(__DIR__.'/../../..').'/'); |
|
15 | 15 | chdir(ROOTPATH); |
16 | 16 | |
17 | 17 | class_alias('Kenjis\CodeIgniter_Cli\Command\Command', 'Command'); |
18 | -class_alias('Kenjis\CodeIgniter_Cli\Command\Seed', 'Seeder'); |
|
18 | +class_alias('Kenjis\CodeIgniter_Cli\Command\Seed', 'Seeder'); |
|
19 | 19 | class_alias('Aura\Cli\Help', 'Help'); |
20 | 20 | |
21 | 21 | // Fix argv |
22 | 22 | $_SERVER['argv'] = [ |
23 | - ROOTPATH . 'cli', |
|
23 | + ROOTPATH.'cli', |
|
24 | 24 | ]; |
25 | 25 | $_SERVER['argc'] = 1; |
26 | 26 | |
27 | -require ROOTPATH . '/ci_instance.php'; |
|
27 | +require ROOTPATH.'/ci_instance.php'; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Fixture for testing |
31 | 31 | */ |
32 | -$ci =& get_instance(); |
|
32 | +$ci = & get_instance(); |
|
33 | 33 | |
34 | 34 | // switch database to SQLite for testing |
35 | 35 | $config = [ |
36 | - 'hostname' => 'sqlite:' . __DIR__ . '/tests/data/sqlite-database.db', |
|
36 | + 'hostname' => 'sqlite:'.__DIR__.'/tests/data/sqlite-database.db', |
|
37 | 37 | 'username' => '', |
38 | 38 | 'password' => '', |
39 | 39 | 'database' => '', |
@@ -57,6 +57,6 @@ discard block |
||
57 | 57 | 'migration_table' => 'migrations', |
58 | 58 | 'migration_auto_latest' => false, |
59 | 59 | 'migration_version' => 20150429110003, |
60 | - 'migration_path' => __DIR__ . '/tests/Fake/migrations/', |
|
60 | + 'migration_path' => __DIR__.'/tests/Fake/migrations/', |
|
61 | 61 | ]; |
62 | 62 | $ci->load->library('migration', $config); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | // check class exist |
63 | - foreach (glob($migration_path . '*_*.php') as $file) { |
|
63 | + foreach (glob($migration_path.'*_*.php') as $file) { |
|
64 | 64 | $name = basename($file, '.php'); |
65 | 65 | if (preg_match($migration_type === 'timestamp' ? '/^\d{14}_(\w+)$/' : '/^\d{3}_(\w+)$/', $name, $match)) { |
66 | 66 | if (strtolower($match[1]) === strtolower($classname)) { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | - $template = file_get_contents(__DIR__ . '/templates/Migration.txt'); |
|
75 | + $template = file_get_contents(__DIR__.'/templates/Migration.txt'); |
|
76 | 76 | $search = [ |
77 | 77 | '@@classname@@', |
78 | 78 | '@@date@@', |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $generated = @file_put_contents($file_path, $output, LOCK_EX); |
86 | 86 | |
87 | 87 | if ($generated !== false) { |
88 | - $this->stdio->outln('<<green>>Generated: ' . $file_path . '<<reset>>'); |
|
88 | + $this->stdio->outln('<<green>>Generated: '.$file_path.'<<reset>>'); |
|
89 | 89 | } else { |
90 | 90 | $this->stdio->errln( |
91 | 91 | "<<red>>Can't write to \"$file_path\"<<reset>>" |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $migrations = []; |
101 | 101 | |
102 | 102 | // find max version |
103 | - foreach (glob($migration_path . '*_*.php') as $file) { |
|
103 | + foreach (glob($migration_path.'*_*.php') as $file) { |
|
104 | 104 | $name = basename($file, '.php'); |
105 | 105 | |
106 | 106 | if (preg_match('/^\d{3}_(\w+)$/', $name)) { |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | $version = max($migrations); |
115 | 115 | } |
116 | 116 | |
117 | - return $migration_path . sprintf('%03d', ++$version) . '_' . $classname . '.php'; |
|
117 | + return $migration_path.sprintf('%03d', ++$version).'_'.$classname.'.php'; |
|
118 | 118 | } |
119 | 119 | |
120 | - return $migration_path . date('YmdHis') . '_' . $classname . '.php'; |
|
120 | + return $migration_path.date('YmdHis').'_'.$classname.'.php'; |
|
121 | 121 | } |
122 | 122 | } |
@@ -16,10 +16,10 @@ |
||
16 | 16 | { |
17 | 17 | public function __invoke($type, $classname = null) |
18 | 18 | { |
19 | - $generator = __NAMESPACE__ . '\\Generate\\' . ucfirst($type); |
|
20 | - if (! class_exists($generator)) { |
|
19 | + $generator = __NAMESPACE__.'\\Generate\\'.ucfirst($type); |
|
20 | + if (!class_exists($generator)) { |
|
21 | 21 | $this->stdio->errln( |
22 | - '<<red>>No such generator class: ' . $generator . '<<reset>>' |
|
22 | + '<<red>>No such generator class: '.$generator.'<<reset>>' |
|
23 | 23 | ); |
24 | 24 | return Status::FAILURE; |
25 | 25 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | array_shift($argv); |
29 | 29 | $arguments = implode(' ', $argv); |
30 | 30 | |
31 | - $console = FCPATH . 'index.php'; |
|
31 | + $console = FCPATH.'index.php'; |
|
32 | 32 | $this->stdio->outln( |
33 | 33 | "<<green>>php {$console} {$controller} {$method} {$arguments}<<reset>>" |
34 | 34 | ); |