diff options
author | Morris Jobke <hey@morrisjobke.de> | 2019-01-28 22:32:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-28 22:32:49 +0100 |
commit | 9cd871983a368752d122a73da244606bdeba312f (patch) | |
tree | d1882e1e677d7cee12926e5688ccfbfd31a505f5 | |
parent | 31b2f194af74bdba60bdd2640e5fc47340157795 (diff) | |
parent | becce6b7520912257c3d72697a3aefec9923a467 (diff) |
Merge pull request #382 from SMillerDev/codestyle_psr2
Define an official codestyle and adhere to it.
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 @@ -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/" - }, - "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" - }, - { - "name": "Tobias Schultze", - "homepage": "https://github.com/Tobion" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "request", - "response", - "stream", - "uri", - "url" - ], - "time": "2017-03-20T17:10:46+00:00" - }, - { - "name": "kevinrob/guzzle-cache-middleware", - "version": "v2.1.1", - "source": { - "type": "git", - "url": "https://github.com/Kevinrob/guzzle-cache-middleware.git", - "reference": "6952064f7747756b0be7b4c234c0fd7535ea4c8c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Kevinrob/guzzle-cache-middleware/zipball/6952064f7747756b0be7b4c234c0fd7535ea4c8c", - "reference": "6952064f7747756b0be7b4c234c0fd7535ea4c8c", - "shasum": "" - }, - "require": { - "php": ">=5.5.0" - }, - "require-dev": { - "cache/array-adapter": "^0.4", - "doctrine/cache": "^1.0", - "guzzlehttp/guzzle": "^6.0", - "illuminate/cache": "^5.0", - "league/flysystem": "^1.0", - "phpunit/phpunit": "^4.0 || ^5.0", - "psr/cache": "^1.0" - }, - "suggest": { - "doctrine/cache": "This library have a lot of ready-to-use cache storage (to be use with Kevinrob\\GuzzleCache\\Storage\\DoctrineCacheStorage)", - "guzzlehttp/guzzle": "For using this library. It was created for Guzzle6. (but you can use it with any PSR-7 HTTP Client)", - "laravel/framework": "To be use with Kevinrob\\GuzzleCache\\Storage\\LaravelCacheStorage", - "league/flysystem": "To be use with Kevinrob\\GuzzleCache\\Storage\\FlysystemStorage", - "psr/cache": "To be use with Kevinrob\\GuzzleCache\\Storage\\Psr6CacheStorage" - }, - "type": "library", - "autoload": { - "psr-4": { - "Kevinrob\\GuzzleCache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kevin Robatel", - "email": "kevinrob2@gmail.com", - "homepage": "https://github.com/Kevinrob" - } - ], - "description": "A HTTP/1.1 Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack. (RFC 7234)", - "homepage": "https://github.com/Kevinrob/guzzle-cache-middleware", - "keywords": [ - "Etag", - "Flysystem", - "Guzzle", - "cache", - "cache-control", - "doctrine", - "expiration", - "guzzle6", - "handler", - "http", - "http 1.1", - "middleware", - "performance", - "php", - "promise", - "psr6", - "psr7", - "rfc7234", - "validation" - ], - "time": "2017-08-17T12:23:43+00:00" - }, - { "name": "myclabs/deep-copy", "version": "1.8.1", "source": { @@ -1336,56 +1080,6 @@ "time": "2018-08-09T05:50:03+00:00" }, { - "name": "psr/http-message", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", |