Skip to content

Commit

Permalink
Merge branch '8.x'
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Nov 27, 2023
2 parents ffeff4f + 466ed3d commit 2c91f5c
Show file tree
Hide file tree
Showing 43 changed files with 277 additions and 15 deletions.
51 changes: 42 additions & 9 deletions .github/workflows/analyse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: analyse
on:
push:
pull_request:
workflow_dispatch:

jobs:
analyse:
Expand All @@ -14,10 +15,12 @@ jobs:
- "ubuntu-latest"
php:
- 8.2
dependencies:
- "highest"
experimental:
- false

name: PHP${{ matrix.php }} on ${{ matrix.os }}
name: PHP${{ matrix.php }} PHPStan & Pint

steps:
- name: Checkout code
Expand All @@ -27,20 +30,50 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, intl, fileinfo
extensions: dom, curl, libxml, mbstring, zip, pcntl, sqlite3, pdo_sqlite, bcmath, fileinfo
coverage: none

- name: Install dependencies
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--prefer-dist --no-cache"

- name: Installed dependencies
run: composer show -D

- name: Execute Code Style Analysis
run: vendor/bin/pint --test

- name: Execute Static Code Analysis
run: vendor/bin/phpstan analyse

lint:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
os:
- "ubuntu-latest"
php:
- 8.3
dependencies:
- "highest"
experimental:
- false

name: PHP${{ matrix.php }} Code Lint

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, sqlite3, pdo_sqlite, bcmath, fileinfo
coverage: none

- name: Install dependencies
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--prefer-dist --no-cache"

