Browse Source

update PHP coding style (by Nextcloud)

pull/679/head
korelstar 3 months ago
parent
commit
1f772ea26d
  1. 2
      composer.json
  2. 2
      lib/Controller/NotesApiController.php
  3. 2
      lib/Controller/NotesController.php
  4. 2
      lib/Service/Note.php
  5. 2
      lib/Service/NoteUtil.php
  6. 2
      lib/Service/Util.php
  7. 4
      tests/api/AbstractAPITest.php
  8. 4
      tests/api/CommonAPITest.php
  9. 6
      tests/nextcloud-version.php

2
composer.json

@ -1,7 +1,7 @@
{
"require-dev": {
"christophwurst/nextcloud": "^20.0",
"nextcloud/coding-standard": "^0.3.0",
"nextcloud/coding-standard": "^0.5.0",
"squizlabs/php_codesniffer": "3.*",
"phan/phan": "^3.0",
"guzzlehttp/guzzle": "^7.0",

2
lib/Controller/NotesApiController.php

@ -53,7 +53,7 @@ class NotesApiController extends ApiController {
}
$notesData = array_map(function ($note) use ($metas, $pruneBefore, $exclude) {
$lastUpdate = $metas[$note->getId()]->getLastUpdate();
if ($pruneBefore && $lastUpdate<$pruneBefore) {
if ($pruneBefore && $lastUpdate < $pruneBefore) {
return [ 'id' => $note->getId() ];
} else {
return $note->getData($exclude);

2
lib/Controller/NotesController.php

@ -54,7 +54,7 @@ class NotesController extends Controller {
$metas = $this->metaService->updateAll($userId, $data['notes']);
$notes = array_map(function ($note) use ($metas, $pruneBefore) {
$lastUpdate = $metas[$note->getId()]->getLastUpdate();
if ($pruneBefore && $lastUpdate<$pruneBefore) {
if ($pruneBefore && $lastUpdate < $pruneBefore) {
return [ 'id' => $note->getId() ];
} else {
return $note->getData([ 'content' ]);

2
lib/Service/Note.php

@ -136,7 +136,7 @@ class Note {
* @throws \OCP\Files\NotPermittedException
*/
public function setTitleCategory(string $title, ?string $category = null) : void {
if ($category===null) {
if ($category === null) {
$category = $this->getCategory();
}
$oldParent = $this->file->getParent();

2
lib/Service/NoteUtil.php

@ -166,7 +166,7 @@ class NoteUtil {
public function deleteEmptyFolder(Folder $folder, Folder $notesFolder) : void {
$content = $folder->getDirectoryListing();
$isEmpty = !count($content);
$isNotesFolder = $folder->getPath()===$notesFolder->getPath();
$isNotesFolder = $folder->getPath() === $notesFolder->getPath();
if ($isEmpty && !$isNotesFolder) {
$this->util->logger->debug('Deleting empty category folder '.$folder->getPath());
$parent = $folder->getParent();

2
lib/Service/Util.php

@ -23,7 +23,7 @@ class Util {
}
public static function retryIfLocked(callable $f, int $maxRetries = 5, int $sleep = 1) {
for ($try=1; $try <= $maxRetries; $try++) {
for ($try = 1; $try <= $maxRetries; $try++) {
try {
return $f();
} catch (\OCP\Lock\LockedException $e) {

4
tests/api/AbstractAPITest.php

@ -111,7 +111,7 @@ abstract class AbstractAPITest extends TestCase {
$note,
$messagePrefix.': Note has property '.$key.' (reference note: '.$refNote->title.')'
);
if ($key==='title') {
if ($key === 'title') {
// allow suffix for title (e.g. "Note title (2)")
$this->assertStringStartsWith(
$refNote->$key,
@ -125,7 +125,7 @@ abstract class AbstractAPITest extends TestCase {
$messagePrefix.': Property '.$key.' suffix (reference note: '.$refNote->title.')'
);
}
} elseif ($key==='modified') {
} elseif ($key === 'modified') {
// allow delta if the test runs slowly
$this->assertEqualsWithDelta(
$refNote->$key,

4
tests/api/CommonAPITest.php

@ -232,10 +232,10 @@ abstract class CommonAPITest extends AbstractAPITest {
$note = $notes[0]; // @phan-suppress-current-line PhanTypeArraySuspiciousNullable
$request = (object)[ 'content' => 'New test content' ];
// update will fail
$response1 = $this->http->request('PUT', 'notes/'.$note->id, [ 'auth' => $auth, 'json' => $request]);
$response1 = $this->http->request('PUT', 'notes/'.$note->id, [ 'auth' => $auth, 'json' => $request]);
$this->assertEquals(507, $response1->getStatusCode());
// craete will fail
$response2 = $this->http->request('POST', 'notes', [ 'auth' => $auth, 'json' => $request]);
$response2 = $this->http->request('POST', 'notes', [ 'auth' => $auth, 'json' => $request]);
$this->assertEquals(507, $response2->getStatusCode());
}

6
tests/nextcloud-version.php

@ -14,7 +14,7 @@ function getNCVersionFromComposer($path) {
}
$dev = getValidProperty($json, 'require-dev');
$v = getValidProperty($dev, 'christophwurst/nextcloud');
if (substr($v, 0, 1)=='^') {
if (substr($v, 0, 1) == '^') {
$v = substr($v, 1);
}
return $v;
@ -36,7 +36,7 @@ function getNCVersionFromComposerBranchAlias($path) {
$extra = getValidProperty($json, 'extra');
$branchAlias = getValidProperty($extra, 'branch-alias');
$v = getValidProperty($branchAlias, 'dev-master');
if (substr($v, -4)=='-dev') {
if (substr($v, -4) == '-dev') {
$v = substr($v, 0, -4);
}
return $v;
@ -83,7 +83,7 @@ function versionCompare($sv1, $sv2, $type) {
$v1 = explode('.', $sv1);
$v2 = explode('.', $sv2);
$count = min(count($v1), count($v2));
for ($i=0; $i<$count; $i++) {
for ($i = 0; $i < $count; $i++) {
if ($type == 'max' && $v1[$i] < $v2[$i]) {
return true;
}

Loading…
Cancel
Save