update PHP coding style (by Nextcloud)
This commit is contained in:
parent
8fd307268e
commit
1f772ea26d
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"christophwurst/nextcloud": "^20.0",
|
"christophwurst/nextcloud": "^20.0",
|
||||||
"nextcloud/coding-standard": "^0.3.0",
|
"nextcloud/coding-standard": "^0.5.0",
|
||||||
"squizlabs/php_codesniffer": "3.*",
|
"squizlabs/php_codesniffer": "3.*",
|
||||||
"phan/phan": "^3.0",
|
"phan/phan": "^3.0",
|
||||||
"guzzlehttp/guzzle": "^7.0",
|
"guzzlehttp/guzzle": "^7.0",
|
||||||
|
|
|
@ -53,7 +53,7 @@ class NotesApiController extends ApiController {
|
||||||
}
|
}
|
||||||
$notesData = array_map(function ($note) use ($metas, $pruneBefore, $exclude) {
|
$notesData = array_map(function ($note) use ($metas, $pruneBefore, $exclude) {
|
||||||
$lastUpdate = $metas[$note->getId()]->getLastUpdate();
|
$lastUpdate = $metas[$note->getId()]->getLastUpdate();
|
||||||
if ($pruneBefore && $lastUpdate<$pruneBefore) {
|
if ($pruneBefore && $lastUpdate < $pruneBefore) {
|
||||||
return [ 'id' => $note->getId() ];
|
return [ 'id' => $note->getId() ];
|
||||||
} else {
|
} else {
|
||||||
return $note->getData($exclude);
|
return $note->getData($exclude);
|
||||||
|
|
|
@ -54,7 +54,7 @@ class NotesController extends Controller {
|
||||||
$metas = $this->metaService->updateAll($userId, $data['notes']);
|
$metas = $this->metaService->updateAll($userId, $data['notes']);
|
||||||
$notes = array_map(function ($note) use ($metas, $pruneBefore) {
|
$notes = array_map(function ($note) use ($metas, $pruneBefore) {
|
||||||
$lastUpdate = $metas[$note->getId()]->getLastUpdate();
|
$lastUpdate = $metas[$note->getId()]->getLastUpdate();
|
||||||
if ($pruneBefore && $lastUpdate<$pruneBefore) {
|
if ($pruneBefore && $lastUpdate < $pruneBefore) {
|
||||||
return [ 'id' => $note->getId() ];
|
return [ 'id' => $note->getId() ];
|
||||||
} else {
|
} else {
|
||||||
return $note->getData([ 'content' ]);
|
return $note->getData([ 'content' ]);
|
||||||
|
|
|
@ -136,7 +136,7 @@ class Note {
|
||||||
* @throws \OCP\Files\NotPermittedException
|
* @throws \OCP\Files\NotPermittedException
|
||||||
*/
|
*/
|
||||||
public function setTitleCategory(string $title, ?string $category = null) : void {
|
public function setTitleCategory(string $title, ?string $category = null) : void {
|
||||||
if ($category===null) {
|
if ($category === null) {
|
||||||
$category = $this->getCategory();
|
$category = $this->getCategory();
|
||||||
}
|
}
|
||||||
$oldParent = $this->file->getParent();
|
$oldParent = $this->file->getParent();
|
||||||
|
|
|
@ -166,7 +166,7 @@ class NoteUtil {
|
||||||
public function deleteEmptyFolder(Folder $folder, Folder $notesFolder) : void {
|
public function deleteEmptyFolder(Folder $folder, Folder $notesFolder) : void {
|
||||||
$content = $folder->getDirectoryListing();
|
$content = $folder->getDirectoryListing();
|
||||||
$isEmpty = !count($content);
|
$isEmpty = !count($content);
|
||||||
$isNotesFolder = $folder->getPath()===$notesFolder->getPath();
|
$isNotesFolder = $folder->getPath() === $notesFolder->getPath();
|
||||||
if ($isEmpty && !$isNotesFolder) {
|
if ($isEmpty && !$isNotesFolder) {
|
||||||
$this->util->logger->debug('Deleting empty category folder '.$folder->getPath());
|
$this->util->logger->debug('Deleting empty category folder '.$folder->getPath());
|
||||||
$parent = $folder->getParent();
|
$parent = $folder->getParent();
|
||||||
|
|
|
@ -23,7 +23,7 @@ class Util {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function retryIfLocked(callable $f, int $maxRetries = 5, int $sleep = 1) {
|
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 {
|
try {
|
||||||
return $f();
|
return $f();
|
||||||
} catch (\OCP\Lock\LockedException $e) {
|
} catch (\OCP\Lock\LockedException $e) {
|
||||||
|
|
|
@ -111,7 +111,7 @@ abstract class AbstractAPITest extends TestCase {
|
||||||
$note,
|
$note,
|
||||||
$messagePrefix.': Note has property '.$key.' (reference note: '.$refNote->title.')'
|
$messagePrefix.': Note has property '.$key.' (reference note: '.$refNote->title.')'
|
||||||
);
|
);
|
||||||
if ($key==='title') {
|
if ($key === 'title') {
|
||||||
// allow suffix for title (e.g. "Note title (2)")
|
// allow suffix for title (e.g. "Note title (2)")
|
||||||
$this->assertStringStartsWith(
|
$this->assertStringStartsWith(
|
||||||
$refNote->$key,
|
$refNote->$key,
|
||||||
|
@ -125,7 +125,7 @@ abstract class AbstractAPITest extends TestCase {
|
||||||
$messagePrefix.': Property '.$key.' suffix (reference note: '.$refNote->title.')'
|
$messagePrefix.': Property '.$key.' suffix (reference note: '.$refNote->title.')'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} elseif ($key==='modified') {
|
} elseif ($key === 'modified') {
|
||||||
// allow delta if the test runs slowly
|
// allow delta if the test runs slowly
|
||||||
$this->assertEqualsWithDelta(
|
$this->assertEqualsWithDelta(
|
||||||
$refNote->$key,
|
$refNote->$key,
|
||||||
|
|
|
@ -232,10 +232,10 @@ abstract class CommonAPITest extends AbstractAPITest {
|
||||||
$note = $notes[0]; // @phan-suppress-current-line PhanTypeArraySuspiciousNullable
|
$note = $notes[0]; // @phan-suppress-current-line PhanTypeArraySuspiciousNullable
|
||||||
$request = (object)[ 'content' => 'New test content' ];
|
$request = (object)[ 'content' => 'New test content' ];
|
||||||
// update will fail
|
// 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());
|
$this->assertEquals(507, $response1->getStatusCode());
|
||||||
// craete will fail
|
// 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());
|
$this->assertEquals(507, $response2->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ function getNCVersionFromComposer($path) {
|
||||||
}
|
}
|
||||||
$dev = getValidProperty($json, 'require-dev');
|
$dev = getValidProperty($json, 'require-dev');
|
||||||
$v = getValidProperty($dev, 'christophwurst/nextcloud');
|
$v = getValidProperty($dev, 'christophwurst/nextcloud');
|
||||||
if (substr($v, 0, 1)=='^') {
|
if (substr($v, 0, 1) == '^') {
|
||||||
$v = substr($v, 1);
|
$v = substr($v, 1);
|
||||||
}
|
}
|
||||||
return $v;
|
return $v;
|
||||||
|
@ -36,7 +36,7 @@ function getNCVersionFromComposerBranchAlias($path) {
|
||||||
$extra = getValidProperty($json, 'extra');
|
$extra = getValidProperty($json, 'extra');
|
||||||
$branchAlias = getValidProperty($extra, 'branch-alias');
|
$branchAlias = getValidProperty($extra, 'branch-alias');
|
||||||
$v = getValidProperty($branchAlias, 'dev-master');
|
$v = getValidProperty($branchAlias, 'dev-master');
|
||||||
if (substr($v, -4)=='-dev') {
|
if (substr($v, -4) == '-dev') {
|
||||||
$v = substr($v, 0, -4);
|
$v = substr($v, 0, -4);
|
||||||
}
|
}
|
||||||
return $v;
|
return $v;
|
||||||
|
@ -83,7 +83,7 @@ function versionCompare($sv1, $sv2, $type) {
|
||||||
$v1 = explode('.', $sv1);
|
$v1 = explode('.', $sv1);
|
||||||
$v2 = explode('.', $sv2);
|
$v2 = explode('.', $sv2);
|
||||||
$count = min(count($v1), count($v2));
|
$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]) {
|
if ($type == 'max' && $v1[$i] < $v2[$i]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue