Skip to content

Commit

Permalink
Merge branch '9.x' into 10.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 Jul 30, 2024
2 parents 900576a + c905450 commit f5795b4
Show file tree
Hide file tree
Showing 68 changed files with 1,055 additions and 459 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/analyse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
coverage: none

- name: Install dependencies
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--prefer-dist --no-cache"
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
coverage: none

- name: Install dependencies
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--prefer-dist --no-cache"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/audits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
coverage: none

- name: Install dependencies
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "highest"
composer-options: "--prefer-dist --prefer-stable --no-cache"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coveralls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
coverage: xdebug

- name: Install dependencies
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--prefer-dist --no-cache"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
coverage: none

- name: Install dependencies
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--prefer-dist --no-cache"
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/update-stubs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, intl, fileinfo, :php-psr
coverage: none

- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress

Expand Down
6 changes: 4 additions & 2 deletions bin/sync
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ $files->copy("{$workingPath}/skeleton/database/factories/UserFactory.php", "{$wo
transform([
'namespace Database\Factories;' => 'namespace {{ factoryNamespace }};',
'use Illuminate\Support\Str;'.PHP_EOL => 'use Illuminate\Support\Str;'.PHP_EOL.'use {{ namespacedModel }};'.PHP_EOL,
'\Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>' => '\Illuminate\Database\Eloquent\Factories\Factory<\{{ namespacedModel }}>',
' * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>' => ' * @template TModel of \{{ namespacedModel }}
*
* @extends \Illuminate\Database\Eloquent\Factories\Factory<TModel>',
' /**
* Define the model\'s default state.' => ' /**
* The name of the factory\'s corresponding model.
*
* @var string
* @var class-string<TModel>
*/
protected $model = {{ model }}::class;
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
},
"require-dev": {
"laravel/framework": "^12.0",
"laravel/pint": "^1.6",
"laravel/pint": "^1.17",
"mockery/mockery": "^1.6",
"phpstan/phpstan": "^1.10.6",
"phpunit/phpunit": "^10.5"
"phpstan/phpstan": "^1.11",
"phpunit/phpunit": "^11.0"
},
"config": {
"preferred-install": {
Expand Down Expand Up @@ -73,7 +73,7 @@
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"lint": [
"@php vendor/bin/pint",
"@php vendor/bin/phpstan analyse"
"@php vendor/bin/phpstan analyse --verbose"
],
"test": "@php vendor/bin/phpunit -c ./ --color",
"ci": [
Expand Down
16 changes: 1 addition & 15 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,16 +1,2 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$model of method Illuminate\\\\Routing\\\\Console\\\\ControllerMakeCommand\\:\\:parseModel\\(\\) expects string, array\\|bool\\|string\\|null given\\.$#"
count: 2
path: src/Console/ControllerMakeCommand.php

-
message: "#^Parameter \\#2 \\$callback of function transform expects callable\\(array\\|bool\\|string\\|null\\)\\: string, Closure\\(string\\)\\: string given\\.$#"
count: 1
path: src/Console/PresetMakeCommand.php

-
message: "#^Parameter \\#2 \\$callback of function transform expects callable\\(array\\|bool\\|string\\|null\\)\\: string, Closure\\(string\\)\\: string given\\.$#"
count: 2
path: src/Console/ViewMakeCommand.php
ignoreErrors: []
11 changes: 2 additions & 9 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,10 @@ parameters:
paths:
- src

excludePaths:
- ./src/Commands/*.php
- ./src/Commands/Database/*.php
- ./src/Commands/Routing/*.php

# The level 8 is the highest level
level: 7
level: 8

ignoreErrors:
- '#Method [a-zA-Z\\\<\>]+::handle\(\) should return bool\|null but returns int.#'
- identifier: missingType.iterableValue

checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
treatPhpDocTypesAsCertain: false
1 change: 0 additions & 1 deletion pint.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"scope": "namespaced",
"strict": true
},
"no_superfluous_phpdoc_tags": false,
"php_unit_method_casing": false
}
}
34 changes: 17 additions & 17 deletions src/Canvas.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class Canvas
* Make Preset from configuration.
*
* @param array<string, mixed> $config
* @return \Orchestra\Canvas\Presets\Preset
*/
public static function preset(array $config, string $basePath): Presets\Preset
{
Expand All @@ -19,22 +18,23 @@ public static function preset(array $config, string $basePath): Presets\Preset

$preset = $config['preset'];

switch ($preset) {
case 'package':
return new Presets\Package($configuration, $basePath);
case 'laravel':
return new Presets\Laravel($configuration, $basePath);
default:
if (class_exists($preset)) {
/**
* @var class-string<\Orchestra\Canvas\Presets\Preset> $preset
*
* @return \Orchestra\Canvas\Presets\Preset
*/
return new $preset($configuration, $basePath);
}
$resolveDefaultPreset = function ($configuration, $basePath) use ($preset) {
if (class_exists($preset)) {
/**
* @var class-string<\Orchestra\Canvas\Presets\Preset> $preset
*
* @return \Orchestra\Canvas\Presets\Preset
*/
return new $preset($configuration, $basePath);
}

return new Presets\Laravel($configuration, $basePath);
}
return new Presets\Laravel($configuration, $basePath);
};

return match ($preset) {
'package' => new Presets\Package($configuration, $basePath),
'laravel' => new Presets\Laravel($configuration, $basePath),
default => $resolveDefaultPreset($configuration, $basePath),
};
}
}
3 changes: 0 additions & 3 deletions src/CanvasServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class CanvasServiceProvider extends ServiceProvider implements DeferrableProvide
{
/**
* Register services.
*
* @return void
*/
public function register(): void
{
Expand Down Expand Up @@ -55,7 +53,6 @@ public function boot(): void
{
if ($this->app->runningInConsole()) {
$this->commands([
Console\CodeMakeCommand::class,
Console\GeneratorMakeCommand::class,
Console\PresetMakeCommand::class,
]);
Expand Down
13 changes: 6 additions & 7 deletions src/Console/BatchesTableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

namespace Orchestra\Canvas\Console;

use Illuminate\Filesystem\Filesystem;
use Orchestra\Canvas\Core\Concerns\MigrationGenerator;
use Symfony\Component\Console\Attribute\AsCommand;

/**
* @see https://github.com/laravel/framework/blob/master/src/Illuminate/Queue/Console/BatchesTableCommand.php
* @see https://github.com/laravel/framework/blob/11.x/src/Illuminate/Queue/Console/BatchesTableCommand.php
*/
#[AsCommand(name: 'make:queue-batches-table', description: 'Create a migration for the batches database table')]
#[AsCommand(name: 'make:queue-batches-table', description: 'Create a migration for the batches database table', aliases: ['queue:batches-table'])]
class BatchesTableCommand extends \Illuminate\Queue\Console\BatchesTableCommand
{
use MigrationGenerator;
Expand All @@ -22,14 +21,14 @@ class BatchesTableCommand extends \Illuminate\Queue\Console\BatchesTableCommand
protected $name = 'make:queue-batches-table';

/**
* Create a new notifications table command instance.
* Configures the current command.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @return void
*/
public function __construct(Filesystem $files)
#[\Override]
protected function configure()
{
parent::__construct($files);
parent::configure();

$this->addGeneratorPresetOptions();
}
Expand Down
13 changes: 6 additions & 7 deletions src/Console/CacheTableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@

namespace Orchestra\Canvas\Console;

use Illuminate\Filesystem\Filesystem;
use Orchestra\Canvas\Core\Concerns\MigrationGenerator;
use Symfony\Component\Console\Attribute\AsCommand;

/**
* @see https://github.com/laravel/framework/blob/master/src/Illuminate/Cache/Console/CacheTableCommand.php
* @see https://github.com/laravel/framework/blob/11.x/src/Illuminate/Cache/Console/CacheTableCommand.php
*/
#[AsCommand(name: 'make:cache-table', description: 'Create a migration for the cache database table')]
#[AsCommand(name: 'make:cache-table', description: 'Create a migration for the cache database table', aliases: ['cache:table'])]
class CacheTableCommand extends \Illuminate\Cache\Console\CacheTableCommand
{
use MigrationGenerator;

/**
* Create a new session table command instance.
* Configures the current command.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @return void
*/
public function __construct(Filesystem $files)
#[\Override]
protected function configure()
{
parent::__construct($files);
parent::configure();

$this->addGeneratorPresetOptions();
}
Expand Down
11 changes: 6 additions & 5 deletions src/Console/CastMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace Orchestra\Canvas\Console;

use Illuminate\Filesystem\Filesystem;
use Orchestra\Canvas\Core\Concerns\CodeGenerator;
use Orchestra\Canvas\Core\Concerns\UsesGeneratorOverrides;
use Symfony\Component\Console\Attribute\AsCommand;

/**
* @see https://github.com/laravel/framework/blob/master/src/Illuminate/Foundation/Console/CastMakeCommand.php
* @see https://github.com/laravel/framework/blob/11.x/src/Illuminate/Foundation/Console/CastMakeCommand.php
*/
#[AsCommand(name: 'make:cast', description: 'Create a new custom Eloquent cast class')]
class CastMakeCommand extends \Illuminate\Foundation\Console\CastMakeCommand
Expand All @@ -17,13 +16,14 @@ class CastMakeCommand extends \Illuminate\Foundation\Console\CastMakeCommand
use UsesGeneratorOverrides;

/**
* Create a new creator command instance.
* Configures the current command.
*
* @return void
*/
public function __construct(Filesystem $files)
#[\Override]
protected function configure()
{
parent::__construct($files);
parent::configure();

$this->addGeneratorPresetOptions();
}
Expand All @@ -38,6 +38,7 @@ public function __construct(Filesystem $files)
#[\Override]
public function handle()
{
/** @phpstan-ignore return.type */
return $this->generateCode() ? self::SUCCESS : self::FAILURE;
}

Expand Down
11 changes: 6 additions & 5 deletions src/Console/ChannelMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

namespace Orchestra\Canvas\Console;

use Illuminate\Filesystem\Filesystem;
use Orchestra\Canvas\Core\Concerns\CodeGenerator;
use Orchestra\Canvas\Core\Concerns\TestGenerator;
use Orchestra\Canvas\Core\Concerns\UsesGeneratorOverrides;
use Symfony\Component\Console\Attribute\AsCommand;

/**
* @see https://github.com/laravel/framework/blob/master/src/Illuminate/Foundation/Console/ChannelMakeCommand.php
* @see https://github.com/laravel/framework/blob/11.x/src/Illuminate/Foundation/Console/ChannelMakeCommand.php
*/
#[AsCommand(name: 'make:channel', description: 'Create a new channel class')]
class ChannelMakeCommand extends \Illuminate\Foundation\Console\ChannelMakeCommand
Expand All @@ -19,13 +18,14 @@ class ChannelMakeCommand extends \Illuminate\Foundation\Console\ChannelMakeComma
use UsesGeneratorOverrides;

/**
* Create a new creator command instance.
* Configures the current command.
*
* @return void
*/
public function __construct(Filesystem $files)
#[\Override]
protected function configure()
{
parent::__construct($files);
parent::configure();

$this->addGeneratorPresetOptions();
}
Expand All @@ -40,6 +40,7 @@ public function __construct(Filesystem $files)
#[\Override]
public function handle()
{
/** @phpstan-ignore return.type */
return $this->generateCode() ? self::SUCCESS : self::FAILURE;
}

Expand Down
Loading

0 comments on commit f5795b4

Please sign in to comment.