summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2020-08-24 22:29:35 +0200
committerSean Molenaar <SMillerDev@users.noreply.github.com>2020-08-25 20:52:48 +0200
commit54630030c35067c168847b3eaf109d93058e586a (patch)
treeb9507a58686635fafa8289f502c90c18793ee7c2
parentea95ccb378a2c22f3a8865561b723afe155d2f1b (diff)
Add phpstan checks
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
-rw-r--r--Makefile6
-rw-r--r--composer.json3
-rw-r--r--composer.lock59
-rw-r--r--lib/Cron/Updater.php1
-rw-r--r--lib/Db/Item.php18
-rw-r--r--phpstan.neon.dist9
6 files changed, 92 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index c25161d70..2ba124b9e 100644
--- a/Makefile
+++ b/Makefile
@@ -113,6 +113,11 @@ clean:
phpcs:
./vendor/bin/phpcs --standard=PSR2 lib
+# Reports PHP static violations
+.PHONY: phpstan
+phpstan:
+ ./vendor/bin/phpstan analyse --level=1 lib
+
# Same as clean but also removes dependencies installed by composer and
# npm
.PHONY: distclean
@@ -192,4 +197,5 @@ test:
# \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
$(MAKE) phpcs
+ $(MAKE) phpstan
./bin/tools/generate_authors.php
diff --git a/composer.json b/composer.json
index a3b166093..26654a69c 100644
--- a/composer.json
+++ b/composer.json
@@ -56,7 +56,8 @@
"phpunit/phpunit": "^7.5",
"squizlabs/php_codesniffer": "^3.4",
"guzzlehttp/guzzle": "^6.3",
- "symfony/service-contracts": "1.1.8"
+ "symfony/service-contracts": "1.1.8",
+ "phpstan/phpstan": "^0.12.38"
},
"replace": {
"guzzlehttp/guzzle": "*",
diff --git a/composer.lock b/composer.lock
index 18fe13329..9b63aaee6 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": "5d0dd841527ad1bf8a165119686cfec8",
+ "content-hash": "bc8a010805b2f925d3c58ddc19b728e8",
"packages": [
{
"name": "andreskrey/readability.php",
@@ -804,6 +804,62 @@
"time": "2020-03-05T15:02:03+00:00"
},
{
+ "name": "phpstan/phpstan",
+ "version": "0.12.38",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/phpstan.git",
+ "reference": "ad606c5f1c641b465b739e79a3a0f1a5a57cf1b4"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/phpstan/zipball/ad606c5f1c641b465b739e79a3a0f1a5a57cf1b4",
+ "reference": "ad606c5f1c641b465b739e79a3a0f1a5a57cf1b4",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1|^8.0"
+ },
+ "conflict": {
+ "phpstan/phpstan-shim": "*"
+ },
+ "bin": [
+ "phpstan",
+ "phpstan.phar"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "0.12-dev"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHPStan - PHP Static Analysis Tool",
+ "funding": [
+ {
+ "url": "https://github.com/ondrejmirtes",
+ "type": "github"
+ },
+ {
+ "url": "https://www.patreon.com/phpstan",
+ "type": "patreon"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2020-08-19T08:13:30+00:00"
+ },
+ {
"name": "phpunit/php-code-coverage",
"version": "6.1.4",
"source": {
@@ -1053,6 +1109,7 @@
"keywords": [
"tokenizer"
],
+ "abandoned": true,
"time": "2019-09-17T06:23:10+00:00"
},
{
diff --git a/lib/Cron/Updater.php b/lib/Cron/Updater.php
index 66ca4a908..9a65554a9 100644
--- a/lib/Cron/Updater.php
+++ b/lib/Cron/Updater.php
@@ -34,7 +34,6 @@ class Updater extends TimedJob
private $updaterService;
public function __construct(
- ITimeFactroy $time,
Config $config,
StatusService $status,
UpdaterService $updaterService
diff --git a/lib/Db/Item.php b/lib/Db/Item.php
index 3dedd308d..ae2bb4d17 100644
--- a/lib/Db/Item.php
+++ b/lib/Db/Item.php
@@ -77,7 +77,7 @@ class Item extends Entity implements IAPI, \JsonSerializable
public static function fromImport($import): Item
{
- $item = new static();
+ $item = new Item();
$item->setGuid($import['guid']);
$item->setGuidHash($import['guid']);
$item->setUrl($import['url']);
@@ -147,6 +147,22 @@ class Item extends Entity implements IAPI, \JsonSerializable
/**
* @return null|string
*/
+ public function getMediaThumbnail()
+ {
+ return $this->mediaThumbnail;
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getMediaDescription()
+ {
+ return $this->mediaDescription;
+ }
+
+ /**
+ * @return null|string
+ */
public function getEnclosureMime()
{
return $this->enclosureMime;
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
new file mode 100644
index 000000000..113409c06
--- /dev/null
+++ b/phpstan.neon.dist
@@ -0,0 +1,9 @@
+parameters:
+ inferPrivatePropertyTypeFromConstructor: true
+ treatPhpDocTypesAsCertain: false
+ bootstrapFiles:
+ - %currentWorkingDirectory%/../../lib/base.php
+ excludes_analyse:
+ - %currentWorkingDirectory%/lib/Migration/*.php
+ - %currentWorkingDirectory%/lib/AppInfo/Application.php
+ - %currentWorkingDirectory%/lib/Fetcher/Client/Legacy*.php