Skip to content

Commit acc25e8

Browse files
committed
refactor: simplified named arguments
1 parent b7c88f7 commit acc25e8

File tree

124 files changed

+1906
-2002
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+1906
-2002
lines changed

bin/console

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
1414

1515
try {
1616
Translation::create()
17-
->setLanguagesDir(PMF_LANGUAGE_DIR)
17+
->setTranslationsDir(PMF_LANGUAGE_DIR)
1818
->setDefaultLanguage('en')
1919
->setCurrentLanguage('en')
2020
->setMultiByteLanguage();

phpmyfaq/add.php

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
use phpMyFAQ\Question;
2424
use phpMyFAQ\Strings;
2525
use phpMyFAQ\System;
26-
use phpMyFAQ\Twig\TwigWrapper;
2726
use phpMyFAQ\Translation;
27+
use phpMyFAQ\Twig\TwigWrapper;
2828
use Symfony\Component\HttpFoundation\RedirectResponse;
2929
use Symfony\Component\HttpFoundation\Request;
3030
use Twig\TwigFilter;
@@ -96,47 +96,51 @@
9696

9797
// Twig template variables
9898
$templateVars = [
99-
... $templateVars,
100-
'title' => sprintf('%s - %s', Translation::get(languageKey: 'msgAddContent'), $faqConfig->getTitle()),
101-
'metaDescription' => sprintf('%s | %s', Translation::get(languageKey: 'msgNewContentHeader'), $faqConfig->getTitle()),
102-
'msgNewContentHeader' => Translation::get(languageKey: 'msgNewContentHeader'),
103-
'msgNewContentAddon' => Translation::get(languageKey: 'msgNewContentAddon'),
99+
...$templateVars,
100+
'title' => sprintf('%s - %s', Translation::get(key: 'msgAddContent'), $faqConfig->getTitle()),
101+
'metaDescription' => sprintf('%s | %s', Translation::get(key: 'msgNewContentHeader'), $faqConfig->getTitle()),
102+
'msgNewContentHeader' => Translation::get(key: 'msgNewContentHeader'),
103+
'msgNewContentAddon' => Translation::get(key: 'msgNewContentAddon'),
104104
'lang' => $Language->getLanguage(),
105105
'openQuestionID' => $selectedQuestion,
106-
'defaultContentMail' => ($user->getUserId() > 0) ? $user->getUserData('email') : '',
107-
'defaultContentName' => ($user->getUserId() > 0) ? $user->getUserData('display_name') : '',
108-
'msgNewContentName' => Translation::get(languageKey: 'msgNewContentName'),
109-
'msgNewContentMail' => Translation::get(languageKey: 'msgNewContentMail'),
110-
'msgNewContentCategory' => Translation::get(languageKey: 'msgNewContentCategory'),
106+
'defaultContentMail' => $user->getUserId() > 0 ? $user->getUserData('email') : '',
107+
'defaultContentName' => $user->getUserId() > 0 ? $user->getUserData('display_name') : '',
108+
'msgNewContentName' => Translation::get(key: 'msgNewContentName'),
109+
'msgNewContentMail' => Translation::get(key: 'msgNewContentMail'),
110+
'msgNewContentCategory' => Translation::get(key: 'msgNewContentCategory'),
111111
'selectedCategory' => $selectedCategory,
112112
'categories' => $category->getCategoryTree(),
113-
'msgNewContentTheme' => Translation::get(languageKey: 'msgNewContentTheme'),
113+
'msgNewContentTheme' => Translation::get(key: 'msgNewContentTheme'),
114114
'readonly' => $readonly,
115115
'printQuestion' => $question,
116-
'msgNewContentArticle' => Translation::get(languageKey: 'msgNewContentArticle'),
117-
'msgNewContentKeywords' => Translation::get(languageKey: 'msgNewContentKeywords'),
118-
'msgNewContentLink' => Translation::get(languageKey: 'msgNewContentLink'),
119-
'captchaFieldset' =>
120-
$captchaHelper->renderCaptcha($captcha, 'add', Translation::get(languageKey: 'msgCaptcha'), $user->isLoggedIn()),
121-
'msgNewContentSubmit' => Translation::get(languageKey: 'msgNewContentSubmit'),
116+
'msgNewContentArticle' => Translation::get(key: 'msgNewContentArticle'),
117+
'msgNewContentKeywords' => Translation::get(key: 'msgNewContentKeywords'),
118+
'msgNewContentLink' => Translation::get(key: 'msgNewContentLink'),
119+
'captchaFieldset' => $captchaHelper->renderCaptcha(
120+
$captcha,
121+
'add',
122+
Translation::get(key: 'msgCaptcha'),
123+
$user->isLoggedIn(),
124+
),
125+
'msgNewContentSubmit' => Translation::get(key: 'msgNewContentSubmit'),
122126
'enableWysiwygEditor' => $faqConfig->get('main.enableWysiwygEditorFrontend'),
123127
'currentTimestamp' => $request->server->get('REQUEST_TIME'),
124-
'msgSeparateKeywordsWithCommas' => Translation::get(languageKey: 'msgSeparateKeywordsWithCommas'),
128+
'msgSeparateKeywordsWithCommas' => Translation::get(key: 'msgSeparateKeywordsWithCommas'),
125129
'noCategories' => $categories === [],
126-
'msgFormDisabledDueToMissingCategories' => Translation::get(languageKey: 'msgFormDisabledDueToMissingCategories'),
130+
'msgFormDisabledDueToMissingCategories' => Translation::get(key: 'msgFormDisabledDueToMissingCategories'),
127131
'displayFullForm' => $displayFullForm,
128132
];
129133

130134
// Collect data for displaying form
131135
foreach ($formData as $input) {
132-
$active = sprintf('id%d_active', (int)$input->input_id);
133-
$label = sprintf('id%d_label', (int)$input->input_id);
134-
$required = sprintf('id%d_required', (int)$input->input_id);
136+
$active = sprintf('id%d_active', (int) $input->input_id);
137+
$label = sprintf('id%d_label', (int) $input->input_id);
138+
$required = sprintf('id%d_required', (int) $input->input_id);
135139
$templateVars = [
136140
...$templateVars,
137-
$active => (bool)$input->input_active,
141+
$active => (bool) $input->input_active,
138142
$label => $input->input_label,
139-
$required => ((int)$input->input_required !== 0) ? 'required' : ''
143+
$required => (int) $input->input_required !== 0 ? 'required' : '',
140144
];
141145
}
142146

phpmyfaq/attachment.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
use phpMyFAQ\Faq\Permission;
2121
use phpMyFAQ\Filter;
2222
use phpMyFAQ\Permission\MediumPermission;
23-
use phpMyFAQ\Twig\TwigWrapper;
2423
use phpMyFAQ\Translation;
24+
use phpMyFAQ\Twig\TwigWrapper;
2525
use Symfony\Component\Config\FileLocator;
2626
use Symfony\Component\DependencyInjection\ContainerBuilder;
2727
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
@@ -70,7 +70,8 @@
7070
$userPermission = $faqPermission->get(Permission::USER, $attachment->getRecordId());
7171
$groupPermission = $faqPermission->get(Permission::GROUP, $attachment->getRecordId());
7272
} catch (AttachmentException $attachmentException) {
73-
$attachmentErrors[] = Translation::get(languageKey: 'msgAttachmentInvalid') . ' (' . $attachmentException->getMessage() . ')';
73+
$attachmentErrors[] =
74+
Translation::get(key: 'msgAttachmentInvalid') . ' (' . $attachmentException->getMessage() . ')';
7475
}
7576

