mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-07 17:02:34 +00:00
Add phpstan level 7(#544)
This commit is contained in:
@ -26,15 +26,9 @@ public function boot(): void
|
||||
ResourceCollection::withoutWrapping();
|
||||
|
||||
// facades
|
||||
$this->app->bind('ssh', function () {
|
||||
return new SSH;
|
||||
});
|
||||
$this->app->bind('notifier', function () {
|
||||
return new Notifier;
|
||||
});
|
||||
$this->app->bind('ftp', function () {
|
||||
return new FTP;
|
||||
});
|
||||
$this->app->bind('ssh', fn (): \App\Helpers\SSH => new SSH);
|
||||
$this->app->bind('notifier', fn (): \App\Helpers\Notifier => new Notifier);
|
||||
$this->app->bind('ftp', fn (): \App\Helpers\FTP => new FTP);
|
||||
|
||||
Sanctum::usePersonalAccessTokenModel(PersonalAccessToken::class);
|
||||
}
|
||||
|
@ -11,22 +11,31 @@ class DemoServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $error = 'Cannot modify on Demo!';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected array $canDelete = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected array $canUpdate = [
|
||||
'App\Models\ServerLog',
|
||||
'App\Models\Script',
|
||||
'App\Models\ScriptExecution',
|
||||
\App\Models\ServerLog::class,
|
||||
\App\Models\Script::class,
|
||||
\App\Models\ScriptExecution::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected array $canCreate = [
|
||||
'App\Models\ServerLog',
|
||||
'App\Models\Script',
|
||||
'App\Models\ScriptExecution',
|
||||
'App\Models\FirewallRule',
|
||||
'App\Models\PersonalAccessToken',
|
||||
\App\Models\ServerLog::class,
|
||||
\App\Models\Script::class,
|
||||
\App\Models\ScriptExecution::class,
|
||||
\App\Models\FirewallRule::class,
|
||||
\App\Models\PersonalAccessToken::class,
|
||||
];
|
||||
|
||||
public function register(): void
|
||||
@ -41,8 +50,9 @@ public function boot(): void
|
||||
}
|
||||
|
||||
// get all classes inside App\Models namespace
|
||||
$models = collect(scandir(app_path('Models')))
|
||||
->filter(fn ($file) => ! in_array($file, ['.', '..']))
|
||||
$files = scandir(app_path('Models')) ?: [];
|
||||
$models = collect($files)
|
||||
->filter(fn ($file): bool => ! in_array($file, ['.', '..']))
|
||||
->map(fn ($file) => 'App\\Models\\'.str_replace('.php', '', $file));
|
||||
|
||||
foreach ($models as $model) {
|
||||
@ -69,7 +79,7 @@ public function boot(): void
|
||||
|
||||
private function preventUpdating(string $model): void
|
||||
{
|
||||
$model::updating(function ($m) {
|
||||
$model::updating(function ($m): void {
|
||||
$throw = true;
|
||||
if ($m instanceof User && ! $m->isDirty(['name', 'email', 'password', 'two_factor_secret', 'two_factor_recovery_codes'])) {
|
||||
$throw = false;
|
||||
@ -82,14 +92,14 @@ private function preventUpdating(string $model): void
|
||||
|
||||
private function preventDeletion(string $model): void
|
||||
{
|
||||
$model::deleting(function ($m) {
|
||||
$model::deleting(function ($m): void {
|
||||
abort(403, $this->error);
|
||||
});
|
||||
}
|
||||
|
||||
private function preventCreating(string $model): void
|
||||
{
|
||||
$model::creating(function ($m) {
|
||||
$model::creating(function ($m): void {
|
||||
abort(403, $this->error);
|
||||
});
|
||||
}
|
||||
|
@ -31,8 +31,6 @@ public function boot(): void
|
||||
*/
|
||||
protected function configureRateLimiting(): void
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
RateLimiter::for('api', fn (Request $request) => Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user