Add phpstan checks

Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
This commit is contained in:
Sean Molenaar 2020-08-24 22:29:35 +02:00 committed by Sean Molenaar
parent ea95ccb378
commit 54630030c3
6 changed files with 92 additions and 4 deletions

View File

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

View File

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

59
composer.lock generated
View File

@ -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",
@ -803,6 +803,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",
@ -1053,6 +1109,7 @@
"keywords": [
"tokenizer"
],
"abandoned": true,
"time": "2019-09-17T06:23:10+00:00"
},
{

View File

@ -34,7 +34,6 @@ class Updater extends TimedJob
private $updaterService;
public function __construct(
ITimeFactroy $time,
Config $config,
StatusService $status,
UpdaterService $updaterService

View File

@ -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']);
@ -144,6 +144,22 @@ class Item extends Entity implements IAPI, \JsonSerializable
return $this->enclosureLink;
}
/**
* @return null|string
*/
public function getMediaThumbnail()
{
return $this->mediaThumbnail;
}
/**
* @return null|string
*/
public function getMediaDescription()
{
return $this->mediaDescription;
}
/**
* @return null|string
*/

9
phpstan.neon.dist Normal file
View File

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