Enable space after cast sniff and remove .git-blame-ignore-revs

This commit is contained in:
Michael Weimann 2022-12-25 11:59:45 +01:00 committed by GitHub
parent 86cc0a238d
commit 59cfce0c76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
52 changed files with 117 additions and 126 deletions

View File

@ -1,10 +0,0 @@
# Set native parameter types
2b88322c0c1dcab3b0dd064ad880b0f31645da49
# Set native return types
aff8826c9941d3f18984dcd4f220dd25ad547f42
# Set native property types
b004f865b42886738d90f9915c1cccfcc3599322
# Use constructor property promotion
984f8038d3ab096b6018a2df084fd158644bc080
# Add useless comment phpcs sniff
c1d350f2b122ff7dff0c3a0ed2b3c0a515c176f6

View File

@ -39,4 +39,5 @@
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion" /> <rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion" />
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment" /> <rule ref="SlevomatCodingStandard.Commenting.EmptyComment" />
<rule ref="SlevomatCodingStandard.Commenting.UselessFunctionDocComment" /> <rule ref="SlevomatCodingStandard.Commenting.UselessFunctionDocComment" />
<rule ref="Generic.Formatting.SpaceAfterCast" />
</ruleset> </ruleset>

View File

@ -15,7 +15,7 @@ return [
'api_key' => '', 'api_key' => '',
// Enable maintenance mode (show a static page) // Enable maintenance mode (show a static page)
'maintenance' => (bool)env('MAINTENANCE', false), 'maintenance' => (bool) env('MAINTENANCE', false),
// Application name (not the event name) // Application name (not the event name)
'app_name' => env('APP_NAME', 'Engelsystem'), 'app_name' => env('APP_NAME', 'Engelsystem'),
@ -220,13 +220,13 @@ return [
'display_news' => env('DISPLAY_NEWS', 10), 'display_news' => env('DISPLAY_NEWS', 10),
// Users are able to sign up // Users are able to sign up
'registration_enabled' => (bool)env('REGISTRATION_ENABLED', true), 'registration_enabled' => (bool) env('REGISTRATION_ENABLED', true),
// Only arrived angels can sign up for shifts // Only arrived angels can sign up for shifts
'signup_requires_arrival' => (bool)env('SIGNUP_REQUIRES_ARRIVAL', false), 'signup_requires_arrival' => (bool) env('SIGNUP_REQUIRES_ARRIVAL', false),
// Whether newly-registered user should automatically be marked as arrived // Whether newly-registered user should automatically be marked as arrived
'autoarrive' => (bool)env('ANGEL_AUTOARRIVE', false), 'autoarrive' => (bool) env('ANGEL_AUTOARRIVE', false),
// Only allow shift signup this number of hours in advance // Only allow shift signup this number of hours in advance
// Setting this to 0 disables the feature // Setting this to 0 disables the feature
@ -256,31 +256,31 @@ return [
// Whether the Password field should be enabled on registration. // Whether the Password field should be enabled on registration.
// This is useful when using oauth, disabling it also disables normal // This is useful when using oauth, disabling it also disables normal
// registration without oauth. // registration without oauth.
'enable_password' => (bool)env('ENABLE_PASSWORD', true), 'enable_password' => (bool) env('ENABLE_PASSWORD', true),
// Whether the DECT field should be enabled // Whether the DECT field should be enabled
'enable_dect' => (bool)env('ENABLE_DECT', true), 'enable_dect' => (bool) env('ENABLE_DECT', true),
// Whether the mobile number can be shown to other users // Whether the mobile number can be shown to other users
'enable_mobile_show' => (bool)env('ENABLE_MOBILE_SHOW', false), 'enable_mobile_show' => (bool) env('ENABLE_MOBILE_SHOW', false),
// Enables prename and lastname // Enables prename and lastname
'enable_user_name' => (bool)env('ENABLE_USER_NAME', false), 'enable_user_name' => (bool) env('ENABLE_USER_NAME', false),
// Enable displaying the pronoun fields // Enable displaying the pronoun fields
'enable_pronoun' => (bool)env('ENABLE_PRONOUN', true), 'enable_pronoun' => (bool) env('ENABLE_PRONOUN', true),
// Enables the planned arrival/leave date // Enables the planned arrival/leave date
'enable_planned_arrival' => (bool)env('ENABLE_PLANNED_ARRIVAL', true), 'enable_planned_arrival' => (bool) env('ENABLE_PLANNED_ARRIVAL', true),
// Enables the T-Shirt configuration on signup and profile // Enables the T-Shirt configuration on signup and profile
'enable_tshirt_size' => (bool)env('ENABLE_TSHIRT_SIZE', true), 'enable_tshirt_size' => (bool) env('ENABLE_TSHIRT_SIZE', true),
// Enables the goody configuration on signup and profile // Enables the goody configuration on signup and profile
'enable_goody' => (bool)env('ENABLE_GOODY', false), 'enable_goody' => (bool) env('ENABLE_GOODY', false),
// Enables the food voucher in the user profile // Enables the food voucher in the user profile
'enable_voucher' => (bool)env('ENABLE_VOUCHER', true), 'enable_voucher' => (bool) env('ENABLE_VOUCHER', true),
// Number of shifts to freeload until angel is locked for shift signup. // Number of shifts to freeload until angel is locked for shift signup.
'max_freeloadable_shifts' => env('MAX_FREELOADABLE_SHIFTS', 2), 'max_freeloadable_shifts' => env('MAX_FREELOADABLE_SHIFTS', 2),
@ -293,7 +293,7 @@ return [
// Multiply 'night shifts' and freeloaded shifts (start or end between 2 and 6 exclusive) by 2 // Multiply 'night shifts' and freeloaded shifts (start or end between 2 and 6 exclusive) by 2
'night_shifts' => [ 'night_shifts' => [
'enabled' => (bool)env('NIGHT_SHIFTS', true), // Disable to weigh every shift the same 'enabled' => (bool) env('NIGHT_SHIFTS', true), // Disable to weigh every shift the same
'start' => env('NIGHT_SHIFTS_START', 2), 'start' => env('NIGHT_SHIFTS_START', 2),
'end' => env('NIGHT_SHIFTS_END', 6), 'end' => env('NIGHT_SHIFTS_END', 6),
'multiplier' => env('NIGHT_SHIFTS_MULTIPLIER', 2), 'multiplier' => env('NIGHT_SHIFTS_MULTIPLIER', 2),
@ -359,7 +359,7 @@ return [
'trusted_proxies' => env('TRUSTED_PROXIES', ['127.0.0.0/8', '::ffff:127.0.0.0/8', '::1/128']), 'trusted_proxies' => env('TRUSTED_PROXIES', ['127.0.0.0/8', '::ffff:127.0.0.0/8', '::1/128']),
// Add additional headers // Add additional headers
'add_headers' => (bool)env('ADD_HEADERS', true), 'add_headers' => (bool) env('ADD_HEADERS', true),
'headers' => [ 'headers' => [
'X-Content-Type-Options' => 'nosniff', 'X-Content-Type-Options' => 'nosniff',
'X-Frame-Options' => 'sameorigin', 'X-Frame-Options' => 'sameorigin',

View File

@ -16,7 +16,7 @@ class StateFactory extends Factory
$arrival = $this->faker->optional()->dateTimeThisMonth(); $arrival = $this->faker->optional()->dateTimeThisMonth();
return [ return [
'arrived' => (bool)$arrival, 'arrived' => (bool) $arrival,
'arrival_date' => $arrival ? Carbon::instance($arrival) : null, 'arrival_date' => $arrival ? Carbon::instance($arrival) : null,
'active' => $this->faker->boolean(.3), 'active' => $this->faker->boolean(.3),
'force_active' => $this->faker->boolean(.1), 'force_active' => $this->faker->boolean(.1),

View File

@ -114,7 +114,7 @@ class CreateEventConfigTable extends Migration
protected function getConfigValue(Collection $config, string $name): mixed protected function getConfigValue(Collection $config, string $name): mixed
{ {
$value = $config->where('name', $name)->first('value', (object)['value' => null])->value; $value = $config->where('name', $name)->first('value', (object) ['value' => null])->value;
return $value ? json_decode($value, true) : null; return $value ? json_decode($value, true) : null;
} }

View File

@ -29,7 +29,7 @@ class FixMissingArrivalDates extends Migration
->first(); ->first();
$state->arrival_date = $personalData->planned_arrival_date; $state->arrival_date = $personalData->planned_arrival_date;
$connection->table('users_state') $connection->table('users_state')
->update((array)$state); ->update((array) $state);
} }
} }

View File

@ -49,9 +49,9 @@ class CreateAngelTypesTable extends Migration
'name' => $record->name, 'name' => $record->name,
'description' => $record->description, 'description' => $record->description,
'contact_name' => (string)$record->contact_name, 'contact_name' => (string) $record->contact_name,
'contact_dect' => (string)$record->contact_dect, 'contact_dect' => (string) $record->contact_dect,
'contact_email' => (string)$record->contact_email, 'contact_email' => (string) $record->contact_email,
'restricted' => $record->restricted, 'restricted' => $record->restricted,
'requires_driver_license' => $record->requires_driver_license, 'requires_driver_license' => $record->requires_driver_license,

View File

@ -44,7 +44,7 @@ class CreateUserAngelTypesTable extends Migration
'user_id' => $record->user_id, 'user_id' => $record->user_id,
'angel_type_id' => $record->angeltype_id, 'angel_type_id' => $record->angeltype_id,
'confirm_user_id' => $record->confirm_user_id ?: null, 'confirm_user_id' => $record->confirm_user_id ?: null,
'supporter' => (bool)$record->supporter, 'supporter' => (bool) $record->supporter,
]); ]);
} }
@ -84,7 +84,7 @@ class CreateUserAngelTypesTable extends Migration
'user_id' => $record->user_id, 'user_id' => $record->user_id,
'angeltype_id' => $record->angel_type_id, 'angeltype_id' => $record->angel_type_id,
'confirm_user_id' => $record->confirm_user_id ?: null, 'confirm_user_id' => $record->confirm_user_id ?: null,
'supporter' => (bool)$record->supporter, 'supporter' => (bool) $record->supporter,
]); ]);
} }

