use Nextcloud Coding Standard
This commit is contained in:
parent
552bae269a
commit
017e825daf
|
@ -7,6 +7,7 @@ js/
|
|||
report
|
||||
clover.xml
|
||||
composer.lock
|
||||
.php_cs.cache
|
||||
appinfo/info.xsd
|
||||
|
||||
# just sane ignores
|
||||
|
|
|
@ -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
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,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
return ['routes' => [
|
||||
////////// P A G E //////////
|
||||
[
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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 = []) {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Notes;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Notes\Controller;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Notes\Controller;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Notes\Controller;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Notes\Migration;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Notes\Migration;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Notes;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Notes\Service;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Notes\Service;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Notes\Service;
|
||||
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Notes\Service;
|
||||
|
||||
use OCA\Notes\Service\SettingsService;
|
||||
|
||||
use OCP\Files\File;
|
||||
use OCP\Files\FileInfo;
|
||||
use OCP\Files\Folder;
|
||||
|
||||
class NotesService {
|
||||
|
||||
private $metaService;
|
||||
private $settings;
|
||||
private $noteUtil;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Notes\Service;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
|
||||
script('notes', 'notes');
|
||||
style('notes', 'notes');
|
||||
?>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Notes\Tests\API;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Notes\Tests\API;
|
||||
|
||||
|
|
|
@ -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…
Reference in New Issue