@@ -24,7 +24,6 @@ |
||
24 | 24 | use Baleen\Cli\Exception\CliException; |
25 | 25 | use Baleen\Migrations\Migration\SimpleMigration; |
26 | 26 | use League\Flysystem\Filesystem; |
27 | -use phpDocumentor\Reflection\DocBlock\Tag; |
|
28 | 27 | use Zend\Code\Generator\ClassGenerator; |
29 | 28 | use Zend\Code\Generator\DocBlock\Tag\GenericTag; |
30 | 29 | use Zend\Code\Generator\DocBlockGenerator; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | $timestamp = date('YmdHis'); |
79 | - $className = ['v'.$timestamp]; |
|
79 | + $className = ['v' . $timestamp]; |
|
80 | 80 | $title = $input->getArgument('title'); |
81 | 81 | if (!empty($title)) { |
82 | 82 | $title = preg_replace('/[^A-Za-z\d_]+/', '', $title); |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | { |
162 | 162 | $className = $class->getName(); |
163 | 163 | $file = new FileGenerator([ |
164 | - 'fileName' => $className.'.php', |
|
164 | + 'fileName' => $className . '.php', |
|
165 | 165 | 'classes' => [$class], |
166 | 166 | ]); |
167 | 167 | $contents = $file->generate(); |
168 | 168 | |
169 | - $relativePath = $destinationDir.DIRECTORY_SEPARATOR.$file->getFilename(); |
|
169 | + $relativePath = $destinationDir . DIRECTORY_SEPARATOR . $file->getFilename(); |
|
170 | 170 | if ($filesystem->has($relativePath)) { |
171 | 171 | throw new CliException(sprintf( |
172 | 172 | 'Could not generate migration. File already exists: %s', |
@@ -25,7 +25,6 @@ |
||
25 | 25 | use Baleen\Migrations\Migration\MigrationInterface; |
26 | 26 | use Baleen\Migrations\Repository\RepositoryInterface; |
27 | 27 | use Baleen\Migrations\Storage\StorageInterface; |
28 | -use Baleen\Migrations\Version as V; |
|
29 | 28 | use Baleen\Migrations\Version; |
30 | 29 | use Baleen\Migrations\Version\Collection\LinkedVersions; |
31 | 30 | use Baleen\Migrations\Version\Collection\MigratedVersions; |
@@ -197,8 +197,7 @@ discard block |
||
197 | 197 | $this->command->setRepository($this->repository); |
198 | 198 | $this->command->setStorage($this->storage); |
199 | 199 | $currentMsg = $migrated->last() === false ? |
200 | - '/[Nn]othing has been migrated/' : |
|
201 | - '/[Cc]urrent version.*?' . $migrated->last()->getId() . '.*?$/'; |
|
200 | + '/[Nn]othing has been migrated/' : '/[Cc]urrent version.*?' . $migrated->last()->getId() . '.*?$/'; |
|
202 | 201 | $this->output->shouldReceive('writeln')->once()->with($currentMsg); |
203 | 202 | if ($pendingCount > 0) { |
204 | 203 | $this->output->shouldReceive('writeln')->with(m::on(function($messages) use ($pendingCount) { |
@@ -238,7 +237,7 @@ discard block |
||
238 | 237 | // the number of pending migrations with the foreach loop below (see comment below). |
239 | 238 | $repVersions = [ |
240 | 239 | [], |
241 | - Version::fromArray(range(1,10)), |
|
240 | + Version::fromArray(range(1, 10)), |
|
242 | 241 | ]; |
243 | 242 | $repositories = []; |
244 | 243 | foreach ($repVersions as $versions) { |
@@ -247,7 +246,7 @@ discard block |
||
247 | 246 | } |
248 | 247 | $storageVersions = [ |
249 | 248 | [], |
250 | - Version::fromArray(range(1,3)), |
|
249 | + Version::fromArray(range(1, 3)), |
|
251 | 250 | ]; |
252 | 251 | $storages = []; |
253 | 252 | foreach ($storageVersions as $versions) { |
@@ -258,7 +257,7 @@ discard block |
||
258 | 257 | $combinations = $this->combinations([$repositories, $storages]); |
259 | 258 | |
260 | 259 | // calculate pending number of migrations and set that as the third parameter. See note in function header. |
261 | - foreach($combinations as &$combination) { // NB: addressing by reference! |
|
260 | + foreach ($combinations as &$combination) { // NB: addressing by reference! |
|
262 | 261 | $pending = $combination[0]->count() - $combination[1]->count(); |
263 | 262 | $combination[] = $pending; |
264 | 263 | } |
@@ -319,16 +318,16 @@ discard block |
||
319 | 318 | $file3 = '/var/log/http/website/error.log'; |
320 | 319 | $dir1 = '/var'; |
321 | 320 | return [ |
322 | - ['', '', ''], // empty |
|
323 | - ['/', '/', ''], // from root to root |
|
324 | - ['/var', '/var', ''], // from directory to directory |
|
325 | - ['/var/log.php', '/var/log.php', ''], // from file to file |
|
326 | - ['/', '/var/log.php', 'var/log.php'], // from root to file |
|
327 | - ['', '/var/log.php', 'var/log.php'], // without $from (same as from root) |
|
328 | - ['/var', '', '..'], // towards root |
|
329 | - ['/var', '', '..'], // without $to (same as towards root) |
|
330 | - [$file1, $file2, '../../..' . $file2], // backwards traversal |
|
331 | - [$file1, $file3, 'website/error.log'], // inward traversal |
|
321 | + ['', '', ''], // empty |
|
322 | + ['/', '/', ''], // from root to root |
|
323 | + ['/var', '/var', ''], // from directory to directory |
|
324 | + ['/var/log.php', '/var/log.php', ''], // from file to file |
|
325 | + ['/', '/var/log.php', 'var/log.php'], // from root to file |
|
326 | + ['', '/var/log.php', 'var/log.php'], // without $from (same as from root) |
|
327 | + ['/var', '', '..'], // towards root |
|
328 | + ['/var', '', '..'], // without $to (same as towards root) |
|
329 | + [$file1, $file2, '../../..' . $file2], // backwards traversal |
|
330 | + [$file1, $file3, 'website/error.log'], // inward traversal |
|
332 | 331 | [$dir1, $file1, 'log/http/access.log'], // inward traversal from directory |
333 | 332 | ]; |
334 | 333 | } |
@@ -19,7 +19,6 @@ |
||
19 | 19 | |
20 | 20 | namespace BaleenTest\Cli\Provider; |
21 | 21 | |
22 | -use Baleen\Cli\Helper\ConfigHelper; |
|
23 | 22 | use Baleen\Cli\Provider\Services; |
24 | 23 | use Mockery as m; |
25 | 24 | use Symfony\Component\Console\Helper\HelperSet; |
@@ -53,7 +53,7 @@ |
||
53 | 53 | $msg = sprintf('Config file created at "<info>%s</info>".', $message->getConfig()->getFileName()); |
54 | 54 | } else { |
55 | 55 | $msg = sprintf( |
56 | - '<error>Error: Could not create and write file "<info>%s</info>". '. |
|
56 | + '<error>Error: Could not create and write file "<info>%s</info>". ' . |
|
57 | 57 | 'Please check file and directory permissions.</error>', |
58 | 58 | $message->getConfig()->getFileName() |
59 | 59 | ); |
@@ -60,8 +60,7 @@ |
||
60 | 60 | $headVersion = $migratedVersions->last(); |
61 | 61 | |
62 | 62 | $currentMessage = $headVersion ? |
63 | - "Current version: <comment>{$headVersion->getId()}</comment>" : |
|
64 | - 'Nothing has been migrated yet.'; |
|
63 | + "Current version: <comment>{$headVersion->getId()}</comment>" : 'Nothing has been migrated yet.'; |
|
65 | 64 | $output->writeln($currentMessage); |
66 | 65 | |
67 | 66 | $diff = array_diff($availableMigrations->toArray(), $migratedVersions->toArray()); |
@@ -60,7 +60,7 @@ |
||
60 | 60 | protected function outputVersions(LinkedVersions $versions, OutputInterface $output) |
61 | 61 | { |
62 | 62 | foreach ($versions as $version) { |
63 | - $output->writeln('<comment>('.$version->getId().')</comment> '.get_class($version->getMigration())); |
|
63 | + $output->writeln('<comment>(' . $version->getId() . ')</comment> ' . get_class($version->getMigration())); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | } |
@@ -38,8 +38,7 @@ discard block |
||
38 | 38 | $version = (string) $input->getArgument(ExecuteMessage::ARG_VERSION); |
39 | 39 | |
40 | 40 | $direction = $input->getArgument(ExecuteMessage::ARG_DIRECTION) == Options::DIRECTION_DOWN ? |
41 | - Options::DIRECTION_DOWN : |
|
42 | - Options::DIRECTION_UP; |
|
41 | + Options::DIRECTION_DOWN : Options::DIRECTION_UP; |
|
43 | 42 | $dryRun = (bool) $input->getOption(ExecuteMessage::OPT_DRY_RUN); |
44 | 43 | $forced = true; // because we're executing a single migration |
45 | 44 | |
@@ -47,7 +46,7 @@ discard block |
||
47 | 46 | |
48 | 47 | $canExecute = true; |
49 | 48 | if ($input->isInteractive()) { |
50 | - $output->writeln('<error>WARNING!</error> You are about to manually execute a database migration that '. |
|
49 | + $output->writeln('<error>WARNING!</error> You are about to manually execute a database migration that ' . |
|
51 | 50 | 'could result in schema changes and data lost.'); |
52 | 51 | $question = sprintf('Are you sure you wish to migrate "%s" (y/n)? ', $direction); |
53 | 52 | $canExecute = $command->getCliCommand() |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function getMigrationsDirectoryPath() |
153 | 153 | { |
154 | - return getcwd().DIRECTORY_SEPARATOR.$this->getMigrationsDirectory(); |
|
154 | + return getcwd() . DIRECTORY_SEPARATOR . $this->getMigrationsDirectory(); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function getStorageFilePath() |
177 | 177 | { |
178 | - return getcwd().DIRECTORY_SEPARATOR.$this->getStorageFile(); |
|
178 | + return getcwd() . DIRECTORY_SEPARATOR . $this->getStorageFile(); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function getConfigFilePath() |
193 | 193 | { |
194 | - return getcwd().DIRECTORY_SEPARATOR.$this->getFileName(); |
|
194 | + return getcwd() . DIRECTORY_SEPARATOR . $this->getFileName(); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | // add all message classes to the container |
116 | 116 | foreach ($commands as $alias => $config) { |
117 | - $container->add($alias, function (Container $container, $config) { |
|
117 | + $container->add($alias, function(Container $container, $config) { |
|
118 | 118 | /** @var MessageFactoryInterface $factory */ |
119 | 119 | $factory = !empty($config['factory']) ? $config['factory'] : DefaultFactory::class; |
120 | 120 | $factory = $container->get($factory); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | // setup the command bus to know which handler to use for each message class |
133 | - $container->singleton(Services::COMMAND_BUS, function () use ($commands) { |
|
133 | + $container->singleton(Services::COMMAND_BUS, function() use ($commands) { |
|
134 | 134 | $map = []; |
135 | 135 | foreach ($commands as $alias => $config) { |
136 | 136 | $message = $config['message']; |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | }); |
143 | 143 | |
144 | 144 | // create a service (that's just an array) that has a list of all the commands for the app |
145 | - $container->add(Services::COMMANDS, function (ContainerInterface $container) use ($commands) { |
|
145 | + $container->add(Services::COMMANDS, function(ContainerInterface $container) use ($commands) { |
|
146 | 146 | $commandList = []; |
147 | 147 | foreach ($commands as $alias => $config) { |
148 | 148 | $commandList[] = new BaseCommand($container, $alias, $config['message']); |