diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
index 17f554a..53e0696 100644
--- a/.php-cs-fixer.dist.php
+++ b/.php-cs-fixer.dist.php
@@ -4,8 +4,10 @@
$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
- ->name('artisan')
- ->notPath('bootstrap/cache');
+ ->ignoreDotFiles(false)
+ ->name(['.php-cs-fixer.dist.php', 'artisan'])
+ ->exclude(['bootstrap/cache', 'node_modules', 'storage'])
+ ->notPath('public/frankenphp-worker.php');
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
@@ -15,5 +17,240 @@
'@PHP80Migration:risky' => true,
'@PHP83Migration' => true,
'@PHPUnit100Migration:risky' => true,
+
+ // Alias
+ 'array_push' => true,
+ 'backtick_to_shell_exec' => true,
+ 'ereg_to_preg' => true,
+ 'mb_str_functions' => true,
+ 'no_alias_language_construct_call' => true,
+ 'no_mixed_echo_print' => true,
+ 'set_type_to_cast' => true,
+
+ // Array Notation
+ 'no_multiline_whitespace_around_double_arrow' => true,
+ 'return_to_yield_from' => true,
+ 'trim_array_spaces' => true,
+ 'whitespace_after_comma_in_array' => true,
+ 'yield_from_array_to_yields' => true,
+
+ // Attribute Notation
+ 'attribute_empty_parentheses' => true,
+
+ // Basic
+ 'no_trailing_comma_in_singleline' => true,
+ // 'numeric_literal_separator' => true,
+ 'psr_autoloading' => true,
+
+ // Casing
+ 'class_reference_name_casing' => true,
+ 'integer_literal_case' => true,
+ 'magic_constant_casing' => true,
+ 'magic_method_casing' => true,
+ 'native_function_casing' => true,
+ 'native_type_declaration_casing' => true,
+
+ // Cast Notation
+ 'modernize_types_casting' => true,
+ 'no_short_bool_cast' => true,
+
+ // Class Notation
+ 'class_attributes_separation' => true,
+ // 'final_class' => true,
+ // 'final_internal_class' => true,
+ // 'final_public_method_for_abstract_class' => true,
+ 'no_null_property_initialization' => true,
+ 'ordered_interfaces' => true,
+ 'ordered_traits' => true,
+ 'ordered_types' => true,
+ 'phpdoc_readonly_class_comment_to_keyword' => true,
+ 'protected_to_private' => true,
+ 'self_accessor' => true,
+ 'self_static_accessor' => true,
+
+ // Class Usage
+ 'date_time_immutable' => true,
+
+ // Comment
+ 'comment_to_phpdoc' => true,
+ // 'header_comment' => ['header' => ''],
+ 'multiline_comment_opening_closing' => true,
+ // 'no_empty_comment' => true,
+ 'single_line_comment_spacing' => true,
+ 'single_line_comment_style' => true,
+
+ // Constant Notation
+ 'native_constant_invocation' => true,
+
+ // Control Structure
+ 'empty_loop_body' => true,
+ 'empty_loop_condition' => true,
+ 'include' => true,
+ 'no_alternative_syntax' => true,
+ 'no_superfluous_elseif' => true,
+ 'no_unneeded_braces' => true,
+ 'no_unneeded_control_parentheses' => true,
+ 'no_useless_else' => true,
+ 'simplified_if_return' => true,
+ 'switch_continue_to_break' => true,
+ 'trailing_comma_in_multiline' => [
+ 'after_heredoc' => true,
+ 'elements' => ['arguments', 'arrays', 'match', 'parameters'],
+ ],
+ // 'yoda_style' => true,
+
+ // Doctrine Annotation
+ // 'doctrine_annotation_array_assignment' => true,
+ // 'doctrine_annotation_braces' => true,
+ // 'doctrine_annotation_indentation' => true,
+ // 'doctrine_annotation_spaces' => true,
+
+ // Function Notation
+ 'date_time_create_from_format_call' => true,
+ 'fopen_flag_order' => true,
+ 'fopen_flags' => true,
+ 'lambda_not_used_import' => true,
+ 'native_function_invocation' => ['include' => ['@all'], 'scope' => 'namespaced'],
+ 'no_useless_sprintf' => true,
+ 'nullable_type_declaration_for_default_null_value' => true,
+ // 'phpdoc_to_param_type' => true,
+ // 'phpdoc_to_property_type' => true,
+ // 'phpdoc_to_return_type' => true,
+ 'regular_callable_call' => true,
+ // 'single_line_throw' => true,
+ 'static_lambda' => true,
+
+ // Import
+ // 'fully_qualified_strict_types' => true,
+ 'global_namespace_import' => true,
+ // 'group_import' => true,
+ 'no_unneeded_import_alias' => true,
+ 'no_unused_imports' => true,
+ 'ordered_imports' => true,
+
+ // Language Construct
+ // 'class_keyword' => true,
+ 'combine_consecutive_issets' => true,
+ 'combine_consecutive_unsets' => true,
+ 'declare_parentheses' => true,
+ 'dir_constant' => true,
+ // 'error_suppression' => true,
+ 'explicit_indirect_variable' => true,
+ 'function_to_constant' => true,
+ 'is_null' => true,
+ 'no_unset_on_property' => true,
+ 'nullable_type_declaration' => true,
+ 'single_space_around_construct' => true,
+
+ // List Notation
+
+ // Namespace Notation
+ 'no_leading_namespace_whitespace' => true,
+
+ // Naming
+ 'no_homoglyph_names' => true,
+
+ // Operator
+ 'increment_style' => true,
+ 'logical_operators' => true,
+ 'long_to_shorthand_operator' => true,
+ 'new_with_parentheses' => true,
+ 'no_useless_concat_operator' => true,
+ 'no_useless_nullsafe_operator' => true,
+ // 'not_operator_with_space' => true,
+ 'object_operator_without_whitespace' => true,
+ 'operator_linebreak' => ['only_booleans' => true, 'position' => 'end'],
+ 'standardize_increment' => true,
+ 'standardize_not_equals' => true,
+ // 'ternary_to_elvis_operator' => true,
+
+ // PHP Tag
+ 'echo_tag_syntax' => true,
+ 'linebreak_after_opening_tag' => true,
+
+ // PHPUnit
+ 'php_unit_construct' => true,
+ // 'php_unit_data_provider_name' => true,
+ 'php_unit_data_provider_return_type' => true,
+ 'php_unit_fqcn_annotation' => true,
+ // 'php_unit_internal_class' => true,
+ 'php_unit_method_casing' => ['case' => 'snake_case'],
+ 'php_unit_mock_short_will_return' => true,
+ 'php_unit_set_up_tear_down_visibility' => true,
+ // 'php_unit_size_class' => true,
+ // 'php_unit_strict' => true,
+ // 'php_unit_test_annotation' => true, // Don't use because it doesn't currently support #[Test] attribute
+ 'php_unit_test_case_static_method_calls' => ['call_type' => 'this'],
+ // 'php_unit_test_class_requires_covers' => true,
+
+ // PHPDoc
+ 'align_multiline_comment' => true,
+ // 'general_phpdoc_annotation_remove' => true,
+ // 'general_phpdoc_tag_rename' => true,
+ 'no_blank_lines_after_phpdoc' => true,
+ 'no_empty_phpdoc' => true,
+ 'no_superfluous_phpdoc_tags' => true,
+ // 'phpdoc_add_missing_param_annotation' => true,
+ 'phpdoc_align' => ['align' => 'left'],
+ 'phpdoc_annotation_without_dot' => true,
+ 'phpdoc_indent' => true,
+ 'phpdoc_inline_tag_normalizer' => true,
+ 'phpdoc_line_span' => true,
+ // 'phpdoc_no_access' => true,
+ // 'phpdoc_no_alias_tag' => true,
+ // 'phpdoc_no_empty_return' => true,
+ // 'phpdoc_no_package' => true,
+ 'phpdoc_no_useless_inheritdoc' => true,
+ 'phpdoc_order_by_value' => true,
+ 'phpdoc_order' => true,
+ 'phpdoc_return_self_reference' => true,
+ 'phpdoc_scalar' => true,
+ // 'phpdoc_separation' => true,
+ 'phpdoc_single_line_var_spacing' => true,
+ 'phpdoc_summary' => true,
+ 'phpdoc_tag_casing' => true,
+ 'phpdoc_tag_type' => true,
+ // 'phpdoc_to_comment' => true,
+ 'phpdoc_trim_consecutive_blank_line_separation' => true,
+ 'phpdoc_trim' => true,
+ 'phpdoc_types' => true,
+ 'phpdoc_types_order' => ['null_adjustment' => 'always_last'],
+ 'phpdoc_var_annotation_correct_order' => true,
+ 'phpdoc_var_without_name' => true,
+
+ // Return Notation
+ 'no_useless_return' => true,
+ 'return_assignment' => true,
+ 'simplified_null_return' => true,
+
+ // Semicolon
+ 'multiline_whitespace_before_semicolons' => true,
+ 'no_empty_statement' => true,
+ 'no_singleline_whitespace_before_semicolons' => true,
+ 'semicolon_after_instruction' => true,
+ 'space_after_semicolon' => true,
+
+ // Strict
+ 'strict_comparison' => true,
+ 'strict_param' => true,
+
+ // String Notation
+ 'escape_implicit_backslashes' => true,
+ 'explicit_string_variable' => true,
+ 'heredoc_closing_marker' => true,
+ 'heredoc_to_nowdoc' => true,
+ 'multiline_string_to_heredoc' => true,
+ 'no_binary_string' => true,
+ 'single_quote' => true,
+ 'string_length_to_empty' => true,
+ 'string_line_ending' => true,
+
+ // Whitespace
+ 'blank_line_before_statement' => true,
+ 'method_chaining_indentation' => true,
+ 'no_extra_blank_lines' => true,
+ 'no_spaces_around_offset' => true,
+ 'type_declaration_spaces' => true,
+ 'types_spaces' => true,
])
->setFinder($finder);
diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist
index 39b0a36..c5337e7 100644
--- a/.phpcs.xml.dist
+++ b/.phpcs.xml.dist
@@ -9,6 +9,7 @@
*.blade.php
./bootstrap/cache/*
./node_modules/*
+ ./public/frankenphp-worker.php
./storage/*
./vendor/*
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index 3400682..e21136c 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -24,6 +24,6 @@ protected function commands(): void
{
$this->load(__DIR__ . '/Commands');
- require base_path('routes/console.php');
+ require \base_path('routes/console.php');
}
}
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index 8bd0c96..eee5088 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -25,7 +25,7 @@ class Handler extends ExceptionHandler
*/
public function register(): void
{
- $this->reportable(function (Throwable $e): void {
+ $this->reportable(static function (Throwable $e): void {
//
});
}
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
index cd4ebd3..c499f29 100644
--- a/app/Http/Middleware/Authenticate.php
+++ b/app/Http/Middleware/Authenticate.php
@@ -14,6 +14,6 @@ class Authenticate extends Middleware
*/
protected function redirectTo(Request $request): ?string
{
- return $request->expectsJson() ? null : route('login');
+ return $request->expectsJson() ? null : \route('login');
}
}
diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php
index a6fe6a8..4a592b2 100644
--- a/app/Http/Middleware/RedirectIfAuthenticated.php
+++ b/app/Http/Middleware/RedirectIfAuthenticated.php
@@ -15,7 +15,7 @@ class RedirectIfAuthenticated
/**
* Handle an incoming request.
*
- * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
+ * @param Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next, string ...$guards): Response
{
@@ -23,7 +23,7 @@ public function handle(Request $request, Closure $next, string ...$guards): Resp
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
- return redirect(RouteServiceProvider::HOME);
+ return \redirect(RouteServiceProvider::HOME);
}
}
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 8325058..43b86d0 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -4,7 +4,11 @@
namespace App\Providers;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Log;
use Illuminate\Support\ServiceProvider;
+use Illuminate\Translation\Translator;
+use OutOfBoundsException;
class AppServiceProvider extends ServiceProvider
{
@@ -13,7 +17,19 @@ class AppServiceProvider extends ServiceProvider
*/
public function register(): void
{
- //
+ $this->app->resolving('translator', function (Translator $translator): void {
+ $translator->handleMissingKeysUsing(function (string $key): string {
+ $message = "Missing translation key [{$key}] detected.";
+
+ if (!$this->isProduction()) {
+ throw new OutOfBoundsException($message);
+ }
+
+ Log::warning($message);
+
+ return $key;
+ });
+ });
}
/**
@@ -21,6 +37,17 @@ public function register(): void
*/
public function boot(): void
{
- //
+ if ($this->isProduction()) {
+ Model::shouldBeStrict();
+ }
+ }
+
+ private function isProduction(): bool
+ {
+ $environment = $this->app->environment('production');
+
+ \assert(\is_bool($environment));
+
+ return $environment;
}
}
diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php
index 027e187..e2be6d8 100644
--- a/app/Providers/BroadcastServiceProvider.php
+++ b/app/Providers/BroadcastServiceProvider.php
@@ -16,6 +16,6 @@ public function boot(): void
{
Broadcast::routes();
- require base_path('routes/channels.php');
+ require \base_path('routes/channels.php');
}
}
diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php
index 4695cb1..00e43e6 100644
--- a/app/Providers/RouteServiceProvider.php
+++ b/app/Providers/RouteServiceProvider.php
@@ -28,16 +28,16 @@ public function boot(): void
{
RateLimiter::for(
'api',
- fn(Request $request) => Limit::perMinute(60)->by($request->user()?->id ?? $request->ip()),
+ static fn(Request $request) => Limit::perMinute(60)->by($request->user()?->id ?? $request->ip()),
);
- $this->routes(function (): void {
+ $this->routes(static function (): void {
Route::middleware('api')
->prefix('api')
- ->group(base_path('routes/api.php'));
+ ->group(\base_path('routes/api.php'));
Route::middleware('web')
- ->group(base_path('routes/web.php'));
+ ->group(\base_path('routes/web.php'));
});
}
}
diff --git a/artisan b/artisan
index f380aa4..6509981 100755
--- a/artisan
+++ b/artisan
@@ -34,7 +34,7 @@ $kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput(),
- new Symfony\Component\Console\Output\ConsoleOutput()
+ new Symfony\Component\Console\Output\ConsoleOutput(),
);
/*
diff --git a/bootstrap/app.php b/bootstrap/app.php
index 08d677b..7caf736 100644
--- a/bootstrap/app.php
+++ b/bootstrap/app.php
@@ -14,7 +14,7 @@
*/
$app = new Illuminate\Foundation\Application(
- $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
+ $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__),
);
/*
@@ -30,17 +30,17 @@
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
- App\Http\Kernel::class
+ App\Http\Kernel::class,
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
- App\Console\Kernel::class
+ App\Console\Kernel::class,
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
- App\Exceptions\Handler::class
+ App\Exceptions\Handler::class,
);
/*
diff --git a/config/app.php b/config/app.php
index d4fdd98..0456f83 100644
--- a/config/app.php
+++ b/config/app.php
@@ -158,13 +158,9 @@
*/
'providers' => ServiceProvider::defaultProviders()->merge([
- /*
- * Package Service Providers...
- */
+ // Package Service Providers...
- /*
- * Application Service Providers...
- */
+ // Application Service Providers...
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
diff --git a/config/logging.php b/config/logging.php
index 489219b..5b37380 100644
--- a/config/logging.php
+++ b/config/logging.php
@@ -110,7 +110,7 @@
'syslog' => [
'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'),
- 'facility' => LOG_USER,
+ 'facility' => \LOG_USER,
'replace_placeholders' => true,
],
diff --git a/config/sanctum.php b/config/sanctum.php
index 8d6cabf..ff6129a 100644
--- a/config/sanctum.php
+++ b/config/sanctum.php
@@ -20,7 +20,7 @@
'stateful' => explode(',', is_string($domains = env('SANCTUM_STATEFUL_DOMAINS')) ? $domains : sprintf(
'%s%s',
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
- Sanctum::currentApplicationUrlWithPort()
+ Sanctum::currentApplicationUrlWithPort(),
)),
/*
diff --git a/config/view.php b/config/view.php
index d9c90c0..528cbf4 100644
--- a/config/view.php
+++ b/config/view.php
@@ -32,7 +32,7 @@
'compiled' => env(
'VIEW_COMPILED_PATH',
- realpath(storage_path('framework/views'))
+ realpath(storage_path('framework/views')),
),
];
diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php
index dd13bd3..1d78ee1 100644
--- a/database/factories/UserFactory.php
+++ b/database/factories/UserFactory.php
@@ -26,9 +26,9 @@ class UserFactory extends Factory
public function definition(): array
{
return [
- 'name' => fake()->name(),
- 'email' => fake()->unique()->safeEmail(),
- 'email_verified_at' => now(),
+ 'name' => \fake()->name(),
+ 'email' => \fake()->unique()->safeEmail(),
+ 'email_verified_at' => \now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
@@ -39,7 +39,7 @@ public function definition(): array
*/
public function unverified(): static
{
- return $this->state(fn(array $attributes) => [
+ return $this->state(static fn(array $attributes) => [
'email_verified_at' => null,
]);
}
diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php
index ca7a762..bab828e 100644
--- a/database/migrations/2014_10_12_000000_create_users_table.php
+++ b/database/migrations/2014_10_12_000000_create_users_table.php
@@ -12,7 +12,7 @@
*/
public function up(): void
{
- Schema::create('users', function (Blueprint $table): void {
+ Schema::create('users', static function (Blueprint $table): void {
$table->id();
$table->string('name');
$table->string('email')->unique();
diff --git a/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php b/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php
index efa1cbf..c7f7151 100644
--- a/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php
+++ b/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php
@@ -12,7 +12,7 @@
*/
public function up(): void
{
- Schema::create('password_reset_tokens', function (Blueprint $table): void {
+ Schema::create('password_reset_tokens', static function (Blueprint $table): void {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
diff --git a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php
index 43a6fac..c6a2b64 100644
--- a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php
+++ b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php
@@ -12,7 +12,7 @@
*/
public function up(): void
{
- Schema::create('failed_jobs', function (Blueprint $table): void {
+ Schema::create('failed_jobs', static function (Blueprint $table): void {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
diff --git a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php
index 36a655a..a2095b4 100644
--- a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php
+++ b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php
@@ -12,7 +12,7 @@
*/
public function up(): void
{
- Schema::create('personal_access_tokens', function (Blueprint $table): void {
+ Schema::create('personal_access_tokens', static function (Blueprint $table): void {
$table->id();
$table->morphs('tokenable');
$table->string('name');
diff --git a/public/index.php b/public/index.php
index 3b634f1..5d9ce35 100644
--- a/public/index.php
+++ b/public/index.php
@@ -53,7 +53,7 @@
$kernel = $app->make(Kernel::class);
$response = $kernel->handle(
- $request = Request::capture()
+ $request = Request::capture(),
)->send();
$kernel->terminate($request, $response);
diff --git a/routes/api.php b/routes/api.php
index 853cbb5..8f4eed7 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -16,4 +16,4 @@
|
*/
-Route::middleware('auth:sanctum')->get('/user', fn(Request $request) => $request->user());
+Route::middleware('auth:sanctum')->get('/user', static fn(Request $request) => $request->user());
diff --git a/routes/channels.php b/routes/channels.php
index 3979ba6..7ac0bf4 100644
--- a/routes/channels.php
+++ b/routes/channels.php
@@ -15,4 +15,4 @@
|
*/
-Broadcast::channel('App.Models.User.{id}', fn($user, $id) => (int) $user->id === (int) $id);
+Broadcast::channel('App.Models.User.{id}', static fn($user, $id) => (int) $user->id === (int) $id);
diff --git a/routes/console.php b/routes/console.php
index 9d0c787..ed712de 100644
--- a/routes/console.php
+++ b/routes/console.php
@@ -18,11 +18,10 @@
*/
/**
- * See: https://github.com/larastan/larastan/issues/1110
+ * See: https://github.com/larastan/larastan/issues/1110.
*
* @var Command $this
*/
-
Artisan::command('inspire', function (): void {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');
diff --git a/routes/web.php b/routes/web.php
index 6483cf4..89c80cd 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -15,4 +15,4 @@
|
*/
-Route::get('/', fn() => view('welcome'));
+Route::get('/', static fn() => view('welcome'));
diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php
index 19fe97c..9aa9bd7 100644
--- a/tests/Unit/ExampleTest.php
+++ b/tests/Unit/ExampleTest.php
@@ -13,6 +13,6 @@ class ExampleTest extends TestCase
*/
public function test_that_true_is_true(): void
{
- //$this->assertTrue(true);
+ // $this->assertTrue(true);
}
}