update PHP coding style (by Nextcloud)

This commit is contained in:
korelstar 2021-02-03 21:30:50 +01:00
parent 8fd307268e
commit 1f772ea26d
9 changed files with 13 additions and 13 deletions

View File

@ -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",

View File

@ -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);

View File

@ -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' ]);

View File

@ -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();

View File

@ -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();

View File

@ -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) {

View File

@ -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,

View File

@ -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());
}

View File

@ -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;
}