7677
// Check on group permissions
@@ -111,8 +112,13 @@
111112
}
112113

113114
if (
114-
$attachment && $attachment->getRecordId() > 0 && ($faqConfig->get('records.allowDownloadsForGuests') ||
115-
(($groupPermission || ($groupPermission && $userPermission)) && isset($permission['dlattachment'])))
115+
$attachment
116+
&& $attachment->getRecordId() > 0
117+
&& (
118+
$faqConfig->get('records.allowDownloadsForGuests')
119+
|| ($groupPermission || $groupPermission && $userPermission)
120+
&& isset($permission['dlattachment'])
121+
)
116122
) {
117123
$response = new StreamedResponse(function () use ($attachment) {
118124
$attachment->rawOut();
@@ -124,19 +130,19 @@
124130
if ($attachment->getMimeType() === 'application/pdf') {
125131
$response->headers->set(
126132
'Content-Disposition',
127-
'inline; filename="' . rawurlencode($attachment->getFilename()) . '"'
133+
'inline; filename="' . rawurlencode($attachment->getFilename()) . '"',
128134
);
129135
} else {
130136
$response->headers->set(
131137
'Content-Disposition',
132-
'attachment; filename="' . rawurlencode($attachment->getFilename()) . '"'
138+
'attachment; filename="' . rawurlencode($attachment->getFilename()) . '"',
133139
);
134140
}
135141

136142
$response->headers->set('Content-MD5', $attachment->getRealHash());
137143
$response->send();
138144
} else {
139-
$attachmentErrors[] = Translation::get(languageKey: 'msgAttachmentInvalid');
145+
$attachmentErrors[] = Translation::get(key: 'msgAttachmentInvalid');
140146
}
141147

142148
// If we're here, there was an error with file download
@@ -145,7 +151,7 @@
145151

146152
// Twig template variables
147153
$templateVars = [
148-
... $templateVars,
154+
...$templateVars,
149155
'attachmentErrors' => $attachmentErrors,
150156
];
151157

phpmyfaq/bookmarks.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
* @since 2023-07-20
1717
*/
1818

19-
use phpMyFAQ\Twig\TwigWrapper;
2019
use phpMyFAQ\Bookmark;
21-
use phpMyFAQ\Translation;
2220
use phpMyFAQ\Session\Token;
21+
use phpMyFAQ\Translation;
22+
use phpMyFAQ\Twig\TwigWrapper;
2323
use Symfony\Component\HttpFoundation\RedirectResponse;
2424

2525
if (!defined('IS_VALID_PHPMYFAQ')) {
@@ -38,11 +38,13 @@
3838

3939
// Twig template variables
4040
$templateVars = [
41-
... $templateVars,
42-
'title' => sprintf('%s - %s', Translation::get(languageKey: 'msgBookmarks'), $faqConfig->getTitle()),
41+
...$templateVars,
42+
'title' => sprintf('%s - %s', Translation::get(key: 'msgBookmarks'), $faqConfig->getTitle()),
4343
'bookmarksList' => $bookmark->getBookmarkList(),
4444
'csrfTokenDeleteBookmark' => Token::getInstance($container->get('session'))->getTokenString('delete-bookmark'),
45-
'csrfTokenDeleteAllBookmarks' => Token::getInstance($container->get('session'))->getTokenString('delete-all-bookmarks')
45+
'csrfTokenDeleteAllBookmarks' => Token::getInstance($container->get('session'))->getTokenString(
46+
'delete-all-bookmarks',
47+
),
4648
];
4749

4850
return $templateVars;

phpmyfaq/contact.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
* @since 2002-09-16
1616
*/
1717

18-
use phpMyFAQ\Twig\TwigWrapper;
1918
use phpMyFAQ\Translation;
19+
use phpMyFAQ\Twig\TwigWrapper;
2020

2121
if (!defined('IS_VALID_PHPMYFAQ')) {
2222
http_response_code(400);
2323
exit();
2424
}
2525

26-
2726
$faqConfig = $container->get('phpmyfaq.configuration');
2827
$user = $container->get('phpmyfaq.user.current_user');
2928

@@ -46,16 +45,20 @@
4645

4746
// Twig template variables
4847
$templateVars = [
49-
... $templateVars,
50-
'title' => sprintf('%s - %s', Translation::get(languageKey: 'msgContact'), $faqConfig->getTitle()),
48+
...$templateVars,
49+
'title' => sprintf('%s - %s', Translation::get(key: 'msgContact'), $faqConfig->getTitle()),
5150
'msgContactOwnText' => $contactText,
5251
'privacyURL' => $faqConfig->get('main.privacyURL'),
5352
'lang' => $Language->getLanguage(),
54-
'defaultContentMail' => ($user->getUserId() > 0) ? $user->getUserData('email') : '',
55-
'defaultContentName' => ($user->getUserId() > 0) ? $user->getUserData('display_name') : '',
53+
'defaultContentMail' => $user->getUserId() > 0 ? $user->getUserData('email') : '',
54+
'defaultContentName' => $user->getUserId() > 0 ? $user->getUserData('display_name') : '',
5655
'version' => $faqConfig->getVersion(),
57-
'captchaFieldset' =>
58-
$captchaHelper->renderCaptcha($captcha, 'contact', Translation::get(languageKey: 'msgCaptcha'), $user->isLoggedIn()),
56+
'captchaFieldset' => $captchaHelper->renderCaptcha(
57+
$captcha,
58+
'contact',
59+
Translation::get(key: 'msgCaptcha'),
60+
$user->isLoggedIn(),
61+
),
5962
];
6063

61-
return $templateVars;#
64+
return $templateVars; //

0 commit comments

Comments
 (0)