diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b57f917a..bbbee89e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,6 +100,15 @@ jobs: run: php artisan migrate --no-interaction -vvv --force - name: Execute code style check via Laravel Pint run: vendor/bin/pint --test -v + - name: Rector Cache + uses: actions/cache@v4 + with: + path: /tmp/rector + key: ${{ runner.os }}-rector-${{ github.run_id }} + restore-keys: ${{ runner.os }}-rector- + - run: mkdir -p /tmp/rector + - name: Rector Dry Run + run: vendor/bin/rector process --dry-run - name: Execute tests (Unit and Feature tests) via PHPUnit if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork }} env: diff --git a/app/Auth/ExternalUser.php b/app/Auth/ExternalUser.php index 737ca573a..c01229a93 100644 --- a/app/Auth/ExternalUser.php +++ b/app/Auth/ExternalUser.php @@ -214,7 +214,7 @@ private function isRuleFulfilled($values, mixed $rule): bool // Loop through all values and try to match the regex and save the result foreach ($values as $value) { - $matches[] = preg_match($rule->regex, $value); + $matches[] = preg_match($rule->regex, (string) $value); } // Check if regex has to (not) match with all array entries diff --git a/app/Auth/LDAP/LDAPController.php b/app/Auth/LDAP/LDAPController.php index 2120a4cbb..0b84c86f8 100644 --- a/app/Auth/LDAP/LDAPController.php +++ b/app/Auth/LDAP/LDAPController.php @@ -57,7 +57,7 @@ public function login(Request $request) try { // Run login method from AuthenticatesUsers trait return $this->ldapLogin($request); - } catch (MissingAttributeException $e) { + } catch (MissingAttributeException) { // If an attribute is missing during the login process, return error return abort(500, __('auth.error.missing_attributes')); } diff --git a/app/Auth/LDAP/LDAPProvider.php b/app/Auth/LDAP/LDAPProvider.php index 46ded3823..9b9b40b45 100644 --- a/app/Auth/LDAP/LDAPProvider.php +++ b/app/Auth/LDAP/LDAPProvider.php @@ -40,6 +40,7 @@ public function __construct(Hasher $hasher, $model) * @param mixed $identifier * @return \Illuminate\Contracts\Auth\Authenticatable|null */ + #[\Override] public function retrieveById($identifier) { return $this->eloquent->retrieveById($identifier); @@ -52,6 +53,7 @@ public function retrieveById($identifier) * @param string $token * @return \Illuminate\Contracts\Auth\Authenticatable|null */ + #[\Override] public function retrieveByToken($identifier, $token) { return $this->eloquent->retrieveByToken($identifier, $token); @@ -63,11 +65,13 @@ public function retrieveByToken($identifier, $token) * @param string $token * @return void */ + #[\Override] public function updateRememberToken(Authenticatable $user, $token) { $this->eloquent->updateRememberToken($user, $token); } + #[\Override] public function rehashPasswordIfRequired(Authenticatable $user, array $credentials, bool $force = false): void { $this->eloquent->rehashPasswordIfRequired($user, $credentials, $force); @@ -78,6 +82,7 @@ public function rehashPasswordIfRequired(Authenticatable $user, array $credentia * * @return \Illuminate\Contracts\Auth\Authenticatable|null */ + #[\Override] public function retrieveByCredentials(array $credentials) { // Find ldap user by username @@ -102,6 +107,7 @@ public function retrieveByCredentials(array $credentials) * * @return bool */ + #[\Override] public function validateCredentials(Authenticatable $user, array $credentials) { // Bind to LDAP with user credentials diff --git a/app/Auth/LDAP/LDAPUser.php b/app/Auth/LDAP/LDAPUser.php index 506c2cac7..0d9d9fcb7 100644 --- a/app/Auth/LDAP/LDAPUser.php +++ b/app/Auth/LDAP/LDAPUser.php @@ -25,7 +25,7 @@ public function __construct(LDAPUserObject $ldap_user) foreach ($raw_attributes as $attribute_name => $attribute_values) { // If the current LDAP attribute matches the name of the LDAP attribute in the mapping // add all values to the attribute of the user - if (strcasecmp($ldap_attribute, $attribute_name) == 0) { + if (strcasecmp((string) $ldap_attribute, $attribute_name) == 0) { foreach ($attribute_values as $value) { $this->addAttributeValue($attribute, $value); } diff --git a/app/Auth/LDAP/LDAPUserObject.php b/app/Auth/LDAP/LDAPUserObject.php index d0ae97b1c..68955935d 100644 --- a/app/Auth/LDAP/LDAPUserObject.php +++ b/app/Auth/LDAP/LDAPUserObject.php @@ -10,6 +10,7 @@ class LDAPUserObject extends Model /** * The "booting" method of the model. */ + #[\Override] protected static function boot(): void { parent::boot(); @@ -27,6 +28,7 @@ public function __construct(array $attributes = []) /** * Get a new query for builder filtered by the current models object classes. */ + #[\Override] public function newQuery(): Builder { $query = $this->registerModelScopes( diff --git a/app/Auth/Local/LocalProvider.php b/app/Auth/Local/LocalProvider.php index 1f706eaf2..b282188f2 100644 --- a/app/Auth/Local/LocalProvider.php +++ b/app/Auth/Local/LocalProvider.php @@ -12,6 +12,7 @@ class LocalProvider extends EloquentUserProvider implements UserProvider * * @return \Illuminate\Contracts\Auth\Authenticatable|null */ + #[\Override] public function retrieveByCredentials(array $credentials) { $email = $credentials['email'] ?? null; diff --git a/app/Auth/Shibboleth/ShibbolethController.php b/app/Auth/Shibboleth/ShibbolethController.php index 4410b3853..f667e195c 100644 --- a/app/Auth/Shibboleth/ShibbolethController.php +++ b/app/Auth/Shibboleth/ShibbolethController.php @@ -45,9 +45,9 @@ public function callback(Request $request) { try { $user = $this->provider->login($request); - } catch (MissingAttributeException $e) { + } catch (MissingAttributeException) { return redirect('/external_login?error=missing_attributes'); - } catch (ShibbolethSessionDuplicateException $e) { + } catch (ShibbolethSessionDuplicateException) { // Prevented login attempt with duplicate shibboleth session, redirect to logout to kill SP session return redirect($this->provider->logout(url('/external_login?error=shibboleth_session_duplicate_exception'))); } diff --git a/app/Auth/Shibboleth/ShibbolethProvider.php b/app/Auth/Shibboleth/ShibbolethProvider.php index c2ffbdd73..02aa5df84 100644 --- a/app/Auth/Shibboleth/ShibbolethProvider.php +++ b/app/Auth/Shibboleth/ShibbolethProvider.php @@ -134,6 +134,6 @@ public function login(Request $request) public function hashShibbolethSessionId($shibbolethSessionId) { - return hash('sha256', $shibbolethSessionId); + return hash('sha256', (string) $shibbolethSessionId); } } diff --git a/app/Auth/Shibboleth/ShibbolethServiceProvider.php b/app/Auth/Shibboleth/ShibbolethServiceProvider.php index 2e39555d7..e528b933c 100644 --- a/app/Auth/Shibboleth/ShibbolethServiceProvider.php +++ b/app/Auth/Shibboleth/ShibbolethServiceProvider.php @@ -10,10 +10,9 @@ class ShibbolethServiceProvider extends ServiceProvider /** * Register the Shibboleth provider. */ + #[\Override] public function register(): void { - $this->app->singleton(ShibbolethProvider::class, function (Application $app) { - return new ShibbolethProvider; - }); + $this->app->singleton(fn (Application $app): \App\Auth\Shibboleth\ShibbolethProvider => new ShibbolethProvider); } } diff --git a/app/Console/Commands/CheckDatabaseConnectionCommand.php b/app/Console/Commands/CheckDatabaseConnectionCommand.php index 4cbefd11a..f0c5f3070 100644 --- a/app/Console/Commands/CheckDatabaseConnectionCommand.php +++ b/app/Console/Commands/CheckDatabaseConnectionCommand.php @@ -32,7 +32,7 @@ public function handle() $this->info('Successfully connected to the database.'); return 0; - } catch (Exception $e) { + } catch (Exception) { $this->error('Connecting to the database failed.'); return 1; diff --git a/app/Console/Commands/CleanupRecordingsCommand.php b/app/Console/Commands/CleanupRecordingsCommand.php index e857ffcf0..838039f6d 100644 --- a/app/Console/Commands/CleanupRecordingsCommand.php +++ b/app/Console/Commands/CleanupRecordingsCommand.php @@ -37,7 +37,7 @@ public function handle() if ($retentionPeriod != TimePeriod::UNLIMITED) { $day = now()->subDays($retentionPeriod->value)->toDateString(); Log::info('Removing recordings data older than '.$day); - Recording::where('start', '<', $day)->get()->each(function ($recording) { + Recording::where('start', '<', $day)->get()->each(function ($recording): void { $recording->delete(); }); } diff --git a/app/Console/Commands/CleanupRoomsCommand.php b/app/Console/Commands/CleanupRoomsCommand.php index 606ef3c83..64cd29f64 100644 --- a/app/Console/Commands/CleanupRoomsCommand.php +++ b/app/Console/Commands/CleanupRoomsCommand.php @@ -35,13 +35,13 @@ public function handle() ->join('users', 'rooms.user_id', '=', 'users.id') ->select('rooms.id') ->whereNull('delete_inactive') - ->where(function ($query) use ($neverUsedPeriod, $inactivePeriod, $createdDate, $lastStartDate) { - $query->where(function ($query) use ($inactivePeriod, $lastStartDate) { + ->where(function ($query) use ($neverUsedPeriod, $inactivePeriod, $createdDate, $lastStartDate): void { + $query->where(function ($query) use ($inactivePeriod, $lastStartDate): void { if ($inactivePeriod != TimePeriod::UNLIMITED) { $query->where('meetings.start', '<', $lastStartDate); } }) - ->orWhere(function ($query) use ($neverUsedPeriod, $createdDate) { + ->orWhere(function ($query) use ($neverUsedPeriod, $createdDate): void { if ($neverUsedPeriod != TimePeriod::UNLIMITED) { $query->where('rooms.created_at', '<', $createdDate) ->whereNull('meetings.start'); diff --git a/app/Console/Commands/DeleteObsoleteTokensCommand.php b/app/Console/Commands/DeleteObsoleteTokensCommand.php index f8258a4af..21be02d16 100644 --- a/app/Console/Commands/DeleteObsoleteTokensCommand.php +++ b/app/Console/Commands/DeleteObsoleteTokensCommand.php @@ -36,11 +36,11 @@ public function handle() if ($expireDuration != TimePeriod::UNLIMITED) { $expiredTokens = RoomToken::query() - ->where(function ($query) use ($expireDuration) { + ->where(function ($query) use ($expireDuration): void { $query->whereNull('last_usage') ->where('created_at', '<', Carbon::now()->subDays($expireDuration->value)); }) - ->orWhere(function ($query) use ($expireDuration) { + ->orWhere(function ($query) use ($expireDuration): void { $query->whereNotNull('last_usage') ->where('last_usage', '<', Carbon::now()->subDays($expireDuration->value)); }) diff --git a/app/Console/Commands/ImportDatabaseCommand.php b/app/Console/Commands/ImportDatabaseCommand.php index ee84e1fe7..27014818b 100644 --- a/app/Console/Commands/ImportDatabaseCommand.php +++ b/app/Console/Commands/ImportDatabaseCommand.php @@ -59,7 +59,7 @@ public function handle() $this->bar = $this->output->createProgressBar(100); // Run command and show output in realtime - $process = Process::forever()->start($command, function (string $type, string $output) { + $process = Process::forever()->start($command, function (string $type, string $output): void { if (Str::contains($output, 'ERROR')) { $this->bar->clear(); $this->error($output); diff --git a/app/Console/Commands/ImportGreenlight2Command.php b/app/Console/Commands/ImportGreenlight2Command.php index e860fae54..d12fba1f5 100644 --- a/app/Console/Commands/ImportGreenlight2Command.php +++ b/app/Console/Commands/ImportGreenlight2Command.php @@ -260,7 +260,7 @@ protected function importRooms(Collection $rooms, int $roomType, array $userMap, // walk through all found greenlight rooms foreach ($rooms as $room) { // convert room settings from json string to object - $room->room_settings = json_decode($room->room_settings); + $room->room_settings = json_decode((string) $room->room_settings); // check if a room with the same id exists $dbRoom = Room::find($room->uid); diff --git a/app/Console/Commands/ImportLocalesCommand.php b/app/Console/Commands/ImportLocalesCommand.php index 8a267e317..deb897e77 100644 --- a/app/Console/Commands/ImportLocalesCommand.php +++ b/app/Console/Commands/ImportLocalesCommand.php @@ -88,7 +88,7 @@ public function handle(): void // Delete all old php locales files $localeFiles = $disk->files($lang['code']); foreach ($localeFiles as $localeFile) { - $path_parts = pathinfo($localeFile); + $path_parts = pathinfo((string) $localeFile); if ($path_parts['extension'] == 'php') { $disk->delete($localeFile); diff --git a/app/Console/Commands/UpgradeDatabaseCommand.php b/app/Console/Commands/UpgradeDatabaseCommand.php index 54017758a..807cd5756 100644 --- a/app/Console/Commands/UpgradeDatabaseCommand.php +++ b/app/Console/Commands/UpgradeDatabaseCommand.php @@ -99,9 +99,7 @@ public function handle() $this->info('Migrating old application settings'); $this->info('Overview of old settings:'); - $this->table(['Key', 'Value'], collect($oldSettings)->map(function ($value, $key) { - return [$key, $value]; - })); + $this->table(['Key', 'Value'], collect($oldSettings)->map(fn ($value, $key) => [$key, $value])); // Apply old settings to new settings $generalSettings = app(GeneralSettings::class); diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index c00a0906f..a2d18a292 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -39,6 +39,7 @@ class Kernel extends ConsoleKernel /** * Define the application's command schedule. */ + #[\Override] protected function schedule(Schedule $schedule): void { $schedule->command(PollServerCommand::class)->everyMinute()->onOneServer(); @@ -56,6 +57,7 @@ protected function schedule(Schedule $schedule): void /** * Register the commands for the application. */ + #[\Override] protected function commands(): void { $this->load(__DIR__.'/Commands'); diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 20feb60f4..036c3854a 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -49,6 +49,7 @@ class Handler extends ExceptionHandler * * @throws \Exception */ + #[\Override] public function report(Throwable $exception) { parent::report($exception); @@ -57,6 +58,7 @@ public function report(Throwable $exception) /** * Register the exception handling callbacks for the application. */ + #[\Override] public function register(): void { $this->reportable(function (Throwable $e) { diff --git a/app/Exports/AttendanceExport.php b/app/Exports/AttendanceExport.php index 31aaa0b54..b46d486d3 100644 --- a/app/Exports/AttendanceExport.php +++ b/app/Exports/AttendanceExport.php @@ -17,27 +17,13 @@ */ class AttendanceExport implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithStyles { - /** - * @var Meeting Meeting the attendance should be exported for - */ - private $meeting; - - /** - * @var string Timezone the datetimes should be shown in - */ - private $timezone; - /** * AttendanceExport constructor. * * @param Meeting $meeting Meeting the attendance should be exported for * @param string $timezone Timezone the datetimes should be shown in */ - public function __construct(Meeting $meeting, string $timezone) - { - $this->meeting = $meeting; - $this->timezone = $timezone; - } + public function __construct(private readonly Meeting $meeting, private readonly string $timezone) {} /** * Collection of the data to export into the excel file @@ -46,7 +32,7 @@ public function __construct(Meeting $meeting, string $timezone) */ public function collection() { - return (new MeetingService($this->meeting))->attendance(); + return new MeetingService($this->meeting)->attendance(); } /** diff --git a/app/Http/Controllers/RecordingController.php b/app/Http/Controllers/RecordingController.php index 4da76912c..d68fa8cfe 100644 --- a/app/Http/Controllers/RecordingController.php +++ b/app/Http/Controllers/RecordingController.php @@ -51,14 +51,10 @@ public function download(Recording $recording) // Get all files in the recording directory, remove the root folder and filter the files by the whitelist $files = Collection::make(Storage::disk('recordings')->allFiles($recording->id)) - ->map(function (string $filename) use ($recording) { - return explode($recording->id.'/', $filename, 2)[1]; - }) - ->filter(function (string $filename) { - return preg_match('/'.config('recording.download_allowlist').'/', $filename); - }); - - $response = new StreamedResponse(function () use ($recording, $files) { + ->map(fn (string $filename) => explode($recording->id.'/', $filename, 2)[1]) + ->filter(fn (string $filename) => preg_match('/'.config('recording.download_allowlist').'/', $filename)); + + $response = new StreamedResponse(function () use ($recording, $files): void { // create a new zip stream $zip = new ZipStream( outputName: __('rooms.recordings.filename').'_'.$recording->start->format('Y-m-d').'.zip', diff --git a/app/Http/Controllers/api/v1/ApplicationController.php b/app/Http/Controllers/api/v1/ApplicationController.php index 895663111..27eaaa0ad 100644 --- a/app/Http/Controllers/api/v1/ApplicationController.php +++ b/app/Http/Controllers/api/v1/ApplicationController.php @@ -27,6 +27,6 @@ public function config() */ public function currentUser() { - return (new UserResource(Auth::user()))->withPermissions()->withoutRoles(); + return new UserResource(Auth::user())->withPermissions()->withoutRoles(); } } diff --git a/app/Http/Controllers/api/v1/MeetingController.php b/app/Http/Controllers/api/v1/MeetingController.php index be8220934..06a3c0ce9 100644 --- a/app/Http/Controllers/api/v1/MeetingController.php +++ b/app/Http/Controllers/api/v1/MeetingController.php @@ -50,15 +50,15 @@ public function index(Request $request) if ($request->has('search') && trim($request->search) != '') { $searchQueries = explode(' ', preg_replace('/\s\s+/', ' ', $request->search)); foreach ($searchQueries as $searchQuery) { - $resource = $resource->where(function ($query) use ($searchQuery) { - $query->whereHas('room', function ($subQuery) use ($searchQuery) { + $resource = $resource->where(function ($query) use ($searchQuery): void { + $query->whereHas('room', function ($subQuery) use ($searchQuery): void { $subQuery->whereLike('name', '%'.$searchQuery.'%'); }) - ->orWhereHas('room.owner', function ($subQuery) use ($searchQuery) { + ->orWhereHas('room.owner', function ($subQuery) use ($searchQuery): void { $subQuery->whereLike('firstname', '%'.$searchQuery.'%') ->orWhereLike('lastname', '%'.$searchQuery.'%'); }) - ->orWhereHas('server', function ($subQuery) use ($searchQuery) { + ->orWhereHas('server', function ($subQuery) use ($searchQuery): void { $subQuery->whereLike('name', '%'.$searchQuery.'%'); }); }); diff --git a/app/Http/Controllers/api/v1/PermissionController.php b/app/Http/Controllers/api/v1/PermissionController.php index b4914ef3a..418dade6f 100644 --- a/app/Http/Controllers/api/v1/PermissionController.php +++ b/app/Http/Controllers/api/v1/PermissionController.php @@ -15,7 +15,7 @@ class PermissionController extends Controller */ public function index() { - return (new PermissionResourceCollection(Permission::all()))->additional([ + return new PermissionResourceCollection(Permission::all())->additional([ 'meta' => [ 'restrictions' => config('permissions.restrictions'), ], diff --git a/app/Http/Controllers/api/v1/RecordingController.php b/app/Http/Controllers/api/v1/RecordingController.php index a631700f6..0a8bf5cbb 100644 --- a/app/Http/Controllers/api/v1/RecordingController.php +++ b/app/Http/Controllers/api/v1/RecordingController.php @@ -54,7 +54,7 @@ public function index(Room $room, Request $request) $allowedAccess[] = RecordingAccess::PARTICIPANT; } - $resource = $resource->whereIn('access', $allowedAccess)->whereHas('formats', function (Builder $query) { + $resource = $resource->whereIn('access', $allowedAccess)->whereHas('formats', function (Builder $query): void { $query->where('disabled', false); }); } diff --git a/app/Http/Controllers/api/v1/RoleController.php b/app/Http/Controllers/api/v1/RoleController.php index 1d77ad5d1..9e75ad427 100644 --- a/app/Http/Controllers/api/v1/RoleController.php +++ b/app/Http/Controllers/api/v1/RoleController.php @@ -82,7 +82,7 @@ public function store(RoleRequest $request) $role->permissions()->sync($new_permissions); - return (new RoleResource($role))->withPermissions(); + return new RoleResource($role)->withPermissions(); } /** @@ -92,7 +92,7 @@ public function store(RoleRequest $request) */ public function show(Role $role) { - return (new RoleResource($role))->withPermissions(); + return new RoleResource($role)->withPermissions(); } /** @@ -133,7 +133,7 @@ public function update(RoleRequest $request, Role $role) $role->name = $request->name; $role->save(); - return (new RoleResource($role))->withPermissions(); + return new RoleResource($role)->withPermissions(); } /** diff --git a/app/Http/Controllers/api/v1/RoomController.php b/app/Http/Controllers/api/v1/RoomController.php index ec3c598a4..42fb10014 100644 --- a/app/Http/Controllers/api/v1/RoomController.php +++ b/app/Http/Controllers/api/v1/RoomController.php @@ -54,7 +54,7 @@ public function index(ShowRoomsRequest $request) if ($request->filter_all && Auth::user()->can('viewAll', Room::class)) { $collection = Room::query(); } else { - $collection = Room::where(function (Builder $query) use ($request) { + $collection = Room::where(function (Builder $query) use ($request): void { // own rooms if ($request->filter_own) { $query->orWhere('user_id', '=', Auth::user()->id); @@ -69,7 +69,7 @@ public function index(ShowRoomsRequest $request) // all rooms that are public if ($request->filter_public) { - $query->orWhere(function (Builder $subQuery) { + $query->orWhere(function (Builder $subQuery): void { $roomTypesWithListingEnforced = RoomType::where('visibility_enforced', true)->where('visibility_default', RoomVisibility::PUBLIC)->get('id'); $roomTypesWithNoListingEnforced = RoomType::where('visibility_enforced', true)->where('visibility_default', RoomVisibility::PRIVATE)->get('id'); $roomTypesWithListingDefault = RoomType::where('visibility_enforced', false)->where('visibility_default', RoomVisibility::PUBLIC)->get('id'); @@ -77,13 +77,13 @@ public function index(ShowRoomsRequest $request) // Room has a room type where the visibility public is enforced ->whereIn('room_type_id', $roomTypesWithListingEnforced) // Room where expert mode is deactivated where the visibility public is the default value - ->orWhere(function (Builder $subSubQuery) use ($roomTypesWithListingDefault) { + ->orWhere(function (Builder $subSubQuery) use ($roomTypesWithListingDefault): void { $subSubQuery ->where('expert_mode', false) ->whereIn('room_type_id', $roomTypesWithListingDefault); }) // Room where expert mode is activated and visibility is set to public - ->orWhere(function (Builder $subSubQuery) use ($roomTypesWithNoListingEnforced) { + ->orWhere(function (Builder $subSubQuery) use ($roomTypesWithNoListingEnforced): void { $subSubQuery ->where('expert_mode', true) ->where('visibility', RoomVisibility::PUBLIC) @@ -123,9 +123,9 @@ public function index(ShowRoomsRequest $request) if ($request->has('search') && trim($request->search) != '') { $searchQueries = explode(' ', preg_replace('/\s\s+/', ' ', $request->search)); foreach ($searchQueries as $searchQuery) { - $collection = $collection->where(function ($query) use ($searchQuery) { + $collection = $collection->where(function ($query) use ($searchQuery): void { $query->whereLike('rooms.name', '%'.$searchQuery.'%') - ->orWhereHas('owner', function ($query2) use ($searchQuery) { + ->orWhereHas('owner', function ($query2) use ($searchQuery): void { $query2->whereLike('users.firstname', '%'.$searchQuery.'%') ->orWhereLike('users.lastname', '%'.$searchQuery.'%'); }); @@ -195,7 +195,7 @@ public function store(CreateRoom $request) */ public function show(Room $room, RoomAuthService $roomAuthService) { - return (new \App\Http\Resources\Room($room))->withDetails(); + return new \App\Http\Resources\Room($room)->withDetails(); } /** @@ -416,7 +416,7 @@ public function transferOwnership(Room $room, TransferOwnershipRequest $request) } return response()->noContent(); - } catch (\Exception $e) { + } catch (\Exception) { DB::rollBack(); Log::error('Failed to transfer ownership of the room {room} from previous owner {oldOwner} to new owner {newOwner}', ['room' => $room->getLogLabel(), 'oldOwner' => $oldOwner->getLogLabel(), 'newOwner' => $newOwner->getLogLabel()]); diff --git a/app/Http/Controllers/api/v1/RoomMemberController.php b/app/Http/Controllers/api/v1/RoomMemberController.php index 00527141a..a4aabcb2b 100644 --- a/app/Http/Controllers/api/v1/RoomMemberController.php +++ b/app/Http/Controllers/api/v1/RoomMemberController.php @@ -64,7 +64,7 @@ public function index(Room $room, Request $request) // Split search query into single words and search for them in firstname and lastname $searchQueries = explode(' ', preg_replace('/\s\s+/', ' ', $request->search)); foreach ($searchQueries as $searchQuery) { - $resource = $resource->where(function ($query) use ($searchQuery) { + $resource = $resource->where(function ($query) use ($searchQuery): void { $query->whereLike('firstname', '%'.$searchQuery.'%') ->orWhereLike('lastname', '%'.$searchQuery.'%'); }); diff --git a/app/Http/Controllers/api/v1/RoomStreamingController.php b/app/Http/Controllers/api/v1/RoomStreamingController.php index 614097e59..17103220a 100644 --- a/app/Http/Controllers/api/v1/RoomStreamingController.php +++ b/app/Http/Controllers/api/v1/RoomStreamingController.php @@ -61,7 +61,7 @@ public function status(Room $room) } throw new \Exception('Error connecting to streaming service'); }); - } catch (\Exception $exception) { + } catch (\Exception) { // Ignore all exceptions (meeting not running, and streaming service connection error) in the status call } diff --git a/app/Http/Controllers/api/v1/RoomTokenController.php b/app/Http/Controllers/api/v1/RoomTokenController.php index 1d0d23cac..1320648f4 100644 --- a/app/Http/Controllers/api/v1/RoomTokenController.php +++ b/app/Http/Controllers/api/v1/RoomTokenController.php @@ -63,7 +63,7 @@ public function index(Room $room, Request $request) // Split search query into single words and search for them in firstname and lastname $searchQueries = explode(' ', preg_replace('/\s\s+/', ' ', $request->search)); foreach ($searchQueries as $searchQuery) { - $resource = $resource->where(function ($query) use ($searchQuery) { + $resource = $resource->where(function ($query) use ($searchQuery): void { $query->whereLike('firstname', '%'.$searchQuery.'%') ->orWhereLike('lastname', '%'.$searchQuery.'%'); }); diff --git a/app/Http/Controllers/api/v1/RoomTypeController.php b/app/Http/Controllers/api/v1/RoomTypeController.php index cefb74241..9149e66dd 100644 --- a/app/Http/Controllers/api/v1/RoomTypeController.php +++ b/app/Http/Controllers/api/v1/RoomTypeController.php @@ -37,7 +37,7 @@ public function index(Request $request) if ($filter === 'own') { // Get list of the room type the current user has access to (Used when creating a new room) $roomTypes = $roomTypes->where('restrict', '=', false) - ->orWhereIn('id', function ($query) { + ->orWhereIn('id', function ($query): void { $query->select('role_room_type.room_type_id') ->from('role_room_type as role_room_type') ->whereIn('role_room_type.role_id', Auth::user()->roles->pluck('id')->all()); @@ -51,7 +51,7 @@ public function index(Request $request) } $roomTypes = $roomTypes->where('restrict', '=', false) - ->orWhereIn('id', function ($query) use ($room) { + ->orWhereIn('id', function ($query) use ($room): void { $query->select('role_room_type.room_type_id') ->from('role_room_type as role_room_type') ->whereIn('role_room_type.role_id', $room->owner->roles->pluck('id')->all()); @@ -81,7 +81,7 @@ public function index(Request $request) public function show(RoomType $roomType) { - return (new RoomTypeResource($roomType))->withDetails()->withDefaultRoomSettings(); + return new RoomTypeResource($roomType)->withDetails()->withDefaultRoomSettings(); } /** @@ -115,7 +115,7 @@ public function update(RoomTypeRequest $request, RoomType $roomType) $roomType->roles()->sync($request->roles); } - return (new RoomTypeResource($roomType))->withDetails()->withDefaultRoomSettings(); + return new RoomTypeResource($roomType)->withDetails()->withDefaultRoomSettings(); } /** @@ -150,7 +150,7 @@ public function store(RoomTypeRequest $request) $roomType->roles()->sync($request->roles); } - return (new RoomTypeResource($roomType))->withDetails()->withDefaultRoomSettings(); + return new RoomTypeResource($roomType)->withDetails()->withDefaultRoomSettings(); } /** diff --git a/app/Http/Controllers/api/v1/ServerController.php b/app/Http/Controllers/api/v1/ServerController.php index b484e61fa..335a8bdc6 100644 --- a/app/Http/Controllers/api/v1/ServerController.php +++ b/app/Http/Controllers/api/v1/ServerController.php @@ -86,7 +86,7 @@ public function index(Request $request) */ public function show(Server $server) { - return (new ServerResource($server))->withApi(); + return new ServerResource($server)->withApi(); } /** @@ -112,7 +112,7 @@ public function update(ServerRequest $request, Server $server) $server->save(); - return (new ServerResource($server))->withApi(); + return new ServerResource($server)->withApi(); } /** @@ -139,7 +139,7 @@ public function store(ServerRequest $request) $server->save(); - return (new ServerResource($server))->withApi(); + return new ServerResource($server)->withApi(); } /** @@ -197,7 +197,7 @@ public function check(ServerConnectionCheckRequest $request) $connectionOk = true; $secretOk = false; } - } catch (\Exception $e) { + } catch (\Exception) { } return \response()->json(['connection_ok' => $connectionOk, 'secret_ok' => $secretOk]); diff --git a/app/Http/Controllers/api/v1/ServerPoolController.php b/app/Http/Controllers/api/v1/ServerPoolController.php index fb64a541f..210ff7343 100644 --- a/app/Http/Controllers/api/v1/ServerPoolController.php +++ b/app/Http/Controllers/api/v1/ServerPoolController.php @@ -68,7 +68,7 @@ public function index(Request $request) */ public function show(ServerPool $serverPool) { - return (new ServerPoolResource($serverPool))->withServers(); + return new ServerPoolResource($serverPool)->withServers(); } /** @@ -84,7 +84,7 @@ public function update(ServerPoolRequest $request, ServerPool $serverPool) $serverPool->save(); $serverPool->servers()->sync($request->servers); - return (new ServerPoolResource($serverPool))->withServers(); + return new ServerPoolResource($serverPool)->withServers(); } /** @@ -100,7 +100,7 @@ public function store(ServerPoolRequest $request) $serverPool->save(); $serverPool->servers()->sync($request->servers); - return (new ServerPoolResource($serverPool))->withServers(); + return new ServerPoolResource($serverPool)->withServers(); } /** diff --git a/app/Http/Controllers/api/v1/SettingsController.php b/app/Http/Controllers/api/v1/SettingsController.php index e1f6b6d4a..50eb1dce6 100644 --- a/app/Http/Controllers/api/v1/SettingsController.php +++ b/app/Http/Controllers/api/v1/SettingsController.php @@ -25,9 +25,7 @@ class SettingsController extends Controller */ public function view() { - $linkStyles = array_filter(LinkButtonStyle::cases(), function ($style) { - return ! in_array($style, LinkButtonStyle::getDeprecated()); - }); + $linkStyles = array_filter(LinkButtonStyle::cases(), fn ($style) => ! in_array($style, LinkButtonStyle::getDeprecated())); return (new Settings)->additional([ 'meta' => [ diff --git a/app/Http/Controllers/api/v1/auth/ResetPasswordController.php b/app/Http/Controllers/api/v1/auth/ResetPasswordController.php index 884c4cac7..50f8ae379 100644 --- a/app/Http/Controllers/api/v1/auth/ResetPasswordController.php +++ b/app/Http/Controllers/api/v1/auth/ResetPasswordController.php @@ -43,7 +43,7 @@ public function reset(Request $request) $response = $this->broker($initial_password_set ? 'new_users' : 'users') ->reset( array_merge(['authenticator' => 'local'], $this->credentials($request)), - function ($user, $password) use ($initial_password_set) { + function ($user, $password) use ($initial_password_set): void { $authService = new AuthenticationService($user); $authService->changePassword($password); $this->guard()->login($user); @@ -66,7 +66,7 @@ function ($user, $password) use ($initial_password_set) { * * @param string $name */ - public function broker($name): PasswordBroker + public function broker($name = null): PasswordBroker { return PasswordBrokerFacade::broker($name); } diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 58273673a..c4ed4f4d6 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -11,6 +11,7 @@ class Authenticate extends Middleware /** * Get the path the user should be redirected to when they are not authenticated. */ + #[\Override] protected function redirectTo(Request $request): ?string { return $request->expectsJson() ? null : URL::to('/login'); diff --git a/app/Http/Middleware/LoggedInUser.php b/app/Http/Middleware/LoggedInUser.php index 235de5810..9372f3dd5 100644 --- a/app/Http/Middleware/LoggedInUser.php +++ b/app/Http/Middleware/LoggedInUser.php @@ -15,11 +15,12 @@ class LoggedInUser extends Middleware * @param \Illuminate\Http\Request $request * @return void */ + #[\Override] protected function authenticate($request, array $guards) { try { parent::authenticate($request, $guards); - } catch (AuthenticationException $exception) { + } catch (AuthenticationException) { } } } diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index ecdd3c1d9..c1a249f7c 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -21,7 +21,7 @@ public function handle(Request $request, Closure $next, ...$guards) foreach ($guards as $guard) { if (Auth::guard($guard)->check()) { - return (new Response('Guests only.'))->setStatusCode(420, 'Guests only'); + return new Response('Guests only.')->setStatusCode(420, 'Guests only'); } } diff --git a/app/Http/Middleware/RoomAuthenticate.php b/app/Http/Middleware/RoomAuthenticate.php index 0649efc79..533a95f36 100644 --- a/app/Http/Middleware/RoomAuthenticate.php +++ b/app/Http/Middleware/RoomAuthenticate.php @@ -12,12 +12,7 @@ class RoomAuthenticate { - protected RoomAuthService $roomAuthService; - - public function __construct(RoomAuthService $roomAuthService) - { - $this->roomAuthService = $roomAuthService; - } + public function __construct(protected RoomAuthService $roomAuthService) {} /** * Handle requests to room routes and determine room unauthenticated status diff --git a/app/Http/Middleware/TrustHosts.php b/app/Http/Middleware/TrustHosts.php index 4d7444d8e..1997eb88b 100644 --- a/app/Http/Middleware/TrustHosts.php +++ b/app/Http/Middleware/TrustHosts.php @@ -11,9 +11,10 @@ class TrustHosts extends Middleware * * @return array */ + #[\Override] public function hosts(): array { - $url = parse_url(config('app.url'), PHP_URL_HOST); + $url = parse_url((string) config('app.url'), PHP_URL_HOST); return [$url]; } diff --git a/app/Http/Requests/AddRoomMember.php b/app/Http/Requests/AddRoomMember.php index ea2696a42..4adb0638a 100644 --- a/app/Http/Requests/AddRoomMember.php +++ b/app/Http/Requests/AddRoomMember.php @@ -12,7 +12,7 @@ public function rules() { return [ 'user' => ['required', 'integer', 'exists:App\Models\User,id', - function ($attribute, $value, $fail) { + function ($attribute, $value, $fail): void { if ($this->room->members()->find($value) or $this->room->owner->id == $value) { $fail(__('validation.custom.room.already_member')); } diff --git a/app/Http/Requests/BulkDestroyRequest.php b/app/Http/Requests/BulkDestroyRequest.php index c5d36f3db..75a18e69f 100644 --- a/app/Http/Requests/BulkDestroyRequest.php +++ b/app/Http/Requests/BulkDestroyRequest.php @@ -12,7 +12,7 @@ public function rules() return [ 'users' => ['required', 'array'], 'users.*' => ['bail', 'required', 'integer', 'distinct', 'exists:App\Models\User,id', - function ($attribute, $value, $fail) { + function ($attribute, $value, $fail): void { $user = User::find($value); if (! $this->room->members()->find($value) or $this->room->owner->is($user)) { $fail(__('validation.custom.room.not_member', ['firstname' => $user->firstname, 'lastname' => $user->lastname])); diff --git a/app/Http/Requests/BulkImportRequest.php b/app/Http/Requests/BulkImportRequest.php index 610bbfaf8..5d5097b56 100644 --- a/app/Http/Requests/BulkImportRequest.php +++ b/app/Http/Requests/BulkImportRequest.php @@ -14,7 +14,7 @@ public function rules() return [ 'role' => ['required', Rule::in([RoomUserRole::USER, RoomUserRole::MODERATOR, RoomUserRole::CO_OWNER])], 'user_emails' => ['required', 'array', - function ($attribute, $value, $fail) { + function ($attribute, $value, $fail): void { $max = 1000; if (count($value) > $max) { $this->getValidatorInstance()->stopOnFirstFailure(); @@ -22,7 +22,7 @@ function ($attribute, $value, $fail) { } }, ], 'user_emails.*' => ['bail', 'required', 'email', 'distinct:ignore_case', - function ($attribute, $value, $fail) { + function ($attribute, $value, $fail): void { $users = User::whereLike('email', $value); if ($users->count() == 0) { $fail(__('validation.custom.room.user_not_found_email')); diff --git a/app/Http/Requests/BulkUpdateRequest.php b/app/Http/Requests/BulkUpdateRequest.php index cc27ab662..30ffb8353 100644 --- a/app/Http/Requests/BulkUpdateRequest.php +++ b/app/Http/Requests/BulkUpdateRequest.php @@ -15,7 +15,7 @@ public function rules() 'role' => ['required', Rule::in([RoomUserRole::USER, RoomUserRole::MODERATOR, RoomUserRole::CO_OWNER])], 'users' => ['required', 'array'], 'users.*' => ['required', 'integer', 'distinct', 'exists:App\Models\User,id', - function ($attribute, $value, $fail) { + function ($attribute, $value, $fail): void { $user = User::find($value); if (! $this->room->members()->find($value) or $this->room->owner->is($user)) { $fail(__('validation.custom.room.not_member', ['firstname' => $user->firstname, 'lastname' => $user->lastname])); diff --git a/app/Http/Requests/ChangeEmailRequest.php b/app/Http/Requests/ChangeEmailRequest.php index 605a56330..61bfba154 100644 --- a/app/Http/Requests/ChangeEmailRequest.php +++ b/app/Http/Requests/ChangeEmailRequest.php @@ -16,9 +16,7 @@ class ChangeEmailRequest extends FormRequest public function rules() { return [ - 'email' => ['required', 'string', 'email', 'max:255', Rule::unique('users', 'email')->where(function ($query) { - return $query->where('authenticator', '=', 'local')->where('id', '!=', $this->user->id); - })], + 'email' => ['required', 'string', 'email', 'max:255', Rule::unique('users', 'email')->where(fn ($query) => $query->where('authenticator', '=', 'local')->where('id', '!=', $this->user->id))], 'current_password' => $this->user->is(Auth::user()) ? ['required', 'current_password'] : [], ]; } diff --git a/app/Http/Requests/JoinMeeting.php b/app/Http/Requests/JoinMeeting.php index 703316f16..c03a1ce72 100644 --- a/app/Http/Requests/JoinMeeting.php +++ b/app/Http/Requests/JoinMeeting.php @@ -8,12 +8,9 @@ class JoinMeeting extends FormRequest { - protected RoomAuthService $roomAuthService; - - public function __construct(RoomAuthService $roomAuthService) + public function __construct(protected RoomAuthService $roomAuthService) { parent::__construct(); - $this->roomAuthService = $roomAuthService; } public function rules(): array diff --git a/app/Http/Requests/RoomTypeRequest.php b/app/Http/Requests/RoomTypeRequest.php index 023a9299c..355efbc93 100644 --- a/app/Http/Requests/RoomTypeRequest.php +++ b/app/Http/Requests/RoomTypeRequest.php @@ -45,6 +45,7 @@ public function rules() * * @return array */ + #[\Override] public function attributes(): array { $locales = [ diff --git a/app/Http/Requests/StartMeeting.php b/app/Http/Requests/StartMeeting.php index 3323fb949..75979d481 100644 --- a/app/Http/Requests/StartMeeting.php +++ b/app/Http/Requests/StartMeeting.php @@ -8,12 +8,9 @@ class StartMeeting extends FormRequest { - protected RoomAuthService $roomAuthService; - - public function __construct(RoomAuthService $roomAuthService) + public function __construct(protected RoomAuthService $roomAuthService) { parent::__construct(); - $this->roomAuthService = $roomAuthService; } public function rules(): array diff --git a/app/Http/Requests/TransferOwnershipRequest.php b/app/Http/Requests/TransferOwnershipRequest.php index 2b90960cb..76cf99e84 100644 --- a/app/Http/Requests/TransferOwnershipRequest.php +++ b/app/Http/Requests/TransferOwnershipRequest.php @@ -14,7 +14,7 @@ public function rules() { return [ 'user' => ['bail', 'required', 'integer', 'exists:App\Models\User,id', - function ($attribute, $value, $fail) { + function ($attribute, $value, $fail): void { $user = User::find($value); // make sure that the given user is not the current owner of the room if ($this->room->owner->is($user)) { diff --git a/app/Http/Requests/UpdateRoomStreamingConfig.php b/app/Http/Requests/UpdateRoomStreamingConfig.php index f75eba99c..1e1fb4b5f 100644 --- a/app/Http/Requests/UpdateRoomStreamingConfig.php +++ b/app/Http/Requests/UpdateRoomStreamingConfig.php @@ -20,6 +20,7 @@ public function rules() ]; } + #[\Override] public function attributes() { return [ @@ -28,6 +29,7 @@ public function attributes() ]; } + #[\Override] public function messages() { return [ diff --git a/app/Http/Resources/Attendee.php b/app/Http/Resources/Attendee.php index 8d5653e96..a84c683dd 100644 --- a/app/Http/Resources/Attendee.php +++ b/app/Http/Resources/Attendee.php @@ -10,6 +10,7 @@ class Attendee extends JsonResource * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Http/Resources/AttendeeSession.php b/app/Http/Resources/AttendeeSession.php index 64b557604..ad8da0ff5 100644 --- a/app/Http/Resources/AttendeeSession.php +++ b/app/Http/Resources/AttendeeSession.php @@ -10,6 +10,7 @@ class AttendeeSession extends JsonResource * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Http/Resources/Config.php b/app/Http/Resources/Config.php index 7cd2e6c7e..57be3fde3 100644 --- a/app/Http/Resources/Config.php +++ b/app/Http/Resources/Config.php @@ -21,6 +21,7 @@ public function __construct() * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { $generalSettings = app(GeneralSettings::class); @@ -41,9 +42,7 @@ public function toArray($request) 'privacy_policy_url' => $generalSettings->privacy_policy_url, 'no_welcome_page' => $generalSettings->no_welcome_page, 'default_locale' => config('app.locale'), - 'enabled_locales' => array_map(function ($locale) { - return $locale['name']; - }, config('app.enabled_locales')), + 'enabled_locales' => array_map(fn ($locale) => $locale['name'], config('app.enabled_locales')), 'version' => config('app.version'), 'whitelabel' => config('app.whitelabel'), 'base_url' => config('app.url'), diff --git a/app/Http/Resources/LastMeeting.php b/app/Http/Resources/LastMeeting.php index b9fa8f8bc..341e28b02 100644 --- a/app/Http/Resources/LastMeeting.php +++ b/app/Http/Resources/LastMeeting.php @@ -12,6 +12,7 @@ class LastMeeting extends JsonResource * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Http/Resources/Meeting.php b/app/Http/Resources/Meeting.php index a2d5631a0..39c41ad8a 100644 --- a/app/Http/Resources/Meeting.php +++ b/app/Http/Resources/Meeting.php @@ -13,6 +13,7 @@ class Meeting extends JsonResource * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Http/Resources/MeetingStat.php b/app/Http/Resources/MeetingStat.php index 2bbe3997d..17f300482 100644 --- a/app/Http/Resources/MeetingStat.php +++ b/app/Http/Resources/MeetingStat.php @@ -12,6 +12,7 @@ class MeetingStat extends JsonResource * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Http/Resources/MeetingWithRoomAndServer.php b/app/Http/Resources/MeetingWithRoomAndServer.php index 4998628f2..6976a2a03 100644 --- a/app/Http/Resources/MeetingWithRoomAndServer.php +++ b/app/Http/Resources/MeetingWithRoomAndServer.php @@ -12,6 +12,7 @@ class MeetingWithRoomAndServer extends JsonResource * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Http/Resources/Permission.php b/app/Http/Resources/Permission.php index 10e7a4e60..4cccfe9af 100644 --- a/app/Http/Resources/Permission.php +++ b/app/Http/Resources/Permission.php @@ -29,14 +29,13 @@ public function withIncludedPermissions() * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ 'id' => $this->id, 'name' => $this->name, - 'included_permissions' => $this->when($this->withIncludedPermissions, function () { - return $this->includedPermissions->pluck('id'); - }), + 'included_permissions' => $this->when($this->withIncludedPermissions, fn () => $this->includedPermissions->pluck('id')), ]; } } diff --git a/app/Http/Resources/PermissionResourceCollection.php b/app/Http/Resources/PermissionResourceCollection.php index 95cf4ae72..ef0fafbd1 100644 --- a/app/Http/Resources/PermissionResourceCollection.php +++ b/app/Http/Resources/PermissionResourceCollection.php @@ -11,12 +11,11 @@ class PermissionResourceCollection extends ResourceCollection * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ - 'data' => $this->collection->map(function (\App\Models\Permission $resource) { - return (new Permission($resource))->withIncludedPermissions(); - })->all(), + 'data' => $this->collection->map(fn (\App\Models\Permission $resource) => new Permission($resource)->withIncludedPermissions())->all(), ]; } } diff --git a/app/Http/Resources/PrivateRoomFile.php b/app/Http/Resources/PrivateRoomFile.php index beb97092e..89fd2368a 100644 --- a/app/Http/Resources/PrivateRoomFile.php +++ b/app/Http/Resources/PrivateRoomFile.php @@ -12,6 +12,7 @@ class PrivateRoomFile extends JsonResource * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Http/Resources/RecordingFormatResource.php b/app/Http/Resources/RecordingFormatResource.php index 95af97cf9..aeed33622 100644 --- a/app/Http/Resources/RecordingFormatResource.php +++ b/app/Http/Resources/RecordingFormatResource.php @@ -11,6 +11,7 @@ class RecordingFormatResource extends JsonResource * @param Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Http/Resources/RecordingResource.php b/app/Http/Resources/RecordingResource.php index 34f504e28..9ff051ed4 100644 --- a/app/Http/Resources/RecordingResource.php +++ b/app/Http/Resources/RecordingResource.php @@ -11,6 +11,7 @@ class RecordingResource extends JsonResource * @param Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Http/Resources/Role.php b/app/Http/Resources/Role.php index 7eb12ee0f..a2ed80972 100644 --- a/app/Http/Resources/Role.php +++ b/app/Http/Resources/Role.php @@ -29,6 +29,7 @@ public function withPermissions() * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ @@ -36,14 +37,10 @@ public function toArray($request) 'name' => $this->name, 'superuser' => $this->superuser, 'updated_at' => $this->updated_at, - 'permissions' => $this->when($this->withPermissions, function () { - return Permission::collection($this->permissions); - }), + 'permissions' => $this->when($this->withPermissions, fn () => Permission::collection($this->permissions)), 'model_name' => $this->model_name, 'room_limit' => $this->room_limit, - 'automatic' => $this->whenPivotLoaded('role_user', function () { - return $this->pivot->automatic; - }), + 'automatic' => $this->whenPivotLoaded('role_user', fn () => $this->pivot->automatic), ]; } } diff --git a/app/Http/Resources/RoleCollection.php b/app/Http/Resources/RoleCollection.php index 722a964f6..eb09e065a 100644 --- a/app/Http/Resources/RoleCollection.php +++ b/app/Http/Resources/RoleCollection.php @@ -13,17 +13,14 @@ class RoleCollection extends ResourceCollection * @param Request $request * @return array */ + #[\Override] public function toArray($request) { - return $this->collection->map(function (Role $role) { - return [ - 'id' => $role->id, - 'name' => $role->name, - 'automatic' => $role->whenPivotLoaded('role_user', function () use ($role) { - return $role->pivot->automatic; - }), - 'superuser' => $role->superuser, - ]; - })->toArray(); + return $this->collection->map(fn (Role $role) => [ + 'id' => $role->id, + 'name' => $role->name, + 'automatic' => $role->whenPivotLoaded('role_user', fn () => $role->pivot->automatic), + 'superuser' => $role->superuser, + ])->toArray(); } } diff --git a/app/Http/Resources/Room.php b/app/Http/Resources/Room.php index cd4604aaa..bd1dce286 100644 --- a/app/Http/Resources/Room.php +++ b/app/Http/Resources/Room.php @@ -12,7 +12,7 @@ class Room extends JsonResource { // Is user authenticated (has valid access code, member or owner) - private bool $authenticated; + private readonly bool $authenticated; // Show details of the room (otherwise only basic information for listing is shown) private bool $withDetails = false; @@ -30,7 +30,7 @@ public function withDetails() } // The token used to authenticate the user - private ?RoomToken $token; + private readonly ?RoomToken $token; /** * Create a new resource instance. @@ -63,7 +63,7 @@ public function getDetails($latestMeeting) 'can_start' => Gate::inspect('start', [$this->resource, $this->token])->allowed(), 'access_code' => $this->when(Gate::inspect('viewAccessCode', [$this->resource])->allowed(), $this->access_code), 'room_type_invalid' => $this->roomTypeInvalid, - 'current_user' => (new UserResource(\Illuminate\Support\Facades\Auth::user()))->withPermissions()->withoutRoles(), + 'current_user' => new UserResource(\Illuminate\Support\Facades\Auth::user())->withPermissions()->withoutRoles(), ]; } @@ -73,6 +73,7 @@ public function getDetails($latestMeeting) * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { $latestMeeting = $this->resource->latestMeeting; diff --git a/app/Http/Resources/RoomFile.php b/app/Http/Resources/RoomFile.php index 0fd52a365..f750a171e 100644 --- a/app/Http/Resources/RoomFile.php +++ b/app/Http/Resources/RoomFile.php @@ -12,6 +12,7 @@ class RoomFile extends JsonResource * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Http/Resources/RoomSettings.php b/app/Http/Resources/RoomSettings.php index 4429d6df6..50c600a5e 100644 --- a/app/Http/Resources/RoomSettings.php +++ b/app/Http/Resources/RoomSettings.php @@ -23,6 +23,7 @@ public function getRoomSettings() * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ @@ -31,7 +32,7 @@ public function toArray($request) 'welcome' => $this->expert_mode ? $this->welcome : '', 'short_description' => $this->short_description, 'access_code' => $this->access_code, - 'room_type' => (new RoomType($this->roomType))->withDefaultRoomSettings()->withFeatures(), + 'room_type' => new RoomType($this->roomType)->withDefaultRoomSettings()->withFeatures(), $this->merge($this->getRoomSettings()), ]; } diff --git a/app/Http/Resources/RoomStreaming.php b/app/Http/Resources/RoomStreaming.php index 0478e5b12..48b25229d 100644 --- a/app/Http/Resources/RoomStreaming.php +++ b/app/Http/Resources/RoomStreaming.php @@ -12,6 +12,7 @@ class RoomStreaming extends JsonResource * * @return array */ + #[\Override] public function toArray(Request $request): array { return [ diff --git a/app/Http/Resources/RoomStreamingConfig.php b/app/Http/Resources/RoomStreamingConfig.php index 29a4755c8..60b72f469 100644 --- a/app/Http/Resources/RoomStreamingConfig.php +++ b/app/Http/Resources/RoomStreamingConfig.php @@ -12,6 +12,7 @@ class RoomStreamingConfig extends JsonResource * * @return array */ + #[\Override] public function toArray(Request $request): array { return [ diff --git a/app/Http/Resources/RoomToken.php b/app/Http/Resources/RoomToken.php index 7499693c9..395ef8f52 100644 --- a/app/Http/Resources/RoomToken.php +++ b/app/Http/Resources/RoomToken.php @@ -12,6 +12,7 @@ class RoomToken extends JsonResource * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Http/Resources/RoomType.php b/app/Http/Resources/RoomType.php index fc5cb43fc..e51f920a4 100644 --- a/app/Http/Resources/RoomType.php +++ b/app/Http/Resources/RoomType.php @@ -82,6 +82,7 @@ public function getDefaultRoomSettings() * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Http/Resources/RoomTypeResourceCollection.php b/app/Http/Resources/RoomTypeResourceCollection.php index 530740dd8..6cde3ef22 100644 --- a/app/Http/Resources/RoomTypeResourceCollection.php +++ b/app/Http/Resources/RoomTypeResourceCollection.php @@ -39,6 +39,7 @@ public function withFeatures(): self * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Http/Resources/RoomTypeStreamingSettings.php b/app/Http/Resources/RoomTypeStreamingSettings.php index 6ed8dc0a6..efca49f81 100644 --- a/app/Http/Resources/RoomTypeStreamingSettings.php +++ b/app/Http/Resources/RoomTypeStreamingSettings.php @@ -12,6 +12,7 @@ class RoomTypeStreamingSettings extends JsonResource * * @return array */ + #[\Override] public function toArray(Request $request): array { return [ diff --git a/app/Http/Resources/RoomUser.php b/app/Http/Resources/RoomUser.php index 06ffc6f6c..ab9e487e4 100644 --- a/app/Http/Resources/RoomUser.php +++ b/app/Http/Resources/RoomUser.php @@ -12,6 +12,7 @@ class RoomUser extends JsonResource * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Http/Resources/Server.php b/app/Http/Resources/Server.php index ed19c9b80..060bda828 100644 --- a/app/Http/Resources/Server.php +++ b/app/Http/Resources/Server.php @@ -29,6 +29,7 @@ public function withApi() * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Http/Resources/ServerPool.php b/app/Http/Resources/ServerPool.php index 54f94d11d..bc05ea0aa 100644 --- a/app/Http/Resources/ServerPool.php +++ b/app/Http/Resources/ServerPool.php @@ -29,6 +29,7 @@ public function withServers(): self * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { return [ @@ -36,9 +37,7 @@ public function toArray($request) 'name' => $this->name, 'description' => $this->description, 'servers_count' => $this->servers()->count(), - 'servers' => $this->when($this->withServers, function () { - return Server::collection($this->servers); - }), + 'servers' => $this->when($this->withServers, fn () => Server::collection($this->servers)), 'model_name' => $this->model_name, 'updated_at' => $this->updated_at, ]; diff --git a/app/Http/Resources/SessionResource.php b/app/Http/Resources/SessionResource.php index c7618231c..f007343ba 100644 --- a/app/Http/Resources/SessionResource.php +++ b/app/Http/Resources/SessionResource.php @@ -12,6 +12,7 @@ class SessionResource extends JsonResource * @param Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Http/Resources/Settings.php b/app/Http/Resources/Settings.php index 7188c7e4d..73eee1cc4 100644 --- a/app/Http/Resources/Settings.php +++ b/app/Http/Resources/Settings.php @@ -22,6 +22,7 @@ public function __construct() * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { $generalSettings = app(GeneralSettings::class); diff --git a/app/Http/Resources/StreamingSettings.php b/app/Http/Resources/StreamingSettings.php index ea76221af..16505e932 100644 --- a/app/Http/Resources/StreamingSettings.php +++ b/app/Http/Resources/StreamingSettings.php @@ -16,6 +16,7 @@ public function __construct() * @param \Illuminate\Http\Request $request * @return array */ + #[\Override] public function toArray($request) { $settings = app(\App\Settings\StreamingSettings::class); diff --git a/app/Http/Resources/User.php b/app/Http/Resources/User.php index 6e8f52900..938d7d627 100644 --- a/app/Http/Resources/User.php +++ b/app/Http/Resources/User.php @@ -57,6 +57,7 @@ public function withoutRoles() * @param Request $request * @return array */ + #[\Override] public function toArray($request) { if (is_null($this->resource)) { @@ -72,15 +73,11 @@ public function toArray($request) 'firstname' => $this->firstname, 'lastname' => $this->lastname, 'user_locale' => $this->locale, - 'permissions' => $this->when($this->withPermissions, function () { - return $this->permissions; - }), + 'permissions' => $this->when($this->withPermissions, fn () => $this->permissions), 'model_name' => $this->model_name, 'room_limit' => $this->room_limit, 'updated_at' => $this->updated_at, - 'roles' => $this->when(! $this->withoutRoles, function () { - return new RoleCollection($this->roles); - }), + 'roles' => $this->when(! $this->withoutRoles, fn () => new RoleCollection($this->roles)), 'bbb_skip_check_audio' => $this->bbb_skip_check_audio, 'initial_password_set' => $this->initial_password_set, 'timezone' => $this->timezone, diff --git a/app/Http/Resources/UserSearch.php b/app/Http/Resources/UserSearch.php index 5b070bb3b..a6a71bbf2 100644 --- a/app/Http/Resources/UserSearch.php +++ b/app/Http/Resources/UserSearch.php @@ -23,6 +23,7 @@ public function __construct($resource) * @param Request $request * @return array */ + #[\Override] public function toArray($request) { return [ diff --git a/app/Jobs/PollServerJob.php b/app/Jobs/PollServerJob.php index fd71ca5ba..0934ffbf6 100644 --- a/app/Jobs/PollServerJob.php +++ b/app/Jobs/PollServerJob.php @@ -15,15 +15,10 @@ class PollServerJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - protected Server $server; - /** * Create a new job instance. */ - public function __construct(Server $server) - { - $this->server = $server; - } + public function __construct(protected Server $server) {} /** * Execute the job. diff --git a/app/Jobs/ProcessRecording.php b/app/Jobs/ProcessRecording.php index da39a6efd..f0d1cfff2 100644 --- a/app/Jobs/ProcessRecording.php +++ b/app/Jobs/ProcessRecording.php @@ -27,17 +27,14 @@ class ProcessRecording implements ShouldBeUnique, ShouldQueue */ public $timeout = 120; - protected string $file; - protected string $tempPath; /** * Create a new job instance. */ - public function __construct(string $file) + public function __construct(protected string $file) { $this->onQueue('recordings'); - $this->file = $file; $filename = pathinfo($this->file, PATHINFO_FILENAME); $this->tempPath = 'temp/'.$filename; } @@ -122,9 +119,7 @@ public function handle(): void $phar->extractTo(Storage::disk('recordings')->path($this->tempPath), null, true); // Find metadata.xml files - $metadataFiles = array_filter(Storage::disk('recordings')->allFiles($this->tempPath), function ($file) { - return str_ends_with($file, 'metadata.xml'); - }); + $metadataFiles = array_filter(Storage::disk('recordings')->allFiles($this->tempPath), fn ($file) => str_ends_with((string) $file, 'metadata.xml')); foreach ($metadataFiles as $metadataFile) { // Each directory with a metadata file inside is a recording format @@ -132,12 +127,12 @@ public function handle(): void // and other files are the actual recording in the recording format $xmlContent = Storage::disk('recordings')->get($metadataFile); - $xml = simplexml_load_string($xmlContent); + $xml = simplexml_load_string((string) $xmlContent); // Create or update the recording format in the database $recordingFormat = RecordingFormat::createFromRecordingXML($xml); - $formatDirectory = dirname($metadataFile); + $formatDirectory = dirname((string) $metadataFile); // Recording format was created or updated (found the corresponding room) if ($recordingFormat != null) { diff --git a/app/Models/IncludedPermissionPermission.php b/app/Models/IncludedPermissionPermission.php index 38d2941a0..624c55f91 100644 --- a/app/Models/IncludedPermissionPermission.php +++ b/app/Models/IncludedPermissionPermission.php @@ -6,13 +6,14 @@ class IncludedPermissionPermission extends Pivot { + #[\Override] protected static function booted(): void { - static::created(function () { + static::created(function (): void { User::$clearPermissionCache = true; }); - static::deleted(function () { + static::deleted(function (): void { User::$clearPermissionCache = true; }); } diff --git a/app/Models/Meeting.php b/app/Models/Meeting.php index 6e4a46890..7ebe4c0fc 100644 --- a/app/Models/Meeting.php +++ b/app/Models/Meeting.php @@ -32,14 +32,6 @@ class Meeting extends Model */ protected $guarded = []; - protected $casts = [ - 'start' => 'datetime', - 'end' => 'datetime', - 'record_attendance' => 'boolean', - 'record' => 'boolean', - 'detached' => 'datetime', - ]; - /** * Generate a new UUID for the model. */ @@ -92,4 +84,15 @@ public function getLogLabel() { return $this->id; } + + protected function casts(): array + { + return [ + 'start' => 'datetime', + 'end' => 'datetime', + 'record_attendance' => 'boolean', + 'record' => 'boolean', + 'detached' => 'datetime', + ]; + } } diff --git a/app/Models/MeetingAttendee.php b/app/Models/MeetingAttendee.php index 233b5fa4a..3f689441d 100644 --- a/app/Models/MeetingAttendee.php +++ b/app/Models/MeetingAttendee.php @@ -13,11 +13,6 @@ class MeetingAttendee extends Model */ protected $guarded = []; - protected $casts = [ - 'join' => 'datetime', - 'leave' => 'datetime', - ]; - public $timestamps = false; /** @@ -39,4 +34,12 @@ public function user() { return $this->belongsTo(User::class); } + + protected function casts(): array + { + return [ + 'join' => 'datetime', + 'leave' => 'datetime', + ]; + } } diff --git a/app/Models/MeetingStat.php b/app/Models/MeetingStat.php index e152d8236..dcede6439 100644 --- a/app/Models/MeetingStat.php +++ b/app/Models/MeetingStat.php @@ -13,13 +13,6 @@ class MeetingStat extends Model */ protected $guarded = []; - protected $casts = [ - 'participant_count' => 'integer', - 'listener_count' => 'integer', - 'voice_participant_count' => 'integer', - 'video_count' => 'integer', - ]; - /** * Meeting the statistical data belongs to * @@ -29,4 +22,14 @@ public function meeting() { return $this->belongsTo(Meeting::class); } + + protected function casts(): array + { + return [ + 'participant_count' => 'integer', + 'listener_count' => 'integer', + 'voice_participant_count' => 'integer', + 'video_count' => 'integer', + ]; + } } diff --git a/app/Models/PermissionRole.php b/app/Models/PermissionRole.php index 150b46ee1..01a6dd69a 100644 --- a/app/Models/PermissionRole.php +++ b/app/Models/PermissionRole.php @@ -6,13 +6,14 @@ class PermissionRole extends Pivot { + #[\Override] protected static function booted(): void { - static::created(function () { + static::created(function (): void { User::$clearPermissionCache = true; }); - static::deleted(function () { + static::deleted(function (): void { User::$clearPermissionCache = true; }); } diff --git a/app/Models/Recording.php b/app/Models/Recording.php index f3b7491b4..ac1c7cb73 100644 --- a/app/Models/Recording.php +++ b/app/Models/Recording.php @@ -25,12 +25,6 @@ class Recording extends Model */ public $incrementing = false; - protected $casts = [ - 'start' => 'datetime', - 'end' => 'datetime', - 'access' => RecordingAccess::class, - ]; - public function getLogLabel() { return $this->description.' ['.$this->start->format('Y-m-d H:i').' - '.$this->end->format('Y-m-d H:i').'] ('.$this->id.')'; @@ -73,6 +67,7 @@ public function formats() * * @throws \Exception */ + #[\Override] public function delete() { $response = parent::delete(); @@ -83,4 +78,13 @@ public function delete() return $response; } + + protected function casts(): array + { + return [ + 'start' => 'datetime', + 'end' => 'datetime', + 'access' => RecordingAccess::class, + ]; + } } diff --git a/app/Models/RecordingFormat.php b/app/Models/RecordingFormat.php index 012b23e25..3e4b18ed3 100644 --- a/app/Models/RecordingFormat.php +++ b/app/Models/RecordingFormat.php @@ -14,10 +14,6 @@ class RecordingFormat extends Model 'url', 'format', ]; - protected $casts = [ - 'disabled' => 'boolean', - ]; - /** * Create a recording format and recording (if it doesn't exist yet) in the database from the metadata of a recording format provided by BigBlueButton. * @@ -96,4 +92,11 @@ public function recording() { return $this->belongsTo(Recording::class); } + + protected function casts(): array + { + return [ + 'disabled' => 'boolean', + ]; + } } diff --git a/app/Models/Role.php b/app/Models/Role.php index 69c6a62d3..f04aad246 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Traits\AddsModelNameTrait; +use Illuminate\Database\Eloquent\Attributes\Scope; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -23,10 +24,6 @@ class Role extends Model */ protected $fillable = ['name']; - protected $casts = [ - 'superuser' => 'boolean', - ]; - /** * Users that have the role. * @@ -75,7 +72,7 @@ public function filterRestrictedPermissions(Collection $permissionIDs): Collecti // Split the restriction and permission names into groups and permissions $restrictionGroup = explode('.', $restriction, 2)[0]; $restrictionPermission = explode('.', $restriction, 2)[1] ?? null; - $permissionGroup = explode('.', $permission->name, 2)[0]; + $permissionGroup = explode('.', (string) $permission->name, 2)[0]; // If the restriction applies to all permissions in the group, it is restricted return $restrictionPermission === '*' && $restrictionGroup === $permissionGroup; @@ -98,15 +95,22 @@ public function roomTypes() * * @param Builder $query Query that should be scoped * @param string $name Name to search for - * @return Builder The scoped query */ - public function scopeWithName(Builder $query, $name) + #[Scope] + protected function withName(Builder $query, $name) { - return $query->whereLike('name', '%'.$name.'%'); + $query->whereLike('name', '%'.$name.'%'); } public function getLogLabel() { return $this->name.' ('.$this->id.')'; } + + protected function casts(): array + { + return [ + 'superuser' => 'boolean', + ]; + } } diff --git a/app/Models/RoleUser.php b/app/Models/RoleUser.php index 4f7fa9d49..e338f47a0 100644 --- a/app/Models/RoleUser.php +++ b/app/Models/RoleUser.php @@ -6,16 +6,20 @@ class RoleUser extends Pivot { - protected $casts = ['automatic' => 'boolean']; - + #[\Override] protected static function booted(): void { - static::created(function () { + static::created(function (): void { User::$clearPermissionCache = true; }); - static::deleted(function () { + static::deleted(function (): void { User::$clearPermissionCache = true; }); } + + protected function casts(): array + { + return ['automatic' => 'boolean']; + } } diff --git a/app/Models/Room.php b/app/Models/Room.php index 181d29ab7..f56460efb 100644 --- a/app/Models/Room.php +++ b/app/Models/Room.php @@ -9,6 +9,7 @@ use App\Services\RoomAuthService; use App\Settings\GeneralSettings; use App\Traits\AddsModelNameTrait; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasOne; @@ -29,9 +30,10 @@ class Room extends Model * * @return void */ + #[\Override] protected static function booted() { - static::creating(function ($model) { + static::creating(function ($model): void { // if the meeting has no ID yet, create a unique id // 36^9 possible room ids ≈ 10^14 @@ -53,7 +55,7 @@ protected static function booted() } }); - static::deleting(function ($model) { + static::deleting(function ($model): void { $model->files->each->delete(); $model->recordings->each->delete(); \Storage::deleteDirectory($model->id); @@ -394,9 +396,9 @@ public function getModeratorOnlyMessage() * Indicates whether the type of the room is restricted for * specific roles and the room owner doesn't has this role. */ - public function getRoomTypeInvalidAttribute(): bool + protected function roomTypeInvalid(): Attribute { - return ! self::roomTypePermitted($this->owner, $this->roomType); + return Attribute::make(get: fn () => ! self::roomTypePermitted($this->owner, $this->roomType)); } /** diff --git a/app/Models/RoomFile.php b/app/Models/RoomFile.php index 7e5320b23..9ba1c2985 100644 --- a/app/Models/RoomFile.php +++ b/app/Models/RoomFile.php @@ -10,12 +10,6 @@ class RoomFile extends Model { use HasFactory; - protected $casts = [ - 'default' => 'boolean', - 'download' => 'boolean', - 'use_in_meeting' => 'boolean', - ]; - /** * Room file belongs to * @@ -38,6 +32,7 @@ public function getLogLabel() * * @throws \Exception */ + #[\Override] public function delete() { $response = parent::delete(); @@ -48,4 +43,13 @@ public function delete() return $response; } + + protected function casts(): array + { + return [ + 'default' => 'boolean', + 'download' => 'boolean', + 'use_in_meeting' => 'boolean', + ]; + } } diff --git a/app/Models/RoomStreaming.php b/app/Models/RoomStreaming.php index 091108703..980e63958 100644 --- a/app/Models/RoomStreaming.php +++ b/app/Models/RoomStreaming.php @@ -2,6 +2,7 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -23,11 +24,6 @@ class RoomStreaming extends Model 'pause_image', ]; - protected $casts = [ - 'enabled' => 'boolean', - 'enabled_for_current_meeting' => 'boolean', - ]; - protected $with = ['room']; public function room(): BelongsTo @@ -35,9 +31,16 @@ public function room(): BelongsTo return $this->belongsTo(Room::class, 'room_id', 'id'); } - // Override enabled attribute value to respect global streaming setting - public function getEnabledAttribute($value): bool + protected function enabled(): Attribute + { + return Attribute::make(get: fn ($value) => config('streaming.enabled') && $this->room->roomType->streamingSettings->enabled && $value); + } + + protected function casts(): array { - return config('streaming.enabled') && $this->room->roomType->streamingSettings->enabled && $value; + return [ + 'enabled' => 'boolean', + 'enabled_for_current_meeting' => 'boolean', + ]; } } diff --git a/app/Models/RoomToken.php b/app/Models/RoomToken.php index d868d997d..62ae9b8fd 100644 --- a/app/Models/RoomToken.php +++ b/app/Models/RoomToken.php @@ -5,6 +5,7 @@ use App\Enums\RoomUserRole; use App\Enums\TimePeriod; use App\Settings\RoomSettings; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -15,11 +16,6 @@ class RoomToken extends Model { use HasFactory; - protected $casts = [ - 'last_usage' => 'datetime', - 'role' => RoomUserRole::class, - ]; - /** * @var string Override primary key with correct value. */ @@ -40,9 +36,10 @@ class RoomToken extends Model * * @return void */ + #[\Override] protected static function booted() { - static::creating(function ($model) { + static::creating(function ($model): void { while (true) { $token = Str::random(100); if (DB::table('room_tokens')->where('token', '=', $token)->doesntExist()) { @@ -67,6 +64,7 @@ public function room() /** * @return string Name of the key to search for route binding. */ + #[\Override] public function getRouteKeyName() { return 'token'; @@ -77,9 +75,9 @@ public function getRouteKeyName() * * @return string */ - public function getFullnameAttribute() + protected function fullname(): Attribute { - return $this->firstname.' '.$this->lastname; + return Attribute::make(get: fn () => $this->firstname.' '.$this->lastname); } /** @@ -87,10 +85,20 @@ public function getFullnameAttribute() * * @return null */ - public function getExpiresAttribute() + protected function expires(): Attribute { - $tokenExpiration = app(RoomSettings::class)->token_expiration; + return Attribute::make(get: function () { + $tokenExpiration = app(RoomSettings::class)->token_expiration; - return $tokenExpiration != TimePeriod::UNLIMITED ? ($this->last_usage != null ? $this->last_usage->addDays($tokenExpiration->value) : $this->created_at->addDays($tokenExpiration->value)) : null; + return $tokenExpiration != TimePeriod::UNLIMITED ? ($this->last_usage != null ? $this->last_usage->addDays($tokenExpiration->value) : $this->created_at->addDays($tokenExpiration->value)) : null; + }); + } + + protected function casts(): array + { + return [ + 'last_usage' => 'datetime', + 'role' => RoomUserRole::class, + ]; } } diff --git a/app/Models/RoomTypeStreamingSettings.php b/app/Models/RoomTypeStreamingSettings.php index c1bcbf50a..91e21afe1 100644 --- a/app/Models/RoomTypeStreamingSettings.php +++ b/app/Models/RoomTypeStreamingSettings.php @@ -19,14 +19,17 @@ class RoomTypeStreamingSettings extends Model 'default_pause_image', ]; - protected $casts = [ - 'enabled' => 'boolean', - ]; - protected $with = ['roomType']; public function roomType(): BelongsTo { return $this->belongsTo(RoomType::class, 'room_type_id', 'id'); } + + protected function casts(): array + { + return [ + 'enabled' => 'boolean', + ]; + } } diff --git a/app/Models/RoomUser.php b/app/Models/RoomUser.php index 84ce3b496..1707b04e5 100644 --- a/app/Models/RoomUser.php +++ b/app/Models/RoomUser.php @@ -7,7 +7,10 @@ class RoomUser extends Pivot { - protected $casts = [ - 'role' => RoomUserRole::class, - ]; + protected function casts(): array + { + return [ + 'role' => RoomUserRole::class, + ]; + } } diff --git a/app/Models/Server.php b/app/Models/Server.php index 8b180c708..29326aa68 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -5,7 +5,9 @@ use App\Enums\ServerHealth; use App\Enums\ServerStatus; use App\Traits\AddsModelNameTrait; +use Illuminate\Database\Eloquent\Attributes\Scope; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsToMany; @@ -15,27 +17,15 @@ class Server extends Model { use AddsModelNameTrait, HasFactory; - protected $casts = [ - 'strength' => 'integer', - 'status' => ServerStatus::class, - 'participant_count' => 'integer', - 'listener_count' => 'integer', - 'voice_participant_count' => 'integer', - 'video_count' => 'integer', - 'meeting_count' => 'integer', - 'error_count' => 'integer', - 'recover_count' => 'integer', - 'load' => 'integer', - ]; - /** * The "booted" method of the model. * * @return void */ + #[\Override] protected static function booted() { - static::updating(function (self $model) { + static::updating(function (self $model): void { /** * If status is changed and new status is disabled, reset live usage data @@ -51,7 +41,7 @@ protected static function booted() } } }); - static::updated(function (self $model) { + static::updated(function (self $model): void { // Check if server is failing (error count increased or recover count decreased) if ($model->error_count > $model->getOriginal('error_count') || $model->recover_count < $model->getOriginal('recover_count')) { \Log::error('Server {server} failing', [ @@ -137,11 +127,11 @@ public function stats() * * @param Builder $query Query that should be scoped * @param string $name Name to search for - * @return Builder The scoped query */ - public function scopeWithName(Builder $query, $name) + #[Scope] + protected function withName(Builder $query, $name) { - return $query->whereLike('name', '%'.$name.'%'); + $query->whereLike('name', '%'.$name.'%'); } public function getLogLabel() @@ -149,13 +139,15 @@ public function getLogLabel() return $this->name.' ('.$this->id.')'; } - public function getHealthAttribute(): ?ServerHealth + protected function health(): Attribute { - if ($this->status == ServerStatus::DISABLED) { - return null; - } + return Attribute::make(get: function () { + if ($this->status == ServerStatus::DISABLED) { + return null; + } - return self::calcHealth($this->recover_count, $this->error_count); + return self::calcHealth($this->recover_count, $this->error_count); + })->withoutObjectCaching(); } private static function calcHealth(int $recover_count, int $error_count): ServerHealth @@ -169,4 +161,20 @@ private static function calcHealth(int $recover_count, int $error_count): Server return ServerHealth::UNHEALTHY; } + + protected function casts(): array + { + return [ + 'strength' => 'integer', + 'status' => ServerStatus::class, + 'participant_count' => 'integer', + 'listener_count' => 'integer', + 'voice_participant_count' => 'integer', + 'video_count' => 'integer', + 'meeting_count' => 'integer', + 'error_count' => 'integer', + 'recover_count' => 'integer', + 'load' => 'integer', + ]; + } } diff --git a/app/Models/ServerPool.php b/app/Models/ServerPool.php index 5949b06d1..5ca5e62ee 100644 --- a/app/Models/ServerPool.php +++ b/app/Models/ServerPool.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Traits\AddsModelNameTrait; +use Illuminate\Database\Eloquent\Attributes\Scope; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -20,6 +21,7 @@ class ServerPool extends Model * * @return void */ + #[\Override] protected static function booted() { static::deleting(function (self $model) { @@ -53,11 +55,11 @@ public function roomTypes() * * @param Builder $query Query that should be scoped * @param string $name Name to search for - * @return Builder The scoped query */ - public function scopeWithName(Builder $query, $name) + #[Scope] + protected function withName(Builder $query, $name) { - return $query->whereLike('name', '%'.$name.'%'); + $query->whereLike('name', '%'.$name.'%'); } public function getLogLabel() diff --git a/app/Models/ServerStat.php b/app/Models/ServerStat.php index 027f1bfbc..c18ecdba2 100644 --- a/app/Models/ServerStat.php +++ b/app/Models/ServerStat.php @@ -6,14 +6,6 @@ class ServerStat extends Model { - protected $casts = [ - 'participant_count' => 'integer', - 'listener_count' => 'integer', - 'voice_participant_count' => 'integer', - 'video_count' => 'integer', - 'meeting_count' => 'integer', - ]; - /** * Server the statistical data belongs to * @@ -23,4 +15,15 @@ public function server() { return $this->belongsTo(Server::class); } + + protected function casts(): array + { + return [ + 'participant_count' => 'integer', + 'listener_count' => 'integer', + 'voice_participant_count' => 'integer', + 'video_count' => 'integer', + 'meeting_count' => 'integer', + ]; + } } diff --git a/app/Models/Session.php b/app/Models/Session.php index 373e705e0..9c0a9e67b 100644 --- a/app/Models/Session.php +++ b/app/Models/Session.php @@ -12,10 +12,6 @@ class Session extends Model public $timestamps = false; - protected $casts = [ - 'last_activity' => 'datetime', - ]; - protected $dateFormat = 'U'; /** @@ -32,4 +28,11 @@ public function sessionData() { return $this->hasMany(SessionData::class); } + + protected function casts(): array + { + return [ + 'last_activity' => 'datetime', + ]; + } } diff --git a/app/Models/User.php b/app/Models/User.php index 7fe6ecb1f..de82905c9 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -7,7 +7,9 @@ use App\Traits\AddsModelNameTrait; use Carbon\Carbon; use Illuminate\Contracts\Translation\HasLocalePreference; +use Illuminate\Database\Eloquent\Attributes\Scope; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Foundation\Auth\User as Authenticatable; @@ -26,9 +28,10 @@ class User extends Authenticatable implements HasLocalePreference * * @return void */ + #[\Override] protected static function booted() { - static::deleting(function ($model) { + static::deleting(function ($model): void { $model->myRooms->each->delete(); }); } @@ -52,17 +55,6 @@ protected static function booted() 'password', 'remember_token', ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ - protected $casts = [ - 'email_verified_at' => 'datetime', - 'bbb_skip_check_audio' => 'boolean', - 'initial_password_set' => 'boolean', - ]; - protected $appends = ['fullname']; // Cached list of all permissions of the user @@ -72,9 +64,9 @@ protected static function booted() // Is set to true on any change by the pivot models that control the permissions of the user (RoleUser, PermissionRole, IncludedPermissionPermission) public static $clearPermissionCache = false; - public function getFullnameAttribute() + protected function fullname(): Attribute { - return $this->firstname.' '.$this->lastname; + return Attribute::make(get: fn () => $this->firstname.' '.$this->lastname); } public function getLogLabel() @@ -87,9 +79,9 @@ public function getLogLabel() * * @return string|null */ - public function getImageUrlAttribute() + protected function imageUrl(): Attribute { - return $this->image != null ? Storage::disk('public')->url($this->image) : null; + return Attribute::make(get: fn () => $this->image != null ? Storage::disk('public')->url($this->image) : null); } /** @@ -128,22 +120,20 @@ public function roomFavorites() * * @return int limit of rooms of this user: -1: unlimited, 0: zero rooms, 1: one room, 2: two rooms ... */ - public function getRoomLimitAttribute() + protected function roomLimit(): Attribute { - $globalRoomLimit = app(RoomSettings::class)->limit; + return Attribute::make(get: function () { + $globalRoomLimit = app(RoomSettings::class)->limit; + $role_limits = $this->roles()->pluck('room_limit'); + $role_limits->transform(fn ($item, $key) => $item ?? $globalRoomLimit); + // check if any role has unlimited rooms, if yes set to unlimited + if ($role_limits->contains(-1)) { + return -1; + } - $role_limits = $this->roles()->pluck('room_limit'); - $role_limits->transform(function ($item, $key) use ($globalRoomLimit) { - return $item !== null ? $item : $globalRoomLimit; + // return highest room limit + return (int) $role_limits->max(); }); - - // check if any role has unlimited rooms, if yes set to unlimited - if ($role_limits->contains(-1)) { - return -1; - } - - // return highest room limit - return (int) $role_limits->max(); } /** @@ -173,11 +163,11 @@ public function sharedRooms() * * @param Builder $query Query that should be scoped * @param string $firstname Firstname to search for - * @return Builder The scoped query */ - public function scopeWithFirstName(Builder $query, $firstname) + #[Scope] + protected function withFirstName(Builder $query, $firstname) { - return $query->whereLike('firstname', '%'.$firstname.'%'); + $query->whereLike('firstname', '%'.$firstname.'%'); } /** @@ -185,11 +175,11 @@ public function scopeWithFirstName(Builder $query, $firstname) * * @param Builder $query Query that should be scoped * @param int $role Role the user has - * @return Builder The scoped query */ - public function scopeWithRole(Builder $query, $role) + #[Scope] + protected function withRole(Builder $query, $role) { - return $query->join('role_user', 'role_user.user_id', '=', 'users.id')->where('role_user.role_id', $role); + $query->join('role_user', 'role_user.user_id', '=', 'users.id')->where('role_user.role_id', $role); } /** @@ -197,11 +187,11 @@ public function scopeWithRole(Builder $query, $role) * * @param Builder $query Query that should be scoped * @param string $lastname Lastname to search for - * @return Builder The scoped query */ - public function scopeWithLastName(Builder $query, $lastname) + #[Scope] + protected function withLastName(Builder $query, $lastname) { - return $query->whereLike('lastname', '%'.$lastname.'%'); + $query->whereLike('lastname', '%'.$lastname.'%'); } /** @@ -209,11 +199,11 @@ public function scopeWithLastName(Builder $query, $lastname) * * @param Builder $query Query that should be scoped * @param string $email Email to search for - * @return Builder The scoped query */ - public function scopeWithEmail(Builder $query, $email) + #[Scope] + protected function withEmail(Builder $query, $email) { - return $query->whereLike('email', '%'.$email.'%'); + $query->whereLike('email', '%'.$email.'%'); } /** @@ -224,16 +214,16 @@ public function scopeWithEmail(Builder $query, $email) * * @param Builder $query Query that should be scoped * @param string $name Name to search for - * @return Builder The scoped query */ - public function scopeWithName(Builder $query, $name) + #[Scope] + protected function withName(Builder $query, $name) { - $name = preg_replace('/\s\s+/', ' ', $name); - $splittedName = explode(' ', $name); + $name = preg_replace('/\s\s+/', ' ', (string) $name); + $splittedName = explode(' ', (string) $name); - return $query->where(function (Builder $query) use ($splittedName) { + $query->where(function (Builder $query) use ($splittedName): void { foreach ($splittedName as $name) { - $query->where(function (Builder $query) use ($name) { + $query->where(function (Builder $query) use ($name): void { $query->withFirstName($name)->orWhere->withLastName($name)->orWhere->withEmail($name); }); } @@ -255,27 +245,28 @@ public function roles() * * @return string[] */ - public function getPermissionsAttribute() + protected function permissions(): Attribute { - $permissions = []; - - DB::table('permissions') - ->join('permission_role', 'permission_role.permission_id', '=', 'permissions.id') - ->join('role_user', 'permission_role.role_id', '=', 'role_user.role_id') - ->leftJoin('included_permissions', 'permissions.id', '=', 'included_permissions.permission_id') - ->leftJoin('permissions as permissions2', 'permissions2.id', '=', 'included_permissions.included_permission_id') - ->where('role_user.user_id', '=', $this->id) - ->get(['permissions.name', 'permissions2.name as included_permission_name']) - ->each(function ($item) use (&$permissions) { - if ($item->included_permission_name != null) { - array_push($permissions, $item->included_permission_name); - } - - array_push($permissions, $item->name); - }); - - // remove duplicates; array_keys(array_flip( is much faster than array_unique (see https://dev.to/devmount/4-php-tricks-to-boost-script-performance-ol1) - return array_keys(array_flip($permissions)); + return Attribute::make(get: function () { + $permissions = []; + DB::table('permissions') + ->join('permission_role', 'permission_role.permission_id', '=', 'permissions.id') + ->join('role_user', 'permission_role.role_id', '=', 'role_user.role_id') + ->leftJoin('included_permissions', 'permissions.id', '=', 'included_permissions.permission_id') + ->leftJoin('permissions as permissions2', 'permissions2.id', '=', 'included_permissions.included_permission_id') + ->where('role_user.user_id', '=', $this->id) + ->get(['permissions.name', 'permissions2.name as included_permission_name']) + ->each(function ($item) use (&$permissions): void { + if ($item->included_permission_name != null) { + array_push($permissions, $item->included_permission_name); + } + + array_push($permissions, $item->name); + }); + + // remove duplicates; array_keys(array_flip( is much faster than array_unique (see https://dev.to/devmount/4-php-tricks-to-boost-script-performance-ol1) + return array_keys(array_flip($permissions)); + }); } /** @@ -289,7 +280,7 @@ public function hasPermission(string $permission) // Check if the permission cache is not set or if it should be cleared if ($this->permissionsCache == null || self::$clearPermissionCache) { // Build permission cache - $this->permissionsCache = $this->getPermissionsAttribute(); + $this->permissionsCache = $this->permissions; self::$clearPermissionCache = false; } @@ -331,8 +322,20 @@ public function sendPasswordResetNotification($token) /** * @return bool */ - public function getSuperuserAttribute() + protected function superuser(): Attribute + { + return Attribute::make(get: fn () => $this->roles->where('superuser', true)->isNotEmpty()); + } + + /** + * The attributes that should be cast to native types. + */ + protected function casts(): array { - return $this->roles->where('superuser', true)->isNotEmpty(); + return [ + 'email_verified_at' => 'datetime', + 'bbb_skip_check_audio' => 'boolean', + 'initial_password_set' => 'boolean', + ]; } } diff --git a/app/Notifications/EmailChanged.php b/app/Notifications/EmailChanged.php index e4a3dbdd9..643c0c464 100644 --- a/app/Notifications/EmailChanged.php +++ b/app/Notifications/EmailChanged.php @@ -14,15 +14,7 @@ class EmailChanged extends Notification implements ShouldQueue { use Queueable; - private string $email; - - private string $fullname; - - public function __construct(string $email, string $fullname) - { - $this->email = $email; - $this->fullname = $fullname; - } + public function __construct(private string $email, private string $fullname) {} /** * Get the notification's delivery channels. diff --git a/app/Notifications/PasswordReset.php b/app/Notifications/PasswordReset.php index 2815dd813..cd3339275 100644 --- a/app/Notifications/PasswordReset.php +++ b/app/Notifications/PasswordReset.php @@ -15,28 +15,19 @@ class PasswordReset extends Notification implements ShouldQueue { use Queueable; - /** - * The password reset token. - * - * @var string - */ - private $token; - - /** - * The date when the password will expire. - * - * @var Carbon - */ - private $expireDate; - /** * Create a new notification instance. */ - public function __construct(string $token, Carbon $expireDate) - { - $this->token = $token; - $this->expireDate = $expireDate; - } + public function __construct( + /** + * The password reset token. + */ + private string $token, + /** + * The date when the password will expire. + */ + private Carbon $expireDate + ) {} /** * Get the notification's delivery channels. diff --git a/app/Notifications/RoomExpires.php b/app/Notifications/RoomExpires.php index 3d5429271..722d80acf 100644 --- a/app/Notifications/RoomExpires.php +++ b/app/Notifications/RoomExpires.php @@ -12,22 +12,17 @@ class RoomExpires extends Notification implements ShouldQueue { use Queueable; - /** - * The room. - * - * @var Room - */ - private $room; - /** * Create a new notification instance. * * @return void */ - public function __construct(Room $room) - { - $this->room = $room; - } + public function __construct( + /** + * The room. + */ + private Room $room + ) {} /** * Get the notification's delivery channels. diff --git a/app/Notifications/UserWelcome.php b/app/Notifications/UserWelcome.php index e35cbd5ed..0bdf85f24 100644 --- a/app/Notifications/UserWelcome.php +++ b/app/Notifications/UserWelcome.php @@ -15,28 +15,19 @@ class UserWelcome extends Notification implements ShouldQueue { use Queueable; - /** - * The password reset token. - * - * @var string - */ - private $token; - - /** - * The date when the password will expire. - * - * @var Carbon - */ - private $expireDate; - /** * Create a new notification instance. */ - public function __construct(string $token, Carbon $expireDate) - { - $this->token = $token; - $this->expireDate = $expireDate; - } + public function __construct( + /** + * The password reset token. + */ + private string $token, + /** + * The date when the password will expire. + */ + private Carbon $expireDate + ) {} /** * Get the notification's delivery channels. diff --git a/app/Notifications/VerifyEmail.php b/app/Notifications/VerifyEmail.php index 59668e5e4..3be1fc139 100644 --- a/app/Notifications/VerifyEmail.php +++ b/app/Notifications/VerifyEmail.php @@ -12,15 +12,7 @@ class VerifyEmail extends Notification implements ShouldQueue { use Queueable; - private NewVerifyEmailToken $token; - - private string $timezone; - - public function __construct(NewVerifyEmailToken $token, string $timezone) - { - $this->token = $token; - $this->timezone = $timezone; - } + public function __construct(private NewVerifyEmailToken $token, private string $timezone) {} /** * Get the notification's delivery channels. diff --git a/app/Plugins/PluginServiceProvider.php b/app/Plugins/PluginServiceProvider.php index 6c9f8978f..f1d3f28b6 100644 --- a/app/Plugins/PluginServiceProvider.php +++ b/app/Plugins/PluginServiceProvider.php @@ -11,13 +11,14 @@ class PluginServiceProvider extends ServiceProvider /** * Register services. */ + #[\Override] public function register(): void { $contracts = config('plugins.contracts'); foreach ($contracts as $contract) { - $this->app->bind($contract, function (Application $app) use ($contract) { + $this->app->bind($contract, function (Application $app) use ($contract): object { $reflect = new ReflectionClass($contract); $contractName = $reflect->getShortName(); diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index b5e086548..d9b4230cd 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -23,17 +23,14 @@ public function boot(): void Schema::defaultStringLength(191); } + #[\Override] public function register(): void { - $this->app->singleton(LocaleService::class, function () { - return new LocaleService(new Filesystem); - }); + $this->app->singleton(fn (): \App\Services\LocaleService => new LocaleService(new Filesystem)); $this->app->singleton(ResolvesUsers::class, Users::class); - $this->app->singleton(RoomAuthService::class, function () { - return new RoomAuthService; - }); + $this->app->singleton(fn (): \App\Services\RoomAuthService => new RoomAuthService); $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class); $this->app->register(TelescopeServiceProvider::class); diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 0e62fbd91..40a46f46f 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -45,16 +45,10 @@ public function boot(): void } }); - $this->app->auth->provider('ldap', function ($app, array $config) { - return new LDAPProvider($app['hash'], $config['model']); - }); + $this->app->auth->provider('ldap', fn ($app, array $config) => new LDAPProvider($app['hash'], $config['model'])); - $this->app->auth->provider('local', function ($app, array $config) { - return new LocalProvider($app['hash'], $config['model']); - }); + $this->app->auth->provider('local', fn ($app, array $config) => new LocalProvider($app['hash'], $config['model'])); - Gate::define('viewPulse', function (User $user) { - return $user->can('system.monitor'); - }); + Gate::define('viewPulse', fn (User $user) => $user->can('system.monitor')); } } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index b23dddc8b..b7c749d46 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -37,6 +37,7 @@ class EventServiceProvider extends ServiceProvider /** * Register any events for your application. */ + #[\Override] public function boot(): void { // @@ -45,6 +46,7 @@ public function boot(): void /** * Determine if events and listeners should be automatically discovered. */ + #[\Override] public function shouldDiscoverEvents(): bool { return false; diff --git a/app/Providers/FakerServiceProvider.php b/app/Providers/FakerServiceProvider.php index fd8c92641..288232912 100644 --- a/app/Providers/FakerServiceProvider.php +++ b/app/Providers/FakerServiceProvider.php @@ -4,7 +4,6 @@ use App\Faker\TextProvider; use Faker\Factory; -use Faker\Generator; use Illuminate\Support\ServiceProvider; class FakerServiceProvider extends ServiceProvider @@ -12,9 +11,10 @@ class FakerServiceProvider extends ServiceProvider /** * Register services. */ + #[\Override] public function register(): void { - $this->app->singleton(Generator::class, function () { + $this->app->singleton(function (): \Faker\Generator { $faker = Factory::create(); $faker->addProvider(new TextProvider($faker)); diff --git a/app/Providers/HorizonServiceProvider.php b/app/Providers/HorizonServiceProvider.php index 82580866a..f02eb3d28 100644 --- a/app/Providers/HorizonServiceProvider.php +++ b/app/Providers/HorizonServiceProvider.php @@ -11,6 +11,7 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider /** * Bootstrap any application services. */ + #[\Override] public function boot(): void { parent::boot(); @@ -21,10 +22,9 @@ public function boot(): void * * This gate determines who can access Horizon in non-local environments. */ + #[\Override] protected function gate(): void { - Gate::define('viewHorizon', function ($user) { - return $user->can('system.monitor'); - }); + Gate::define('viewHorizon', fn ($user) => $user->can('system.monitor')); } } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 21dc575db..ed57dc181 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -23,11 +23,12 @@ class RouteServiceProvider extends ServiceProvider /** * Define your route model bindings, pattern filters, and other route configuration. */ + #[\Override] public function boot(): void { $this->configureRateLimiting(); - $this->routes(function () { + $this->routes(function (): void { Route::middleware('api') ->prefix('api') ->group(base_path('routes/api.php')); @@ -42,22 +43,14 @@ public function boot(): void */ protected function configureRateLimiting(): void { - RateLimiter::for('api', function (Request $request) { - return Limit::perMinute(200)->by($request->user()?->id ?: $request->ip()); - }); + RateLimiter::for('api', fn (Request $request) => Limit::perMinute(200)->by($request->user()?->id ?: $request->ip())); - RateLimiter::for('password_reset', function (Request $request) { - return Limit::perMinutes(30, 5)->by($request->user()?->id ?: $request->ip()); - }); + RateLimiter::for('password_reset', fn (Request $request) => Limit::perMinutes(30, 5)->by($request->user()?->id ?: $request->ip())); - RateLimiter::for('password_email', function (Request $request) { - return Limit::perMinutes(30, 5)->by($request->user()?->id ?: $request->ip()); - }); + RateLimiter::for('password_email', fn (Request $request) => Limit::perMinutes(30, 5)->by($request->user()?->id ?: $request->ip())); // Rate limit verify email requests - RateLimiter::for('verify_email', function (Request $request) { - return Limit::perMinutes(30, 5)->by($request->user()->id); - }); + RateLimiter::for('verify_email', fn (Request $request) => Limit::perMinutes(30, 5)->by($request->user()->id)); // Rate limit for changes to the current user profile, requiring to current password of the user if the user is editing himself // Prevent brute force attacks on the password diff --git a/app/Providers/TelescopeServiceProvider.php b/app/Providers/TelescopeServiceProvider.php index 217df7e73..9951c8733 100644 --- a/app/Providers/TelescopeServiceProvider.php +++ b/app/Providers/TelescopeServiceProvider.php @@ -12,6 +12,7 @@ class TelescopeServiceProvider extends TelescopeApplicationServiceProvider /** * Register any application services. */ + #[\Override] public function register(): void { // Telescope::night(); @@ -54,10 +55,9 @@ protected function hideSensitiveRequestDetails(): void * * This gate determines who can access Telescope in non-local environments. */ + #[\Override] protected function gate(): void { - Gate::define('viewTelescope', function ($user) { - return $user->can('system.monitor'); - }); + Gate::define('viewTelescope', fn ($user) => $user->can('system.monitor')); } } diff --git a/app/Providers/TranslationServiceProvider.php b/app/Providers/TranslationServiceProvider.php index 92097876e..fd2222265 100644 --- a/app/Providers/TranslationServiceProvider.php +++ b/app/Providers/TranslationServiceProvider.php @@ -12,10 +12,9 @@ class TranslationServiceProvider extends BaseTranslationServiceProvider * * @return void */ + #[\Override] protected function registerLoader() { - $this->app->singleton('translation.loader', function ($app) { - return new FileLoader($app['files'], [config('app.default_locale_dir'), config('app.custom_locale_dir')]); - }); + $this->app->singleton('translation.loader', fn ($app) => new FileLoader($app['files'], [config('app.default_locale_dir'), config('app.custom_locale_dir')])); } } diff --git a/app/Rules/Password.php b/app/Rules/Password.php index d8bbe7cdb..8973d42b7 100644 --- a/app/Rules/Password.php +++ b/app/Rules/Password.php @@ -16,7 +16,7 @@ class Password implements Rule public function passes($attribute, $value) { // Password should contain at least 1 uppercase letter, 1 lowercase letter, 1 symbol, 1 number - return preg_match('/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*(_|[^\w])).+$/', $value) !== 0; + return preg_match('/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*(_|[^\w])).+$/', (string) $value) !== 0; } /** diff --git a/app/Rules/ValidName.php b/app/Rules/ValidName.php index ff3a02e89..c592c7668 100644 --- a/app/Rules/ValidName.php +++ b/app/Rules/ValidName.php @@ -24,11 +24,11 @@ public function __construct() */ public function passes($attribute, $value) { - if (preg_match('/^['.config('bigbluebutton.allowed_name_characters').']+$/u', $value)) { + if (preg_match('/^['.config('bigbluebutton.allowed_name_characters').']+$/u', (string) $value)) { return true; } $this->attribute = $attribute; - $this->failedChars = array_unique(str_split(preg_replace('/['.config('bigbluebutton.allowed_name_characters').']+/u', '', $value))); + $this->failedChars = array_unique(str_split((string) preg_replace('/['.config('bigbluebutton.allowed_name_characters').']+/u', '', (string) $value))); return false; } diff --git a/app/Rules/ValidRoomType.php b/app/Rules/ValidRoomType.php index 15d30c3d0..efcba7cad 100644 --- a/app/Rules/ValidRoomType.php +++ b/app/Rules/ValidRoomType.php @@ -9,20 +9,17 @@ class ValidRoomType implements Rule { - /** - * @var User The owner of the room. - */ - private User $owner; - /** * Create a new rule instance. * * @return void */ - public function __construct(User $owner) - { - $this->owner = $owner; - } + public function __construct( + /** + * @var User The owner of the room. + */ + private readonly User $owner + ) {} /** * Determine if the validation rule passes. diff --git a/app/Services/AuthenticationService.php b/app/Services/AuthenticationService.php index 273105c5a..add4412cb 100644 --- a/app/Services/AuthenticationService.php +++ b/app/Services/AuthenticationService.php @@ -11,12 +11,7 @@ class AuthenticationService { - private User $user; - - public function __construct(User $user) - { - $this->user = $user; - } + public function __construct(private readonly User $user) {} public function sendResetLink(): string { diff --git a/app/Services/BigBlueButton/LaravelHTTPClient.php b/app/Services/BigBlueButton/LaravelHTTPClient.php index 3059264c2..dd69fe2d9 100644 --- a/app/Services/BigBlueButton/LaravelHTTPClient.php +++ b/app/Services/BigBlueButton/LaravelHTTPClient.php @@ -15,7 +15,7 @@ /** * Allows to send requests to the BBB server with a Laravel HTTP Client contract implementation. */ -final class LaravelHTTPClient implements TransportInterface +final readonly class LaravelHTTPClient implements TransportInterface { private PendingRequest $httpClient; diff --git a/app/Services/EmailVerification/EmailVerificationService.php b/app/Services/EmailVerification/EmailVerificationService.php index 573c4ee3e..8abd3b003 100644 --- a/app/Services/EmailVerification/EmailVerificationService.php +++ b/app/Services/EmailVerification/EmailVerificationService.php @@ -13,12 +13,7 @@ class EmailVerificationService { - private User $user; - - public function __construct(User $user) - { - $this->user = $user; - } + public function __construct(private readonly User $user) {} /** * Send the email verification notification. @@ -33,7 +28,7 @@ public function sendEmailVerificationNotification(string $newEmail): bool Notification::route('mail', [ $newEmail => $this->user->fullname, - ])->notifyNow((new VerifyEmailNotification($token, $this->user->timezone))->locale($this->user->locale)); + ])->notifyNow(new VerifyEmailNotification($token, $this->user->timezone)->locale($this->user->locale)); return true; } @@ -82,7 +77,7 @@ public function changeEmail(string $newEmail) Notification::route('mail', [ $oldEmail => $this->user->fullname, - ])->notify((new EmailChanged($this->user->email, $this->user->fullname))->locale($this->user->locale)); + ])->notify(new EmailChanged($this->user->email, $this->user->fullname)->locale($this->user->locale)); } /** diff --git a/app/Services/EmailVerification/NewVerifyEmailToken.php b/app/Services/EmailVerification/NewVerifyEmailToken.php index 7b927cda4..c8a93e34d 100644 --- a/app/Services/EmailVerification/NewVerifyEmailToken.php +++ b/app/Services/EmailVerification/NewVerifyEmailToken.php @@ -6,15 +6,7 @@ class NewVerifyEmailToken { - private VerifyEmail $verifyEmail; - - private string $plainTextToken; - - public function __construct(VerifyEmail $verifyEmail, string $plainTextToken) - { - $this->verifyEmail = $verifyEmail; - $this->plainTextToken = $plainTextToken; - } + public function __construct(private readonly VerifyEmail $verifyEmail, private readonly string $plainTextToken) {} public function getVerifyEmail(): VerifyEmail { diff --git a/app/Services/LoadBalancingService.php b/app/Services/LoadBalancingService.php index 9a42d660d..67000e219 100644 --- a/app/Services/LoadBalancingService.php +++ b/app/Services/LoadBalancingService.php @@ -27,9 +27,7 @@ public function getLowestUsageServer(): ?Server ->where('recover_count', '>=', config('bigbluebutton.server_online_threshold')) ->where('error_count', '=', 0) ->whereNotNull('load') - ->sortBy(function (Server $server) { - return $server->load / $server->strength; - }) + ->sortBy(fn (Server $server) => $server->load / $server->strength) ->first(); } } diff --git a/app/Services/LocaleService.php b/app/Services/LocaleService.php index 5808a78c7..156d72812 100644 --- a/app/Services/LocaleService.php +++ b/app/Services/LocaleService.php @@ -8,12 +8,7 @@ class LocaleService { - protected Filesystem $filesystem; - - public function __construct(Filesystem $filesystem) - { - $this->filesystem = $filesystem; - } + public function __construct(protected Filesystem $filesystem) {} /** * Get locale data as JSON @@ -81,7 +76,7 @@ private function getLocaleData(string $locale, bool $withFallback = true, bool $ $localeFiles = $disk->files($locale); // Go through all locale files foreach ($localeFiles as $localeFile) { - $path_parts = pathinfo($localeFile); + $path_parts = pathinfo((string) $localeFile); // Skip non-PHP files if ($path_parts['extension'] != 'php') { diff --git a/app/Services/MeetingService.php b/app/Services/MeetingService.php index 56c89cc9e..311a4c3bf 100644 --- a/app/Services/MeetingService.php +++ b/app/Services/MeetingService.php @@ -27,8 +27,6 @@ class MeetingService { - private Meeting $meeting; - private ServerService $serverService; public function setServerService(ServerService $serverService): self @@ -38,10 +36,9 @@ public function setServerService(ServerService $serverService): self return $this; } - public function __construct(Meeting $meeting) + public function __construct(private readonly Meeting $meeting) { - $this->meeting = $meeting; - $this->serverService = new ServerService($meeting->server); + $this->serverService = new ServerService($this->meeting->server); } /** @@ -106,7 +103,7 @@ public function start(): ?\BigBlueButton\Responses\CreateMeetingResponse // get files that should be used in this meeting and add links to the files $files = $this->meeting->room->files()->where('use_in_meeting', true)->orderBy('default', 'desc')->get(); foreach ($files as $file) { - $meetingParams->addPresentation((new RoomFileService($file))->url(), null, preg_replace("/[^A-Za-z0-9.-_\(\)]/", '', $file->filename)); + $meetingParams->addPresentation(new RoomFileService($file)->url(), null, preg_replace("/[^A-Za-z0-9.-_\(\)]/", '', (string) $file->filename)); } if (empty($meetingParams->getPresentations()) && app(BigBlueButtonSettings::class)->default_presentation) { @@ -140,7 +137,7 @@ public function start(): ?\BigBlueButton\Responses\CreateMeetingResponse try { $result = $this->serverService->getBigBlueButton()->createMeeting($meetingParams); } // Catch exceptions, e.g. network connection issues - catch (\Exception $exception) { + catch (\Exception) { // Handle failed api call $this->serverService->handleApiCallFailed(); @@ -255,9 +252,7 @@ public static function setCustomCreateMeetingParameters(CreateMeetingParameters // Special handling for disabledFeatures and disabledFeaturesExclude try { if ($parameter == 'disabledFeatures' || $parameter == 'disabledFeaturesExclude') { - $value = array_map(function ($value) { - return Feature::from($value); - }, $value); + $value = array_map(fn ($value) => Feature::from($value), $value); } } catch (\ValueError $e) { Log::warning('Custom create parameter {parameter} value {value} is not an enum value', ['value' => $value, 'parameter' => $parameter]); @@ -275,7 +270,7 @@ public static function setCustomCreateMeetingParameters(CreateMeetingParameters if ($reflectionClass->isEnum()) { try { $value = $typeName::from($value); - } catch (\ValueError $e) { + } catch (\ValueError) { Log::warning('Custom create parameter {parameter} value {value} is not an enum value', ['value' => $value, 'parameter' => $parameter]); $errors[] = __('validation.custom_parameter_enum', ['parameter' => $parameter]); @@ -290,7 +285,7 @@ public static function setCustomCreateMeetingParameters(CreateMeetingParameters // Set the parameter $meetingParams->$setParamMethod($value); - } catch (\ReflectionException $e) { + } catch (\ReflectionException) { // Log a warning if a parameter cannot be found Log::warning('Custom create parameter {parameter} can not be found', ['parameter' => $parameter]); @@ -410,7 +405,7 @@ public static function setCustomJoinMeetingParameters(JoinMeetingParameters $mee if ($reflectionClass->isEnum()) { try { $value = $typeName::from($value); - } catch (\ValueError $e) { + } catch (\ValueError) { Log::warning('Custom join parameter {parameter} value {value} is not an enum value', ['value' => $value, 'parameter' => $parameter]); $errors[] = __('validation.custom_parameter_enum', ['parameter' => $parameter]); @@ -425,7 +420,7 @@ public static function setCustomJoinMeetingParameters(JoinMeetingParameters $mee // Set the parameter $meetingParams->$setParamMethod($value); - } catch (\ReflectionException $e) { + } catch (\ReflectionException) { // Log a warning if a parameter cannot be found Log::warning('Custom join parameter {parameter} can not be found', ['parameter' => $parameter]); @@ -505,9 +500,7 @@ public function updateAttendance(\BigBlueButton\Core\Meeting $bbbMeeting) { // Get collection of all attendees, remove duplicated (user joins twice) $collection = collect($bbbMeeting->getAttendees()); - $uniqueAttendees = $collection->unique(function ($attendee) { - return $attendee->getUserId(); - }); + $uniqueAttendees = $collection->unique(fn ($attendee) => $attendee->getUserId()); // List of all created and found attendees $newAndExistingAttendees = []; @@ -567,9 +560,7 @@ public function updateAttendance(\BigBlueButton\Core\Meeting $bbbMeeting) // get all active attendees from database $allAttendees = MeetingAttendee::where('meeting_id', $this->meeting->id)->whereNull('leave')->get(); // remove added or found attendees, to only have attendees left that are no longer active - $leftAttendees = $allAttendees->filter(function ($attendee, $key) use ($newAndExistingAttendees) { - return ! in_array($attendee->id, $newAndExistingAttendees); - }); + $leftAttendees = $allAttendees->filter(fn ($attendee, $key) => ! in_array($attendee->id, $newAndExistingAttendees)); // set end time of left attendees to current datetime foreach ($leftAttendees as $leftAttendee) { $leftAttendee->leave = now(); @@ -615,9 +606,7 @@ public function attendance(): Collection|\Illuminate\Support\Collection */ private function mapAttendanceSessions($sessions): mixed { - return $sessions->map(function ($session) { - return ['id' => $session->id, 'join' => $session->join, 'leave' => $session->leave, 'duration' => (int) $session->join->diffInMinutes($session->leave)]; - }); + return $sessions->map(fn ($session) => ['id' => $session->id, 'join' => $session->join, 'leave' => $session->leave, 'duration' => (int) $session->join->diffInMinutes($session->leave)]); } /** diff --git a/app/Services/ProvisioningService.php b/app/Services/ProvisioningService.php index 84df125fd..5b52ed16f 100644 --- a/app/Services/ProvisioningService.php +++ b/app/Services/ProvisioningService.php @@ -27,11 +27,11 @@ abstract class AbstractProvisioner { - private string $modelName; + private readonly string $modelName; - public function __construct(private string $model, private array $expectedProperties) + public function __construct(private readonly string $model, private readonly array $expectedProperties) { - $name = (new ReflectionClass($model))->getShortname(); + $name = new ReflectionClass($model)->getShortname(); $this->modelName = Str::of($name)->snake()->replace('_', ' ')->value(); } @@ -64,7 +64,7 @@ protected function destroyWrapper(array $match, ?callable $callback = null) foreach ($match as $key => $value) { $query = $query->where($key, $value); } - $query->get()->each(function (object $item) use ($callback) { + $query->get()->each(function (object $item) use ($callback): void { if ($callback) { $callback($item); } @@ -100,7 +100,7 @@ public function __construct() public function create(object $properties) { - $this->createWrapper($properties, function ($srv) use ($properties) { + $this->createWrapper($properties, function ($srv) use ($properties): void { $status = ServerStatus::{strtoupper($properties->status)}; $srv->name = $properties->name; $srv->description = $properties->description; @@ -132,7 +132,7 @@ public function __construct() public function create(object $properties) { - $this->createWrapper($properties, function ($pool) use ($properties) { + $this->createWrapper($properties, function ($pool) use ($properties): void { $servers = Server::whereIn('name', $properties->servers)->get(); $pool->name = $properties->name; $pool->description = $properties->description; @@ -162,7 +162,7 @@ public function __construct() public function create(object $properties) { - $this->createWrapper($properties, function ($type) use ($properties) { + $this->createWrapper($properties, function ($type) use ($properties): void { $type->name = $properties->name; $type->description = $properties->description; $type->color = $properties->color; @@ -206,7 +206,7 @@ public function __construct() public function create(object $properties) { - $this->createWrapper($properties, function ($role) use ($properties) { + $this->createWrapper($properties, function ($role) use ($properties): void { foreach ($properties->permissions as $group => $perms) { foreach ($perms as $item) { $permName = "$group.$item"; @@ -247,6 +247,7 @@ public function __construct() parent::__construct(User::class, $expectedProperties); } + #[\Override] protected function instanceName(object $properties) { return "$properties->firstname $properties->lastname"; @@ -254,7 +255,7 @@ protected function instanceName(object $properties) public function create(object $properties) { - $this->createWrapper($properties, function ($user) use ($properties) { + $this->createWrapper($properties, function ($user) use ($properties): void { $roles = Role::whereIn('name', $properties->roles)->get(); $user->firstname = $properties->firstname; $user->lastname = $properties->lastname; diff --git a/app/Services/RoomFileService.php b/app/Services/RoomFileService.php index 89f2ed608..e550fa3c6 100644 --- a/app/Services/RoomFileService.php +++ b/app/Services/RoomFileService.php @@ -9,8 +9,6 @@ class RoomFileService { - private RoomFile $file; - private ?int $timeLimit = null; public function getTimeLimit(): int @@ -25,10 +23,7 @@ public function setTimeLimit(?int $timeLimit): self return $this; } - public function __construct(RoomFile $file) - { - $this->file = $file; - } + public function __construct(private readonly RoomFile $file) {} protected function checkFileExists(): bool { @@ -37,7 +32,7 @@ protected function checkFileExists(): bool try { Log::error('Room file {file} not found', ['file' => $this->file->getLogLabel()]); $this->file->delete(); - } catch (\Exception $exception) { + } catch (\Exception) { } return false; diff --git a/app/Services/RoomService.php b/app/Services/RoomService.php index b5a8242cc..7941291df 100644 --- a/app/Services/RoomService.php +++ b/app/Services/RoomService.php @@ -12,12 +12,7 @@ class RoomService { - protected Room $room; - - public function __construct(Room $room) - { - $this->room = $room; - } + public function __construct(protected Room $room) {} /** * Start a new meeting @@ -111,7 +106,7 @@ public function start(): MeetingService RoomStarted::dispatch($this->room); $lock->release(); - } catch (LockTimeoutException $e) { + } catch (LockTimeoutException) { abort(CustomStatusCodes::ROOM_START_FAILED->value, __('app.errors.room_start')); } @@ -144,7 +139,7 @@ public function join(): MeetingService try { // Check if meeting is running $meetingRunning = $meetingService->isRunning(); - } catch (\Exception $e) { + } catch (\Exception) { Log::warning('Error checking if room {room} is running on the BBB server', ['room' => $this->room->getLogLabel()]); abort(CustomStatusCodes::JOIN_FAILED->value, __('app.errors.join_failed')); } diff --git a/app/Services/ServerService.php b/app/Services/ServerService.php index 5df342bf1..b581623ca 100644 --- a/app/Services/ServerService.php +++ b/app/Services/ServerService.php @@ -23,14 +23,11 @@ public function getBigBlueButton(): BigBlueButton return $this->bbb; } - protected Server $server; - protected ServerLoadCalculationPluginContract $loadCalculationPlugin; - public function __construct(Server $server) + public function __construct(protected Server $server) { - $this->server = $server; - $this->bbb = new BigBlueButton($server->base_url, $server->secret, new LaravelHTTPClient); + $this->bbb = new BigBlueButton($this->server->base_url, $this->server->secret, new LaravelHTTPClient); $this->loadCalculationPlugin = app(ServerLoadCalculationPluginContract::class); } @@ -53,7 +50,7 @@ public function getMeetings() } return $response->getMeetings(); - } catch (\Exception $exception) { + } catch (\Exception) { // TODO add better error handling when provided by api return null; } @@ -73,7 +70,7 @@ private function getBBBVersion(): ?string $version = $response->getBbbVersion(); return $version != '' ? $version : null; - } catch (\Exception $exception) { + } catch (\Exception) { return null; } } @@ -147,7 +144,7 @@ private function endDetachedMeetings() try { $meetingService->end(); Log::notice('Ended detached meeting {meeting} for room {room}', ['room' => $meeting->room->getLogLabel(), 'meeting' => $meeting->getLogLabel()]); - } catch (\Exception $e) { + } catch (\Exception) { Log::error('Failed to end detached meeting {meeting} for room {room}', ['room' => $meeting->room->getLogLabel(), 'meeting' => $meeting->getLogLabel()]); } } @@ -166,9 +163,9 @@ public function panic(): array $success = 0; foreach ($query->get() as $meeting) { try { - (new MeetingService($meeting))->end(); + new MeetingService($meeting)->end(); $success++; - } catch (\Exception $exception) { + } catch (\Exception) { // Connection error, but try to continue // as the server should be marked as offline } @@ -273,7 +270,7 @@ public function updateUsage($updateServerStatistics = false, $updateMeetingStati // Update meeting attendance if enabled for this running meeting if ($meeting->record_attendance && $updateAttendance) { - (new MeetingService($meeting))->updateAttendance($bbbMeeting); + new MeetingService($meeting)->updateAttendance($bbbMeeting); } // Save meeting statistics if enabled @@ -310,7 +307,7 @@ public function updateUsage($updateServerStatistics = false, $updateMeetingStati if ($meeting != null && $meeting->end == null) { Log::warning('Meeting {meeting} for room {room} is not running on the BBB server', ['room' => $meeting->room->getLogLabel(), 'meeting' => $meeting->getLogLabel()]); - (new MeetingService($meeting))->setEnd(); + new MeetingService($meeting)->setEnd(); } } diff --git a/app/Services/StreamingService.php b/app/Services/StreamingService.php index b2e0fe8e2..88e401449 100644 --- a/app/Services/StreamingService.php +++ b/app/Services/StreamingService.php @@ -9,7 +9,7 @@ class StreamingService { - private ServerService $serverService; + private readonly ServerService $serverService; public function __construct(public Meeting $meeting) { @@ -63,7 +63,7 @@ public function getHttpClient() public function getJobId(): string { - $host = parse_url($this->meeting->server->base_url)['host']; + $host = parse_url((string) $this->meeting->server->base_url)['host']; return hash('sha256', $this->meeting->id.'@'.$host); } @@ -95,7 +95,7 @@ public function getStatus() { try { $response = $this->getHttpClient()->get($this->getJobId()); - } catch (\Exception $exception) { + } catch (\Exception) { return false; } @@ -125,7 +125,7 @@ public function start() 'pauseImageUrl' => $pauseImageUrl, 'rtmpUrl' => $this->meeting->room->streaming->url, ]); - } catch (\Exception $exception) { + } catch (\Exception) { return false; } @@ -136,7 +136,7 @@ public function stop() { try { $response = $this->getHttpClient()->post($this->getJobId().'/stop'); - } catch (\Exception $exception) { + } catch (\Exception) { return false; } @@ -147,7 +147,7 @@ public function resume() { try { $response = $this->getHttpClient()->post($this->getJobId().'/resume'); - } catch (\Exception $exception) { + } catch (\Exception) { return false; } @@ -158,7 +158,7 @@ public function pause() { try { $response = $this->getHttpClient()->post($this->getJobId().'/pause'); - } catch (\Exception $exception) { + } catch (\Exception) { return false; } diff --git a/app/Settings/BannerSettings.php b/app/Settings/BannerSettings.php index ac115b78b..d7842b22b 100644 --- a/app/Settings/BannerSettings.php +++ b/app/Settings/BannerSettings.php @@ -10,21 +10,21 @@ class BannerSettings extends Settings { public bool $enabled; - public ?string $message; + public ?string $message = null; - public ?string $link; + public ?string $link = null; - public ?string $icon; + public ?string $icon = null; - public ?string $color; + public ?string $color = null; - public ?string $background; + public ?string $background = null; - public ?string $title; + public ?string $title = null; public LinkButtonStyle $link_style; - public ?string $link_text; + public ?string $link_text = null; public LinkTarget $link_target; diff --git a/app/Settings/BigBlueButtonSettings.php b/app/Settings/BigBlueButtonSettings.php index 2a66edfd3..28553c508 100644 --- a/app/Settings/BigBlueButtonSettings.php +++ b/app/Settings/BigBlueButtonSettings.php @@ -6,13 +6,13 @@ class BigBlueButtonSettings extends Settings { - public ?string $logo; + public ?string $logo = null; - public ?string $logo_dark; + public ?string $logo_dark = null; - public ?string $style; + public ?string $style = null; - public ?string $default_presentation; + public ?string $default_presentation = null; public static function group(): string { diff --git a/app/Settings/GeneralSettings.php b/app/Settings/GeneralSettings.php index 54cf16088..f309f26cb 100644 --- a/app/Settings/GeneralSettings.php +++ b/app/Settings/GeneralSettings.php @@ -8,11 +8,11 @@ class GeneralSettings extends Settings { public string $name; - public ?string $help_url; + public ?string $help_url = null; - public ?string $legal_notice_url; + public ?string $legal_notice_url = null; - public ?string $privacy_policy_url; + public ?string $privacy_policy_url = null; public int $pagination_page_size; diff --git a/app/Settings/RoomSettings.php b/app/Settings/RoomSettings.php index bd3e8cef4..f2ea5f022 100644 --- a/app/Settings/RoomSettings.php +++ b/app/Settings/RoomSettings.php @@ -17,7 +17,7 @@ class RoomSettings extends Settings public TimePeriod $auto_delete_deadline_period; - public ?string $file_terms_of_use; + public ?string $file_terms_of_use = null; public static function group(): string { diff --git a/app/Settings/StreamingSettings.php b/app/Settings/StreamingSettings.php index 08a022e29..06c57c758 100644 --- a/app/Settings/StreamingSettings.php +++ b/app/Settings/StreamingSettings.php @@ -6,11 +6,11 @@ class StreamingSettings extends Settings { - public ?string $default_pause_image; + public ?string $default_pause_image = null; - public ?string $css_file; + public ?string $css_file = null; - public ?string $join_parameters; + public ?string $join_parameters = null; public static function group(): string { diff --git a/composer.json b/composer.json index a35bf0d32..bf28153f3 100644 --- a/composer.json +++ b/composer.json @@ -35,11 +35,13 @@ "require-dev": { "barryvdh/laravel-ide-helper": "^3.0", "brianium/paratest": "^7.9", + "driftingly/rector-laravel": "^2.0", "fakerphp/faker": "^1.9.1", "laravel/pint": "^1.14", "mockery/mockery": "^1.4.2", "php-coveralls/php-coveralls": "^2.3.0", "phpunit/phpunit": "^12.1", + "rector/rector": "^2.0", "timacdonald/log-fake": "^2.0.1" }, "config": { @@ -92,6 +94,7 @@ "test": "php artisan test --parallel", "test-ci": "php artisan test --parallel --testsuite=Unit,Feature", "test-integration": "php artisan test --parallel --testsuite=Integration", - "fix-cs": "pint" + "fix-cs": "pint", + "rector": "rector" } } diff --git a/composer.lock b/composer.lock index 535ea1b6c..d5e48703f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3fd34081f74a0dcf38cf8748c1e2dfba", + "content-hash": "8b6b60fdc6825b9da86f4aea124ca0ef", "packages": [ { "name": "brick/math", @@ -8583,6 +8583,41 @@ ], "time": "2025-03-24T13:50:44+00:00" }, + { + "name": "driftingly/rector-laravel", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/driftingly/rector-laravel.git", + "reference": "68c23d123bd80777536ce460936748d135bd6982" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/driftingly/rector-laravel/zipball/68c23d123bd80777536ce460936748d135bd6982", + "reference": "68c23d123bd80777536ce460936748d135bd6982", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "rector/rector": "^2.0" + }, + "type": "rector-extension", + "autoload": { + "psr-4": { + "RectorLaravel\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Rector upgrades rules for Laravel Framework", + "support": { + "issues": "https://github.com/driftingly/rector-laravel/issues", + "source": "https://github.com/driftingly/rector-laravel/tree/2.0.4" + }, + "time": "2025-04-13T14:43:39+00:00" + }, { "name": "fakerphp/faker", "version": "v1.24.1", @@ -9228,6 +9263,64 @@ }, "time": "2023-11-22T10:21:01+00:00" }, + { + "name": "phpstan/phpstan", + "version": "2.1.13", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "e55e03e6d4ac49cd1240907e5b08e5cd378572a9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e55e03e6d4ac49cd1240907e5b08e5cd378572a9", + "reference": "e55e03e6d4ac49cd1240907e5b08e5cd378572a9", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2025-04-27T12:28:25+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "12.1.2", @@ -9655,6 +9748,65 @@ ], "time": "2025-04-22T06:11:09+00:00" }, + { + "name": "rector/rector", + "version": "2.0.14", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "63923bc9383c1212476c41d8cebf58a425e6f98d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/63923bc9383c1212476c41d8cebf58a425e6f98d", + "reference": "63923bc9383c1212476c41d8cebf58a425e6f98d", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0", + "phpstan/phpstan": "^2.1.12" + }, + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" + }, + "suggest": { + "ext-dom": "To manipulate phpunit.xml via the custom-rule command" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "keywords": [ + "automation", + "dev", + "migration", + "refactoring" + ], + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/2.0.14" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2025-04-28T00:03:14+00:00" + }, { "name": "sebastian/cli-parser", "version": "4.0.0", @@ -10920,6 +11072,6 @@ "ext-simplexml": "*", "ext-zip": "*" }, - "platform-dev": [], - "plugin-api-version": "2.3.0" + "platform-dev": {}, + "plugin-api-version": "2.6.0" } diff --git a/config/ldap.php b/config/ldap.php index 293e5097e..bc6bbd17a 100644 --- a/config/ldap.php +++ b/config/ldap.php @@ -52,7 +52,7 @@ 'filter' => env('LDAP_FILTER', ''), - 'object_classes' => explode(',', env('LDAP_OBJECT_CLASSES', 'top,person,organizationalperson,inetorgperson')), + 'object_classes' => explode(',', (string) env('LDAP_OBJECT_CLASSES', 'top,person,organizationalperson,inetorgperson')), 'login_attribute' => env('LDAP_LOGIN_ATTRIBUTE', 'uid'), diff --git a/config/mail.php b/config/mail.php index 7988e85be..4375bf576 100644 --- a/config/mail.php +++ b/config/mail.php @@ -44,7 +44,7 @@ 'verify_peer' => env('MAIL_VERIFY_PEER', true), 'auto_tls' => env('MAIL_AUTO_TLS', true), 'timeout' => null, - 'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)), + 'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)), ], 'ses' => [ diff --git a/config/permissions.php b/config/permissions.php index 1c227cff9..5fbe9e56a 100644 --- a/config/permissions.php +++ b/config/permissions.php @@ -1,5 +1,5 @@ explode(',', env('PERMISSION_RESTRICTIONS', '')), + 'restrictions' => explode(',', (string) env('PERMISSION_RESTRICTIONS', '')), ]; diff --git a/config/plugins.php b/config/plugins.php index d571cbeac..c4e6f816d 100644 --- a/config/plugins.php +++ b/config/plugins.php @@ -1,7 +1,7 @@ explode(',', env('PLUGINS', '')), + 'enabled' => explode(',', (string) env('PLUGINS', '')), 'contracts' => [ \App\Plugins\Contracts\ServerLoadCalculationPluginContract::class, ], diff --git a/config/pulse.php b/config/pulse.php index c43128565..910c69100 100644 --- a/config/pulse.php +++ b/config/pulse.php @@ -164,7 +164,7 @@ Recorders\Servers::class => [ 'server_name' => env('PULSE_SERVER_NAME', gethostname()), - 'directories' => explode(':', env('PULSE_SERVER_DIRECTORIES', '/')), + 'directories' => explode(':', (string) env('PULSE_SERVER_DIRECTORIES', '/')), ], Recorders\SlowJobs::class => [ diff --git a/config/sanctum.php b/config/sanctum.php index 10874969e..3709806d2 100644 --- a/config/sanctum.php +++ b/config/sanctum.php @@ -15,7 +15,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() diff --git a/rector.php b/rector.php new file mode 100644 index 000000000..2529a4e2a --- /dev/null +++ b/rector.php @@ -0,0 +1,35 @@ +withCache( + cacheClass: FileCacheStorage::class, + cacheDirectory: '/tmp/rector' + ) + ->withPaths([ + __DIR__.'/app', + __DIR__.'/config', + __DIR__.'/routes', + __DIR__.'/tests', + ]) + // uncomment to reach your current PHP version + ->withPhpSets() + ->withSets([ + LaravelLevelSetList::UP_TO_LARAVEL_120, + ]) + ->withSkip([ + ArgumentAdderRector::class, + ReturnNeverTypeRector::class, + ContainerBindConcreteWithClosureOnlyRector::class, + ]) + ->withTypeCoverageLevel(0) + ->withDeadCodeLevel(0) + ->withCodeQualityLevel(0); diff --git a/routes/api.php b/routes/api.php index 9055225de..ab137199a 100644 --- a/routes/api.php +++ b/routes/api.php @@ -38,7 +38,7 @@ | */ -Route::prefix('v1')->name('api.v1.')->group(function () { +Route::prefix('v1')->name('api.v1.')->group(function (): void { Route::get('locale/{locale}', [LocaleController::class, 'show'])->name('locale.get'); Route::post('locale', [LocaleController::class, 'update'])->name('locale.update'); @@ -56,7 +56,7 @@ Route::post('password/email', [ForgotPasswordController::class, 'sendResetLinkEmail'])->name('password.email')->middleware(['enable_if_config:auth.local.enabled', 'guest', 'throttle:password_email']); - Route::middleware('auth:users,ldap')->group(function () { + Route::middleware('auth:users,ldap')->group(function (): void { Route::get('settings', [SettingsController::class, 'view'])->name('settings.view')->middleware('can:settings.viewAny'); Route::put('settings', [SettingsController::class, 'update'])->name('settings.update')->middleware('can:settings.update'); @@ -100,18 +100,18 @@ Route::delete('rooms/{room}/member/{user}', [RoomMemberController::class, 'destroy'])->name('rooms.member.destroy')->middleware('can:manageMembers,room'); // Recording operations - Route::middleware('can:manageRecordings,room')->scopeBindings()->group(function () { + Route::middleware('can:manageRecordings,room')->scopeBindings()->group(function (): void { Route::put('rooms/{room}/recordings/{recording}', [RecordingController::class, 'update'])->name('rooms.recordings.update'); Route::delete('rooms/{room}/recordings/{recording}', [RecordingController::class, 'destroy'])->name('rooms.recordings.destroy'); }); // Streaming operations - Route::middleware('can:viewStreaming,room')->scopeBindings()->group(function () { + Route::middleware('can:viewStreaming,room')->scopeBindings()->group(function (): void { Route::get('rooms/{room}/streaming/config', [RoomStreamingController::class, 'getConfig'])->name('rooms.streaming.config.get'); Route::get('rooms/{room}/streaming/status', [RoomStreamingController::class, 'status'])->name('rooms.streaming.status'); }); - Route::middleware('can:manageStreaming,room')->scopeBindings()->group(function () { + Route::middleware('can:manageStreaming,room')->scopeBindings()->group(function (): void { Route::put('rooms/{room}/streaming/config', [RoomStreamingController::class, 'updateConfig'])->name('rooms.streaming.config.update'); Route::post('rooms/{room}/streaming/start', [RoomStreamingController::class, 'start'])->name('rooms.streaming.start'); Route::post('rooms/{room}/streaming/stop', [RoomStreamingController::class, 'stop'])->name('rooms.streaming.stop'); @@ -126,7 +126,7 @@ Route::delete('rooms/{room}/tokens/{token}', [RoomTokenController::class, 'destroy'])->name('rooms.tokens.destroy')->middleware('can:manageTokens,room'); // File operations - Route::middleware('can:manageFiles,room')->scopeBindings()->group(function () { + Route::middleware('can:manageFiles,room')->scopeBindings()->group(function (): void { Route::post('rooms/{room}/files', [RoomFileController::class, 'store'])->name('rooms.files.add'); Route::put('rooms/{room}/files/{file}', [RoomFileController::class, 'update'])->name('rooms.files.update'); Route::delete('rooms/{room}/files/{file}', [RoomFileController::class, 'destroy'])->name('rooms.files.destroy'); @@ -137,7 +137,7 @@ // User profile changes // If editing own profile current password is required, this middleware should prevent brute forcing of the current password - Route::middleware('throttle:current_password')->group(function () { + Route::middleware('throttle:current_password')->group(function (): void { Route::put('users/{user}/email', [UserController::class, 'changeEmail'])->name('users.email.change')->middleware('can:updateAttributes,user'); Route::put('users/{user}/password', [UserController::class, 'changePassword'])->name('users.password.change')->middleware('can:changePassword,user'); }); @@ -158,14 +158,12 @@ Route::get('meetings', [MeetingController::class, 'index'])->name('meetings.index'); Route::get('rooms/{room}/meetings', [RoomController::class, 'meetings'])->name('rooms.meetings'); - Route::get('getTimezones', function () { - return response()->json(['data' => timezone_identifiers_list()]); - }); + Route::get('getTimezones', fn () => response()->json(['data' => timezone_identifiers_list()])); }); Route::get('rooms/{room}', [RoomController::class, 'show'])->name('rooms.show')->middleware('room.authenticate:true'); - Route::middleware('room.authenticate')->scopeBindings()->group(function () { + Route::middleware('room.authenticate')->scopeBindings()->group(function (): void { Route::options('rooms/{room}/start', [RoomController::class, 'getStartRequirements'])->name('rooms.start-requirements')->middleware('can:start,room'); Route::options('rooms/{room}/join', [RoomController::class, 'getJoinRequirements'])->name('rooms.join-requirements'); @@ -182,7 +180,5 @@ }); if (! env('DISABLE_CATCHALL_ROUTES')) { - Route::any('/{any}', function () { - return response()->json(['message' => 'Not found!'], 404); - })->where('any', '.*'); + Route::any('/{any}', fn () => response()->json(['message' => 'Not found!'], 404))->where('any', '.*'); } diff --git a/routes/web.php b/routes/web.php index b5ff98369..1042b345f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -24,18 +24,16 @@ // Do not change this url format! Needs to be in this format in order to be compatible with the BBB recording player Route::get('recording/{formatName}/{recording}/{resource?}', [RecordingController::class, 'resource'])->where('resource', '.*')->name('recording.resource'); -Route::middleware('enable_if_config:services.shibboleth.enabled')->group(function () { +Route::middleware('enable_if_config:services.shibboleth.enabled')->group(function (): void { Route::get('auth/shibboleth/redirect', [ShibbolethController::class, 'redirect'])->name('auth.shibboleth.redirect'); Route::get('auth/shibboleth/callback', [ShibbolethController::class, 'callback'])->name('auth.shibboleth.callback'); Route::match(['get', 'post'], 'auth/shibboleth/logout', [ShibbolethController::class, 'logout'])->name('auth.shibboleth.logout'); }); if (config('greenlight.compatibility')) { - Route::prefix(config('greenlight.base'))->group(function () { + Route::prefix(config('greenlight.base'))->group(function (): void { // room urls - Route::get('/{id}', function ($id) { - return redirect('/rooms/'.$id); - })->where('id', '([A-Za-z0-9-]{3}-[A-Za-z0-9]{3}-[A-Za-z0-9]{3}(-[A-Za-z0-9]{3})?)'); + Route::get('/{id}', fn ($id) => redirect('/rooms/'.$id))->where('id', '([A-Za-z0-9-]{3}-[A-Za-z0-9]{3}-[A-Za-z0-9]{3}(-[A-Za-z0-9]{3})?)'); // login Route::redirect('/ldap_signin', '/login'); Route::redirect('/signin', '/login'); diff --git a/tests/Backend/Feature/api/v1/ApplicationTest.php b/tests/Backend/Feature/api/v1/ApplicationTest.php index 2e4888459..7fb9ad2ee 100644 --- a/tests/Backend/Feature/api/v1/ApplicationTest.php +++ b/tests/Backend/Feature/api/v1/ApplicationTest.php @@ -19,6 +19,7 @@ class ApplicationTest extends TestCase /** * Setup resources for all tests */ + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Feature/api/v1/ForgotPasswordTest.php b/tests/Backend/Feature/api/v1/ForgotPasswordTest.php index b68d000e3..96ab1bbb3 100644 --- a/tests/Backend/Feature/api/v1/ForgotPasswordTest.php +++ b/tests/Backend/Feature/api/v1/ForgotPasswordTest.php @@ -15,6 +15,7 @@ class ForgotPasswordTest extends TestCase { use RefreshDatabase, WithFaker; + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Feature/api/v1/LdapLoginTest.php b/tests/Backend/Feature/api/v1/LdapLoginTest.php index 3d5d75d69..a85473b91 100644 --- a/tests/Backend/Feature/api/v1/LdapLoginTest.php +++ b/tests/Backend/Feature/api/v1/LdapLoginTest.php @@ -88,11 +88,12 @@ class LdapLoginTest extends TestCase /** * @see TestCase::setUp() */ + #[\Override] protected function setUp(): void { parent::setUp(); Config::set('ldap.enabled', true); - Config::set('ldap.mapping', json_decode($this->ldapMapping)); + Config::set('ldap.mapping', json_decode((string) $this->ldapMapping)); Container::getConnection('default')->getConfiguration()->set('use_tls', false); Container::getConnection('default')->getConfiguration()->set('use_ssl', false); @@ -246,7 +247,7 @@ public function test_attribute_mapping_logging() */ public function test_incomplete_attribute_mapping() { - $newAttributeConf = json_decode($this->ldapMapping); + $newAttributeConf = json_decode((string) $this->ldapMapping); unset($newAttributeConf->attributes->first_name); Config::set('ldap.mapping', $newAttributeConf); @@ -263,7 +264,7 @@ public function test_incomplete_attribute_mapping() */ public function test_non_existing_ldap_attribute_mapping() { - $newAttributeConf = json_decode($this->ldapMapping); + $newAttributeConf = json_decode((string) $this->ldapMapping); $newAttributeConf->attributes->first_name = 'wrongAttribute'; Config::set('ldap.mapping', $newAttributeConf); @@ -280,7 +281,7 @@ public function test_non_existing_ldap_attribute_mapping() */ public function test_non_existing_model_attribute_mapping() { - $newAttributeConf = json_decode($this->ldapMapping); + $newAttributeConf = json_decode((string) $this->ldapMapping); $newAttributeConf->attributes->new_attribute = 'givenName'; Config::set('ldap.mapping', $newAttributeConf); @@ -321,7 +322,7 @@ public function test_role_mapping() */ public function test_role_mapping_invalid_ldap_attribute() { - $newAttributeConf = json_decode($this->ldapMapping); + $newAttributeConf = json_decode((string) $this->ldapMapping); $newAttributeConf->roles[0]->rules[0]->attribute = 'notExistingAttribute'; Config::set('ldap.mapping', $newAttributeConf); @@ -346,7 +347,7 @@ public function test_role_mapping_invalid_ldap_attribute() */ public function test_role_mapping_invalid_roles() { - $newAttributeConf = json_decode($this->ldapMapping); + $newAttributeConf = json_decode((string) $this->ldapMapping); $newAttributeConf->roles[0]->name = 'notExistingRole'; Config::set('ldap.mapping', $newAttributeConf); @@ -371,7 +372,7 @@ public function test_role_mapping_invalid_roles() */ public function test_empty_role_map() { - $newAttributeConf = json_decode($this->ldapMapping); + $newAttributeConf = json_decode((string) $this->ldapMapping); $newAttributeConf->roles = []; Config::set('ldap.mapping', $newAttributeConf); @@ -403,9 +404,7 @@ public function test_mapping_on_second_login() $this->assertAuthenticated($this->guard); $user = $this->getAuthenticatedUser(); $user->load('roles'); - $roleNames = array_map(function ($role) { - return $role->name; - }, $user->roles->all()); + $roleNames = array_map(fn ($role) => $role->name, $user->roles->all()); $this->assertCount(2, $roleNames); $this->assertContains('admin', $roleNames); @@ -425,9 +424,7 @@ public function test_mapping_on_second_login() $this->assertAuthenticated($this->guard); $this->assertDatabaseCount('role_user', 3); $user->load('roles'); - $roleNames = array_map(function ($role) { - return $role->name; - }, $user->roles->all()); + $roleNames = array_map(fn ($role) => $role->name, $user->roles->all()); $this->assertCount(3, $roleNames); $this->assertContains('admin', $roleNames); @@ -448,9 +445,7 @@ public function test_mapping_on_second_login() $this->assertAuthenticated($this->guard); $this->assertDatabaseCount('role_user', 2); $user->load('roles'); - $roleNames = array_map(function ($role) { - return $role->name; - }, $user->roles->all()); + $roleNames = array_map(fn ($role) => $role->name, $user->roles->all()); $this->assertCount(2, $roleNames); $this->assertContains('user', $roleNames); diff --git a/tests/Backend/Feature/api/v1/LocalesTest.php b/tests/Backend/Feature/api/v1/LocalesTest.php index 5b54047c3..8a32bd997 100644 --- a/tests/Backend/Feature/api/v1/LocalesTest.php +++ b/tests/Backend/Feature/api/v1/LocalesTest.php @@ -34,11 +34,12 @@ class LocalesTest extends TestCase /** * @see TestCase::setUp() */ + #[\Override] protected function setUp(): void { parent::setUp(); Config::set('ldap.enabled', true); - Config::set('ldap.mapping', json_decode($this->ldapMapping)); + Config::set('ldap.mapping', json_decode((string) $this->ldapMapping)); $this->withoutMix(); config([ @@ -61,7 +62,7 @@ public function test_not_existing_locale_in_accept_header() $response = $this->withHeaders([ 'Accept-Language' => 'foo', ])->get('/'); - $response->assertSee('', false); + $response->assertSeeHtml(''); } /** @@ -78,11 +79,11 @@ public function test_locale_of_authenticated_user() $response = $this->actingAs($user)->withHeaders([ 'Accept-Language' => '', ])->get('/'); - $response->assertSee('', false); + $response->assertSeeHtml(''); $user->update(['locale' => 'de']); $response = $this->actingAs($user)->get('/'); - $response->assertSee('', false); + $response->assertSeeHtml(''); } /** @@ -95,7 +96,7 @@ public function test_locale_persisted_in_session() $response = $this->session([ 'locale' => 'de', ])->get('/'); - $response->assertSee('', false); + $response->assertSeeHtml(''); } /** @@ -111,7 +112,7 @@ public function test_locale_in_header_and_session() ])->withHeaders([ 'Accept-Language' => 'fr', ])->get('/'); - $response->assertSee('', false); + $response->assertSeeHtml(''); } /** @@ -126,7 +127,7 @@ public function test_locale_in_header() $response = $this->withHeaders([ 'Accept-Language' => 'de', ])->get('/'); - $response->assertSee('', false); + $response->assertSeeHtml(''); } /** @@ -146,7 +147,7 @@ public function test_locale_different_locales_everywhere() ])->withHeaders([ 'Accept-Language' => 'be', ])->get('/'); - $response->assertSee('', false); + $response->assertSeeHtml(''); } /** @@ -161,7 +162,7 @@ public function test_set_locale() $response = $this->withHeaders([ 'Accept-Language' => '', ])->get('/'); - $response->assertSee('', false); + $response->assertSeeHtml(''); $response = $this->from(config('app.url'))->postJson(route('api.v1.locale.update'), [ 'locale' => 'us', @@ -175,7 +176,7 @@ public function test_set_locale() $response->assertOk(); $response = $this->get('/'); - $response->assertSee('', false); + $response->assertSeeHtml(''); } /** @@ -195,7 +196,7 @@ public function test_set_locale_updates_current_users_locale() ])->withHeaders([ 'Accept-Language' => 'be', ])->from(config('app.url'))->get('/'); - $response->assertSee('', false); + $response->assertSeeHtml(''); $response = $this->actingAs($user)->from(config('app.url'))->postJson(route('api.v1.locale.update'), [ 'locale' => 'de', @@ -203,7 +204,7 @@ public function test_set_locale_updates_current_users_locale() $response->assertOk(); $response = $this->actingAs($user)->from(config('app.url'))->get('/'); - $response->assertSee('', false); + $response->assertSeeHtml(''); $this->assertDatabaseHas('users', [ 'id' => $user->id, 'locale' => 'de', diff --git a/tests/Backend/Feature/api/v1/LoginTest.php b/tests/Backend/Feature/api/v1/LoginTest.php index eaa989477..0e500acae 100644 --- a/tests/Backend/Feature/api/v1/LoginTest.php +++ b/tests/Backend/Feature/api/v1/LoginTest.php @@ -17,6 +17,7 @@ class LoginTest extends TestCase { use RefreshDatabase, WithFaker; + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Feature/api/v1/MeetingTest.php b/tests/Backend/Feature/api/v1/MeetingTest.php index a87266069..c3c572df8 100644 --- a/tests/Backend/Feature/api/v1/MeetingTest.php +++ b/tests/Backend/Feature/api/v1/MeetingTest.php @@ -25,6 +25,7 @@ class MeetingTest extends TestCase /** * Setup ressources for all tests */ + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Feature/api/v1/PermissionTest.php b/tests/Backend/Feature/api/v1/PermissionTest.php index 9a8d22b7a..d384530ca 100644 --- a/tests/Backend/Feature/api/v1/PermissionTest.php +++ b/tests/Backend/Feature/api/v1/PermissionTest.php @@ -20,9 +20,7 @@ public function test_index() $this->getJson(route('api.v1.roles.index'))->assertStatus(401); $this->actingAs($user)->getJson(route('api.v1.permissions.index')) ->assertSuccessful() - ->assertJsonFragment(['data' => array_map(function ($permission) { - return ['id' => $permission['id'], 'name' => $permission['name'], 'included_permissions' => []]; - }, $permissions)]); + ->assertJsonFragment(['data' => array_map(fn ($permission) => ['id' => $permission['id'], 'name' => $permission['name'], 'included_permissions' => []], $permissions)]); } public function test_included_permissions_index() diff --git a/tests/Backend/Feature/api/v1/RecordingTest.php b/tests/Backend/Feature/api/v1/RecordingTest.php index c265d7ea5..21f84e119 100644 --- a/tests/Backend/Feature/api/v1/RecordingTest.php +++ b/tests/Backend/Feature/api/v1/RecordingTest.php @@ -39,6 +39,7 @@ class RecordingTest extends TestCase /** * Setup resources for all tests */ + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Feature/api/v1/ResetPasswordTest.php b/tests/Backend/Feature/api/v1/ResetPasswordTest.php index ef363d321..1cc3e5683 100644 --- a/tests/Backend/Feature/api/v1/ResetPasswordTest.php +++ b/tests/Backend/Feature/api/v1/ResetPasswordTest.php @@ -16,6 +16,7 @@ class ResetPasswordTest extends TestCase { use RefreshDatabase, WithFaker; + #[\Override] protected function setUp(): void { parent::setUp(); @@ -50,7 +51,7 @@ public function test_reset_password() return true; }); $query = []; - parse_str(parse_url($resetUrl, PHP_URL_QUERY), $query); + parse_str(parse_url((string) $resetUrl, PHP_URL_QUERY), $query); $this->postJson(route('api.v1.password.reset')) ->assertUnprocessable() diff --git a/tests/Backend/Feature/api/v1/RoleTest.php b/tests/Backend/Feature/api/v1/RoleTest.php index 03ec65ca7..34b53923e 100644 --- a/tests/Backend/Feature/api/v1/RoleTest.php +++ b/tests/Backend/Feature/api/v1/RoleTest.php @@ -17,6 +17,7 @@ class RoleTest extends TestCase public const INVALID_ID = 999999999; + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Feature/api/v1/Room/FileTest.php b/tests/Backend/Feature/api/v1/Room/FileTest.php index eefd26deb..6f4df7440 100644 --- a/tests/Backend/Feature/api/v1/Room/FileTest.php +++ b/tests/Backend/Feature/api/v1/Room/FileTest.php @@ -37,6 +37,7 @@ class FileTest extends TestCase protected $file_toobig; + #[\Override] protected function setUp(): void { parent::setUp(); @@ -463,7 +464,7 @@ public function test_download_for_bbb() \Auth::logout(); - $this->get((new RoomFileService($room_file))->url()) + $this->get(new RoomFileService($room_file)->url()) ->assertSuccessful(); } @@ -799,7 +800,7 @@ public function test_start_meeting_with_file() $request = $bbbfaker->getRequest(0); // Get xml from request (presentation data) - $xml = simplexml_load_string($request->body()); + $xml = simplexml_load_string((string) $request->body()); $downloadUrl = (string) $xml->module->document->attributes()->url; $fileName = (string) $xml->module->document->attributes()->filename; diff --git a/tests/Backend/Feature/api/v1/Room/MembershipTest.php b/tests/Backend/Feature/api/v1/Room/MembershipTest.php index ed655ef3d..61df7debb 100644 --- a/tests/Backend/Feature/api/v1/Room/MembershipTest.php +++ b/tests/Backend/Feature/api/v1/Room/MembershipTest.php @@ -24,6 +24,7 @@ class MembershipTest extends TestCase protected $viewAllPermission; + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Feature/api/v1/Room/RoomDescriptionTest.php b/tests/Backend/Feature/api/v1/Room/RoomDescriptionTest.php index e96a75d19..23c6bc094 100644 --- a/tests/Backend/Feature/api/v1/Room/RoomDescriptionTest.php +++ b/tests/Backend/Feature/api/v1/Room/RoomDescriptionTest.php @@ -32,6 +32,7 @@ class RoomDescriptionTest extends TestCase /** * Setup ressources for all tests */ + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Feature/api/v1/Room/RoomStatisticTest.php b/tests/Backend/Feature/api/v1/Room/RoomStatisticTest.php index ef3fa9968..60cdecade 100644 --- a/tests/Backend/Feature/api/v1/Room/RoomStatisticTest.php +++ b/tests/Backend/Feature/api/v1/Room/RoomStatisticTest.php @@ -35,6 +35,7 @@ class RoomStatisticTest extends TestCase /** * Setup resources for all tests */ + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Feature/api/v1/Room/RoomStreamingTest.php b/tests/Backend/Feature/api/v1/Room/RoomStreamingTest.php index 4cc30ace4..2d8b234ff 100644 --- a/tests/Backend/Feature/api/v1/Room/RoomStreamingTest.php +++ b/tests/Backend/Feature/api/v1/Room/RoomStreamingTest.php @@ -28,6 +28,7 @@ class RoomStreamingTest extends TestCase /** * Setup resources for all tests */ + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Feature/api/v1/Room/RoomTest.php b/tests/Backend/Feature/api/v1/Room/RoomTest.php index 669b701ca..dc9ad0fed 100644 --- a/tests/Backend/Feature/api/v1/Room/RoomTest.php +++ b/tests/Backend/Feature/api/v1/Room/RoomTest.php @@ -52,6 +52,7 @@ class RoomTest extends TestCase /** * Setup resources for all tests */ + #[\Override] protected function setUp(): void { parent::setUp(); @@ -1303,9 +1304,9 @@ public function test_room_list() foreach ($results->json('data') as $room) { if ($room['id'] == $roomPrivateExpert1->id) { - self::assertNull($room['last_meeting']['end']); + $this->assertNull($room['last_meeting']['end']); } else { - self::assertNull($room['last_meeting']); + $this->assertNull($room['last_meeting']); } } @@ -1552,9 +1553,9 @@ public function test_end_meeting_callback() $meeting->start = date('Y-m-d H:i:s'); $meeting->save(); - self::assertNull($meeting->end); + $this->assertNull($meeting->end); - $url = (new MeetingService($meeting))->getCallbackUrl(); + $url = new MeetingService($meeting)->getCallbackUrl(); // check with invalid salt $this->getJson($url.'test') @@ -1566,7 +1567,7 @@ public function test_end_meeting_callback() // Check if timestamp was set $meeting->refresh(); - self::assertNotNull($meeting->end); + $this->assertNotNull($meeting->end); // Check if RoomEnded Event is called Event::assertDispatched(RoomEnded::class); @@ -1578,7 +1579,7 @@ public function test_end_meeting_callback() ->assertSuccessful(); $meeting->refresh(); - self::assertEquals($meeting->end, $end); + $this->assertEquals($meeting->end, $end); } public function test_settings_access() @@ -2103,7 +2104,7 @@ public function test_update_settings_expert() // Check if correct setting values get returned $new_settings = $response->json('data'); - $settings['room_type'] = (new RoomTypeResource($roomType))->withDefaultRoomSettings()->withFeatures(); + $settings['room_type'] = new RoomTypeResource($roomType)->withDefaultRoomSettings()->withFeatures(); $settings['allow_membership'] = false; $settings['everyone_can_start'] = false; $settings['lock_settings_disable_cam'] = true; @@ -2738,7 +2739,7 @@ public function test_start_with_server() $this->assertNull($room->delete_inactive); // Clear - (new MeetingService($room->latestMeeting))->end(); + new MeetingService($room->latestMeeting)->end(); // Create meeting without agreement to record attendance $this->actingAs($room->owner)->postJson(route('api.v1.rooms.start', ['room' => $room]), ['consent_record_attendance' => false, 'consent_record' => false, 'consent_record_video' => false]) @@ -2758,7 +2759,7 @@ public function test_start_with_server() // Clear $room->refresh(); - (new MeetingService($room->latestMeeting))->end(); + new MeetingService($room->latestMeeting)->end(); // Room token moderator Auth::logout(); @@ -2772,13 +2773,13 @@ public function test_start_with_server() $response = $this->withHeaders(['Token' => $moderatorToken->token]) ->postJson(route('api.v1.rooms.start', ['room' => $room]), ['name' => 'Max Mustermann', 'consent_record_attendance' => false, 'consent_record' => false, 'consent_record_video' => false]); - $url_components = parse_url($response['url']); + $url_components = parse_url((string) $response['url']); parse_str($url_components['query'], $params); $this->assertEquals('John Doe', $params['fullName']); // Clear $room->refresh(); - (new MeetingService($room->latestMeeting))->end(); + new MeetingService($room->latestMeeting)->end(); $this->flushHeaders(); @@ -2811,13 +2812,13 @@ public function test_start_with_server() $response = $this->withHeaders(['Token' => $userToken->token]) ->postJson(route('api.v1.rooms.start', ['room' => $room]), ['consent_record_attendance' => false, 'consent_record' => false, 'consent_record_video' => false]); - $url_components = parse_url($response['url']); + $url_components = parse_url((string) $response['url']); parse_str($url_components['query'], $params); $this->assertEquals('John Doe', $params['fullName']); // Clear $room->refresh(); - (new MeetingService($room->latestMeeting))->end(); + new MeetingService($room->latestMeeting)->end(); $this->flushHeaders(); @@ -2825,13 +2826,13 @@ public function test_start_with_server() $response = $this->withHeaders(['Token' => $userToken->token]) ->actingAs($this->user) ->postJson(route('api.v1.rooms.start', ['room' => $room]), ['consent_record_attendance' => false, 'consent_record' => false, 'consent_record_video' => false]); - $url_components = parse_url($response['url']); + $url_components = parse_url((string) $response['url']); parse_str($url_components['query'], $params); $this->assertEquals($this->user->fullName, $params['fullName']); // Clear $room->refresh(); - (new MeetingService($room->latestMeeting))->end(); + new MeetingService($room->latestMeeting)->end(); $this->flushHeaders(); @@ -3060,7 +3061,7 @@ public function test_start_while_starting() ->assertStatus(462); $lock->release(); - } catch (LockTimeoutException $e) { + } catch (LockTimeoutException) { $this->fail('lock did not work'); } } @@ -3241,7 +3242,7 @@ public function test_join() $response = $this->withHeaders(['Access-Code' => $room->access_code])->postJson(route('api.v1.rooms.join', ['room' => $room]), ['name' => $this->faker->name, 'consent_record_attendance' => true, 'consent_record' => false, 'consent_record_video' => false]) ->assertSuccessful(); $queryParams = []; - parse_str(parse_url($response->json('url'))['query'], $queryParams); + parse_str(parse_url((string) $response->json('url'))['query'], $queryParams); $this->assertEquals('false', $queryParams['userdata-bbb_skip_check_audio']); $this->flushHeaders(); @@ -3259,7 +3260,7 @@ public function test_join() $response = $this->withHeaders(['Token' => $moderatorToken->token]) ->postJson(route('api.v1.rooms.join', ['room' => $room]), ['name' => 'Max Mustermann', 'consent_record_attendance' => true, 'consent_record' => false, 'consent_record_video' => false]) ->assertSuccessful(); - $url_components = parse_url($response['url']); + $url_components = parse_url((string) $response['url']); parse_str($url_components['query'], $params); $this->assertEquals('John Doe', $params['fullName']); $this->flushHeaders(); @@ -3275,7 +3276,7 @@ public function test_join() $response = $this->withHeaders(['Token' => $userToken->token]) ->postJson(route('api.v1.rooms.join', ['room' => $room]), ['consent_record_attendance' => true, 'consent_record' => false, 'consent_record_video' => false]) ->assertSuccessful(); - $url_components = parse_url($response['url']); + $url_components = parse_url((string) $response['url']); parse_str($url_components['query'], $params); $this->assertEquals('John Doe', $params['fullName']); $this->flushHeaders(); @@ -3284,7 +3285,7 @@ public function test_join() $response = $this->actingAs($this->user)->withHeaders(['Access-Code' => $room->access_code, 'Token' => $userToken->token]) ->postJson(route('api.v1.rooms.join', ['room' => $room]), ['consent_record_attendance' => true, 'consent_record' => false, 'consent_record_video' => false]) ->assertSuccessful(); - $url_components = parse_url($response['url']); + $url_components = parse_url((string) $response['url']); parse_str($url_components['query'], $params); $this->assertEquals($this->user->fullName, $params['fullName']); $this->flushHeaders(); @@ -3438,7 +3439,7 @@ public function test_join_url() $response = $this->postJson(route('api.v1.rooms.join', ['room' => $room]), ['name' => $guestName, 'consent_record_attendance' => true, 'consent_record' => false, 'consent_record_video' => false]) ->assertSuccessful(); $queryParams = []; - parse_str(parse_url($response->json('url'))['query'], $queryParams); + parse_str(parse_url((string) $response->json('url'))['query'], $queryParams); $this->assertEquals('VIEWER', $queryParams['role']); $this->assertEquals('true', $queryParams['guest']); $this->assertEquals($guestName, $queryParams['fullName']); @@ -3453,7 +3454,7 @@ public function test_join_url() $response = $this->actingAs($this->user)->postJson(route('api.v1.rooms.join', ['room' => $room]), ['consent_record_attendance' => true, 'consent_record' => false, 'consent_record_video' => false]) ->assertSuccessful(); $queryParams = []; - parse_str(parse_url($response->json('url'))['query'], $queryParams); + parse_str(parse_url((string) $response->json('url'))['query'], $queryParams); $this->assertEquals('VIEWER', $queryParams['role']); $this->assertEquals($this->user->fullname, $queryParams['fullName']); // Check if avatarURL is set, if profile image exists @@ -3465,7 +3466,7 @@ public function test_join_url() $response = $this->actingAs($room->owner)->postJson(route('api.v1.rooms.join', ['room' => $room]), ['consent_record_attendance' => true, 'consent_record' => false, 'consent_record_video' => false]) ->assertSuccessful(); $queryParams = []; - parse_str(parse_url($response->json('url'))['query'], $queryParams); + parse_str(parse_url((string) $response->json('url'))['query'], $queryParams); $this->assertEquals('MODERATOR', $queryParams['role']); // Check if avatarURL empty, if no profile image is set $this->assertFalse(isset($queryParams['avatarURL'])); @@ -3475,7 +3476,7 @@ public function test_join_url() $response = $this->actingAs($this->user)->postJson(route('api.v1.rooms.join', ['room' => $room]), ['consent_record_attendance' => true, 'consent_record' => false, 'consent_record_video' => false]) ->assertSuccessful(); $queryParams = []; - parse_str(parse_url($response->json('url'))['query'], $queryParams); + parse_str(parse_url((string) $response->json('url'))['query'], $queryParams); $this->assertEquals('VIEWER', $queryParams['role']); // Testing member moderator @@ -3483,7 +3484,7 @@ public function test_join_url() $response = $this->actingAs($this->user)->postJson(route('api.v1.rooms.join', ['room' => $room]), ['consent_record_attendance' => true, 'consent_record' => false, 'consent_record_video' => false]) ->assertSuccessful(); $queryParams = []; - parse_str(parse_url($response->json('url'))['query'], $queryParams); + parse_str(parse_url((string) $response->json('url'))['query'], $queryParams); $this->assertEquals('MODERATOR', $queryParams['role']); // Testing member co-owner @@ -3491,7 +3492,7 @@ public function test_join_url() $response = $this->actingAs($this->user)->postJson(route('api.v1.rooms.join', ['room' => $room]), ['consent_record_attendance' => true, 'consent_record' => false, 'consent_record_video' => false]) ->assertSuccessful(); $queryParams = []; - parse_str(parse_url($response->json('url'))['query'], $queryParams); + parse_str(parse_url((string) $response->json('url'))['query'], $queryParams); $this->assertEquals('MODERATOR', $queryParams['role']); // Reset room membership @@ -3503,7 +3504,7 @@ public function test_join_url() $response = $this->actingAs($this->user)->postJson(route('api.v1.rooms.join', ['room' => $room]), ['consent_record_attendance' => true, 'consent_record' => false, 'consent_record_video' => false]) ->assertSuccessful(); $queryParams = []; - parse_str(parse_url($response->json('url'))['query'], $queryParams); + parse_str(parse_url((string) $response->json('url'))['query'], $queryParams); $this->assertEquals('VIEWER', $queryParams['role']); $this->role->permissions()->detach($this->viewAllPermission); @@ -3513,7 +3514,7 @@ public function test_join_url() $response = $this->actingAs($this->user)->postJson(route('api.v1.rooms.join', ['room' => $room]), ['consent_record_attendance' => true, 'consent_record' => false, 'consent_record_video' => false]) ->assertSuccessful(); $queryParams = []; - parse_str(parse_url($response->json('url'))['query'], $queryParams); + parse_str(parse_url((string) $response->json('url'))['query'], $queryParams); $this->assertEquals('MODERATOR', $queryParams['role']); $this->role->permissions()->detach($this->managePermission); } diff --git a/tests/Backend/Feature/api/v1/Room/RoomTokenTest.php b/tests/Backend/Feature/api/v1/Room/RoomTokenTest.php index e8218a65e..28fa4adee 100644 --- a/tests/Backend/Feature/api/v1/Room/RoomTokenTest.php +++ b/tests/Backend/Feature/api/v1/Room/RoomTokenTest.php @@ -24,6 +24,7 @@ class RoomTokenTest extends TestCase /** * Setup resources for all tests */ + #[\Override] protected function setUp(): void { parent::setUp(); @@ -116,12 +117,12 @@ public function test_index() // Check expire date $results = $this->actingAs($this->user)->getJson(route('api.v1.rooms.tokens.get', ['room' => $this->room]))->json('data'); $token = RoomToken::find($results[0]['token']); - self::assertEquals($token->created_at->addDays(90)->toISOString(), $results[0]['expires']); + $this->assertEquals($token->created_at->addDays(90)->toISOString(), $results[0]['expires']); $this->roomSettings->token_expiration = TimePeriod::UNLIMITED; $this->roomSettings->save(); $results = $this->actingAs($this->user)->getJson(route('api.v1.rooms.tokens.get', ['room' => $this->room]))->json('data'); - self::assertNull($results[0]['expires']); + $this->assertNull($results[0]['expires']); // Check default sorting / fallback (firstname asc) $this->actingAs($this->user)->getJson(route('api.v1.rooms.tokens.get', ['room' => $this->room])) diff --git a/tests/Backend/Feature/api/v1/RoomTypeTest.php b/tests/Backend/Feature/api/v1/RoomTypeTest.php index 366df80d0..46ee7f047 100644 --- a/tests/Backend/Feature/api/v1/RoomTypeTest.php +++ b/tests/Backend/Feature/api/v1/RoomTypeTest.php @@ -29,6 +29,7 @@ class RoomTypeTest extends TestCase /** * Setup ressources for all tests */ + #[\Override] protected function setUp(): void { parent::setUp(); @@ -173,16 +174,6 @@ public function test_index() 'enabled' => true, ], ], - ], - [ - 'id' => $roomTypePublicEnforced->id, - 'name' => $roomTypePublicEnforced->name, - 'color' => $roomTypePublicEnforced->color, - 'features' => [ - 'streaming' => [ - 'enabled' => false, - ], - ], ] ) ->assertJsonCount(4, 'data'); diff --git a/tests/Backend/Feature/api/v1/ServerPoolTest.php b/tests/Backend/Feature/api/v1/ServerPoolTest.php index 58a56d404..5bf537622 100644 --- a/tests/Backend/Feature/api/v1/ServerPoolTest.php +++ b/tests/Backend/Feature/api/v1/ServerPoolTest.php @@ -26,6 +26,7 @@ class ServerPoolTest extends TestCase /** * Setup resources for all tests */ + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Feature/api/v1/ServerTest.php b/tests/Backend/Feature/api/v1/ServerTest.php index 32fd5223d..a490160ee 100644 --- a/tests/Backend/Feature/api/v1/ServerTest.php +++ b/tests/Backend/Feature/api/v1/ServerTest.php @@ -29,6 +29,7 @@ class ServerTest extends TestCase /** * Setup resources for all tests */ + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Feature/api/v1/SessionTest.php b/tests/Backend/Feature/api/v1/SessionTest.php index 8a3a291d2..39be905fe 100644 --- a/tests/Backend/Feature/api/v1/SessionTest.php +++ b/tests/Backend/Feature/api/v1/SessionTest.php @@ -22,6 +22,7 @@ class SessionTest extends TestCase protected $otherUserSession; + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Feature/api/v1/SettingsTest.php b/tests/Backend/Feature/api/v1/SettingsTest.php index 2b201a90b..9fafc94ab 100644 --- a/tests/Backend/Feature/api/v1/SettingsTest.php +++ b/tests/Backend/Feature/api/v1/SettingsTest.php @@ -27,6 +27,7 @@ class SettingsTest extends TestCase /** * Setup resources for all tests */ + #[\Override] protected function setUp(): void { parent::setUp(); @@ -110,9 +111,7 @@ public function test_view_settings() $role->permissions()->attach(Permission::where('name', 'settings.viewAny')->first()); $this->user->roles()->attach($role); - $linkStyles = array_filter(LinkButtonStyle::cases(), function ($style) { - return ! in_array($style, LinkButtonStyle::getDeprecated()); - }); + $linkStyles = array_filter(LinkButtonStyle::cases(), fn ($style) => ! in_array($style, LinkButtonStyle::getDeprecated())); $this->getJson(route('api.v1.settings.view')) ->assertJson([ diff --git a/tests/Backend/Feature/api/v1/ShibbolethTest.php b/tests/Backend/Feature/api/v1/ShibbolethTest.php index 20f0c8dbd..de34ee8e8 100644 --- a/tests/Backend/Feature/api/v1/ShibbolethTest.php +++ b/tests/Backend/Feature/api/v1/ShibbolethTest.php @@ -81,11 +81,12 @@ class ShibbolethTest extends TestCase /** * Setup resources for all tests */ + #[\Override] protected function setUp(): void { parent::setUp(); Config::set('services.shibboleth.enabled', true); - Config::set('services.shibboleth.mapping', json_decode($this->mapping)); + Config::set('services.shibboleth.mapping', json_decode((string) $this->mapping)); Config::set('app.enabled_locales', ['de' => ['name' => 'Deutsch', 'dateTimeFormat' => []], 'en' => ['name' => 'English', 'dateTimeFormat' => []], 'fr' => ['name' => 'Français', 'dateTimeFormat' => []]]); Role::factory()->create(['name' => 'admin']); diff --git a/tests/Backend/Feature/api/v1/StreamingTest.php b/tests/Backend/Feature/api/v1/StreamingTest.php index 737d7b05e..c8d23e7cf 100644 --- a/tests/Backend/Feature/api/v1/StreamingTest.php +++ b/tests/Backend/Feature/api/v1/StreamingTest.php @@ -16,6 +16,7 @@ class StreamingTest extends TestCase { use RefreshDatabase, WithFaker; + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Feature/api/v1/UserTest.php b/tests/Backend/Feature/api/v1/UserTest.php index cb246d846..6acc80e06 100644 --- a/tests/Backend/Feature/api/v1/UserTest.php +++ b/tests/Backend/Feature/api/v1/UserTest.php @@ -774,7 +774,7 @@ function ($notification, $channels, $notifiable) use ($user, $newEmail, &$verifi } ); $query = []; - parse_str(parse_url($verificationUrl, PHP_URL_QUERY), $query); + parse_str(parse_url((string) $verificationUrl, PHP_URL_QUERY), $query); // Try to verify email as unauthenticated user Auth::logout(); @@ -822,9 +822,7 @@ function ($notification, $channels, $notifiable) use ($user, $newEmail, &$verifi // Check if notification is sent to old email Notification::assertSentOnDemand( EmailChanged::class, - function ($notification, $channels, $notifiable) use ($user, $email) { - return $notifiable->routes['mail'] === [$email => $user->fullname]; - } + fn ($notification, $channels, $notifiable) => $notifiable->routes['mail'] === [$email => $user->fullname] ); // Try to change email with same email @@ -888,9 +886,7 @@ public function test_change_email_admin() // Check if notification is sent to old email Notification::assertSentOnDemand( EmailChanged::class, - function ($notification, $channels, $notifiable) use ($user, $email) { - return $notifiable->routes['mail'] === [$email => $user->fullname]; - } + fn ($notification, $channels, $notifiable) => $notifiable->routes['mail'] === [$email => $user->fullname] ); // Check rate limiter does not affect admin diff --git a/tests/Backend/Integration/api/v1/RoomFileTest.php b/tests/Backend/Integration/api/v1/RoomFileTest.php index ee9235bf7..211f282e0 100644 --- a/tests/Backend/Integration/api/v1/RoomFileTest.php +++ b/tests/Backend/Integration/api/v1/RoomFileTest.php @@ -48,6 +48,6 @@ public function test_start_meeting_with_file() // Clear $room->refresh(); - (new MeetingService($room->latestMeeting))->end(); + new MeetingService($room->latestMeeting)->end(); } } diff --git a/tests/Backend/Integration/api/v1/RoomTest.php b/tests/Backend/Integration/api/v1/RoomTest.php index 06a650fd2..79604b0b3 100644 --- a/tests/Backend/Integration/api/v1/RoomTest.php +++ b/tests/Backend/Integration/api/v1/RoomTest.php @@ -31,6 +31,7 @@ class RoomTest extends TestCase /** * Setup ressources for all tests */ + #[\Override] protected function setUp(): void { parent::setUp(); @@ -127,9 +128,9 @@ public function test_lobby_enabled_enforced() $room1->refresh(); $room2->refresh(); $room3->refresh(); - (new MeetingService($room1->latestMeeting))->end(); - (new MeetingService($room2->latestMeeting))->end(); - (new MeetingService($room3->latestMeeting))->end(); + new MeetingService($room1->latestMeeting)->end(); + new MeetingService($room2->latestMeeting)->end(); + new MeetingService($room3->latestMeeting)->end(); } /** @@ -202,8 +203,8 @@ public function test_lobby_enabled_expert_mode() // Clear $room1->refresh(); $room2->refresh(); - (new MeetingService($room1->latestMeeting))->end(); - (new MeetingService($room2->latestMeeting))->end(); + new MeetingService($room1->latestMeeting)->end(); + new MeetingService($room2->latestMeeting)->end(); } /** @@ -254,7 +255,7 @@ public function test_lobby_enabled_without_expert_mode() // Clear $room->refresh(); - (new MeetingService($room->latestMeeting))->end(); + new MeetingService($room->latestMeeting)->end(); } /** @@ -340,9 +341,9 @@ public function test_lobby_only_guests_enforced() $room1->refresh(); $room2->refresh(); $room3->refresh(); - (new MeetingService($room1->latestMeeting))->end(); - (new MeetingService($room2->latestMeeting))->end(); - (new MeetingService($room3->latestMeeting))->end(); + new MeetingService($room1->latestMeeting)->end(); + new MeetingService($room2->latestMeeting)->end(); + new MeetingService($room3->latestMeeting)->end(); } /** @@ -415,8 +416,8 @@ public function test_lobby_only_guests_expert_mode() // Clear $room1->refresh(); $room2->refresh(); - (new MeetingService($room1->latestMeeting))->end(); - (new MeetingService($room2->latestMeeting))->end(); + new MeetingService($room1->latestMeeting)->end(); + new MeetingService($room2->latestMeeting)->end(); } /** @@ -467,7 +468,7 @@ public function test_lobby_only_guests_without_expert_mode() // Clear $room->refresh(); - (new MeetingService($room->latestMeeting))->end(); + new MeetingService($room->latestMeeting)->end(); } /** diff --git a/tests/Backend/TestCase.php b/tests/Backend/TestCase.php index 6ee74f1c0..61d3595ba 100644 --- a/tests/Backend/TestCase.php +++ b/tests/Backend/TestCase.php @@ -21,6 +21,7 @@ abstract class TestCase extends BaseTestCase * * @return \Illuminate\Foundation\Application */ + #[\Override] public function createApplication() { $app = require __DIR__.'/../../bootstrap/app.php'; @@ -46,6 +47,7 @@ public function createApplication() public StreamingSettings $streamingSettings; + #[\Override] protected function setUp(): void { if (! defined('LARAVEL_START')) { @@ -71,6 +73,7 @@ protected function initSettings() $this->streamingSettings = app(StreamingSettings::class); } + #[\Override] protected function tearDown(): void { DirectoryEmulator::teardown(); diff --git a/tests/Backend/Unit/Console/CreateSuperuserTest.php b/tests/Backend/Unit/Console/CreateSuperuserTest.php index 37db08dcc..c54764c04 100644 --- a/tests/Backend/Unit/Console/CreateSuperuserTest.php +++ b/tests/Backend/Unit/Console/CreateSuperuserTest.php @@ -14,6 +14,7 @@ class CreateSuperuserTest extends TestCase /** * @see TestCase::setUp() */ + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Unit/Console/DeleteObsoleteTokensTest.php b/tests/Backend/Unit/Console/DeleteObsoleteTokensTest.php index 07f71149c..4c06e91b1 100644 --- a/tests/Backend/Unit/Console/DeleteObsoleteTokensTest.php +++ b/tests/Backend/Unit/Console/DeleteObsoleteTokensTest.php @@ -16,6 +16,7 @@ class DeleteObsoleteTokensTest extends TestCase /** * @see TestCase::setUp() */ + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Unit/Console/DeleteUnverifiedNewUsersTest.php b/tests/Backend/Unit/Console/DeleteUnverifiedNewUsersTest.php index df1fc2508..dbb8fd7c6 100644 --- a/tests/Backend/Unit/Console/DeleteUnverifiedNewUsersTest.php +++ b/tests/Backend/Unit/Console/DeleteUnverifiedNewUsersTest.php @@ -16,6 +16,7 @@ class DeleteUnverifiedNewUsersTest extends TestCase /** * @see TestCase::setUp() */ + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Unit/Console/ImportGreenlight2Test.php b/tests/Backend/Unit/Console/ImportGreenlight2Test.php index fa34468c2..4242fb3a0 100644 --- a/tests/Backend/Unit/Console/ImportGreenlight2Test.php +++ b/tests/Backend/Unit/Console/ImportGreenlight2Test.php @@ -27,6 +27,7 @@ class ImportGreenlight2Test extends TestCase /** * @see TestCase::setUp() */ + #[\Override] protected function setUp(): void { parent::setUp(); @@ -60,14 +61,14 @@ private function fakeDatabase(bool $roomAuth, Collection $users, Collection $roo // mock connection to greenlight postgres database and queries DB::shouldReceive('connection') ->with('greenlight') - ->andReturn(Mockery::mock('Illuminate\Database\Connection', function ($mock) use ($sharedAccesses, $rooms, $users, $roomAuth) { + ->andReturn(Mockery::mock(\Illuminate\Database\Connection::class, function ($mock) use ($sharedAccesses, $rooms, $users, $roomAuth): void { $mock->shouldReceive('table') ->with('features') ->once() - ->andReturn(Mockery::mock('Illuminate\Database\Query\Builder', function ($mock) use ($roomAuth) { + ->andReturn(Mockery::mock(\Illuminate\Database\Query\Builder::class, function ($mock) use ($roomAuth): void { $mock->shouldReceive('where') ->with('name', 'Room Authentication') - ->andReturn(Mockery::mock('Illuminate\Database\Query\Builder', function ($mock) use ($roomAuth) { + ->andReturn(Mockery::mock(\Illuminate\Database\Query\Builder::class, function ($mock) use ($roomAuth): void { $mock->shouldReceive('first') ->with('value') ->andReturn((object) ['value' => $roomAuth]); @@ -77,10 +78,10 @@ private function fakeDatabase(bool $roomAuth, Collection $users, Collection $roo $mock->shouldReceive('table') ->with('users') ->once() - ->andReturn(Mockery::mock('Illuminate\Database\Query\Builder', function ($mock) use ($users) { + ->andReturn(Mockery::mock(\Illuminate\Database\Query\Builder::class, function ($mock) use ($users): void { $mock->shouldReceive('where') ->with('deleted', false) - ->andReturn(Mockery::mock('Illuminate\Database\Query\Builder', function ($mock) use ($users) { + ->andReturn(Mockery::mock(\Illuminate\Database\Query\Builder::class, function ($mock) use ($users): void { $mock->shouldReceive('get') ->with(['id', 'provider', 'username', 'social_uid', 'email', 'name', 'password_digest']) ->andReturn($users); @@ -90,10 +91,10 @@ private function fakeDatabase(bool $roomAuth, Collection $users, Collection $roo $mock->shouldReceive('table') ->with('rooms') ->once() - ->andReturn(Mockery::mock('Illuminate\Database\Query\Builder', function ($mock) use ($rooms) { + ->andReturn(Mockery::mock(\Illuminate\Database\Query\Builder::class, function ($mock) use ($rooms): void { $mock->shouldReceive('where') ->with('deleted', false) - ->andReturn(Mockery::mock('Illuminate\Database\Query\Builder', function ($mock) use ($rooms) { + ->andReturn(Mockery::mock(\Illuminate\Database\Query\Builder::class, function ($mock) use ($rooms): void { $mock->shouldReceive('get') ->with(['id', 'uid', 'user_id', 'name', 'room_settings', 'access_code']) ->andReturn($rooms); @@ -103,7 +104,7 @@ private function fakeDatabase(bool $roomAuth, Collection $users, Collection $roo $mock->shouldReceive('table') ->with('shared_accesses') ->once() - ->andReturn(Mockery::mock('Illuminate\Database\Query\Builder', function ($mock) use ($sharedAccesses) { + ->andReturn(Mockery::mock(\Illuminate\Database\Query\Builder::class, function ($mock) use ($sharedAccesses): void { $mock->shouldReceive('get') ->with(['room_id', 'user_id']) ->andReturn($sharedAccesses); @@ -112,19 +113,17 @@ private function fakeDatabase(bool $roomAuth, Collection $users, Collection $roo $mock->shouldReceive('table') ->with('users') ->once() - ->andReturn(Mockery::mock('Illuminate\Database\Query\Builder', function ($mock) use ($users) { + ->andReturn(Mockery::mock(\Illuminate\Database\Query\Builder::class, function ($mock) use ($users): void { $mock->shouldReceive('select') ->with('provider') - ->andReturn(Mockery::mock('Illuminate\Database\Query\Builder', function ($mock) use ($users) { + ->andReturn(Mockery::mock(\Illuminate\Database\Query\Builder::class, function ($mock) use ($users): void { $mock->shouldReceive('whereNotIn') ->with('provider', ['greenlight', 'ldap']) - ->andReturn(Mockery::mock('Illuminate\Database\Query\Builder', function ($mock) use ($users) { + ->andReturn(Mockery::mock(\Illuminate\Database\Query\Builder::class, function ($mock) use ($users): void { $mock->shouldReceive('distinct') - ->andReturn(Mockery::mock('Illuminate\Database\Query\Builder', function ($mock) use ($users) { + ->andReturn(Mockery::mock(\Illuminate\Database\Query\Builder::class, function ($mock) use ($users): void { $mock->shouldReceive('get') - ->andReturn($users->unique('provider')->whereNotIn('provider', ['greenlight', 'ldap'])->map(function ($user) { - return (object) ['provider' => $user->provider]; - })); + ->andReturn($users->unique('provider')->whereNotIn('provider', ['greenlight', 'ldap'])->map(fn ($user) => (object) ['provider' => $user->provider])); })); })); })); diff --git a/tests/Backend/Unit/Console/LocalesCacheTest.php b/tests/Backend/Unit/Console/LocalesCacheTest.php index 49c5a0a71..638aab636 100644 --- a/tests/Backend/Unit/Console/LocalesCacheTest.php +++ b/tests/Backend/Unit/Console/LocalesCacheTest.php @@ -17,7 +17,7 @@ class LocalesCacheTest extends TestCase */ public function test_locales_cache() { - $mock = $this->partialMock(LocaleService::class, function (MockInterface $mock) { + $mock = $this->partialMock(LocaleService::class, function (MockInterface $mock): void { $mock->shouldReceive('buildCache') ->once() ->with() diff --git a/tests/Backend/Unit/Console/helper/GreenlightSharedAccess.php b/tests/Backend/Unit/Console/helper/GreenlightSharedAccess.php index af04e03d6..13c630bba 100644 --- a/tests/Backend/Unit/Console/helper/GreenlightSharedAccess.php +++ b/tests/Backend/Unit/Console/helper/GreenlightSharedAccess.php @@ -4,19 +4,8 @@ class GreenlightSharedAccess { - public $id; - - public $room_id; - - public $user_id; - /** * GreenlightSharedAccess constructor. */ - public function __construct($id, $room_id, $user_id) - { - $this->id = $id; - $this->room_id = $room_id; - $this->user_id = $user_id; - } + public function __construct(public $id, public $room_id, public $user_id) {} } diff --git a/tests/Backend/Unit/Console/helper/GreenlightUser.php b/tests/Backend/Unit/Console/helper/GreenlightUser.php index 8ccfe4c21..176c60298 100644 --- a/tests/Backend/Unit/Console/helper/GreenlightUser.php +++ b/tests/Backend/Unit/Console/helper/GreenlightUser.php @@ -4,31 +4,8 @@ class GreenlightUser { - public $id; - - public $provider; - - public $name; - - public $username; - - public $social_uid; - - public $email; - - public $password_digest; - /** * GreenlightUser constructor. */ - public function __construct($id, $provider, $name, $username, $social_uid, $email, $password_digest) - { - $this->id = $id; - $this->provider = $provider; - $this->name = $name; - $this->username = $username; - $this->social_uid = $social_uid; - $this->email = $email; - $this->password_digest = $password_digest; - } + public function __construct(public $id, public $provider, public $name, public $username, public $social_uid, public $email, public $password_digest) {} } diff --git a/tests/Backend/Unit/EnsureModelNotStaleTest.php b/tests/Backend/Unit/EnsureModelNotStaleTest.php index 3ea5ffdb2..ab6eea5fa 100644 --- a/tests/Backend/Unit/EnsureModelNotStaleTest.php +++ b/tests/Backend/Unit/EnsureModelNotStaleTest.php @@ -13,6 +13,7 @@ class EnsureModelNotStaleTest extends TestCase { use RefreshDatabase; + #[\Override] protected function setUp(): void { putenv('DISABLE_CATCHALL_ROUTES=true'); @@ -22,12 +23,11 @@ protected function setUp(): void \Route::post('api/test/{role}', [ 'middleware' => ['api', 'check.stale:role,\App\Http\Resources\Role,withPermissions'], 'as' => 'test.stale.check', - function (Role $role) { - return 'OK'; - }, + fn (Role $role) => 'OK', ]); } + #[\Override] protected function tearDown(): void { putenv('DISABLE_CATCHALL_ROUTES'); @@ -49,11 +49,11 @@ public function test_stale_model() $this->postJson(route('test.stale.check', ['role' => $role]), ['name' => 'foo', 'updated_at' => $role->updated_at->sub(new DateInterval('P1D'))]) ->assertStatus(CustomStatusCodes::STALE_MODEL->value) - ->assertJsonFragment(['new_model' => json_decode((new \App\HTTP\Resources\Role(Role::find($role->id)))->withPermissions()->toJson(), true)]); + ->assertJsonFragment(['new_model' => json_decode(new \App\HTTP\Resources\Role(Role::find($role->id))->withPermissions()->toJson(), true)]); $this->postJson(route('test.stale.check', ['role' => $role]), ['name' => 'foo', 'updated_at' => null]) ->assertStatus(CustomStatusCodes::STALE_MODEL->value) - ->assertJsonFragment(['new_model' => json_decode((new \App\HTTP\Resources\Role(Role::find($role->id)))->withPermissions()->toJson(), true)]); + ->assertJsonFragment(['new_model' => json_decode(new \App\HTTP\Resources\Role(Role::find($role->id))->withPermissions()->toJson(), true)]); } public function test_actual_model() diff --git a/tests/Backend/Unit/ExternalUserTest.php b/tests/Backend/Unit/ExternalUserTest.php index af4dd9fca..b9f79a3bb 100644 --- a/tests/Backend/Unit/ExternalUserTest.php +++ b/tests/Backend/Unit/ExternalUserTest.php @@ -15,6 +15,7 @@ class ExternalUserTest extends TestCase { use RefreshDatabase; + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Unit/Jobs/ProcessRecordingTest.php b/tests/Backend/Unit/Jobs/ProcessRecordingTest.php index 761e14940..d2a969764 100644 --- a/tests/Backend/Unit/Jobs/ProcessRecordingTest.php +++ b/tests/Backend/Unit/Jobs/ProcessRecordingTest.php @@ -39,12 +39,12 @@ public function test_process_invalid_recording_file() copy(base_path('tests/Backend/Fixtures/Recordings/invalid-recording.tar'), Storage::disk('recordings-spool')->path('invalid-recording.tar')); - $job = (new ProcessRecording('invalid-recording.tar'))->withFakeQueueInteractions(); + $job = new ProcessRecording('invalid-recording.tar')->withFakeQueueInteractions(); $failed = false; try { $job->handle(); - } catch (RecordingExtractionFailed $e) { + } catch (RecordingExtractionFailed) { $failed = true; } @@ -68,7 +68,7 @@ public function test_process_valid_recording_file_but_not_meeting() $this->assertCount(1, Storage::disk('recordings-spool')->files('')); $this->assertCount(0, Storage::disk('recordings-spool')->files('failed')); - $job = (new ProcessRecording('notes.tar'))->withFakeQueueInteractions(); + $job = new ProcessRecording('notes.tar')->withFakeQueueInteractions(); $job->handle(); @@ -93,7 +93,7 @@ public function test_missing_file() Log::swap(new LogFake); Queue::fake(); - $job = (new ProcessRecording('notes.tar'))->withFakeQueueInteractions(); + $job = new ProcessRecording('notes.tar')->withFakeQueueInteractions(); $job->handle(); @@ -122,7 +122,7 @@ public function test_retry_failed_job() $this->assertCount(1, Storage::disk('recordings-spool')->files('failed')); $this->assertCount(0, Storage::disk('recordings-spool')->files('')); - $job = (new ProcessRecording('notes.tar'))->withFakeQueueInteractions(); + $job = new ProcessRecording('notes.tar')->withFakeQueueInteractions(); $job->handle(); @@ -149,7 +149,7 @@ public function test_single_format() $this->assertCount(1, Storage::disk('recordings-spool')->files('')); - $job = (new ProcessRecording('notes.tar'))->withFakeQueueInteractions(); + $job = new ProcessRecording('notes.tar')->withFakeQueueInteractions(); $job->handle(); @@ -194,7 +194,7 @@ public function test_multiple_formats() $this->assertCount(1, Storage::disk('recordings-spool')->files('')); - $job = (new ProcessRecording('multiple.tar'))->withFakeQueueInteractions(); + $job = new ProcessRecording('multiple.tar')->withFakeQueueInteractions(); $job->handle(); diff --git a/tests/Backend/Unit/LocaleServiceTest.php b/tests/Backend/Unit/LocaleServiceTest.php index 169f4202c..bd1b0b1df 100644 --- a/tests/Backend/Unit/LocaleServiceTest.php +++ b/tests/Backend/Unit/LocaleServiceTest.php @@ -19,7 +19,7 @@ public function test_build_cache() 'app.enabled_locales' => ['de' => ['name' => 'Deutsch', 'dateTimeFormat' => []], 'en' => ['name' => 'English', 'dateTimeFormat' => []]], ]); - $mock = $this->partialMock(LocaleService::class, function (MockInterface $mock) { + $mock = $this->partialMock(LocaleService::class, function (MockInterface $mock): void { $mock->shouldReceive('buildJsonLocale') ->once() ->with('de') @@ -58,7 +58,7 @@ public function test_json_locale() ]); // Mock the result of building the locale for the german locale - $mock = $this->partialMock(LocaleService::class, function (MockInterface $mock) { + $mock = $this->partialMock(LocaleService::class, function (MockInterface $mock): void { $mock->shouldReceive('buildJsonLocale') ->once() ->with('de') diff --git a/tests/Backend/Unit/MeetingTest.php b/tests/Backend/Unit/MeetingTest.php index 701ab838e..e2af0c712 100644 --- a/tests/Backend/Unit/MeetingTest.php +++ b/tests/Backend/Unit/MeetingTest.php @@ -24,6 +24,7 @@ class MeetingTest extends TestCase private $meeting; + #[\Override] protected function setUp(): void { parent::setUp(); @@ -65,8 +66,8 @@ public function test_start_parameters() $this->assertStringContainsString('http://localhost/rooms/'.$meeting->room->id, $data['moderatorOnlyMessage']); $this->assertStringContainsString('123-456-789', $data['moderatorOnlyMessage']); - $salt = urldecode(explode('?salt=', $data['meta_endCallbackUrl'])[1]); - $this->assertTrue((new MeetingService($meeting))->validateCallbackSalt($salt)); + $salt = urldecode(explode('?salt=', (string) $data['meta_endCallbackUrl'])[1]); + $this->assertTrue(new MeetingService($meeting)->validateCallbackSalt($salt)); $this->assertArrayNotHasKey('logo', $data); } @@ -265,7 +266,7 @@ public function test_start_parameters_with_own_presentation() $request = Http::recorded()[0][0]; $body = $request->body(); - $xml = simplexml_load_string($body); + $xml = simplexml_load_string((string) $body); $docs = $xml->module->document; $this->assertCount(3, $docs); @@ -303,7 +304,7 @@ public function test_start_parameters_without_own_presentation() $request = Http::recorded()[0][0]; $body = $request->body(); - $xml = simplexml_load_string($body); + $xml = simplexml_load_string((string) $body); $docs = $xml->module->document; $this->assertCount(1, $docs); diff --git a/tests/Backend/Unit/ProvisioningServiceTest.php b/tests/Backend/Unit/ProvisioningServiceTest.php index 4a120bd31..a38e39def 100644 --- a/tests/Backend/Unit/ProvisioningServiceTest.php +++ b/tests/Backend/Unit/ProvisioningServiceTest.php @@ -20,6 +20,7 @@ class ProvisioningServiceTest extends TestCase { use RefreshDatabase; + #[\Override] protected function setUp(): void { parent::setUp(); @@ -449,7 +450,7 @@ public function test_user_create() $this->svc->user->create($this->testUser); $user = User::where('firstname', $this->testUser->firstname)->where('lastname', $this->testUser->lastname)->first(); $this->assertEquals($this->testUser->email, $user->email); - $this->assertTrue(str_starts_with($user->password, '$2y$04$')); + $this->assertTrue(str_starts_with((string) $user->password, '$2y$04$')); $this->assertEquals($this->testUser->authenticator, $user->authenticator); $this->assertEquals($this->testUser->locale, $user->locale); $this->assertEquals($this->testUser->timezone, $user->timezone); diff --git a/tests/Backend/Unit/Rules/ValidRoomTypeTest.php b/tests/Backend/Unit/Rules/ValidRoomTypeTest.php index 763872c97..045adda10 100644 --- a/tests/Backend/Unit/Rules/ValidRoomTypeTest.php +++ b/tests/Backend/Unit/Rules/ValidRoomTypeTest.php @@ -43,6 +43,6 @@ public function test_passes() public function test_message() { $user = User::factory()->create(); - $this->assertEquals(__('validation.custom.invalid_room_type'), (new ValidRoomType($user))->message()); + $this->assertEquals(__('validation.custom.invalid_room_type'), new ValidRoomType($user)->message()); } } diff --git a/tests/Backend/Unit/Seeder/RolesAndPermissionsSeederTest.php b/tests/Backend/Unit/Seeder/RolesAndPermissionsSeederTest.php index df07e1648..fecf5a3c7 100644 --- a/tests/Backend/Unit/Seeder/RolesAndPermissionsSeederTest.php +++ b/tests/Backend/Unit/Seeder/RolesAndPermissionsSeederTest.php @@ -13,6 +13,7 @@ class RolesAndPermissionsSeederTest extends TestCase { use RefreshDatabase,WithFaker; + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Unit/ServerServiceTest.php b/tests/Backend/Unit/ServerServiceTest.php index aa11f8f73..f9ff10d75 100644 --- a/tests/Backend/Unit/ServerServiceTest.php +++ b/tests/Backend/Unit/ServerServiceTest.php @@ -64,9 +64,9 @@ public function test_get_meetings_with_response() $server->status = 1; $meetings = $serverService->getMeetings(); - self::assertCount(2, $meetings); - self::assertEquals('409e94ee-e317-4040-8cb2-8000a289b49d', $meetings[0]->getMeetingId()); - self::assertEquals('216b94ffe-a225-3041-ac62-5000a289b49d', $meetings[1]->getMeetingId()); + $this->assertCount(2, $meetings); + $this->assertEquals('409e94ee-e317-4040-8cb2-8000a289b49d', $meetings[0]->getMeetingId()); + $this->assertEquals('216b94ffe-a225-3041-ac62-5000a289b49d', $meetings[1]->getMeetingId()); } /** @@ -83,7 +83,7 @@ public function test_get_meetings_with_failed_response() $server->status = ServerStatus::ENABLED; - self::assertNull($serverService->getMeetings()); + $this->assertNull($serverService->getMeetings()); } /** diff --git a/tests/Backend/Unit/StreamingServiceTest.php b/tests/Backend/Unit/StreamingServiceTest.php index 51e60840a..b74dcd852 100644 --- a/tests/Backend/Unit/StreamingServiceTest.php +++ b/tests/Backend/Unit/StreamingServiceTest.php @@ -17,6 +17,7 @@ class StreamingServiceTest extends TestCase /** * Setup resources for all tests */ + #[\Override] protected function setUp(): void { parent::setUp(); @@ -147,7 +148,7 @@ public function test_start() $this->assertEquals('rtmp://example.com/live/1234', $request->data()['rtmpUrl']); // Validate join url $joinUrl = $request->data()['joinUrl']; - $joinUrlParsed = parse_url($joinUrl); + $joinUrlParsed = parse_url((string) $joinUrl); parse_str($joinUrlParsed['query'], $joinUrlParams); $this->assertEquals('bbb.example.com', $joinUrlParsed['host']); $this->assertEquals('/bigbluebutton/api/join', $joinUrlParsed['path']); @@ -197,7 +198,7 @@ public function test_start() $request = Http::recorded()->pop()[0]; // Validate join url $joinUrl = $request->data()['joinUrl']; - $joinUrlParsed = parse_url($joinUrl); + $joinUrlParsed = parse_url((string) $joinUrl); parse_str($joinUrlParsed['query'], $joinUrlParams); $this->assertEquals('https://example.com/streaming.css', $joinUrlParams['userdata-bbb_custom_style_url']); $this->assertEquals('true', $joinUrlParams['userdata-bbb_hide_nav_bar']); diff --git a/tests/Backend/Unit/UserTest.php b/tests/Backend/Unit/UserTest.php index 6a0769011..6ffc51ee9 100644 --- a/tests/Backend/Unit/UserTest.php +++ b/tests/Backend/Unit/UserTest.php @@ -14,6 +14,7 @@ class UserTest extends TestCase private $users = []; + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Backend/Utils/BigBlueButtonServerFaker.php b/tests/Backend/Utils/BigBlueButtonServerFaker.php index bff9410e3..af63423a7 100644 --- a/tests/Backend/Utils/BigBlueButtonServerFaker.php +++ b/tests/Backend/Utils/BigBlueButtonServerFaker.php @@ -96,9 +96,7 @@ public function addRequest(mixed $response) */ public function addCreateMeetingRequest() { - $response = function (Request $request) { - return BigBlueButtonServerFaker::createCreateMeetingResponse($request); - }; + $response = (fn (Request $request) => BigBlueButtonServerFaker::createCreateMeetingResponse($request)); $this->requests[] = ['request' => null, 'response' => $response]; } diff --git a/tests/Backend/Utils/ServerLoadCalculationPlugin.php b/tests/Backend/Utils/ServerLoadCalculationPlugin.php index a089d1d27..8204e3d3f 100644 --- a/tests/Backend/Utils/ServerLoadCalculationPlugin.php +++ b/tests/Backend/Utils/ServerLoadCalculationPlugin.php @@ -6,11 +6,11 @@ class ServerLoadCalculationPlugin implements ServerLoadCalculationPluginContract { - private const PARTICIPANT_WEIGHT = 1; + private const int PARTICIPANT_WEIGHT = 1; - private const AUDIO_WEIGHT = 2; + private const int AUDIO_WEIGHT = 2; - private const VIDEO_WEIGHT = 3; + private const int VIDEO_WEIGHT = 3; public function getLoad(array $meetings): int {