Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Sep 9, 2023
1 parent 7dc25f1 commit 648f980
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
4 changes: 1 addition & 3 deletions src/CodeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public function setPreset(Presets\Preset $preset)

/**
* Generate code.
*
* @return mixed
*/
public function generateCode(bool $force = false)
{
Expand Down Expand Up @@ -60,7 +58,7 @@ public function getDefaultNamespace(string $rootNamespace): string
/**
* Generator options.
*
* @return array<string, mixed>
* @return array{name: string}
*/
public function generatorOptions(): array
{
Expand Down
19 changes: 17 additions & 2 deletions src/Commands/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
use Illuminate\Console\Concerns\PromptsForMissingInput;
use Illuminate\Console\OutputStyle;
use Illuminate\Console\View\Components\Factory;
use Illuminate\Container\Container;
use Orchestra\Canvas\Core\Presets\Preset;
use Orchestra\Testbench\Foundation\Application as Testbench;
use Symfony\Component\Console\Command\Command as SymfonyConsole;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -27,6 +29,13 @@ abstract class Command extends \Symfony\Component\Console\Command\Command
*/
protected $preset;

/**
* The Laravel application instance.
*
* @var \Illuminate\Contracts\Foundation\Application
*/
protected $laravel;

/**
* Construct a new generator command.
*/
Expand All @@ -38,6 +47,7 @@ public function __construct(Preset $preset)

$this->specifyParameters();
}

/**
* Initializes the command after the input has been bound and before the input
* is validated.
Expand All @@ -56,10 +66,15 @@ protected function initialize(InputInterface $input, OutputInterface $output)
*/
public function run(InputInterface $input, OutputInterface $output): int
{
$this->output = new OutputStyle($input, $output);
$container = Container::getInstance();

$this->laravel = $container->bound('app')
? $container->get('app')
: Testbench::create(basePath: $this->preset->laravelPath());

Check failure on line 73 in src/Commands/Command.php

View workflow job for this annotation

GitHub Actions / PHP8.1 on ubuntu-latest (highest)

Call to an undefined method Orchestra\Canvas\Core\Presets\Preset::laravelPath().

return parent::run(
$this->input = $input, $this->output
$this->input = $input,
$this->output = new OutputStyle($input, $output)
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Commands/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
use Symfony\Component\Console\Output\OutputInterface;

/**
* @property string $name
* @property string $description
* @property string|null $name
* @property string|null $description
*/
abstract class Generator extends Command implements GeneratesCodeListener, PromptsForMissingInput
{
Expand Down
4 changes: 0 additions & 4 deletions src/Contracts/GeneratesCodeListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ interface GeneratesCodeListener
{
/**
* Code already exists.
*
* @return mixed
*/
public function codeAlreadyExists(string $className);

Check failure on line 10 in src/Contracts/GeneratesCodeListener.php

View workflow job for this annotation

GitHub Actions / PHP8.1 on ubuntu-latest (highest)

Method Orchestra\Canvas\Core\Contracts\GeneratesCodeListener::codeAlreadyExists() has no return type specified.

Expand All @@ -18,8 +16,6 @@ public function generatingCode(string $stub, string $className): string;

/**
* Code successfully generated.
*
* @return mixed
*/
public function codeHasBeenGenerated(string $className);

Check failure on line 20 in src/Contracts/GeneratesCodeListener.php

View workflow job for this annotation

GitHub Actions / PHP8.1 on ubuntu-latest (highest)

Method Orchestra\Canvas\Core\Contracts\GeneratesCodeListener::codeHasBeenGenerated() has no return type specified.

Expand Down
2 changes: 0 additions & 2 deletions src/GeneratesCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public function __construct(

/**
* Execute generates code processor.
*
* @return mixed
*/
public function __invoke(bool $force = false)

Check failure on line 38 in src/GeneratesCode.php

View workflow job for this annotation

GitHub Actions / PHP8.1 on ubuntu-latest (highest)

Method Orchestra\Canvas\Core\GeneratesCode::__invoke() has no return type specified.
{
Expand Down
1 change: 0 additions & 1 deletion src/Presets/Preset.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public function is(string $name): bool
* Get configuration.
*
* @param mixed|null $default
* @return mixed
*/
public function config(?string $key = null, $default = null)

Check failure on line 36 in src/Presets/Preset.php

View workflow job for this annotation

GitHub Actions / PHP8.1 on ubuntu-latest (highest)

Method Orchestra\Canvas\Core\Presets\Preset::config() has no return type specified.
{
Expand Down

0 comments on commit 648f980

Please sign in to comment.