Browse Source

use Nextcloud Coding Standard

pull/571/head
korelstar 9 months ago
parent
commit
017e825daf
  1. 1
      .gitignore
  2. 18
      .php_cs.dist
  3. 9
      Makefile
  4. 1
      appinfo/routes.php
  5. 1
      composer.json
  6. 5
      lib/Application.php
  7. 4
      lib/Capabilities.php
  8. 4
      lib/Controller/Helper.php
  9. 4
      lib/Controller/NotesApiController.php
  10. 4
      lib/Controller/NotesController.php
  11. 5
      lib/Controller/PageController.php
  12. 5
      lib/Controller/SettingsController.php
  13. 5
      lib/Db/Meta.php
  14. 5
      lib/Db/MetaMapper.php
  15. 5
      lib/Migration/Cleanup.php
  16. 4
      lib/Migration/Version3005Date20200528204430.php
  17. 4
      lib/Migration/Version3005Date20200528204431.php
  18. 4
      lib/NotesHooks.php
  19. 4
      lib/Service/InsufficientStorageException.php
  20. 7
      lib/Service/MetaService.php
  21. 5
      lib/Service/Note.php
  22. 4
      lib/Service/NoteDoesNotExistException.php
  23. 5
      lib/Service/NoteUtil.php
  24. 4
      lib/Service/NotesFolderException.php
  25. 7
      lib/Service/NotesService.php
  26. 5
      lib/Service/SettingsService.php
  27. 4
      lib/Service/TagService.php
  28. 2
      templates/main.php
  29. 5
      tests/api/APIv02Test.php
  30. 5
      tests/api/APIv1Test.php
  31. 4
      tests/api/AbstractAPITest.php
  32. 4
      tests/api/CapabilitiesTest.php
  33. 5
      tests/api/CommonAPITest.php

1
.gitignore

@ -7,6 +7,7 @@ js/
report
clover.xml
composer.lock
.php_cs.cache
appinfo/info.xsd
# just sane ignores

18
.php_cs.dist

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

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

1
appinfo/routes.php

@ -1,4 +1,5 @@
<?php
return ['routes' => [
////////// P A G E //////////
[

1
composer.json

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

5
lib/Application.php

@ -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 = []) {

4
lib/Capabilities.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes;

4
lib/Controller/Helper.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Controller;

4
lib/Controller/NotesApiController.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Controller;

4
lib/Controller/NotesController.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Controller;

5
lib/Controller/PageController.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Controller;
@ -8,7 +10,6 @@ use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\IRequest;
class PageController extends Controller {
public function __construct(string $AppName, IRequest $request) {
parent::__construct($AppName, $request);
}

5
lib/Controller/SettingsController.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Controller;
@ -10,7 +12,6 @@ use OCP\IRequest;
use OCP\IUserSession;
class SettingsController extends Controller {
private $service;
private $userSession;

5
lib/Db/Meta.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Db;
@ -21,7 +23,6 @@ use OCP\AppFramework\Db\Entity;
* @package OCA\Notes\Db
*/
class Meta extends Entity {
protected $userId;
protected $fileId;
protected $lastUpdate;

5
lib/Db/MetaMapper.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Db;
@ -7,7 +9,6 @@ use OCP\AppFramework\Db\QBMapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
class MetaMapper extends QBMapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'notes_meta');
}

5
lib/Migration/Cleanup.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Migration;
@ -8,7 +10,6 @@ use OCP\Migration\IRepairStep;
use OCP\Migration\IOutput;
class Cleanup implements IRepairStep {
private $metaMapper;
public function __construct(MetaMapper $metaMapper) {

4
lib/Migration/Version3005Date20200528204430.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Migration;

4
lib/Migration/Version3005Date20200528204431.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Migration;

4
lib/NotesHooks.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes;

4
lib/Service/InsufficientStorageException.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Service;

7
lib/Service/MetaService.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Service;
@ -47,7 +49,6 @@ use OCA\Notes\Db\MetaMapper;
* with this approach! :-)
*/
class MetaService {
private $metaMapper;
public function __construct(MetaMapper $metaMapper) {
@ -105,7 +106,7 @@ class MetaService {
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;
}

5
lib/Service/Note.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Service;
@ -6,7 +8,6 @@ use OCP\Files\File;
use OCP\Files\Folder;
class Note {
private $file;
private $notesFolder;
private $noteUtil;

4
lib/Service/NoteDoesNotExistException.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Service;

5
lib/Service/NoteUtil.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Service;
@ -9,7 +11,6 @@ use OCP\IL10N;
use OCP\ILogger;
class NoteUtil {
private $db;
private $l10n;
private $root;

4
lib/Service/NotesFolderException.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Service;

7
lib/Service/NotesService.php

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

5
lib/Service/SettingsService.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Service;
@ -7,7 +9,6 @@ use OCP\IL10N;
use OCP\Files\IRootFolder;
class SettingsService {
private $config;
private $l10n;
private $root;

4
lib/Service/TagService.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Service;

2
templates/main.php

@ -1,4 +1,4 @@
<?php
script('notes', 'notes');
style('notes', 'notes');
?>

5
tests/api/APIv02Test.php

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

5
tests/api/APIv1Test.php

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

4
tests/api/AbstractAPITest.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Tests\API;

4
tests/api/CapabilitiesTest.php

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Tests\API;

5
tests/api/CommonAPITest.php

@ -1,9 +1,10 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace OCA\Notes\Tests\API;
abstract class CommonAPITest extends AbstractAPITest {
private $requiredAttributes = [
'id' => 'integer',
'content' => 'string',

Loading…
Cancel
Save