View File

@ -67,7 +67,7 @@ function angeltypes_about_controller()
return [ return [
__('Teams/Job description'), __('Teams/Job description'),
AngelTypes_about_view($angeltypes, (bool)$user) AngelTypes_about_view($angeltypes, (bool) $user)
]; ];
} }

View File

@ -248,7 +248,7 @@ function shift_delete_controller()
'title' => $shift['title'], 'title' => $shift['title'],
'type' => $type->name, 'type' => $type->name,
'room' => $room, 'room' => $room,
'freeloaded' => (bool)$entry['freeloaded'], 'freeloaded' => (bool) $entry['freeloaded'],
]); ]);
} }

View File

@ -20,7 +20,7 @@ function ShiftEntries_freeloaded_count()
return 0; return 0;
} }
return (int)array_shift($result); return (int) array_shift($result);
} }
/** /**
@ -81,7 +81,7 @@ function ShiftEntry_create($shift_entry)
$shift_entry['UID'], $shift_entry['UID'],
$shift_entry['Comment'], $shift_entry['Comment'],
$shift_entry['freeload_comment'], $shift_entry['freeload_comment'],
(int)$shift_entry['freeloaded'], (int) $shift_entry['freeloaded'],
] ]
); );
engelsystem_log( engelsystem_log(
@ -117,7 +117,7 @@ function ShiftEntry_update($shift_entry)
[ [
$shift_entry['Comment'], $shift_entry['Comment'],
$shift_entry['freeload_comment'], $shift_entry['freeload_comment'],
(int)$shift_entry['freeloaded'], (int) $shift_entry['freeloaded'],
$shift_entry['id'] $shift_entry['id']
] ]
); );

View File

@ -59,7 +59,7 @@ function admin_groups()
switch ($request->input('action')) { switch ($request->input('action')) {
case 'edit': case 'edit':
if ($request->has('id')) { if ($request->has('id')) {
$group_id = (int)$request->input('id'); $group_id = (int) $request->input('id');
} else { } else {
return error('Incomplete call, missing Groups ID.', true); return error('Incomplete call, missing Groups ID.', true);
} }
@ -96,7 +96,7 @@ function admin_groups()
$request->has('id') $request->has('id')
&& $request->hasPostData('submit') && $request->hasPostData('submit')
) { ) {
$group_id = (int)$request->input('id'); $group_id = (int) $request->input('id');
} else { } else {
return error('Incomplete call, missing Groups ID.', true); return error('Incomplete call, missing Groups ID.', true);
} }

View File

@ -200,7 +200,7 @@ function admin_rooms()
'title' => $shift['title'], 'title' => $shift['title'],
'type' => $type->name, 'type' => $type->name,
'room' => $room, 'room' => $room,
'freeloaded' => (bool)$entry['freeloaded'], 'freeloaded' => (bool) $entry['freeloaded'],
]); ]);
} }
} }

View File

@ -207,9 +207,9 @@ function admin_shifts()
'description' => $description, 'description' => $description,
]; ];
} elseif ($mode == 'multi') { } elseif ($mode == 'multi') {
$shift_start = (int)$start; $shift_start = (int) $start;
do { do {
$shift_end = $shift_start + (int)$length * 60; $shift_end = $shift_start + (int) $length * 60;
if ($shift_end > $end) { if ($shift_end > $end) {
$shift_end = $end; $shift_end = $end;
@ -571,7 +571,7 @@ function admin_shifts_history(): string
'title' => $shift['title'], 'title' => $shift['title'],
'type' => $type->name, 'type' => $type->name,
'room' => $room, 'room' => $room,
'freeloaded' => (bool)$entry['freeloaded'], 'freeloaded' => (bool) $entry['freeloaded'],
]); ]);
} }

View File

@ -390,7 +390,7 @@ class ImportSchedule extends BaseController
*/ */
protected function getScheduleData(Request $request) protected function getScheduleData(Request $request)
{ {
$scheduleId = (int)$request->getAttribute('schedule_id'); $scheduleId = (int) $request->getAttribute('schedule_id');
/** @var ScheduleUrl $scheduleUrl */ /** @var ScheduleUrl $scheduleUrl */
$scheduleUrl = ScheduleUrl::findOrFail($scheduleId); $scheduleUrl = ScheduleUrl::findOrFail($scheduleId);
@ -405,7 +405,7 @@ class ImportSchedule extends BaseController
throw new ErrorException('schedule.import.request-error'); throw new ErrorException('schedule.import.request-error');
} }
$scheduleData = (string)$scheduleResponse->getBody(); $scheduleData = (string) $scheduleResponse->getBody();
if (!$this->parser->load($scheduleData)) { if (!$this->parser->load($scheduleData)) {
throw new ErrorException('schedule.import.read-error'); throw new ErrorException('schedule.import.read-error');
} }

