This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace agoalofalife\Commands; |
||
3 | |||
4 | |||
5 | use Carbon\Carbon; |
||
6 | use Symfony\Component\Console\Command\Command; |
||
7 | use Symfony\Component\Console\Formatter\OutputFormatterStyle; |
||
8 | use Symfony\Component\Console\Helper\ProgressBar; |
||
9 | use Symfony\Component\Console\Input\InputInterface; |
||
10 | use Symfony\Component\Console\Output\OutputInterface; |
||
11 | |||
12 | class MigrateLaravelCommand extends Command |
||
13 | { |
||
14 | protected $listFileMigrations = [ |
||
15 | 'country' => '_Acreate_table_country', |
||
16 | 'regions' => '_Bcreate_table_regions', |
||
17 | 'cities' => '_Ccreate_table_cities' |
||
18 | ]; |
||
19 | |||
20 | protected $listFilesSeeder = [ |
||
21 | 'CountryTableSeeder' => 'CountryTableSeeder.php', |
||
22 | 'RegionsTableSeeder' => 'RegionsTableSeeder.php', |
||
23 | 'CitiesTableSeeder' => 'CitiesTableSeeder.php' |
||
24 | ]; |
||
25 | |||
26 | protected $formatterStyle; |
||
27 | protected $progressBar; |
||
28 | |||
29 | 2 | public function __construct(OutputFormatterStyle $formatterStyle, ProgressBar $bar) |
|
30 | { |
||
31 | 2 | parent::__construct(); |
|
32 | 2 | $this->formatterStyle = $formatterStyle; |
|
33 | 2 | $this->progressBar = $bar; |
|
34 | 2 | $this->progressBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%'); |
|
35 | 2 | } |
|
36 | |||
37 | 2 | protected function configure() : void |
|
38 | { |
||
39 | 2 | $this->setName('migrate:laravel')->setHelp('to migrate files to Laravel'); |
|
40 | 2 | } |
|
41 | |||
42 | protected function execute(InputInterface $input, OutputInterface $output) |
||
43 | { |
||
44 | $output->getFormatter()->setStyle('fire', $this->formatterStyle); |
||
45 | |||
46 | $output->writeln([ |
||
0 ignored issues
–
show
|
|||
47 | '<fire>There is a migration in the project Laravel</fire>', |
||
48 | '' |
||
49 | ]); |
||
50 | |||
51 | $this->progressBar->start(); |
||
52 | |||
53 | $this->moveMigrate( $this->progressBar ); |
||
54 | $this->moveSeeders( $this->progressBar ); |
||
55 | $this->moveConfig( $this->progressBar ); |
||
56 | |||
57 | $this->progressBar->finish(); |
||
58 | $output->writeln(['']); |
||
0 ignored issues
–
show
array('') is of type array<integer,string,{"0":"string"}> , but the function expects a string|object<Symfony\Co...onsole\Output\iterable> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
59 | $output->writeln(['<info>All successfully copied!</info>']); |
||
0 ignored issues
–
show
array('<info>All successfully copied!</info>') is of type array<integer,string,{"0":"string"}> , but the function expects a string|object<Symfony\Co...onsole\Output\iterable> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
60 | } |
||
61 | |||
62 | View Code Duplication | protected function moveMigrate(ProgressBar $progress) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
63 | { |
||
64 | $pathToMigrationsLaravel = $_SERVER["PWD"] . '/database/migrations/'; |
||
65 | $pathToStubs = __DIR__ . '/../database/migrations/stubs/'; |
||
66 | |||
67 | $this->createDir($pathToMigrationsLaravel); |
||
68 | |||
69 | foreach ($this->listFileMigrations as $name => $migrate) |
||
70 | { |
||
71 | $fileName = $pathToMigrationsLaravel . $this->getDateNormalize() . $migrate . '.php'; |
||
72 | file_put_contents($fileName, $this->getContent($pathToStubs . $name)); |
||
73 | $progress->advance(); |
||
74 | } |
||
75 | } |
||
76 | |||
77 | View Code Duplication | protected function moveSeeders(ProgressBar $progress) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
78 | { |
||
79 | $pathToSeedersLaravel = $_SERVER["PWD"] . '/database/seeds/'; |
||
80 | $pathToSeed = __DIR__ . '/../database/seeds/stubs/'; |
||
81 | |||
82 | $this->createDir($pathToSeedersLaravel); |
||
83 | |||
84 | foreach ($this->listFilesSeeder as $name => $seed) |
||
85 | { |
||
86 | $fileName = $pathToSeedersLaravel . $seed; |
||
87 | file_put_contents($fileName, $this->getContent($pathToSeed . $name)); |
||
88 | $progress->advance(); |
||
89 | } |
||
90 | } |
||
91 | |||
92 | protected function moveConfig(ProgressBar $progress) : void |
||
93 | { |
||
94 | $pathToConfig = __DIR__ . '/../config.php'; |
||
95 | $pathToConfigsLaravel = $_SERVER["PWD"] . '/config/'; |
||
96 | $this->createDir($pathToConfigsLaravel); |
||
97 | |||
98 | copy($pathToConfig,$pathToConfigsLaravel . 'geography.php' ); |
||
99 | $progress->advance(); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * Just create directory |
||
104 | * @param $dir |
||
105 | */ |
||
106 | protected function createDir(string $dir) : void |
||
107 | { |
||
108 | if (is_dir($dir) === false) |
||
109 | { |
||
110 | mkdir($dir, 0777, true); |
||
111 | } |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * Data from stubs file |
||
116 | * @param $nameFile |
||
117 | * @return bool|string |
||
118 | */ |
||
119 | protected function getContent(string $nameFile) : string |
||
120 | { |
||
121 | return file_get_contents($nameFile); |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * Get date normalize mow |
||
126 | * @return mixed |
||
127 | */ |
||
128 | protected function getDateNormalize() : string |
||
129 | { |
||
130 | $date = Carbon::now(); |
||
131 | $date = preg_replace('/-|\s/','_', $date); |
||
132 | $data = preg_replace('/:/','', $date); |
||
133 | |||
134 | return $data; |
||
135 | } |
||
136 | } |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: