Skip to content

Commit

Permalink
use Nextcloud Coding Standard
Browse files Browse the repository at this point in the history
  • Loading branch information
korelstar committed Jul 13, 2020
1 parent 552bae2 commit 017e825
Show file tree
Hide file tree
Showing 33 changed files with 111 additions and 47 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ js/
report
clover.xml
composer.lock
.php_cs.cache
appinfo/info.xsd

# just sane ignores
Expand Down
18 changes: 18 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

require_once './vendor/autoload.php';

use Nextcloud\CodingStandard\Config;

$config = new Config();
$config
->getFinder()
->ignoreVCSIgnored(true)
->notPath('build')
->notPath('l10n')
->notPath('src')
->notPath('vendor')
->in(__DIR__);
return $config;
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ test-api:
lint: lint-php lint-js lint-css lint-xml


lint-php: lint-php-lint lint-php-ncversion lint-php-phan lint-php-phpcs
lint-phpfast: lint-php-lint lint-php-ncversion lint-php-phpcs
lint-php: lint-phpfast lint-php-phan
lint-phpfast: lint-php-lint lint-php-ncversion lint-php-cs-fixer lint-php-phpcs

lint-php-lint:
# Check PHP syntax errors
Expand All @@ -107,6 +107,10 @@ lint-php-phpcs:
# PHP CodeSniffer
vendor/bin/phpcs --standard=tests/phpcs.xml appinfo/ lib/ tests/api/ --report=checkstyle | vendor/bin/cs2pr --graceful-warnings --colorize

lint-php-cs-fixer:
# PHP Coding Standards Fixer (with Nextcloud coding standards)
vendor/bin/php-cs-fixer fix --dry-run --diff


lint-js:
npm run lint
Expand All @@ -125,6 +129,7 @@ lint-fix: lint-php-fix lint-js-fix lint-css-fix

lint-php-fix:
vendor/bin/phpcbf --standard=tests/phpcs.xml appinfo/ lib/ tests/api/
vendor/bin/php-cs-fixer fix

lint-js-fix:
npm run lint:fix
Expand Down
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