View File

@ -25,9 +25,9 @@ function user_atom()
throw new HttpForbidden('Not allowed', ['content-type' => 'text/text']); throw new HttpForbidden('Not allowed', ['content-type' => 'text/text']);
} }
$news = $request->has('meetings') ? News::whereIsMeeting((bool)$request->get('meetings', false)) : News::query(); $news = $request->has('meetings') ? News::whereIsMeeting((bool) $request->get('meetings', false)) : News::query();
$news $news
->limit((int)config('display_news')) ->limit((int) config('display_news'))
->orderByDesc('updated_at'); ->orderByDesc('updated_at');
$output = make_atom_entries_from_news($news->get()); $output = make_atom_entries_from_news($news->get());

View File

@ -12,7 +12,7 @@ use Carbon\Carbon;
*/ */
function form_hidden($name, $value) function form_hidden($name, $value)
{ {
return '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars((string)$value) . '" />'; return '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars((string) $value) . '" />';
} }
/** /**
@ -65,7 +65,7 @@ function form_date($name, $label, $value, $start_date = '', $end_date = '')
return form_element( return form_element(
$label, $label,
'<input class="form-control" id="' . $dom_id . '" type="date" placeholder="YYYY-MM-DD" pattern="[0-9]{4}-[0-9]{2}-[0-9]{2}" min="' . $start_date . '" max="' . $end_date . '" name="' . $name . '" value="' . htmlspecialchars((string)$value) . '" autocomplete="off">', '<input class="form-control" id="' . $dom_id . '" type="date" placeholder="YYYY-MM-DD" pattern="[0-9]{4}-[0-9]{2}-[0-9]{2}" min="' . $start_date . '" max="' . $end_date . '" name="' . $name . '" value="' . htmlspecialchars((string) $value) . '" autocomplete="off">',
$dom_id $dom_id
); );
} }
@ -128,7 +128,7 @@ function form_checkbox($name, $label, $selected, $value = 'checked', $html_id =
} }
return '<div class="form-check">' return '<div class="form-check">'
. '<input class="form-check-input" type="checkbox" id="' . $html_id . '" name="' . $name . '" value="' . htmlspecialchars((string)$value) . '" ' . '<input class="form-check-input" type="checkbox" id="' . $html_id . '" name="' . $name . '" value="' . htmlspecialchars((string) $value) . '" '
. ($selected ? ' checked="checked"' : '') . ' /><label class="form-check-label" for="' . $html_id . '">' . ($selected ? ' checked="checked"' : '') . ' /><label class="form-check-label" for="' . $html_id . '">'
. $label . $label
. '</label></div>'; . '</label></div>';
@ -145,7 +145,7 @@ function form_checkbox($name, $label, $selected, $value = 'checked', $html_id =
*/ */
function form_radio($name, $label, $selected, $value) function form_radio($name, $label, $selected, $value)
{ {
$value = htmlspecialchars((string)$value); $value = htmlspecialchars((string) $value);
$id = preg_replace('/\s/', '-', $name . '_' . $value); $id = preg_replace('/\s/', '-', $name . '_' . $value);
return '<div class="form-check">' return '<div class="form-check">'
@ -216,7 +216,7 @@ function form_submit($name, $label, $class = '', $wrapForm = true, $buttonType =
function form_text($name, $label, $value, $disabled = false, $maxlength = null, $autocomplete = null, $class = '', $data_attributes = []) function form_text($name, $label, $value, $disabled = false, $maxlength = null, $autocomplete = null, $class = '', $data_attributes = [])
{ {
$disabled = $disabled ? ' disabled="disabled"' : ''; $disabled = $disabled ? ' disabled="disabled"' : '';
$maxlength = $maxlength ? ' maxlength=' . (int)$maxlength : ''; $maxlength = $maxlength ? ' maxlength=' . (int) $maxlength : '';
$autocomplete = $autocomplete ? ' autocomplete="' . $autocomplete . '"' : ''; $autocomplete = $autocomplete ? ' autocomplete="' . $autocomplete . '"' : '';
$attr = ''; $attr = '';
foreach ($data_attributes as $attr_key => $attr_value) { foreach ($data_attributes as $attr_key => $attr_value) {
@ -226,7 +226,7 @@ function form_text($name, $label, $value, $disabled = false, $maxlength = null,
return form_element( return form_element(
$label, $label,
'<input class="form-control" id="form_' . $name . '" type="text" name="' . $name '<input class="form-control" id="form_' . $name . '" type="text" name="' . $name
. '" value="' . htmlspecialchars((string)$value) . '"' . $maxlength . $disabled . $autocomplete . $attr . '/>', . '" value="' . htmlspecialchars((string) $value) . '"' . $maxlength . $disabled . $autocomplete . $attr . '/>',
'form_' . $name, 'form_' . $name,
$class $class
); );
@ -247,7 +247,7 @@ function form_text_placeholder($name, $placeholder, $value, $disabled = false)
return form_element( return form_element(
'', '',
'<input class="form-control" id="form_' . $name . '" type="text" name="' . $name '<input class="form-control" id="form_' . $name . '" type="text" name="' . $name
. '" value="' . htmlspecialchars((string)$value) . '" placeholder="' . $placeholder . '" value="' . htmlspecialchars((string) $value) . '" placeholder="' . $placeholder
. '" ' . $disabled . '/>' . '" ' . $disabled . '/>'
); );
} }
@ -268,11 +268,11 @@ function form_email($name, $label, $value, $disabled = false, $autocomplete = nu
{ {
$disabled = $disabled ? ' disabled="disabled"' : ''; $disabled = $disabled ? ' disabled="disabled"' : '';
$autocomplete = $autocomplete ? ' autocomplete="' . $autocomplete . '"' : ''; $autocomplete = $autocomplete ? ' autocomplete="' . $autocomplete . '"' : '';
$maxlength = $maxlength ? ' maxlength=' . (int)$maxlength : ''; $maxlength = $maxlength ? ' maxlength=' . (int) $maxlength : '';
return form_element( return form_element(
$label, $label,
'<input class="form-control" id="form_' . $name . '" type="email" name="' . $name . '" value="' '<input class="form-control" id="form_' . $name . '" type="email" name="' . $name . '" value="'
. htmlspecialchars((string)$value) . '" ' . $disabled . $autocomplete . $maxlength . '/>', . htmlspecialchars((string) $value) . '" ' . $disabled . $autocomplete . $maxlength . '/>',
'form_' . $name 'form_' . $name
); );
} }
@ -352,7 +352,7 @@ function form_textarea($name, $label, $value, $disabled = false)
return form_element( return form_element(
$label, $label,
'<textarea rows="5" class="form-control" id="form_' . $name . '" name="' '<textarea rows="5" class="form-control" id="form_' . $name . '" name="'
. $name . '" ' . $disabled . '>' . htmlspecialchars((string)$value) . '</textarea>', . $name . '" ' . $disabled . '>' . htmlspecialchars((string) $value) . '</textarea>',
'form_' . $name 'form_' . $name
); );
} }

View File

@ -104,7 +104,7 @@ function make_navigation()
continue; continue;
} }
$title = ((array)$options)[0]; $title = ((array) $options)[0];
$menu[] = toolbar_item_link(page_link_to($menu_page), '', $title, $menu_page == $page); $menu[] = toolbar_item_link(page_link_to($menu_page), '', $title, $menu_page == $page);
} }
@ -137,7 +137,7 @@ function make_navigation()
continue; continue;
} }
$title = ((array)$options)[0]; $title = ((array) $options)[0];
$admin_menu[] = toolbar_dropdown_item( $admin_menu[] = toolbar_dropdown_item(
page_link_to($menu_page), page_link_to($menu_page),
__($title), __($title),
@ -160,7 +160,7 @@ function make_navigation()
*/ */
function menu_is_allowed(string $page, $options) function menu_is_allowed(string $page, $options)
{ {
$options = (array)$options; $options = (array) $options;
$permissions = $page; $permissions = $page;
if (isset($options[1])) { if (isset($options[1])) {

View File

@ -266,5 +266,5 @@ function check_email($email)
$domain = idn_to_ascii($domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46); $domain = idn_to_ascii($domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46);
$email = $name . '@' . $domain; $email = $name . '@' . $domain;
} }
return (bool)filter_var($email, FILTER_VALIDATE_EMAIL); return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
} }

View File

@ -188,7 +188,7 @@ function Shift_view($shift, ShiftType $shifttype, Room $room, $angeltypes_source
div('col-sm-6', [ div('col-sm-6', [
'<h2>' . __('Description') . '</h2>', '<h2>' . __('Description') . '</h2>',
$parsedown->parse($shifttype->description), $parsedown->parse($shifttype->description),
$parsedown->parse((string)$shift['description']), $parsedown->parse((string) $shift['description']),
]) ])
]); ]);

View File

@ -62,7 +62,7 @@ class QuestionsController extends BaseController
public function edit(Request $request): Response public function edit(Request $request): Response
{ {
$questionId = (int)$request->getAttribute('question_id'); $questionId = (int) $request->getAttribute('question_id');
$questions = $this->question->find($questionId); $questions = $this->question->find($questionId);
@ -71,7 +71,7 @@ class QuestionsController extends BaseController
public function save(Request $request): Response public function save(Request $request): Response
{ {
$questionId = (int)$request->getAttribute('question_id'); $questionId = (int) $request->getAttribute('question_id');
/** @var Question $question */ /** @var Question $question */
$question = $this->question->findOrNew($questionId); $question = $this->question->findOrNew($questionId);

View File

@ -34,7 +34,7 @@ class UserShirtController extends BaseController
public function editShirt(Request $request): Response public function editShirt(Request $request): Response
{ {
$userId = (int)$request->getAttribute('user_id'); $userId = (int) $request->getAttribute('user_id');
$user = $this->user->findOrFail($userId); $user = $this->user->findOrFail($userId);
@ -46,7 +46,7 @@ class UserShirtController extends BaseController
public function saveShirt(Request $request): Response public function saveShirt(Request $request): Response
{ {
$userId = (int)$request->getAttribute('user_id'); $userId = (int) $request->getAttribute('user_id');
/** @var User $user */ /** @var User $user */
$user = $this->user->findOrFail($userId); $user = $this->user->findOrFail($userId);
@ -64,11 +64,11 @@ class UserShirtController extends BaseController
} }
if ($this->auth->can('admin_arrive')) { if ($this->auth->can('admin_arrive')) {
$user->state->arrived = (bool)$data['arrived']; $user->state->arrived = (bool) $data['arrived'];
} }
$user->state->active = (bool)$data['active']; $user->state->active = (bool) $data['active'];
$user->state->got_shirt = (bool)$data['got_shirt']; $user->state->got_shirt = (bool) $data['got_shirt'];
$user->state->save(); $user->state->save();
$this->log->info( $this->log->info(

View File

@ -37,13 +37,13 @@ class UserWorkLogController extends BaseController
public function editWorklog(Request $request): Response public function editWorklog(Request $request): Response
{ {
$userId = (int)$request->getAttribute('user_id'); $userId = (int) $request->getAttribute('user_id');
$worklogId = $request->getAttribute('worklog_id'); // optional $worklogId = $request->getAttribute('worklog_id'); // optional
$user = $this->user->findOrFail($userId); $user = $this->user->findOrFail($userId);
if (isset($worklogId)) { if (isset($worklogId)) {
$worklog = $this->worklog->findOrFail((int)$worklogId); $worklog = $this->worklog->findOrFail((int) $worklogId);
if ($worklog->user->id != $userId) { if ($worklog->user->id != $userId) {
throw new HttpNotFound(); throw new HttpNotFound();
@ -56,7 +56,7 @@ class UserWorkLogController extends BaseController
public function saveWorklog(Request $request): Response public function saveWorklog(Request $request): Response
{ {
$userId = (int)$request->getAttribute('user_id'); $userId = (int) $request->getAttribute('user_id');
$worklogId = $request->getAttribute('worklog_id'); // optional $worklogId = $request->getAttribute('worklog_id'); // optional
$user = $this->user->findOrFail($userId); $user = $this->user->findOrFail($userId);
@ -68,7 +68,7 @@ class UserWorkLogController extends BaseController
]); ]);
if (isset($worklogId)) { if (isset($worklogId)) {
$worklog = $this->worklog->findOrFail((int)$worklogId); $worklog = $this->worklog->findOrFail((int) $worklogId);
if ($worklog->user->id != $userId) { if ($worklog->user->id != $userId) {
throw new HttpNotFound(); throw new HttpNotFound();
@ -91,8 +91,8 @@ class UserWorkLogController extends BaseController
public function showDeleteWorklog(Request $request): Response public function showDeleteWorklog(Request $request): Response
{ {
$userId = (int)$request->getAttribute('user_id'); $userId = (int) $request->getAttribute('user_id');
$worklogId = (int)$request->getAttribute('worklog_id'); $worklogId = (int) $request->getAttribute('worklog_id');
$user = $this->user->findOrFail($userId); $user = $this->user->findOrFail($userId);
$worklog = $this->worklog->findOrFail($worklogId); $worklog = $this->worklog->findOrFail($worklogId);
@ -109,8 +109,8 @@ class UserWorkLogController extends BaseController
public function deleteWorklog(Request $request): Response public function deleteWorklog(Request $request): Response
{ {
$userId = (int)$request->getAttribute('user_id'); $userId = (int) $request->getAttribute('user_id');
$worklogId = (int)$request->getAttribute('worklog_id'); $worklogId = (int) $request->getAttribute('worklog_id');
$worklog = $this->worklog->findOrFail($worklogId); $worklog = $this->worklog->findOrFail($worklogId);

View File

@ -94,7 +94,7 @@ class MessagesController extends BaseController
*/ */
public function messagesOfConversation(Request $request): Response public function messagesOfConversation(Request $request): Response
{ {
$userId = (int)$request->getAttribute('user_id'); $userId = (int) $request->getAttribute('user_id');
$currentUser = $this->auth->user(); $currentUser = $this->auth->user();
$otherUser = $this->user->findOrFail($userId); $otherUser = $this->user->findOrFail($userId);
@ -132,7 +132,7 @@ class MessagesController extends BaseController
*/ */
public function send(Request $request): Response public function send(Request $request): Response
{ {
$userId = (int)$request->getAttribute('user_id'); $userId = (int) $request->getAttribute('user_id');
$currentUser = $this->auth->user(); $currentUser = $this->auth->user();
@ -156,8 +156,8 @@ class MessagesController extends BaseController
*/ */
public function delete(Request $request): Response public function delete(Request $request): Response
{ {
$otherUserId = (int)$request->getAttribute('user_id'); $otherUserId = (int) $request->getAttribute('user_id');
$msgId = (int)$request->getAttribute('msg_id'); $msgId = (int) $request->getAttribute('msg_id');
$currentUser = $this->auth->user(); $currentUser = $this->auth->user();
$msg = $this->message->findOrFail($msgId); $msg = $this->message->findOrFail($msgId);

View File

@ -152,7 +152,7 @@ class MetricsEngine implements EngineInterface
protected function formatValue(mixed $value): mixed protected function formatValue(mixed $value): mixed
{ {
if (is_bool($value)) { if (is_bool($value)) {
return (int)$value; return (int) $value;
} }
return $this->escape($value); return $this->escape($value);

View File

@ -127,7 +127,7 @@ class Stats
public function vouchers(): int public function vouchers(): int
{ {
return (int)$this->vouchersQuery()->sum('got_voucher'); return (int) $this->vouchersQuery()->sum('got_voucher');
} }
public function vouchersBuckets(array $buckets): array public function vouchersBuckets(array $buckets): array
@ -232,7 +232,7 @@ class Stats
{ {
$query = $this->workSecondsQuery($done, $freeloaded); $query = $this->workSecondsQuery($done, $freeloaded);
return (int)$query->sum($this->raw('end - start')); return (int) $query->sum($this->raw('end - start'));
} }
/** /**
@ -285,7 +285,7 @@ class Stats
*/ */
public function worklogSeconds(): int public function worklogSeconds(): int
{ {
return (int)Worklog::query() return (int) Worklog::query()
->sum($this->raw('hours * 60 * 60')); ->sum($this->raw('hours * 60 * 60'));
} }

View File

@ -48,7 +48,7 @@ class NewsController extends BaseController
public function show(Request $request): Response public function show(Request $request): Response
{ {
$newsId = (int)$request->getAttribute('news_id'); $newsId = (int) $request->getAttribute('news_id');
$news = $this->news $news = $this->news
->with('user') ->with('user')
@ -60,7 +60,7 @@ class NewsController extends BaseController
public function comment(Request $request): Response public function comment(Request $request): Response
{ {
$newsId = (int)$request->getAttribute('news_id'); $newsId = (int) $request->getAttribute('news_id');
$data = $this->validate($request, [ $data = $this->validate($request, [
'comment' => 'required', 'comment' => 'required',
@ -89,7 +89,7 @@ class NewsController extends BaseController
public function deleteComment(Request $request): Response public function deleteComment(Request $request): Response
{ {
$commentId = (int)$request->getAttribute('comment_id'); $commentId = (int) $request->getAttribute('comment_id');
$this->validate( $this->validate(
$request, $request,

View File

@ -100,7 +100,7 @@ class OAuthController extends BaseController
->where('identifier', $resourceId) ->where('identifier', $resourceId)
->get() ->get()
// Explicit case sensitive comparison using PHP as some DBMS collations are case sensitive and some arent // Explicit case sensitive comparison using PHP as some DBMS collations are case sensitive and some arent
->where('identifier', '===', (string)$resourceId) ->where('identifier', '===', (string) $resourceId)
->first(); ->first();
$expirationTime = $accessToken->getExpires(); $expirationTime = $accessToken->getExpires();

View File

@ -30,7 +30,7 @@ class Db
// @TODO: Remove type casting // @TODO: Remove type casting
foreach ($return as $key => $value) { foreach ($return as $key => $value) {
$return[$key] = (array)$value; $return[$key] = (array) $value;
} }
return $return; return $return;
@ -46,7 +46,7 @@ class Db
$result = self::connection()->selectOne($query, $bindings); $result = self::connection()->selectOne($query, $bindings);
// @TODO: remove typecast // @TODO: remove typecast
$result = (array)$result; $result = (array) $result;
if (empty($result)) { if (empty($result)) {
return null; return null;
} }

View File

@ -111,7 +111,7 @@ class Migrate
{ {
$return = $migrated; $return = $migrated;
$return->transform(function ($migration) use ($migrations) { $return->transform(function ($migration) use ($migrations) {
$migration = (array)$migration; $migration = (array) $migration;
if ($migrations->contains('migration', $migration['migration'])) { if ($migrations->contains('migration', $migration['migration'])) {
$migration += $migrations $migration += $migrations
->where('migration', $migration['migration']) ->where('migration', $migration['migration'])

View File

@ -12,7 +12,7 @@ class EventDispatcher
public function listen(array|string $events, callable|string $listener): void public function listen(array|string $events, callable|string $listener): void
{ {
foreach ((array)$events as $event) { foreach ((array) $events as $event) {
$this->listeners[$event][] = $listener; $this->listeners[$event][] = $listener;
} }
} }

View File

@ -23,7 +23,7 @@ class EventsServiceProvider extends ServiceProvider
$config = $this->app->get('config'); $config = $this->app->get('config');
foreach ($config->get('event-handlers', []) as $event => $handlers) { foreach ($config->get('event-handlers', []) as $event => $handlers) {
foreach ((array)$handlers as $handler) { foreach ((array) $handlers as $handler) {
$dispatcher->listen($event, $handler); $dispatcher->listen($event, $handler);
} }
} }

View File

@ -65,7 +65,7 @@ class LegacyDevelopment extends Legacy
private function getDisplayNameOfValue(mixed $arg): string private function getDisplayNameOfValue(mixed $arg): string
{ {
return match (gettype($arg)) { return match (gettype($arg)) {
'string', 'integer', 'double' => (string)$arg, 'string', 'integer', 'double' => (string) $arg,
'boolean' => $arg ? 'true' : 'false', 'boolean' => $arg ? 'true' : 'false',
'object' => get_class($arg), 'object' => get_class($arg),
'resource' => get_resource_type($arg), // @codeCoverageIgnore 'resource' => get_resource_type($arg), // @codeCoverageIgnore

View File

@ -88,7 +88,7 @@ class Authenticator
*/ */
public function can(array|string $abilities): bool public function can(array|string $abilities): bool
{ {
$abilities = (array)$abilities; $abilities = (array) $abilities;
if (empty($this->permissions)) { if (empty($this->permissions)) {
$user = $this->user(); $user = $this->user();

View File

@ -31,7 +31,7 @@ class ConfigureEnvironmentServiceProvider extends ServiceProvider
*/ */
protected function setTimeZone(CarbonTimeZone $timeZone): void protected function setTimeZone(CarbonTimeZone $timeZone): void
{ {
ini_set('date.timezone', (string)$timeZone); ini_set('date.timezone', (string) $timeZone);
date_default_timezone_set($timeZone); date_default_timezone_set($timeZone);
} }

View File

@ -39,7 +39,7 @@ class XmlParser
$this->getFirstXpathContent('conference/acronym'), $this->getFirstXpathContent('conference/acronym'),
$this->getFirstXpathContent('conference/start'), $this->getFirstXpathContent('conference/start'),
$this->getFirstXpathContent('conference/end'), $this->getFirstXpathContent('conference/end'),
(int)$this->getFirstXpathContent('conference/days'), (int) $this->getFirstXpathContent('conference/days'),
$this->getFirstXpathContent('conference/timeslot_duration'), $this->getFirstXpathContent('conference/timeslot_duration'),
$this->getFirstXpathContent('conference/base_url') $this->getFirstXpathContent('conference/base_url')
); );
@ -50,7 +50,7 @@ class XmlParser
foreach ($day->xpath('room') as $roomElement) { foreach ($day->xpath('room') as $roomElement) {
$room = new Room( $room = new Room(
(string)$roomElement->attributes()['name'] (string) $roomElement->attributes()['name']
); );
$events = $this->parseEvents($roomElement->xpath('event'), $room); $events = $this->parseEvents($roomElement->xpath('event'), $room);
@ -59,10 +59,10 @@ class XmlParser
} }
$days[] = new Day( $days[] = new Day(
(string)$day->attributes()['date'], (string) $day->attributes()['date'],
new Carbon($day->attributes()['start']), new Carbon($day->attributes()['start']),
new Carbon($day->attributes()['end']), new Carbon($day->attributes()['end']),
(int)$day->attributes()['index'], (int) $day->attributes()['index'],
$rooms $rooms
); );
} }
@ -93,8 +93,8 @@ class XmlParser
} }
$events[] = new Event( $events[] = new Event(
(string)$event->attributes()['guid'], (string) $event->attributes()['guid'],
(int)$event->attributes()['id'], (int) $event->attributes()['id'],
$room, $room,
$this->getFirstXpathContent('title', $event), $this->getFirstXpathContent('title', $event),
$this->getFirstXpathContent('subtitle', $event), $this->getFirstXpathContent('subtitle', $event),
@ -124,7 +124,7 @@ class XmlParser
{ {
$element = ($xml ?: $this->scheduleXML)->xpath($path); $element = ($xml ?: $this->scheduleXML)->xpath($path);
return $element ? (string)$element[0] : ''; return $element ? (string) $element[0] : '';
} }
/** /**
@ -140,7 +140,7 @@ class XmlParser
foreach ($element->xpath($firstElement) as $element) { foreach ($element->xpath($firstElement) as $element) {
foreach ($element->xpath($secondElement) as $item) { foreach ($element->xpath($secondElement) as $item) {
$items[(string)$item->attributes()[$idAttribute]] = (string)$item; $items[(string) $item->attributes()[$idAttribute]] = (string) $item;
} }
} }

View File

@ -58,7 +58,7 @@ class SessionServiceProvider extends ServiceProvider
'options' => [ 'options' => [
'cookie_httponly' => true, 'cookie_httponly' => true,
'name' => $sessionConfig['name'], 'name' => $sessionConfig['name'],
'cookie_lifetime' => (int)($sessionConfig['lifetime'] * 24 * 60 * 60), 'cookie_lifetime' => (int) ($sessionConfig['lifetime'] * 24 * 60 * 60),
], ],
'handler' => $handler, 'handler' => $handler,
]); ]);

View File

@ -12,7 +12,7 @@ trait ValidatesRequest
protected function validate(Request $request, array $rules): array protected function validate(Request $request, array $rules): array
{ {
$isValid = $this->validator->validate( $isValid = $this->validator->validate(
(array)$request->getParsedBody(), (array) $request->getParsedBody(),
$rules $rules
); );

View File

@ -57,7 +57,7 @@ class Logger extends AbstractLogger
} }
// replace the values of the message // replace the values of the message
$message = str_replace('{' . $key . '}', (string)$val, $message); $message = str_replace('{' . $key . '}', (string) $val, $message);
} }
return $message; return $message;

View File

@ -23,7 +23,7 @@ class Mailer
public function send(string|array $to, string $subject, string $body): void public function send(string|array $to, string $subject, string $body): void
{ {
$message = (new Email()) $message = (new Email())
->to(...(array)$to) ->to(...(array) $to)
->from(sprintf('%s <%s>', $this->fromName, $this->fromAddress)) ->from(sprintf('%s <%s>', $this->fromName, $this->fromAddress))
->subject($subject) ->subject($subject)
->text($body); ->text($body);

View File

@ -170,10 +170,10 @@ class LegacyMiddleware implements MiddlewareInterface
protected function renderPage(string $page, string $title, string $content): ResponseInterface protected function renderPage(string $page, string $title, string $content): ResponseInterface
{ {
if (!empty($page) && is_int($page)) { if (!empty($page) && is_int($page)) {
return response($content, (int)$page); return response($content, (int) $page);
} }
if (strpos((string)$content, '<html') !== false) { if (strpos((string) $content, '<html') !== false) {
return response($content); return response($content);
} }

View File

@ -89,7 +89,7 @@ class RequestHandler implements MiddlewareInterface
// Merge action permissions // Merge action permissions
if (isset($permissions[$method])) { if (isset($permissions[$method])) {
$permissions = array_merge($permissions, (array)$permissions[$method]); $permissions = array_merge($permissions, (array) $permissions[$method]);
} }
foreach ($permissions as $key => $permission) { foreach ($permissions as $key => $permission) {

View File

@ -26,7 +26,7 @@ class Authentication extends TwigExtension
public function isAuthenticated(): bool public function isAuthenticated(): bool
{ {
return (bool)$this->auth->user(); return (bool) $this->auth->user();
} }
public function isGuest(): bool public function isGuest(): bool

View File

@ -35,8 +35,8 @@ class Globals extends TwigExtension implements GlobalsInterface
} }
$query = $this->request->query->get('theme'); $query = $this->request->query->get('theme');
if (!is_null($query) && isset($themes[(int)$query])) { if (!is_null($query) && isset($themes[(int) $query])) {
$themeId = (int)$query; $themeId = (int) $query;
} }
if (array_key_exists($themeId, $themes) === false) { if (array_key_exists($themeId, $themes) === false) {

View File

@ -157,7 +157,7 @@ class LoggerTest extends ApplicationFeatureTest
$this->assertStringContainsString('Oops', $entry['message']); $this->assertStringContainsString('Oops', $entry['message']);
$this->assertStringContainsString('42', $entry['message']); $this->assertStringContainsString('42', $entry['message']);
$this->assertStringContainsString(__FILE__, $entry['message']); $this->assertStringContainsString(__FILE__, $entry['message']);
$this->assertStringContainsString((string)$line, $entry['message']); $this->assertStringContainsString((string) $line, $entry['message']);
$this->assertStringContainsString(__FUNCTION__, $entry['message']); $this->assertStringContainsString(__FUNCTION__, $entry['message']);
} }

View File

@ -34,7 +34,7 @@ class RoutesFileTest extends TestCase
} }
$this->fail( $this->fail(
sprintf('The route "%s %s" is not cacheable', implode(',', (array)$httpMethod), $route) sprintf('The route "%s %s" is not cacheable', implode(',', (array) $httpMethod), $route)
); );
}); });

View File

@ -152,7 +152,7 @@ class NewsControllerTest extends ControllerTest
$news = (new News())->find($id); $news = (new News())->find($id);
$this->assertEquals($text, $news->text); $this->assertEquals($text, $news->text);
$this->assertEquals($isMeeting, (bool)$news->is_meeting); $this->assertEquals($isMeeting, (bool) $news->is_meeting);
} }
/** /**

View File

@ -207,7 +207,7 @@ class ControllerTest extends TestCase
$stats->expects($this->once()) $stats->expects($this->once())
->method('workSeconds') ->method('workSeconds')
->with(true) ->with(true)
->willReturn((int)(60 * 60 * 99.47)); ->willReturn((int) (60 * 60 * 99.47));
$this->setExpects($stats, 'newUsers', null, 3); $this->setExpects($stats, 'newUsers', null, 3);
$this->setExpects($stats, 'arrivedUsers', null, 10, $this->exactly(2)); $this->setExpects($stats, 'arrivedUsers', null, 10, $this->exactly(2));
$this->setExpects($stats, 'currentlyWorkingUsers', null, 5); $this->setExpects($stats, 'currentlyWorkingUsers', null, 5);

View File

@ -151,7 +151,7 @@ class OAuthControllerTest extends TestCase
// Login using provider // Login using provider
$controller->index($request); $controller->index($request);
$this->assertFalse($this->session->has('oauth2_connect_provider')); $this->assertFalse($this->session->has('oauth2_connect_provider'));
$this->assertFalse((bool)$this->otherUser->state->arrived); $this->assertFalse((bool) $this->otherUser->state->arrived);
// Tokens updated // Tokens updated
$oauth = $this->otherUser->oauth[0]; $oauth = $this->otherUser->oauth[0];
@ -165,13 +165,13 @@ class OAuthControllerTest extends TestCase
$this->config->set('oauth', $oauthConfig); $this->config->set('oauth', $oauthConfig);
$controller->index($request); $controller->index($request);
$this->assertTrue((bool)User::find(1)->state->arrived); $this->assertTrue((bool) User::find(1)->state->arrived);
$this->assertTrue($this->log->hasInfoThatContains('as arrived')); $this->assertTrue($this->log->hasInfoThatContains('as arrived'));
$this->log->reset(); $this->log->reset();
// Don't set arrived if already done // Don't set arrived if already done
$controller->index($request); $controller->index($request);
$this->assertTrue((bool)User::find(1)->state->arrived); $this->assertTrue((bool) User::find(1)->state->arrived);
$this->assertFalse($this->log->hasInfoThatContains('as arrived')); $this->assertFalse($this->log->hasInfoThatContains('as arrived'));
} }

View File

@ -63,7 +63,7 @@ class LegacyTest extends TestCase
$this->assertStringContainsString('4242', $logContent); $this->assertStringContainsString('4242', $logContent);
$this->assertStringContainsString('Lorem Ipsum', $logContent); $this->assertStringContainsString('Lorem Ipsum', $logContent);
$this->assertStringContainsString(basename(__FILE__), $logContent); $this->assertStringContainsString(basename(__FILE__), $logContent);
$this->assertStringContainsString((string)$line, $logContent); $this->assertStringContainsString((string) $line, $logContent);
$this->assertStringContainsString(__FUNCTION__, $logContent); $this->assertStringContainsString(__FUNCTION__, $logContent);
$this->assertStringContainsString(json_encode(__CLASS__), $logContent); $this->assertStringContainsString(json_encode(__CLASS__), $logContent);
$this->assertStringContainsString('Test Exception', $logContent); $this->assertStringContainsString('Test Exception', $logContent);

View File

@ -39,6 +39,6 @@ class LogTransportTest extends TestCase
$logger = $this->getMockForAbstractClass(LoggerInterface::class); $logger = $this->getMockForAbstractClass(LoggerInterface::class);
$transport = new LogTransport($logger); $transport = new LogTransport($logger);
$this->assertEquals('log://', (string)$transport); $this->assertEquals('log://', (string) $transport);
} }
} }

View File

@ -151,7 +151,7 @@ class UserTest extends ModelTest
->associate($user) ->associate($user)
->save(); ->save();
$this->assertArraySubset($data, (array)$user->{$name}->attributesToArray()); $this->assertArraySubset($data, (array) $user->{$name}->attributesToArray());
} }
/** /**