Skip to content

Commit

Permalink
Merge pull request #2468 from nextcloud/dependabot/composer/nextcloud…
Browse files Browse the repository at this point in the history
…/coding-standard-1.2.3

Build(deps-dev): Bump nextcloud/coding-standard from 1.2.1 to 1.2.3
  • Loading branch information
christianlupus authored Aug 26, 2024
2 parents e002ea2 + e849a2f commit a3ddd97
Show file tree
Hide file tree
Showing 25 changed files with 121 additions and 118 deletions.
3 changes: 3 additions & 0 deletions .changelog/current/2468-update-code-styling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Maintenance

- Update code styling of PHP files in accordance to Nextcloud preference
24 changes: 12 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 22 additions & 22 deletions lib/Db/RecipeDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function findRecipeById(int $id) {
$cursor->closeCursor();

if ($row === false) {
throw new DoesNotExistException($this->l->t("Recipe with ID %d was not found in database.", [$id]));
throw new DoesNotExistException($this->l->t('Recipe with ID %d was not found in database.', [$id]));
}

$ret = [];
Expand Down Expand Up @@ -177,7 +177,7 @@ public function findAllKeywords(string $user_id) {
$cursor->closeCursor();

$result = array_map(function ($x) {
$x['recipe_count'] = (int) $x['recipe_count'];
$x['recipe_count'] = (int)$x['recipe_count'];
return $x;
}, $result);

Expand Down Expand Up @@ -206,7 +206,7 @@ public function findAllCategories(string $user_id) {
$cursor->closeCursor();

$result = array_map(function ($x) {
$x['recipe_count'] = (int) $x['recipe_count'];
$x['recipe_count'] = (int)$x['recipe_count'];
return $x;
}, $result);

Expand Down Expand Up @@ -235,7 +235,7 @@ public function findAllCategories(string $user_id) {

$result[] = [
'name' => '*',
'recipe_count' => (int) $row['cnt']
'recipe_count' => (int)$row['cnt']
];

$result = array_unique($result, SORT_REGULAR);
Expand Down Expand Up @@ -271,21 +271,21 @@ public function getRecipesByCategory(string $category, string $user_id) {
$qb->orderBy('r.name');
} else {
$qb->select(['r.recipe_id', 'r.name', 'r.date_created', 'r.date_modified', 'k.name AS keywords'])
->from(self::DB_TABLE_RECIPES, 'r')
->leftJoin('r', self::DB_TABLE_KEYWORDS, 'k', 'r.recipe_id = k.recipe_id')
->leftJoin(
'r',
self::DB_TABLE_CATEGORIES,
'c',
$qb->expr()->andX(
'r.user_id = c.user_id',
'r.recipe_id = c.recipe_id'
->from(self::DB_TABLE_RECIPES, 'r')
->leftJoin('r', self::DB_TABLE_KEYWORDS, 'k', 'r.recipe_id = k.recipe_id')
->leftJoin(
'r',
self::DB_TABLE_CATEGORIES,
'c',
$qb->expr()->andX(
'r.user_id = c.user_id',
'r.recipe_id = c.recipe_id'
)
)
)
->where(
$qb->expr()->eq('r.user_id', $qb->createNamedParameter($user_id, IQueryBuilder::PARAM_STR)),
$qb->expr()->isNull('c.name')
);
->where(
$qb->expr()->eq('r.user_id', $qb->createNamedParameter($user_id, IQueryBuilder::PARAM_STR)),
$qb->expr()->isNull('c.name')
);
}

$cursor = $qb->execute();
Expand Down Expand Up @@ -400,7 +400,7 @@ public function findRecipes(array $keywords, string $user_id) {

/**
* @param array $results Array of recipes with double entries for different keywords
* Group recipes by id and convert keywords to comma-separated list
* Group recipes by id and convert keywords to comma-separated list
*/
public function groupKeywordInResult(array $result) {
$recipesGroupedTags = [];
Expand Down Expand Up @@ -477,7 +477,7 @@ public function deleteRecipes(array $ids, string $userId) {
$qb->orWhere(
$qb->expr()->andX(
$qb->expr()->eq('recipe_id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)),
$qb->expr()->eq("user_id", $qb->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
$qb->expr()->eq('user_id', $qb->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
));
}

Expand Down Expand Up @@ -574,8 +574,8 @@ public function getCategoryOfRecipe(int $recipeId, string $userId) {
$qb = $this->db->getQueryBuilder();

$qb->select('name')
->from(self::DB_TABLE_CATEGORIES)
->where('recipe_id = :rid', 'user_id = :uid');
->from(self::DB_TABLE_CATEGORIES)
->where('recipe_id = :rid', 'user_id = :uid');

$qb->setParameter('rid', $recipeId);
$qb->setParameter('uid', $userId);
Expand Down
2 changes: 1 addition & 1 deletion lib/Helper/Filter/JSON/ExtractImageUrlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function apply(array &$json): bool {
$regex = preg_match_all('/\d+/', $img, $matches);

if ($regex !== false && $regex > 0) {
$sum = array_sum(array_map(fn ($x) => ((int) $x), $matches[0]));
$sum = array_sum(array_map(fn ($x) => ((int)$x), $matches[0]));

if ($sum > $maxSum) {
$json['image'] = $img;
Expand Down
4 changes: 2 additions & 2 deletions lib/Helper/Filter/JSON/FixRecipeYieldFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function apply(array &$json): bool {
}

if (is_float($json[self::YIELD]) || is_double($json[self::YIELD])) {
$json[self::YIELD] = (int) $json[self::YIELD];
$json[self::YIELD] = (int)$json[self::YIELD];
return true;
}

Expand Down Expand Up @@ -82,7 +82,7 @@ public function apply(array &$json): bool {
$count
));

$json[self::YIELD] = (int) $last;
$json[self::YIELD] = (int)$last;
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Helper/Filter/JSON/FixToolsFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function apply(array &$json): bool {
$t = $this->textCleaner->cleanUp($t, false);

// Empty string would mean no tools (i.e., empty array)
if($t != "") {
if($t != '') {
$tools[] = $t;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/Helper/Filter/JSON/SchemaConformityFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public function apply(array &$json): bool {
$changed |= $this->setJSONValue($json, '@context', 'http://schema.org');
$changed |= $this->setJSONValue($json, '@type', 'Recipe');

return (bool) $changed;
return (bool)$changed;
}
}
4 changes: 2 additions & 2 deletions lib/Helper/ISO8601DurationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ private function parseIsoFormat(string $duration): string {
// $matches[5] is the tome part of the string (like T4H5M6S)
// $matches[6] to $matches[8] is hours to seconds (like 4H 5M 6S)
$hours = (int)$matches[6];
$minutes = (int) ($matches[7] ?? 0);
$seconds = (int) ($matches[8] ?? 0);
$minutes = (int)($matches[7] ?? 0);
$seconds = (int)($matches[8] ?? 0);

while ($seconds >= 60) {
$seconds -= 60;
Expand Down
2 changes: 1 addition & 1 deletion lib/Helper/TextCleanupHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function cleanUp(

$str = str_replace("\t", ' ', $str);
if($removeBackslashes) {
$str = str_replace("\\", '_', $str);
$str = str_replace('\\', '_', $str);
}

// We want to remove forward-slashes for the name of the recipe, to tie it to the directory structure, which cannot have slashes
Expand Down
8 changes: 4 additions & 4 deletions lib/Helper/TimestampHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private function parseIsoFormat(string $timestamp): string {
* @throws InvalidTimestampException if $timestamp does not comply to ISO 8601 with week and weekday.
*/
private function parseIsoCalendarDateFormat(string $timestamp, string $dateSeparator = '-'): string {
$date = "Y".$dateSeparator."m".$dateSeparator."d";
$date = 'Y'.$dateSeparator.'m'.$dateSeparator.'d';

return $this->parseIsoTimestampWithTimeFormats($timestamp, $date);
}
Expand Down Expand Up @@ -143,19 +143,19 @@ private function parseIsoWeekDateFormat(string $timestamp, string $dateSeparator
*/
private function parseIsoTimestampWithTimeFormats(string $timestamp, string $dateFormat): string {
// Try parsing timestamp without milliseconds
$dt = DateTimeImmutable::createFromFormat($dateFormat . "\\TH:i:sP", $timestamp);
$dt = DateTimeImmutable::createFromFormat($dateFormat . '\\TH:i:sP', $timestamp);
if($dt) {
return $dt->format(self::OUTPUT_FORMAT);
}

// Try parsing timestamp with dot-separated milliseconds
$dt = DateTimeImmutable::createFromFormat($dateFormat . "\\TH:i:s.vP", $timestamp);
$dt = DateTimeImmutable::createFromFormat($dateFormat . '\\TH:i:s.vP', $timestamp);
if($dt) {
return $dt->format(self::OUTPUT_FORMAT);
}

// Try parsing timestamp with comma-separated milliseconds
$dt = DateTimeImmutable::createFromFormat($dateFormat . "\\TH:i:s,vP", $timestamp);
$dt = DateTimeImmutable::createFromFormat($dateFormat . '\\TH:i:s,vP', $timestamp);
if($dt) {
return $dt->format(self::OUTPUT_FORMAT);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/DbCacheService.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private function parseJSONFile(File $jsonFile): array {
throw new InvalidJSONFileException($this->l->t('The JSON file in the folder with ID %d does not have a valid name.', [$id]));
}

$id = (int) $jsonFile->getParent()->getId();
$id = (int)$jsonFile->getParent()->getId();
$json['id'] = $id;

$json = $this->normalizeFileFilter->filter($json, $jsonFile, true);
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/RecipeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public function updateSearchIndex() {
$this->migrateFolderStructure();
} catch (UserFolderNotWritableException $ex) {
// Ignore migration if not permitted.
$this->logger->warning("Cannot migrate cookbook file structure as not permitted.");
$this->logger->warning('Cannot migrate cookbook file structure as not permitted.');
throw $ex;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/AbstractDatabaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function tearDown(): void {
}

private function resetDataFolder() {
$cmd = "rsync -a --delete --delete-delay /dumps/current/plain/data/ /var/www/html/data";
$cmd = 'rsync -a --delete --delete-delay /dumps/current/plain/data/ /var/www/html/data';
$output = [];
$ret = 0;
exec($cmd, $output, $ret);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ public function testUpdateNoName(): void {

$data = ['a', 'new', 'array'];

$errorMsg = "No name was given for the recipe.";
$errorMsg = 'No name was given for the recipe.';
$ex = new NoRecipeNameGivenException($errorMsg);

$this->restParser->method('getParameters')->willReturn($data);
Expand All @@ -433,7 +433,7 @@ public function testUpdateConflictingName(): void {

$recipe = ['a', 'recipe', 'as', 'array'];

$errorMsg = "Another recipe with that name already exists";
$errorMsg = 'Another recipe with that name already exists';
$ex = new RecipeExistsException($errorMsg);

$this->restParser->method('getParameters')->willReturn($recipe);
Expand Down Expand Up @@ -476,7 +476,7 @@ public function testCreateNoName(): void {
$recipe = ['a', 'recipe', 'as', 'array'];
$this->restParser->method('getParameters')->willReturn($recipe);

$errorMsg = "The error that was triggered";
$errorMsg = 'The error that was triggered';
$ex = new NoRecipeNameGivenException($errorMsg);

$this->recipeService->expects($this->once())->method('addRecipe')->with($recipe)->willThrowException($ex);
Expand Down Expand Up @@ -516,13 +516,13 @@ public function testShow(): void {

$id = 123;
$recipe = [
'name' => "My Name",
'name' => 'My Name',
'description' => 'a useful description',
'id' => $id,
];
$this->recipeService->method('getRecipeById')->with($id)->willReturn($recipe);
$this->recipeService->method('getPrintImage')->willReturn(true);
$imageUrl = "/path/to/image/of/id/123";
$imageUrl = '/path/to/image/of/id/123';

$this->urlGenerator->method('linkToRoute')->with(
'cookbook.recipe.image',
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Helper/FileSystem/RecipeNameHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function dpGetFolderName() {
'102 chars' => ["{$ninetyChars}123456789012", "{$ninetyChars}1234567___"],
'105 chars' => ["{$ninetyChars}123456789012345", "{$ninetyChars}1234567___"],
'special chars' => ['a/b:c?d!e"f|g\\h\'i^j&k#l', 'a_b_c_d_e_f_g_h_i_j_k_l'],
'greek chars' => ["Τραγανή granola χωρίς ζάχαρη με ό,τι ξηρούς καρπούς & αποξηραμένα φρούτα έχεις στο ντουλάπι σου", "Τραγανή granola χωρίς ζάχαρη με ό,τι ξηρούς καρπούς _ αποξηραμένα φρούτα έχεις στο ντουλάπι σου"],
'greek chars' => ['Τραγανή granola χωρίς ζάχαρη με ό,τι ξηρούς καρπούς & αποξηραμένα φρούτα έχεις στο ντουλάπι σου', 'Τραγανή granola χωρίς ζάχαρη με ό,τι ξηρούς καρπούς _ αποξηραμένα φρούτα έχεις στο ντουλάπι σου'],
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Helper/Filter/DB/RecipeNameLengthFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function dp() {
yield ['abc', 'abc', false];
yield ['äöü', 'äöü', false];

$tenChars = "0123456789";
$tenChars = '0123456789';
$twentyChars = "$tenChars$tenChars";
$fiftyChars = $twentyChars . $twentyChars . $tenChars;
$hundredTwenty = $fiftyChars . $fiftyChars . $twentyChars;
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Helper/Filter/JSON/FixDescriptionFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public function testNonExisting() {

public function dpApply() {
return [
["abc", "abc", "abc", false],
['abc', 'abc', 'abc', false],
["abc\n\ndef", "abc\n\ndef", "abc\n\ndef", false],
["abc\n\n", "abc\n\n", "abc", true],
["abc\n\n", "abc\n\n", 'abc', true],
// ["abc\n\n", "abc", true],
];
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Helper/Filter/JSON/FixRecipeYieldFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public function dp() {
[3.4,3,true],
[[2], 2, true],
[[4.6], 4, true],
["3", 3, true],
["123 456", 456, true],
['3', 3, true],
['123 456', 456, true],
[[4,5], 5, true],
['', 1, true],
['one two three', 1, true],
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Helper/Filter/JSON/TimezoneFixFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public function db() {
$hours = sprintf('%+03d00', $offset / 3600);

yield ["2024-05-20T10:12:00$hours", "2024-05-20T10:12:00$hours", false];
yield ["2024-05-20T10:12:00", "2024-05-20T10:12:00$hours", true];
yield ['2024-05-20T10:12:00', "2024-05-20T10:12:00$hours", true];
yield ["2024-05-20T10:12:00.20$hours", "2024-05-20T10:12:00.20$hours", false];
yield ["2024-05-20T10:12:00.20", "2024-05-20T10:12:00.20$hours", true];
yield ['2024-05-20T10:12:00.20', "2024-05-20T10:12:00.20$hours", true];
yield ["2024-05-20T1:12:00$hours", "2024-05-20T1:12:00$hours", false];
yield ["2024-05-20T1:12:00", "2024-05-20T1:12:00$hours", true];
yield ['2024-05-20T1:12:00', "2024-05-20T1:12:00$hours", true];
}

/** @dataProvider db */
Expand Down
Loading

0 comments on commit a3ddd97

Please sign in to comment.