Skip to content

Commit

Permalink
chore: Update paths in rector.php and remove unnecessary comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPunyapal committed Aug 8, 2024
1 parent 8608deb commit e11af5c
Show file tree
Hide file tree
Showing 20 changed files with 41 additions and 43 deletions.
4 changes: 2 additions & 2 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
->withMiddleware(function (Middleware $middleware): void {
$middleware->web(append: [
SetLocale::class,
]);

})
->withExceptions(function (Exceptions $exceptions) {
->withExceptions(function (Exceptions $exceptions): void {
//
})->create();
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@

'previous_keys' => [
...array_filter(
explode(',', env('APP_PREVIOUS_KEYS', ''))
explode(',', (string) env('APP_PREVIOUS_KEYS', ''))
),
],

Expand Down
4 changes: 2 additions & 2 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
'strict' => true,
'engine' => 'InnoDB',
'options' => extension_loaded('pdo_mysql') ? array_filter([
\PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],

Expand All @@ -77,7 +77,7 @@
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
\PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],

Expand Down
2 changes: 1 addition & 1 deletion config/logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

'stack' => [
'driver' => 'stack',
'channels' => explode(',', env('LOG_STACK', 'single')),
'channels' => explode(',', (string) env('LOG_STACK', 'single')),
'ignore_exceptions' => false,
],

Expand Down
2 changes: 1 addition & 1 deletion config/sanctum.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
|
*/

'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'stateful' => explode(',', (string) env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'%s%s',
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
Sanctum::currentApplicationUrlWithPort()
Expand Down
3 changes: 2 additions & 1 deletion database/factories/CategoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

namespace Database\Factories;

use App\Models\Category;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Category>
* @extends Factory<Category>
*/
class CategoryFactory extends Factory
{
Expand Down
3 changes: 2 additions & 1 deletion database/factories/PostFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
namespace Database\Factories;

use App\Enums\FeaturedStatus;
use App\Models\Post;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Post>
* @extends Factory<Post>
*/
class PostFactory extends Factory
{
Expand Down
7 changes: 4 additions & 3 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@

namespace Database\Factories;

use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
* @extends Factory<User>
*/
class UserFactory extends Factory
{
protected static ?string $password;
protected static ?string $password = null;

/**
* Define the model's default state.
Expand All @@ -36,7 +37,7 @@ public function definition(): array
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
return $this->state(fn (array $attributes): array => [
'email_verified_at' => null,
]);
}
Expand Down
6 changes: 3 additions & 3 deletions database/migrations/0001_01_01_000000_create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
Schema::create('users', function (Blueprint $table): void {
$table->id();
$table->string('name');
$table->string('email')->unique();
Expand All @@ -23,13 +23,13 @@ public function up(): void
$table->timestamps();
});

Schema::create('password_reset_tokens', function (Blueprint $table) {
Schema::create('password_reset_tokens', function (Blueprint $table): void {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});

Schema::create('sessions', function (Blueprint $table) {
Schema::create('sessions', function (Blueprint $table): void {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
Expand Down
4 changes: 2 additions & 2 deletions database/migrations/0001_01_01_000001_create_cache_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
*/
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
Schema::create('cache', function (Blueprint $table): void {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration');
});

Schema::create('cache_locks', function (Blueprint $table) {
Schema::create('cache_locks', function (Blueprint $table): void {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration');
Expand Down
6 changes: 3 additions & 3 deletions database/migrations/0001_01_01_000002_create_jobs_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
Schema::create('jobs', function (Blueprint $table): void {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
Expand All @@ -23,7 +23,7 @@ public function up(): void
$table->unsignedInteger('created_at');
});

Schema::create('job_batches', function (Blueprint $table) {
Schema::create('job_batches', function (Blueprint $table): void {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
Expand All @@ -36,7 +36,7 @@ public function up(): void
$table->integer('finished_at')->nullable();
});

Schema::create('failed_jobs', function (Blueprint $table) {
Schema::create('failed_jobs', function (Blueprint $table): void {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
public function up(): void
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
Schema::create('personal_access_tokens', function (Blueprint $table): void {
$table->id();
$table->morphs('tokenable');
$table->string('name');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
public function up(): void
{
Schema::create('posts', function (Blueprint $table) {
Schema::create('posts', function (Blueprint $table): void {
$table->id();
$table->string('title', 100);
$table->string('slug', 120)->unique();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
public function up(): void
{
Schema::table('posts', function (Blueprint $table) {
Schema::table('posts', function (Blueprint $table): void {
$table->timestamp('published_at')->nullable()->after('published');
$table->dropColumn('published');
});
Expand All @@ -24,7 +24,7 @@ public function up(): void
*/
public function down(): void
{
Schema::table('posts', function (Blueprint $table) {
Schema::table('posts', function (Blueprint $table): void {
$table->boolean('published')->default(false)->after('body');
$table->dropColumn('published_at');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
public function up(): void
{
Schema::create('categories', function (Blueprint $table) {
Schema::create('categories', function (Blueprint $table): void {
$table->id();
$table->string('title', 100)->unique();
$table->softDeletes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
*/
public function up(): void
{
Schema::table('posts', function (Blueprint $table) {
Schema::table('posts', function (Blueprint $table): void {
$table->renameColumn('category', 'category_id');
});
Schema::table('posts', function (Blueprint $table) {
Schema::table('posts', function (Blueprint $table): void {
$table->unsignedBigInteger('category_id')->change();
$table->foreign('category_id')->references('id')->on('categories');
});
Expand All @@ -27,10 +27,10 @@ public function up(): void
*/
public function down(): void
{
Schema::table('posts', function (Blueprint $table) {
Schema::table('posts', function (Blueprint $table): void {
$table->renameColumn('category_id', 'category');
});
Schema::table('posts', function (Blueprint $table) {
Schema::table('posts', function (Blueprint $table): void {
$table->unsignedTinyInteger('category')->change();
$table->dropForeign(['category_id']);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
public function up(): void
{
Schema::table('posts', function (Blueprint $table) {
Schema::table('posts', function (Blueprint $table): void {
$table->renameColumn('body', 'content');
});
}
Expand All @@ -23,7 +23,7 @@ public function up(): void
*/
public function down(): void
{
Schema::table('posts', function (Blueprint $table) {
Schema::table('posts', function (Blueprint $table): void {
$table->renameColumn('content', 'body');
});
}
Expand Down
4 changes: 2 additions & 2 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function run(): void

// Schema::enableForeignKeyConstraints();

if (Category::count() > 0) {
if (Category::query()->count() > 0) {
return;
}

Expand All @@ -48,7 +48,7 @@ public function run(): void
['title' => 'C++'],
['title' => 'Python'],
)->has(
Post::factory()->count(rand(5, 10))
Post::factory()->count(random_int(5, 10))
)->create();
}
}
2 changes: 1 addition & 1 deletion pint.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"strict_comparison":true,
"fully_qualified_strict_types": {
"import_symbols": true,
"leading_backslash_in_global_namespace": true,
"leading_backslash_in_global_namespace": false,
"phpdoc_tags": [
"phpstan-param",
"phpstan-property",
Expand Down
13 changes: 4 additions & 9 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@
return RectorConfig::configure()
->withPaths([
__DIR__.'/app',
// __DIR__.'/bootstrap',
// __DIR__.'/config',
// __DIR__.'/public',
// __DIR__.'/resources',
// __DIR__.'/routes',
// __DIR__.'/tests',
__DIR__.'/bootstrap/app.php',
__DIR__.'/config',
__DIR__.'/database',
__DIR__.'/public',
])
// register single rule
->withRules([
TypedPropertyFromStrictConstructorRector::class,
])
->withPhpSets(php83: true)
// here we can define, what prepared sets of rules will be applied
->withPreparedSets(
deadCode: true,
codeQuality: true,
Expand All @@ -32,7 +28,6 @@
earlyReturn: true,
strictBooleans: true,
carbon: true,
rectorPreset: true,
)->withSets([
LaravelSetList::LARAVEL_110,
LaravelSetList::LARAVEL_CODE_QUALITY,
Expand Down

0 comments on commit e11af5c

Please sign in to comment.