return ['routes' => [
////////// P A G E //////////
[
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"require-dev": {
"christophwurst/nextcloud": "^16.0",
"nextcloud/coding-standard": "^0.3.0",
"squizlabs/php_codesniffer": "3.*",
"phan/phan": "^3.0",
"guzzlehttp/guzzle": "^7.0",
Expand Down
5 changes: 3 additions & 2 deletions lib/Application.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes;

use OCP\AppFramework\App;

class Application extends App {

public static $API_VERSIONS = [ '0.2', '1.1' ];

public function __construct(array $urlParams = []) {
Expand Down
4 changes: 3 additions & 1 deletion lib/Capabilities.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes;

Expand Down
4 changes: 3 additions & 1 deletion lib/Controller/Helper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Controller;

Expand Down
4 changes: 3 additions & 1 deletion lib/Controller/NotesApiController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Controller;

Expand Down
4 changes: 3 additions & 1 deletion lib/Controller/NotesController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Controller;

Expand Down
5 changes: 3 additions & 2 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Controller;

Expand All @@ -8,7 +10,6 @@
use OCP\IRequest;

class PageController extends Controller {

public function __construct(string $AppName, IRequest $request) {
parent::__construct($AppName, $request);
}
Expand Down
5 changes: 3 additions & 2 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Controller;

Expand All @@ -10,7 +12,6 @@
use OCP\IUserSession;

class SettingsController extends Controller {

private $service;
private $userSession;

Expand Down
5 changes: 3 additions & 2 deletions lib/Db/Meta.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Db;

Expand All @@ -21,7 +23,6 @@
* @package OCA\Notes\Db
*/
class Meta extends Entity {

protected $userId;
protected $fileId;
protected $lastUpdate;
Expand Down
5 changes: 3 additions & 2 deletions lib/Db/MetaMapper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Db;

Expand All @@ -7,7 +9,6 @@
use OCP\DB\QueryBuilder\IQueryBuilder;

class MetaMapper extends QBMapper {

public function __construct(IDBConnection $db) {
parent::__construct($db, 'notes_meta');
}
Expand Down
5 changes: 3 additions & 2 deletions lib/Migration/Cleanup.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Migration;

Expand All @@ -8,7 +10,6 @@
use OCP\Migration\IOutput;

class Cleanup implements IRepairStep {

private $metaMapper;

public function __construct(MetaMapper $metaMapper) {
Expand Down
4 changes: 3 additions & 1 deletion lib/Migration/Version3005Date20200528204430.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Migration;

Expand Down
4 changes: 3 additions & 1 deletion lib/Migration/Version3005Date20200528204431.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Migration;

Expand Down
4 changes: 3 additions & 1 deletion lib/NotesHooks.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes;

Expand Down
4 changes: 3 additions & 1 deletion lib/Service/InsufficientStorageException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Service;

Expand Down
7 changes: 4 additions & 3 deletions lib/Service/MetaService.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Service;

Expand Down Expand Up @@ -47,7 +49,6 @@
* with this approach! :-)
*/
class MetaService {

private $metaMapper;

public function __construct(MetaMapper $metaMapper) {
Expand Down Expand Up @@ -105,7 +106,7 @@ public function update(string $userId, Note $note) : void {
private function getIndexedArray(array $data, string $property) : array {
$property = ucfirst($property);
$getter = 'get'.$property;
$result = array();
$result = [];
foreach ($data as $entity) {
$result[$entity->$getter()] = $entity;
}
Expand Down
5 changes: 3 additions & 2 deletions lib/Service/Note.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Service;

use OCP\Files\File;
use OCP\Files\Folder;

class Note {

private $file;
private $notesFolder;
private $noteUtil;
Expand Down
4 changes: 3 additions & 1 deletion lib/Service/NoteDoesNotExistException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Service;

Expand Down
5 changes: 3 additions & 2 deletions lib/Service/NoteUtil.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Service;

Expand All @@ -9,7 +11,6 @@
use OCP\ILogger;

class NoteUtil {

private $db;
private $l10n;
private $root;
Expand Down
4 changes: 3 additions & 1 deletion lib/Service/NotesFolderException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Service;

Expand Down
7 changes: 3 additions & 4 deletions lib/Service/NotesService.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?php declare(strict_types=1);
<?php

namespace OCA\Notes\Service;
declare(strict_types=1);

use OCA\Notes\Service\SettingsService;
namespace OCA\Notes\Service;

use OCP\Files\File;
use OCP\Files\FileInfo;
use OCP\Files\Folder;

class NotesService {

private $metaService;
private $settings;
private $noteUtil;
Expand Down
5 changes: 3 additions & 2 deletions lib/Service/SettingsService.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Service;

Expand All @@ -7,7 +9,6 @@
use OCP\Files\IRootFolder;

class SettingsService {

private $config;
private $l10n;
private $root;
Expand Down
4 changes: 3 additions & 1 deletion lib/Service/TagService.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Service;

Expand Down
2 changes: 1 addition & 1 deletion templates/main.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

script('notes', 'notes');
style('notes', 'notes');
?>
5 changes: 3 additions & 2 deletions tests/api/APIv02Test.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Tests\API;

class APIv02Test extends CommonAPITest {

public function __construct() {
parent::__construct('0.2', true);
}
Expand Down
5 changes: 3 additions & 2 deletions tests/api/APIv1Test.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Tests\API;

class APIv1Test extends CommonAPITest {

public function __construct() {
parent::__construct('1.1', false);
}
Expand Down
4 changes: 3 additions & 1 deletion tests/api/AbstractAPITest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Tests\API;

Expand Down
4 changes: 3 additions & 1 deletion tests/api/CapabilitiesTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OCA\Notes\Tests\API;

Expand Down
Loading

0 comments on commit 017e825

Please sign in to comment.