Skip to content

Commit

Permalink
Merge pull request #2301 from nextcloud/dependabot/composer/vendor-bi…
Browse files Browse the repository at this point in the history
…n/cs-fixer/main/nextcloud/coding-standard-1.2.3

Chore(deps): Bump nextcloud/coding-standard from 1.2.1 to 1.2.3 in /vendor-bin/cs-fixer
  • Loading branch information
Chartman123 authored Aug 24, 2024
2 parents a7dfe25 + 176fc24 commit 004b5d2
Show file tree
Hide file tree
Showing 17 changed files with 225 additions and 218 deletions.
8 changes: 4 additions & 4 deletions lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ public function cloneQuestion(int $id): DataResponse {

$questionData = $sourceQuestion->read();
unset($questionData['id']);
$questionData["order"] = end($allQuestions)->getOrder() + 1;
$questionData['order'] = end($allQuestions)->getOrder() + 1;

$newQuestion = Question::fromParams($questionData);
$this->questionMapper->insert($newQuestion);
Expand Down Expand Up @@ -947,7 +947,7 @@ private function storeAnswersForQuestion(Form $form, $submissionId, array $quest
if ($optionIndex !== false) {
$answerText = $question['options'][$optionIndex]['text'];
} elseif (!empty($question['extraSettings']['allowOtherAnswer']) && strpos($answer, Constants::QUESTION_EXTRASETTINGS_OTHER_PREFIX) === 0) {
$answerText = str_replace(Constants::QUESTION_EXTRASETTINGS_OTHER_PREFIX, "", $answer);
$answerText = str_replace(Constants::QUESTION_EXTRASETTINGS_OTHER_PREFIX, '', $answer);
}
} elseif ($question['type'] === Constants::ANSWER_TYPE_FILE) {
$uploadedFile = $this->uploadedFileMapper->getByUploadedFileId($answer['uploadedFileId']);
Expand All @@ -972,7 +972,7 @@ private function storeAnswersForQuestion(Form $form, $submissionId, array $quest
$answerText = $answer; // Not a multiple-question, answerText is given answer
}

if ($answerText === "") {
if ($answerText === '') {
continue;
}

Expand Down Expand Up @@ -1143,7 +1143,7 @@ public function insertSubmission(int $formId, array $answers, string $shareHash

// If not logged in, anonymous, or embedded use anonID
if (!$this->currentUser || $form->getIsAnonymous()) {
$anonID = "anon-user-". hash('md5', strval(time() + rand()));
$anonID = 'anon-user-'. hash('md5', strval(time() + rand()));
$submission->setUserId($anonID);
} else {
$submission->setUserId($this->currentUser->getUID());
Expand Down
6 changes: 3 additions & 3 deletions lib/Db/AnswerMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public function deleteBySubmission(int $submissionId): void {
$qb = $this->db->getQueryBuilder();

$qb->delete($this->getTableName())
->where(
$qb->expr()->eq('submission_id', $qb->createNamedParameter($submissionId, IQueryBuilder::PARAM_INT))
);
->where(
$qb->expr()->eq('submission_id', $qb->createNamedParameter($submissionId, IQueryBuilder::PARAM_INT))
);

$qb->executeStatement();
}
Expand Down
12 changes: 6 additions & 6 deletions lib/Db/ShareMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ public function deleteById(int $id): void {
$qb = $this->db->getQueryBuilder();

$qb->delete($this->getTableName())
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
);
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
);
$qb->executeStatement();
}

Expand All @@ -126,9 +126,9 @@ public function deleteByForm(int $formId): void {
$qb = $this->db->getQueryBuilder();

$qb->delete($this->getTableName())
->where(
$qb->expr()->eq('form_id', $qb->createNamedParameter($formId, IQueryBuilder::PARAM_INT))
);
->where(
$qb->expr()->eq('form_id', $qb->createNamedParameter($formId, IQueryBuilder::PARAM_INT))
);
$qb->executeStatement();
}
}
14 changes: 7 additions & 7 deletions lib/Db/SubmissionMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected function countSubmissionsWithFilters(int $formId, ?string $userId = nu
$row = $result->fetch();
$result->closeCursor();

return (int) ($row['num_submissions'] ?? 0);
return (int)($row['num_submissions'] ?? 0);
}

/**
Expand All @@ -151,9 +151,9 @@ public function deleteById(int $id): void {

//Delete Submission
$qb->delete($this->getTableName())
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
);
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
);

$qb->executeStatement();
}
Expand All @@ -173,9 +173,9 @@ public function deleteByForm(int $formId): void {

//Delete Submissions
$qb->delete($this->getTableName())
->where(
$qb->expr()->eq('form_id', $qb->createNamedParameter($formId, IQueryBuilder::PARAM_INT))
);
->where(
$qb->expr()->eq('form_id', $qb->createNamedParameter($formId, IQueryBuilder::PARAM_INT))
);

$qb->executeStatement();
}
Expand Down
12 changes: 6 additions & 6 deletions lib/Migration/Version010200Date20200323141300.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,12 @@ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array
}

$qb_restore->insert('forms_v2_questions')
->values([
'form_id' => $qb_restore->createNamedParameter($id_mapping['events'][$question['form_id']]['newId'], IQueryBuilder::PARAM_INT),
'order' => $qb_restore->createNamedParameter($id_mapping['events'][$question['form_id']]['nextQuestionOrder']++, IQueryBuilder::PARAM_INT),
'type' => $qb_restore->createNamedParameter($this->questionTypeMap[$question['form_question_type']], IQueryBuilder::PARAM_STR),
'text' => $qb_restore->createNamedParameter($question['form_question_text'], IQueryBuilder::PARAM_STR)
]);
->values([
'form_id' => $qb_restore->createNamedParameter($id_mapping['events'][$question['form_id']]['newId'], IQueryBuilder::PARAM_INT),
'order' => $qb_restore->createNamedParameter($id_mapping['events'][$question['form_id']]['nextQuestionOrder']++, IQueryBuilder::PARAM_INT),
'type' => $qb_restore->createNamedParameter($this->questionTypeMap[$question['form_question_type']], IQueryBuilder::PARAM_STR),
'text' => $qb_restore->createNamedParameter($question['form_question_text'], IQueryBuilder::PARAM_STR)
]);
$qb_restore->execute();
$id_mapping['questions'][$question['id']]['newId'] = $qb_restore->getLastInsertId(); //Store new question-id to connect options to new question.
}
Expand Down
16 changes: 8 additions & 8 deletions lib/Migration/Version020200Date20210120082018.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,30 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt

if ($schema->hasTable('forms_v2_answers')) {
$schema->getTable('forms_v2_answers')
->addIndex(['submission_id'], 'forms_answers_submission')
->addIndex(['question_id'], 'forms_answers_question');
->addIndex(['submission_id'], 'forms_answers_submission')
->addIndex(['question_id'], 'forms_answers_question');
}

if ($schema->hasTable('forms_v2_forms')) {
$schema->getTable('forms_v2_forms')
->addIndex(['owner_id'], 'forms_forms_owner')
->addIndex(['created'], 'forms_forms_created');
->addIndex(['owner_id'], 'forms_forms_owner')
->addIndex(['created'], 'forms_forms_created');
}

if ($schema->hasTable('forms_v2_options')) {
$schema->getTable('forms_v2_options')
->addIndex(['question_id'], 'forms_options_question');
->addIndex(['question_id'], 'forms_options_question');
}

if ($schema->hasTable('forms_v2_questions')) {
$schema->getTable('forms_v2_questions')
->addIndex(['form_id', 'order'], 'forms_questions_form_order')
->addIndex(['form_id'], 'forms_questions_form');
->addIndex(['form_id', 'order'], 'forms_questions_form_order')
->addIndex(['form_id'], 'forms_questions_form');
}

if ($schema->hasTable('forms_v2_submissions')) {
$schema->getTable('forms_v2_submissions')
->addIndex(['form_id'], 'forms_submissions_form');
->addIndex(['form_id'], 'forms_submissions_form');
}

return $schema;
Expand Down
8 changes: 4 additions & 4 deletions lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ public function __construct(
* Load the single values, decode, have default values
*/
public function getAllowPermitAll(): bool {
return json_decode($this->config->getAppValue($this->appName, Constants::CONFIG_KEY_ALLOWPERMITALL, "true"));
return json_decode($this->config->getAppValue($this->appName, Constants::CONFIG_KEY_ALLOWPERMITALL, 'true'));
}
public function getAllowPublicLink(): bool {
return json_decode($this->config->getAppValue($this->appName, Constants::CONFIG_KEY_ALLOWPUBLICLINK, "true"));
return json_decode($this->config->getAppValue($this->appName, Constants::CONFIG_KEY_ALLOWPUBLICLINK, 'true'));
}
private function getUnformattedCreationAllowedGroups(): array {
return json_decode($this->config->getAppValue($this->appName, Constants::CONFIG_KEY_CREATIONALLOWEDGROUPS, "[]"));
return json_decode($this->config->getAppValue($this->appName, Constants::CONFIG_KEY_CREATIONALLOWEDGROUPS, '[]'));
}
public function getCreationAllowedGroups(): array {
return $this->formatGroupsForMultiselect($this->getUnformattedCreationAllowedGroups());
}
public function getRestrictCreation(): bool {
return json_decode($this->config->getAppValue($this->appName, Constants::CONFIG_KEY_RESTRICTCREATION, "false"));
return json_decode($this->config->getAppValue($this->appName, Constants::CONFIG_KEY_RESTRICTCREATION, 'false'));
}

/**
Expand Down
16 changes: 8 additions & 8 deletions license.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct() {
*
*/
EOD;
$this->licenseTextLegacy = str_replace('@YEAR@', date("Y"), $this->licenseTextLegacy);
$this->licenseTextLegacy = str_replace('@YEAR@', date('Y'), $this->licenseTextLegacy);
}

/**
Expand Down Expand Up @@ -123,17 +123,17 @@ public function exec($folder, $gitRoot = false) {

public function writeAuthorsFile() {
ksort($this->authors);
$template = "Nextcloud is written by:
$template = 'Nextcloud is written by:
@AUTHORS@
With help from many libraries and frameworks including:
Open Collaboration Services
SabreDAV
jQuery
";
';
$authors = implode(PHP_EOL, array_map(function ($author) {
return " - ".$author;
return ' - '.$author;
}, $this->authors));
$template = str_replace('@AUTHORS@', $authors, $template);
file_put_contents(__DIR__.'/../AUTHORS', $template);
Expand Down Expand Up @@ -162,9 +162,9 @@ public function handleFile($path, $gitRoot) {

[$source, $isStrict] = $this->eatOldLicense($source);
if ($isStrict) {
$source = "<?php" . PHP_EOL . PHP_EOL . 'declare(strict_types=1);' . PHP_EOL . PHP_EOL . $license . PHP_EOL . $source;
$source = '<?php' . PHP_EOL . PHP_EOL . 'declare(strict_types=1);' . PHP_EOL . PHP_EOL . $license . PHP_EOL . $source;
} else {
$source = "<?php" . PHP_EOL . $license . PHP_EOL . $source;
$source = '<?php' . PHP_EOL . $license . PHP_EOL . $source;
}
file_put_contents($path, $source);
echo "License updated: $path" . PHP_EOL;
Expand Down Expand Up @@ -301,8 +301,8 @@ private function checkCopyrightState($path, $gitRoot) {
private function printFilesToCheck() {
if (!empty($this->checkFiles)) {
print "\n";
print "For following files all lines changed since the Nextcloud fork." . PHP_EOL;
print "Please check if these files can be moved over to AGPLv3 or later" . PHP_EOL;
print 'For following files all lines changed since the Nextcloud fork.' . PHP_EOL;
print 'Please check if these files can be moved over to AGPLv3 or later' . PHP_EOL;
print "\n";
foreach ($this->checkFiles as $file) {
print $file . PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Api/ApiV2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ public function testDeleteSingleSubmission(array $submissionsExpected) {
* Keep this test at the end as it might break other tests
*/
public function testTransferOwner() {
$resp = $this->http->request('POST', "api/v2.4/form/transfer", [
$resp = $this->http->request('POST', 'api/v2.4/form/transfer', [
'json' => [
'formId' => $this->testForms[0]['id'],
'uid' => 'user1'
Expand Down
40 changes: 20 additions & 20 deletions tests/Unit/Controller/ApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,26 +455,26 @@ public function testCreateNewForm($expectedForm) {
// Create a partial mock, as we only test newForm and not getForm
/** @var ApiController|MockObject */
$apiController = $this->getMockBuilder(ApiController::class)
->onlyMethods(['getForm'])
->setConstructorArgs(['forms',
$this->request,
$this->createUserSession(),
$this->answerMapper,
$this->formMapper,
$this->optionMapper,
$this->questionMapper,
$this->shareMapper,
$this->submissionMapper,
$this->configService,
$this->formsService,
$this->submissionService,
$this->l10n,
$this->logger,
$this->userManager,
$this->storage,
$this->uploadedFileMapper,
$this->mimeTypeDetector,
])->getMock();
->onlyMethods(['getForm'])
->setConstructorArgs(['forms',
$this->request,
$this->createUserSession(),
$this->answerMapper,
$this->formMapper,
$this->optionMapper,
$this->questionMapper,
$this->shareMapper,
$this->submissionMapper,
$this->configService,
$this->formsService,
$this->submissionService,
$this->l10n,
$this->logger,
$this->userManager,
$this->storage,
$this->uploadedFileMapper,
$this->mimeTypeDetector,
])->getMock();
// Set the time that should be set for `lastUpdated`
\OCA\Forms\Controller\time(123456789);

Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Controller/ConfigControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ public function dataUpdateAppConfig() {
'booleanConfig' => [
'configKey' => 'allowPermitAll',
'configValue' => true,
'strConfig' => "true"
'strConfig' => 'true'
],
'arrayConfig' => [
'configKey' => 'allowPermitAll',
'configValue' => [
"admin",
"group1"
'admin',
'group1'
],
'strConfig' => '["admin","group1"]'
]
Expand Down
18 changes: 9 additions & 9 deletions tests/Unit/Db/SubmissionMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ public function setUp(): void {
parent::setUp();

$this->mockSubmissionMapper = $this->getMockBuilder(SubmissionMapper::class)
->disableOriginalConstructor()
->setMethods(['countSubmissionsWithFilters'])
->getMock();
->disableOriginalConstructor()
->setMethods(['countSubmissionsWithFilters'])
->getMock();
}

/**
* @dataProvider dataHasMultipleFormSubmissionsByUser
*/
public function testHasMultipleFormSubmissionsByUser(int $numberOfSubmissions, bool $expected) {
$this->mockSubmissionMapper->expects($this->once())
->method('countSubmissionsWithFilters')
->will($this->returnValue($numberOfSubmissions));
->method('countSubmissionsWithFilters')
->will($this->returnValue($numberOfSubmissions));

$form = new Form();
$form->setId(1);
Expand Down Expand Up @@ -83,8 +83,8 @@ public function dataHasMultipleFormSubmissionsByUser() {
*/
public function testHasFormSubmissionsByUser(int $numberOfSubmissions, bool $expected) {
$this->mockSubmissionMapper->expects($this->once())
->method('countSubmissionsWithFilters')
->will($this->returnValue($numberOfSubmissions));
->method('countSubmissionsWithFilters')
->will($this->returnValue($numberOfSubmissions));

$form = new Form();
$form->setId(1);
Expand Down Expand Up @@ -114,8 +114,8 @@ public function dataHasFormSubmissionsByUser() {
*/
public function testCountSubmissions(int $numberOfSubmissions, int $expected) {
$this->mockSubmissionMapper->expects($this->once())
->method('countSubmissionsWithFilters')
->will($this->returnValue($numberOfSubmissions));
->method('countSubmissionsWithFilters')
->will($this->returnValue($numberOfSubmissions));

$this->assertEquals($expected, $this->mockSubmissionMapper->countSubmissions(1));
}
Expand Down
Loading

0 comments on commit 004b5d2

Please sign in to comment.