ghaskell /
scaffold
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Ghaskell\Scaffold\Console\Commands; |
||||
| 4 | |||||
| 5 | use Ghaskell\Scaffold\Facades\Vibro; |
||||
| 6 | use Ghaskell\Scaffold\Scaffold; |
||||
| 7 | use Illuminate\Console\Command; |
||||
| 8 | use Symfony\Component\Finder\Finder; |
||||
| 9 | use Illuminate\Filesystem\Filesystem; |
||||
| 10 | |||||
| 11 | //use Illuminate\Console\GeneratorCommand; |
||||
| 12 | |||||
| 13 | class ScaffoldGenerate extends Command |
||||
| 14 | { |
||||
| 15 | protected $migrationFiles; |
||||
| 16 | |||||
| 17 | /** |
||||
| 18 | * The filesystem instance. |
||||
| 19 | * |
||||
| 20 | * @var \Illuminate\Filesystem\Filesystem |
||||
| 21 | */ |
||||
| 22 | protected $files; |
||||
| 23 | |||||
| 24 | /** |
||||
| 25 | * The filesystem instance. |
||||
| 26 | * |
||||
| 27 | * @var \Illuminate\Filesystem\Filesystem |
||||
| 28 | */ |
||||
| 29 | protected $migrations; |
||||
| 30 | |||||
| 31 | |||||
| 32 | /** |
||||
| 33 | * The name and signature of the console command. |
||||
| 34 | * |
||||
| 35 | * @var string |
||||
| 36 | */ |
||||
| 37 | protected $signature = 'scaffold:generate'; |
||||
| 38 | |||||
| 39 | /** |
||||
| 40 | * The console command description. |
||||
| 41 | * |
||||
| 42 | * @var string |
||||
| 43 | */ |
||||
| 44 | protected $description = 'Generate from migration'; |
||||
| 45 | |||||
| 46 | /** |
||||
| 47 | * Create a new command instance. |
||||
| 48 | * |
||||
| 49 | */ |
||||
| 50 | public function __construct(Filesystem $filesystem) |
||||
| 51 | { |
||||
| 52 | parent::__construct(); |
||||
| 53 | $this->files = $filesystem; |
||||
| 54 | $this->migrations = []; |
||||
|
0 ignored issues
–
show
|
|||||
| 55 | } |
||||
| 56 | |||||
| 57 | /** |
||||
| 58 | * Execute the console command. |
||||
| 59 | * |
||||
| 60 | * @return void |
||||
| 61 | */ |
||||
| 62 | public function handle() |
||||
| 63 | { |
||||
| 64 | $this->getMigrations(); |
||||
| 65 | $files = config('scaffold.files'); |
||||
| 66 | |||||
| 67 | $migration = $this->choice('Generate from which migration?', $this->migrations); |
||||
|
0 ignored issues
–
show
$this->migrations of type Illuminate\Filesystem\Filesystem is incompatible with the type array expected by parameter $choices of Illuminate\Console\Command::choice().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 68 | $key = $this->choice('Generate which file?', array_keys($files)); |
||||
| 69 | // $file = $files[$key]; |
||||
| 70 | |||||
| 71 | |||||
| 72 | // foreach ($this->migrations as $migration) { |
||||
| 73 | $this->line("------------------------------------------------------------------------------------------------------------------"); |
||||
| 74 | $this->info("Generating for {$migration}"); |
||||
| 75 | $this->line("------------------------------------------------------------------------------------------------------------------"); |
||||
| 76 | $scaffold = Scaffold::make($migration); |
||||
| 77 | $file = $files[$key]; |
||||
| 78 | $scaffold->generate($key); |
||||
| 79 | if(!empty($file['dependencies'])) { |
||||
| 80 | foreach($file['dependencies'] as $dependency) |
||||
| 81 | { |
||||
| 82 | $scaffold->generate($dependency); |
||||
| 83 | } |
||||
| 84 | } |
||||
| 85 | |||||
| 86 | $scaffold->addRoutes(); |
||||
| 87 | |||||
| 88 | foreach($scaffold->created as $created) { |
||||
| 89 | $this->info("File '$created' generated."); |
||||
| 90 | } |
||||
| 91 | foreach($scaffold->messages as $message) { |
||||
| 92 | $this->comment($message); |
||||
| 93 | } |
||||
| 94 | $this->line("------------------------------------------------------------------------------------------------------------------"); |
||||
| 95 | |||||
| 96 | // } |
||||
| 97 | } |
||||
| 98 | protected function getMigrations() |
||||
| 99 | { |
||||
| 100 | //Remove built in files |
||||
| 101 | $finder = new Finder(); |
||||
| 102 | $files = $finder->files() |
||||
| 103 | ->name('*table.php') |
||||
| 104 | ->notName('2014*') |
||||
| 105 | ->in(database_path() . '/migrations'); |
||||
| 106 | |||||
| 107 | foreach ($files as $file) { |
||||
| 108 | $this->migrations[] = $file->getRealPath() ; |
||||
| 109 | } |
||||
| 110 | } |
||||
| 111 | } |
||||
| 112 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..