summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2019-01-28 22:32:49 +0100
committerGitHub <noreply@github.com>2019-01-28 22:32:49 +0100
commit9cd871983a368752d122a73da244606bdeba312f (patch)
treed1882e1e677d7cee12926e5688ccfbfd31a505f5
parent31b2f194af74bdba60bdd2640e5fc47340157795 (diff)
parentbecce6b7520912257c3d72697a3aefec9923a467 (diff)
Merge pull request #382 from SMillerDev/codestyle_psr2
Define an official codestyle and adhere to it.
-rw-r--r--CONTRIBUTING.md22
-rw-r--r--Makefile6
-rw-r--r--composer.json3
-rw-r--r--composer.lock359
-rw-r--r--docs/install.md4
-rw-r--r--lib/AppInfo/Application.php5
-rw-r--r--lib/Command/Updater/AfterUpdate.php7
-rw-r--r--lib/Command/Updater/AllFeeds.php8
-rw-r--r--lib/Command/Updater/BeforeUpdate.php7
-rw-r--r--lib/Command/Updater/UpdateFeed.php8
-rw-r--r--lib/Config/Config.php52
-rw-r--r--lib/Config/DependencyException.php4
-rw-r--r--lib/Controller/AdminController.php76
-rw-r--r--lib/Controller/ApiController.php10
-rw-r--r--lib/Controller/EntityApiSerializer.php20
-rw-r--r--lib/Controller/ExportController.php13
-rw-r--r--lib/Controller/FeedApiController.php48
-rw-r--r--lib/Controller/FeedController.php73
-rw-r--r--lib/Controller/FolderApiController.php30
-rw-r--r--lib/Controller/FolderController.php50
-rw-r--r--lib/Controller/ItemApiController.php80
-rw-r--r--lib/Controller/ItemController.php82
-rw-r--r--lib/Controller/JSONHttpError.php7
-rw-r--r--lib/Controller/PageController.php61
-rw-r--r--lib/Controller/UserApiController.php6
-rw-r--r--lib/Controller/UtilityApiController.php14
-rw-r--r--lib/Cron/Updater.php9
-rw-r--r--lib/Db/EntityJSONSerializer.php8
-rw-r--r--lib/Db/Feed.php1
-rw-r--r--lib/Db/FeedMapper.php15
-rw-r--r--lib/Db/FeedType.php3
-rw-r--r--lib/Db/Folder.php1
-rw-r--r--lib/Db/FolderMapper.php12
-rw-r--r--lib/Db/Item.php4
-rw-r--r--lib/Db/ItemMapper.php85
-rw-r--r--lib/Db/MapperFactory.php16
-rw-r--r--lib/Db/Mysql/ItemMapper.php9
-rw-r--r--lib/Db/NewsMapper.php17
-rw-r--r--lib/DependencyInjection/IFactory.php1
-rw-r--r--lib/Explore/RecommendedSites.php6
-rw-r--r--lib/Fetcher/FeedFetcher.php190
-rw-r--r--lib/Fetcher/Fetcher.php53
-rw-r--r--lib/Fetcher/FetcherException.php3
-rw-r--r--lib/Fetcher/IFeedFetcher.php46
-rw-r--r--lib/Fetcher/YoutubeFetcher.php52
-rw-r--r--lib/Hooks/User.php3
-rw-r--r--lib/Http/TextDownloadResponse.php3
-rw-r--r--lib/Http/TextResponse.php4
-rw-r--r--lib/Migration/MigrateStatusFlags.php12
-rw-r--r--lib/Plugin/Client/Plugin.php11
-rw-r--r--lib/PostProcessor/LWNProcessor.php19
-rw-r--r--lib/Service/FeedService.php86
-rw-r--r--lib/Service/FolderService.php23
-rw-r--r--lib/Service/ItemService.php122
-rw-r--r--lib/Service/Service.php6
-rw-r--r--lib/Service/ServiceConflictException.php4
-rw-r--r--lib/Service/ServiceException.php4
-rw-r--r--lib/Service/ServiceNotFoundException.php4
-rw-r--r--lib/Service/ServiceValidationException.php4
-rw-r--r--lib/Service/StatusService.php19
-rw-r--r--lib/Settings/Admin.php8
-rw-r--r--lib/Settings/Section.php12
-rw-r--r--lib/Utility/OPMLExporter.php5
-rw-r--r--lib/Utility/PicoFeedClientFactory.php8
-rw-r--r--lib/Utility/PicoFeedFaviconFactory.php8
-rw-r--r--lib/Utility/ProxyConfigParser.php9
-rw-r--r--lib/Utility/Time.php5
-rw-r--r--lib/Utility/Updater.php14
68 files changed, 899 insertions, 1080 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e14b07828..5f591330e 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,8 +1,8 @@
# Contributing
Read this when you want to:
-* file an issue (bug or feature request)
-* help translate the News file to your language
+* [file an issue (bug or feature request)](#Issues)
+* [help translate the News file to your language](#Translation)
* start programming and change the way the News app works
* add cool new feeds to the feed explore section
* want to provide additional full text feed rules
@@ -119,16 +119,8 @@ We usually hang out on **irc.freenode.net** in the **#nextcloud-news** and **#ne
### Coding Style Guidelines
-* Use 4 spaces for indention. Why spaces? Because it looks the same on every machine and on the web where you can't normally control the tab width.
-* Place the open curly braces on the same line as the parameter block, e.g.:
- ```php
- if (condition) {
- // code
- } else {
- // code
- }
- ```
-
-* Place a space before and after the parameter block for if, else, for, foreach, function
-* Everything should be in camelCase except classes which should be in PascalCase
-* For linting JavaScript, a [jshint file](https://github.com/nextcloud/news/blob/master/js/.jshintrc) is used that is run before compiling the JavaScript
+The PHP code should all adhere to [PSR-2](https://www.php-fig.org/psr/psr-2/).
+*Note that this is a different codestyle than nextcloud itself uses.*
+To test the codestyle you can run `make phpcs`.
+
+For linting JavaScript, a [jshint file](https://github.com/nextcloud/news/blob/master/js/.jshintrc) is used that is run before compiling the JavaScript
diff --git a/Makefile b/Makefile
index 048848014..d716d09da 100644
--- a/Makefile
+++ b/Makefile
@@ -108,6 +108,11 @@ endif
clean:
rm -rf ./build
+# Reports PHP codestyle violations
+.PHONY: phpcs
+phpcs:
+ ./vendor/bin/phpcs --standard=PSR2 lib
+
# Same as clean but also removes dependencies installed by composer and
# npm
.PHONY: distclean
@@ -183,3 +188,4 @@ test:
./vendor/phpunit/phpunit/phpunit -c phpunit.xml --coverage-clover build/php-unit.clover
# \Test\TestCase is only allowed to access the db if TRAVIS environment variable is set
env TRAVIS=1 ./vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml --coverage-clover build/php-unit.clover
+ $(MAKE) phpcs
diff --git a/composer.json b/composer.json
index efe82796e..4a03b86a2 100644
--- a/composer.json
+++ b/composer.json
@@ -36,7 +36,8 @@
"nicolus/picofeed": "0.1.35"
},
"require-dev": {
- "phpunit/phpunit": "^6.5"
+ "phpunit/phpunit": "^6.5",
+ "squizlabs/php_codesniffer": "^3.3"
},
"autoload": {
"psr-4": {
diff --git a/composer.lock b/composer.lock
index 441af16c8..2c814bcd0 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "ac4e6dcfaee8b83840050366cacebc4c",
+ "content-hash": "f4a0d96b7e83ec4d9d232412b9e61566",
"packages": [
{
"name": "ezyang/htmlpurifier",
@@ -323,262 +323,6 @@
"time": "2017-07-22T11:58:36+00:00"
},
{
- "name": "guzzlehttp/guzzle",
- "version": "6.3.3",
- "source": {
- "type": "git",
- "url": "https://github.com/guzzle/guzzle.git",
- "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba",
- "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba",
- "shasum": ""
- },
- "require": {
- "guzzlehttp/promises": "^1.0",
- "guzzlehttp/psr7": "^1.4",
- "php": ">=5.5"
- },
- "require-dev": {
- "ext-curl": "*",
- "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
- "psr/log": "^1.0"
- },
- "suggest": {
- "psr/log": "Required for using the Log middleware"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "6.3-dev"
- }
- },
- "autoload": {
- "files": [
- "src/functions_include.php"
- ],
- "psr-4": {
- "GuzzleHttp\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Michael Dowling",
- "email": "mtdowling@gmail.com",
- "homepage": "https://github.com/mtdowling"
- }
- ],
- "description": "Guzzle is a PHP HTTP client library",
- "homepage": "http://guzzlephp.org/",
- "keywords": [
- "client",
- "curl",
- "framework",
- "http",
- "http client",
- "rest",
- "web service"
- ],
- "time": "2018-04-22T15:46:56+00:00"
- },
- {
- "name": "guzzlehttp/promises",
- "version": "v1.3.1",
- "source": {
- "type": "git",
- "url": "https://github.com/guzzle/promises.git",
- "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
- "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
- "shasum": ""
- },
- "require": {
- "php": ">=5.5.0"
- },
- "require-dev": {
- "phpunit/phpunit": "^4.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.4-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "GuzzleHttp\\Promise\\": "src/"
- },
- "files": [
- "src/functions_include.php"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Michael Dowling",
- "email": "mtdowling@gmail.com",
- "homepage": "https://github.com/mtdowling"
- }
- ],
- "description": "Guzzle promises library",
- "keywords": [
- "promise"
- ],
- "time": "2016-12-20T10:07:11+00:00"
- },
- {
- "name": "guzzlehttp/psr7",
- "version": "1.4.2",
- "source": {
- "type": "git",
- "url": "https://github.com/guzzle/psr7.git",
- "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
- "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
- "shasum": ""
- },
- "require": {
- "php": ">=5.4.0",
- "psr/http-message": "~1.0"
- },
- "provide": {
- "psr/http-message-implementation": "1.0"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.4-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "GuzzleHttp\\Psr7\\": "src/"
-