Skip to content

Commit

Permalink
style: Apply php-cs-fixer changes
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Knorr <[email protected]>
  • Loading branch information
juliusknorr committed Sep 15, 2024
1 parent a96f868 commit d52ae38
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/Controller/NotesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function index(int $pruneBefore = 0) : JSONResponse {
// initialize and load settings
$settings = $this->settingsService->getAll($userId, true);

$lastViewedNote = (int) $this->settings->getUserValue(
$lastViewedNote = (int)$this->settings->getUserValue(
$userId,
$this->appName,
'notesLastViewedNote'
Expand Down
10 changes: 5 additions & 5 deletions lib/Service/Note.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public function getExcerpt(int $maxlen = 100) : string {
$excerpt = trim($this->noteUtil->stripMarkdown($this->getContent()));
$title = $this->getTitle();
if (!empty($title)) {
$length = mb_strlen($title, "utf-8");
$length = mb_strlen($title, 'utf-8');
if (strncasecmp($excerpt, $title, $length) === 0) {
$excerpt = mb_substr($excerpt, $length, null, "utf-8");
$excerpt = mb_substr($excerpt, $length, null, 'utf-8');
}
}
$excerpt = trim($excerpt);
if (mb_strlen($excerpt, "utf-8") > $maxlen) {
$excerpt = mb_substr($excerpt, 0, $maxlen, "utf-8") . '';
if (mb_strlen($excerpt, 'utf-8') > $maxlen) {
$excerpt = mb_substr($excerpt, 0, $maxlen, 'utf-8') . '';
}
return str_replace("\n", "\u{2003}", $excerpt);
}
Expand Down Expand Up @@ -107,7 +107,7 @@ public function getData(array $exclude = []) : array {
}
$data['internalPath'] = $this->noteUtil->getPathForUser($this->file);
$data['shareTypes'] = $this->noteUtil->getShareTypes($this->file);
$data['isShared'] = (bool) count($data['shareTypes']);
$data['isShared'] = (bool)count($data['shareTypes']);
$data['error'] = false;
$data['errorType'] = '';
if (!in_array('content', $exclude)) {
Expand Down
20 changes: 10 additions & 10 deletions lib/Service/NoteUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public function getCategoryFolder(Folder $notesFolder, string $category) {
* @param string $title the filename which should be used
* @param string $suffix the suffix (incl. dot) which should be used
* @param int $id the id of the note for which the title should be generated
* used to see if the file itself has the title and not a different file for
* checking for filename collisions
* used to see if the file itself has the title and not a different file for
* checking for filename collisions
* @return string the resolved filename to prevent overwriting different
* files with the same title
* files with the same title
*/
public function generateFileName(Folder $folder, string $title, string $suffix, int $id) : string {
$title = $this->getSafeTitle($title);
Expand All @@ -91,7 +91,7 @@ public function generateFileName(Folder $folder, string $title, string $suffix,
// increments name (2) to name (3)
$match = preg_match('/\s\((?P<id>\d+)\)$/u', $title, $matches);
if ($match) {
$newId = ((int) $matches['id']) + 1;
$newId = ((int)$matches['id']) + 1;
$baseTitle = preg_replace('/\s\(\d+\)$/u', '', $title);
$idSuffix = ' (' . $newId . ')';
} else {
Expand All @@ -100,7 +100,7 @@ public function generateFileName(Folder $folder, string $title, string $suffix,
}
// make sure there's enough room for the ID suffix before appending or it will be
// trimmed by getSafeTitle() and could cause infinite recursion
$newTitle = mb_substr($baseTitle, 0, self::MAX_TITLE_LENGTH - mb_strlen($idSuffix), "UTF-8") . $idSuffix;
$newTitle = mb_substr($baseTitle, 0, self::MAX_TITLE_LENGTH - mb_strlen($idSuffix), 'UTF-8') . $idSuffix;
return $this->generateFileName($folder, $newTitle, $suffix, $id);
}
}
Expand All @@ -117,7 +117,7 @@ public function getSafeTitle(string $content) : string {
$title = preg_replace('/\s/u', ' ', $title);

// using a maximum of 100 chars should be enough
$title = mb_substr($title, 0, self::MAX_TITLE_LENGTH, "UTF-8");
$title = mb_substr($title, 0, self::MAX_TITLE_LENGTH, 'UTF-8');

// ensure that title is not empty
if (empty($title)) {
Expand Down Expand Up @@ -151,10 +151,10 @@ private function sanitisePath(string $str) : string {

public function stripMarkdown(string $str) : string {
// prepare content: remove markdown characters and empty spaces
$str = preg_replace("/^\s*[*+-]\s+/mu", "", $str); // list item
$str = preg_replace("/^#+\s+(.*?)\s*#*$/mu", "$1", $str); // headline
$str = preg_replace("/^(=+|-+)$/mu", "", $str); // separate line for headline
$str = preg_replace("/(\*+|_+)(.*?)\\1/mu", "$2", $str); // emphasis
$str = preg_replace("/^\s*[*+-]\s+/mu", '', $str); // list item
$str = preg_replace("/^#+\s+(.*?)\s*#*$/mu", '$1', $str); // headline
$str = preg_replace('/^(=+|-+)$/mu', '', $str); // separate line for headline
$str = preg_replace("/(\*+|_+)(.*?)\\1/mu", '$2', $str); // emphasis
return $str;
}

Expand Down
8 changes: 4 additions & 4 deletions lib/Service/NotesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function create(string $userId, string $title, string $category) : Note {

// get file name
$fileSuffix = $this->settings->get($userId, 'fileSuffix');
if ($fileSuffix === "custom") {
if ($fileSuffix === 'custom') {
$fileSuffix = $this->settings->get($userId, 'customSuffix');
}
$filename = $this->noteUtil->generateFileName($folder, $title, $fileSuffix, -1);
Expand Down Expand Up @@ -194,7 +194,7 @@ private static function isNote(FileInfo $file, string $customExtension) : bool {
*/
private function getCustomExtension(string $userId) {
$suffix = $this->settings->get($userId, 'customSuffix');
return ltrim($suffix, ".");
return ltrim($suffix, '.');
}

/**
Expand Down Expand Up @@ -238,7 +238,7 @@ public function getAttachment(string $userId, int $noteid, string $path) : File
* @param $fileDataArray
* @throws NotPermittedException
* @throws ImageNotWritableException
* https://github.com/nextcloud/deck/blob/master/lib/Service/AttachmentService.php
* https://github.com/nextcloud/deck/blob/master/lib/Service/AttachmentService.php
*/
public function createImage(string $userId, int $noteid, $fileDataArray) {
$note = $this->get($userId, $noteid);
Expand All @@ -253,7 +253,7 @@ public function createImage(string $userId, int $noteid, $fileDataArray) {
}
$filename = $filename . '.' . explode('.', $fileDataArray['name'])[1];

if ($fileDataArray['tmp_name'] === "") {
if ($fileDataArray['tmp_name'] === '') {
throw new ImageNotWritableException();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Service/SettingsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function getAll(string $uid, $saveInitial = false) : \stdClass {
}
}
if ($toBeSaved) {
$this->set($uid, (array) $settings);
$this->set($uid, (array)$settings);
}
return $settings;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/phan-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

return [
'directory_list' => $testDirs,
"exclude_analysis_directory_list" => [
'exclude_analysis_directory_list' => [
'vendor/',
],
];

0 comments on commit d52ae38

Please sign in to comment.