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.Commenting.EmptyComment" />
<rule ref="SlevomatCodingStandard.Commenting.UselessFunctionDocComment" />
<rule ref="Generic.Formatting.SpaceAfterCast" />
</ruleset>

View File

@ -15,7 +15,7 @@ return [
'api_key' => '',
// Enable maintenance mode (show a static page)
'maintenance' => (bool)env('MAINTENANCE', false),
'maintenance' => (bool) env('MAINTENANCE', false),
// Application name (not the event name)
'app_name' => env('APP_NAME', 'Engelsystem'),
@ -220,13 +220,13 @@ return [
'display_news' => env('DISPLAY_NEWS', 10),
// 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
'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
'autoarrive' => (bool)env('ANGEL_AUTOARRIVE', false),
'autoarrive' => (bool) env('ANGEL_AUTOARRIVE', false),
// Only allow shift signup this number of hours in advance
// Setting this to 0 disables the feature
@ -256,31 +256,31 @@ return [
// Whether the Password field should be enabled on registration.
// This is useful when using oauth, disabling it also disables normal
// registration without oauth.
'enable_password' => (bool)env('ENABLE_PASSWORD', true),
'enable_password' => (bool) env('ENABLE_PASSWORD', true),
// 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
'enable_mobile_show' => (bool)env('ENABLE_MOBILE_SHOW', false),
'enable_mobile_show' => (bool) env('ENABLE_MOBILE_SHOW', false),
// 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_pronoun' => (bool)env('ENABLE_PRONOUN', true),
'enable_pronoun' => (bool) env('ENABLE_PRONOUN', true),
// 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
'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
'enable_goody' => (bool)env('ENABLE_GOODY', false),
'enable_goody' => (bool) env('ENABLE_GOODY', false),
// 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.
'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
'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),
'end' => env('NIGHT_SHIFTS_END', 6),
'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']),
// Add additional headers
'add_headers' => (bool)env('ADD_HEADERS', true),
'add_headers' => (bool) env('ADD_HEADERS', true),
'headers' => [
'X-Content-Type-Options' => 'nosniff',
'X-Frame-Options' => 'sameorigin',

View File

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

View File

@ -114,7 +114,7 @@ class CreateEventConfigTable extends Migration
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;
}

View File

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

View File

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

View File

@ -44,7 +44,7 @@ class CreateUserAngelTypesTable extends Migration
'user_id' => $record->user_id,
'angel_type_id' => $record->angeltype_id,
'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,
'angeltype_id' => $record->angel_type_id,
'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 [
__('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'],
'type' => $type->name,
'room' => $room,
'freeloaded' => (bool)$entry['freeloaded'],
'freeloaded' => (bool) $entry['freeloaded'],
]);
}

View File

@ -20,7 +20,7 @@ function ShiftEntries_freeloaded_count()
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['Comment'],
$shift_entry['freeload_comment'],
(int)$shift_entry['freeloaded'],
(int) $shift_entry['freeloaded'],
]
);
engelsystem_log(
@ -117,7 +117,7 @@ function ShiftEntry_update($shift_entry)
[
$shift_entry['Comment'],
$shift_entry['freeload_comment'],
(int)$shift_entry['freeloaded'],
(int) $shift_entry['freeloaded'],
$shift_entry['id']
]
);

View File

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

View File

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

View File