- name: PHP Lint
run: php -l ./src
1 change: 1 addition & 0 deletions .github/workflows/audits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
- "ubuntu-latest"
php:
- 8.2
- 8.3
experimental:
- true

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: tests
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '0 0 * * 4'

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"illuminate/support": "^11.0",
"orchestra/canvas-core": "^9.0",
"orchestra/testbench-core": "^9.0",
"symfony/polyfill-php83": "^1.28",
"symfony/yaml": "^7.0"
},
"require-dev": {
Expand Down
2 changes: 2 additions & 0 deletions src/Console/BatchesTableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function __construct(Filesystem $files)
* @param string $table
* @return string
*/
#[\Override]
protected function createBaseMigration($table)
{
return $this->createBaseMigrationUsingCanvas($table);
Expand All @@ -44,6 +45,7 @@ protected function createBaseMigration($table)
* @param string $table
* @return bool
*/
#[\Override]
protected function migrationExists($table)
{
return $this->migrationExistsUsingCanvas($table);
Expand Down
2 changes: 2 additions & 0 deletions src/Console/CacheTableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function __construct(Filesystem $files)
* @param string $table
* @return string
*/
#[\Override]
protected function createBaseMigration($table)
{
return $this->createBaseMigrationUsingCanvas($table);
Expand All @@ -44,6 +45,7 @@ protected function createBaseMigration($table)
* @param string $table
* @return bool
*/
#[\Override]
protected function migrationExists($table)
{
return $this->migrationExistsUsingCanvas($table);
Expand Down
3 changes: 3 additions & 0 deletions src/Console/CastMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function __construct(Filesystem $files)
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
#[\Override]
public function handle()
{
return $this->generateCode() ? self::SUCCESS : self::FAILURE;
Expand All @@ -46,6 +47,7 @@ public function handle()
* @param string $name
* @return string
*/
#[\Override]
protected function getPath($name)
{
return $this->getPathUsingCanvas($name);
Expand All @@ -56,6 +58,7 @@ protected function getPath($name)
*
* @return string
*/
#[\Override]
protected function rootNamespace()
{
return $this->rootNamespaceUsingCanvas();
Expand Down
3 changes: 3 additions & 0 deletions src/Console/ChannelMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function __construct(Filesystem $files)
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
#[\Override]
public function handle()
{
return $this->generateCode() ? self::SUCCESS : self::FAILURE;
Expand All @@ -48,6 +49,7 @@ public function handle()
* @param string $name
* @return string
*/
#[\Override]
protected function getPath($name)
{
return $this->getPathUsingCanvas($name);
Expand All @@ -58,6 +60,7 @@ protected function getPath($name)
*
* @return string
*/
#[\Override]
protected function rootNamespace()
{
return $this->rootNamespaceUsingCanvas();
Expand Down
1 change: 1 addition & 0 deletions src/Console/CodeMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected function resolveDefaultStubPath($stub)
*
* @return array<int, array>
*/
#[\Override]
protected function getOptions()
{
return [
Expand Down
11 changes: 6 additions & 5 deletions src/Console/Commander.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Illuminate\Contracts\Console\Kernel as ConsoleKernel;
use Illuminate\Foundation\Application as LaravelApplication;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Orchestra\Canvas\CanvasServiceProvider;
use Orchestra\Canvas\LaravelServiceProvider;
use Symfony\Component\Console\Command\Command as SymfonyCommand;
Expand All @@ -25,9 +24,10 @@ class Commander extends \Orchestra\Testbench\Console\Commander
*
* @return \Closure(\Illuminate\Foundation\Application):void
*/
#[\Override]
protected function resolveApplicationCallback()
{
return function ($app) {
return static function ($app) {
$app->register(CanvasServiceProvider::class);
};
}
Expand All @@ -37,6 +37,7 @@ protected function resolveApplicationCallback()
*
* @return \Illuminate\Foundation\Application
*/
#[\Override]
public function laravel()
{
if (! $this->app instanceof LaravelApplication) {
Expand All @@ -47,9 +48,9 @@ public function laravel()
$app->register(LaravelServiceProvider::class);

Collection::make($kernel->all())
->reject(function (SymfonyCommand $command, string $name) {
return Str::startsWith('make:', $name) || $command instanceof GeneratorCommand;
})->each(function (SymfonyCommand $command) {
->reject(static function (SymfonyCommand $command, string $name) {
return str_starts_with('make:', $name) || $command instanceof GeneratorCommand;
})->each(static function (SymfonyCommand $command) {
$command->setHidden(true);
});
}
Expand Down
4 changes: 4 additions & 0 deletions src/Console/ComponentMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function __construct(Filesystem $files)
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
#[\Override]
public function handle()
{
return $this->generateCode() ? self::SUCCESS : self::FAILURE;
Expand All @@ -60,6 +61,7 @@ public function afterCodeHasBeenGenerated(string $className, string $path): void
* @param string $name
* @return string
*/
#[\Override]
protected function getPath($name)
{
return $this->getPathUsingCanvas($name);
Expand All @@ -70,6 +72,7 @@ protected function getPath($name)
*
* @return string
*/
#[\Override]
protected function rootNamespace()
{
return $this->rootNamespaceUsingCanvas();
Expand All @@ -81,6 +84,7 @@ protected function rootNamespace()
* @param string $path
* @return string
*/
#[\Override]
protected function viewPath($path = '')
{
return $this->viewPathUsingCanvas($path);
Expand Down
4 changes: 4 additions & 0 deletions src/Console/ConsoleMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function __construct(Filesystem $files)
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
#[\Override]
public function handle()
{
return $this->generateCode() ? self::SUCCESS : self::FAILURE;
Expand All @@ -48,6 +49,7 @@ public function handle()
* @param string $name
* @return string
*/
#[\Override]
protected function getPath($name)
{
return $this->getPathUsingCanvas($name);
Expand All @@ -58,6 +60,7 @@ protected function getPath($name)
*
* @return string
*/
#[\Override]
protected function rootNamespace()
{
return $this->rootNamespaceUsingCanvas();
Expand All @@ -69,6 +72,7 @@ protected function rootNamespace()
* @param string $rootNamespace
* @return string
*/
#[\Override]
protected function getDefaultNamespace($rootNamespace)
{
return rtrim($this->generatorPreset()->commandNamespace(), '\\');
Expand Down
41 changes: 41 additions & 0 deletions src/Console/ControllerMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function __construct(Filesystem $files)
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
#[\Override]
public function handle()
{
return $this->generateCode() ? self::SUCCESS : self::FAILURE;
Expand All @@ -48,6 +49,7 @@ public function handle()
* @param string $model
* @return string
*/
#[\Override]
protected function qualifyModel(string $model)
{
return $this->qualifyModelUsingCanvas($model);
Expand All @@ -58,6 +60,7 @@ protected function qualifyModel(string $model)
*
* @return array
*/
#[\Override]
protected function buildParentReplacements()
{
$parentModelClass = $this->parseModel($this->option('parent'));
Expand Down Expand Up @@ -86,6 +89,7 @@ protected function buildParentReplacements()
* @param array $replace
* @return array
*/
#[\Override]
protected function buildModelReplacements(array $replace)
{
$modelClass = $this->parseModel($this->option('model'));
Expand All @@ -96,6 +100,12 @@ protected function buildModelReplacements(array $replace)

$replace = $this->buildFormRequestReplacements($replace, $modelClass);

if ($this->option('requests')) {
$namespace = $this->rootNamespace();
$replace['{{ namespacedRequests }}'] = str_replace('App\\', $namespace, $replace['{{ namespacedRequests }}']);
$replace['{{namespacedRequests}}'] = str_replace('App\\', $namespace, $replace['{{namespacedRequests}}']);
}

return array_merge($replace, [
'DummyFullModelClass' => $modelClass,
'{{ namespacedModel }}' => $modelClass,
Expand All @@ -115,6 +125,7 @@ protected function buildModelReplacements(array $replace)
* @param string $name
* @return string
*/
#[\Override]
protected function getPath($name)
{
return $this->getPathUsingCanvas($name);
Expand All @@ -125,6 +136,7 @@ protected function getPath($name)
*
* @return string
*/
#[\Override]
protected function rootNamespace()
{
return $this->rootNamespaceUsingCanvas();
Expand All @@ -135,8 +147,37 @@ protected function rootNamespace()
*
* @return array<int, string>
*/
#[\Override]
protected function possibleModels()
{
return $this->possibleModelsUsingCanvas();
}

/**
* Generate the form requests for the given model and classes.
*
* @param string $modelClass
* @param string $storeRequestClass
* @param string $updateRequestClass
* @return array
*/
#[\Override]
protected function generateFormRequests($modelClass, $storeRequestClass, $updateRequestClass)
{
$storeRequestClass = 'Store'.class_basename($modelClass).'Request';

$this->call('make:request', [
'name' => $storeRequestClass,
'--preset' => $this->option('preset'),
]);

$updateRequestClass = 'Update'.class_basename($modelClass).'Request';

$this->call('make:request', [
'name' => $updateRequestClass,
'--preset' => $this->option('preset'),
]);

return [$storeRequestClass, $updateRequestClass];
}
}
Loading

0 comments on commit 2c91f5c

Please sign in to comment.