@ -207,9 +207,9 @@ function admin_shifts()
'description' => $description,
];
} elseif ($mode == 'multi') {
$shift_start = (int)$start;
$shift_start = (int) $start;
do {
$shift_end = $shift_start + (int)$length * 60;
$shift_end = $shift_start + (int) $length * 60;
if ($shift_end > $end) {
$shift_end = $end;
@ -571,7 +571,7 @@ function admin_shifts_history(): string
'title' => $shift['title'],
'type' => $type->name,
'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)
{
$scheduleId = (int)$request->getAttribute('schedule_id');
$scheduleId = (int) $request->getAttribute('schedule_id');
/** @var ScheduleUrl $scheduleUrl */
$scheduleUrl = ScheduleUrl::findOrFail($scheduleId);
@ -405,7 +405,7 @@ class ImportSchedule extends BaseController
throw new ErrorException('schedule.import.request-error');
}
$scheduleData = (string)$scheduleResponse->getBody();
$scheduleData = (string) $scheduleResponse->getBody();
if (!$this->parser->load($scheduleData)) {
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']);
}
$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
->limit((int)config('display_news'))
->limit((int) config('display_news'))
->orderByDesc('updated_at');
$output = make_atom_entries_from_news($news->get());

View File

@ -12,7 +12,7 @@ use Carbon\Carbon;
*/
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(
$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
);
}
@ -128,7 +128,7 @@ function form_checkbox($name, $label, $selected, $value = 'checked', $html_id =
}
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 . '">'
. $label
. '</label></div>';
@ -145,7 +145,7 @@ function form_checkbox($name, $label, $selected, $value = 'checked', $html_id =
*/
function form_radio($name, $label, $selected, $value)
{
$value = htmlspecialchars((string)$value);
$value = htmlspecialchars((string) $value);
$id = preg_replace('/\s/', '-', $name . '_' . $value);
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 = [])
{
$disabled = $disabled ? ' disabled="disabled"' : '';
$maxlength = $maxlength ? ' maxlength=' . (int)$maxlength : '';
$maxlength = $maxlength ? ' maxlength=' . (int) $maxlength : '';
$autocomplete = $autocomplete ? ' autocomplete="' . $autocomplete . '"' : '';
$attr = '';
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(
$label,
'<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,
$class
);
@ -247,7 +247,7 @@ function form_text_placeholder($name, $placeholder, $value, $disabled = false)
return form_element(
'',
'<input class="form-control" id="form_' . $name . '" type="text" name="' . $name
. '" value="' . htmlspecialchars((string)$value) . '" placeholder="' . $placeholder
. '" value="' . htmlspecialchars((string) $value) . '" placeholder="' . $placeholder
. '" ' . $disabled . '/>'
);
}
@ -268,11 +268,11 @@ function form_email($name, $label, $value, $disabled = false, $autocomplete = nu
{
$disabled = $disabled ? ' disabled="disabled"' : '';
$autocomplete = $autocomplete ? ' autocomplete="' . $autocomplete . '"' : '';
$maxlength = $maxlength ? ' maxlength=' . (int)$maxlength : '';
$maxlength = $maxlength ? ' maxlength=' . (int) $maxlength : '';
return form_element(
$label,
'<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
);
}
@ -352,7 +352,7 @@ function form_textarea($name, $label, $value, $disabled = false)
return form_element(
$label,
'<textarea rows="5" class="form-control" id="form_' . $name . '" name="'
. $name . '" ' . $disabled . '>' . htmlspecialchars((string)$value) . '</textarea>',
. $name . '" ' . $disabled . '>' . htmlspecialchars((string) $value) . '</textarea>',
'form_' . $name
);
}

View File

@ -104,7 +104,7 @@ function make_navigation()
continue;
}
$title = ((array)$options)[0];
$title = ((array) $options)[0];
$menu[] = toolbar_item_link(page_link_to($menu_page), '', $title, $menu_page == $page);
}
@ -137,7 +137,7 @@ function make_navigation()
continue;
}
$title = ((array)$options)[0];
$title = ((array) $options)[0];
$admin_menu[] = toolbar_dropdown_item(
page_link_to($menu_page),
__($title),
@ -160,7 +160,7 @@ function make_navigation()
*/
function menu_is_allowed(string $page, $options)
{
$options = (array)$options;
$options = (array) $options;
$permissions = $page;
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);
$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', [
'<h2>' . __('Description') . '</h2>',
$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
{
$questionId = (int)$request->getAttribute('question_id');
$questionId = (int) $request->getAttribute('question_id');
$questions = $this->question->find($questionId);
@ -71,7 +71,7 @@ class QuestionsController extends BaseController
public function save(Request $request): Response
{
$questionId = (int)$request->getAttribute('question_id');
$questionId = (int) $request->getAttribute('question_id');
/** @var Question $question */
$question = $this->question->findOrNew($questionId);

View File

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

View File

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

View File

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

View File

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

View File

@ -127,7 +127,7 @@ class Stats
public function vouchers(): int
{
return (int)$this->vouchersQuery()->sum('got_voucher');
return (int) $this->vouchersQuery()->sum('got_voucher');
}
public function vouchersBuckets(array $buckets): array
@ -232,7 +232,7 @@ class Stats
{
$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
{
return (int)Worklog::query()
return (int) Worklog::query()
->sum($this->raw('hours * 60 * 60'));
}

View File

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

View File

@ -100,7 +100,7 @@ class OAuthController extends BaseController
->where('identifier', $resourceId)
->get()
// 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();
$expirationTime = $accessToken->getExpires();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -39,7 +39,7 @@ class XmlParser
$this->getFirstXpathContent('conference/acronym'),
$this->getFirstXpathContent('conference/start'),
$this->getFirstXpathContent('conference/end'),
(int)$this->getFirstXpathContent('conference/days'),
(int) $this->getFirstXpathContent('conference/days'),
$this->getFirstXpathContent('conference/timeslot_duration'),
$this->getFirstXpathContent('conference/base_url')
);
@ -50,7 +50,7 @@ class XmlParser
foreach ($day->xpath('room') as $roomElement) {
$room = new Room(
(string)$roomElement->attributes()['name']
(string) $roomElement->attributes()['name']
);
$events = $this->parseEvents($roomElement->xpath('event'), $room);
@ -59,10 +59,10 @@ class XmlParser
}
$days[] = new Day(
(string)$day->attributes()['date'],
(string) $day->attributes()['date'],
new Carbon($day->attributes()['start']),
new Carbon($day->attributes()['end']),
(int)$day->attributes()['index'],
(int) $day->attributes()['index'],
$rooms
);
}
@ -93,8 +93,8 @@ class XmlParser
}
$events[] = new Event(
(string)$event->attributes()['guid'],
(int)$event->attributes()['id'],
(string) $event->attributes()['guid'],
(int) $event->attributes()['id'],
$room,
$this->getFirstXpathContent('title', $event),
$this->getFirstXpathContent('subtitle', $event),
@ -124,7 +124,7 @@ class XmlParser
{
$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($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' => [
'cookie_httponly' => true,
'name' => $sessionConfig['name'],
'cookie_lifetime' => (int)($sessionConfig['lifetime'] * 24 * 60 * 60),
'cookie_lifetime' => (int) ($sessionConfig['lifetime'] * 24 * 60 * 60),
],
'handler' => $handler,
]);

View File

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

View File

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

View File

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

View File

@ -170,10 +170,10 @@ class LegacyMiddleware implements MiddlewareInterface
protected function renderPage(string $page, string $title, string $content): ResponseInterface
{
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);
}

View File

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

View File

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

View File

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

View File

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

View File

@ -34,7 +34,7 @@ class RoutesFileTest extends TestCase
}
$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);
$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())
->method('workSeconds')
->with(true)
->willReturn((int)(60 * 60 * 99.47));
->willReturn((int) (60 * 60 * 99.47));
$this->setExpects($stats, 'newUsers', null, 3);
$this->setExpects($stats, 'arrivedUsers', null, 10, $this->exactly(2));
$this->setExpects($stats, 'currentlyWorkingUsers', null, 5);

View File

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

View File

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

View File

@ -39,6 +39,6 @@ class LogTransportTest extends TestCase
$logger = $this->getMockForAbstractClass(LoggerInterface::class);
$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)
->save();
$this->assertArraySubset($data, (array)$user->{$name}->attributesToArray());
$this->assertArraySubset($data, (array) $user->{$name}->attributesToArray());
}
/**