Some phpstan issues (#2393)

* Fix bug, method init must be protected
* Added phpstan level 0
* Added exclusions
* Fix: incorrect case in Twig_SimpleFunction
* Fix, no abstract properties, if properties used in methods let's set them
* Fixed Psr\SimpleCache\InvalidArgumentException referenced with incorrect case
* added exclusions
* Fixed: Access to an undefined property Grav\Framework\Form\FormFlash::$uploadObjects.
* Fixed: does not call parent constructor from Grav\Common\Iterator.
* Fixed: does not call parent constructor from Grav\Common\Iterator.
* Fixed: does not call parent constructor
* Fixed: does not call parent constructor
* Minor: correct type for inflector
* Moved phpstan.neon out of public directory
* Added exclusion
* set GRAV_USER_INSTANCE to prevent LogiException in User
* Exlude Stream:create
* Minor: Missing storage property
* Minor: Fixed missing properties (phpstan level 1)
* Added type for $data
* Minor: Ensure $langs is initialized
* Fix possible bug in $http_response_header status code retrieval (PHP 7.1 only)
* Added exclusion for $http_response_header (isset is actually not required)
* Strict null check
This commit is contained in:
Sébastien Vanvelthem 2019-03-13 07:15:22 +01:00 committed by Matias Griese
parent 68d43a0c88
commit ecd39421d6
19 changed files with 959 additions and 14 deletions

View File

@ -53,6 +53,8 @@
},
"require-dev": {
"codeception/codeception": "^2.4",
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-strict-rules": "^0.11",
"phpunit/php-code-coverage": "~6.0",
"fzaninotto/faker": "^1.8",
"victorjonsson/markdowndocs": "dev-master"
@ -80,6 +82,7 @@
},
"scripts": {
"post-create-project-cmd": "bin/grav install",
"phpstan": "vendor/bin/phpstan analyse -l 0 -c ./tests/phpstan/phpstan.neon system/src",
"test": "vendor/bin/codecept run unit",
"test-windows": "vendor\\bin\\codecept run unit"
},

840
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": "96bb72327a133062393d3391201403d9",
"content-hash": "584da9b89b2ab2de09b0ccc5c4bee34d",
"packages": [
{
"name": "antoligy/dom-string-iterators",
@ -2787,6 +2787,50 @@
"description": "Flexible Stub wrapper for PHPUnit's Mock Builder",
"time": "2019-03-02T15:35:10+00:00"
},
{
"name": "composer/xdebug-handler",
"version": "1.3.2",
"source": {
"type": "git",
"url": "https://github.com/composer/xdebug-handler.git",
"reference": "d17708133b6c276d6e42ef887a877866b909d892"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/xdebug-handler/zipball/d17708133b6c276d6e42ef887a877866b909d892",
"reference": "d17708133b6c276d6e42ef887a877866b909d892",
"shasum": ""
},
"require": {
"php": "^5.3.2 || ^7.0",
"psr/log": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Composer\\XdebugHandler\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "John Stevenson",
"email": "john-stevenson@blueyonder.co.uk"
}
],
"description": "Restarts a process without xdebug.",
"keywords": [
"Xdebug",
"performance"
],
"time": "2019-01-28T20:25:53+00:00"
},
{
"name": "doctrine/instantiator",
"version": "1.1.0",
@ -3067,6 +3111,57 @@
],
"time": "2016-12-20T10:07:11+00:00"
},
{
"name": "jean85/pretty-package-versions",
"version": "1.2",
"source": {
"type": "git",
"url": "https://github.com/Jean85/pretty-package-versions.git",
"reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/75c7effcf3f77501d0e0caa75111aff4daa0dd48",
"reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48",
"shasum": ""
},
"require": {
"ocramius/package-versions": "^1.2.0",
"php": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Jean85\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Alessandro Lai",
"email": "alessandro.lai85@gmail.com"
}
],
"description": "A wrapper for ocramius/package-versions to get pretty versions strings",
"keywords": [
"composer",
"package",
"release",
"versions"
],
"time": "2018-06-13T13:22:40+00:00"
},
{
"name": "myclabs/deep-copy",
"version": "1.8.1",
@ -3115,6 +3210,584 @@
],
"time": "2018-06-11T23:09:50+00:00"
},
{
"name": "nette/bootstrap",
"version": "v2.4.6",
"source": {
"type": "git",
"url": "https://github.com/nette/bootstrap.git",
"reference": "268816e3f1bb7426c3a4ceec2bd38a036b532543"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/bootstrap/zipball/268816e3f1bb7426c3a4ceec2bd38a036b532543",
"reference": "268816e3f1bb7426c3a4ceec2bd38a036b532543",
"shasum": ""
},
"require": {
"nette/di": "~2.4.7",
"nette/utils": "~2.4",
"php": ">=5.6.0"
},
"conflict": {
"nette/nette": "<2.2"
},
"require-dev": {
"latte/latte": "~2.2",
"nette/application": "~2.3",
"nette/caching": "~2.3",
"nette/database": "~2.3",
"nette/forms": "~2.3",
"nette/http": "~2.4.0",
"nette/mail": "~2.3",
"nette/robot-loader": "^2.4.2 || ^3.0",
"nette/safe-stream": "~2.2",
"nette/security": "~2.3",
"nette/tester": "~2.0",
"tracy/tracy": "^2.4.1"
},
"suggest": {
"nette/robot-loader": "to use Configurator::createRobotLoader()",
"tracy/tracy": "to use Configurator::enableTracy()"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "🅱 Nette Bootstrap: the simple way to configure and bootstrap your Nette application.",
"homepage": "https://nette.org",
"keywords": [
"bootstrapping",
"configurator",
"nette"
],
"time": "2018-05-17T12:52:20+00:00"
},
{
"name": "nette/di",
"version": "v2.4.15",
"source": {
"type": "git",
"url": "https://github.com/nette/di.git",
"reference": "d0561b8f77e8ef2ed6d83328860e16c81a5a8649"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/di/zipball/d0561b8f77e8ef2ed6d83328860e16c81a5a8649",
"reference": "d0561b8f77e8ef2ed6d83328860e16c81a5a8649",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"nette/neon": "^2.3.3 || ~3.0.0",
"nette/php-generator": "^2.6.1 || ^3.0.0",
"nette/utils": "^2.5.0 || ~3.0.0",
"php": ">=5.6.0"
},
"conflict": {
"nette/bootstrap": "<2.4",
"nette/nette": "<2.2"
},
"require-dev": {
"nette/tester": "^2.0",
"tracy/tracy": "^2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "💎 Nette Dependency Injection Container: Flexible, compiled and full-featured DIC with perfectly usable autowiring and support for all new PHP 7.1 features.",
"homepage": "https://nette.org",
"keywords": [
"compiled",
"di",
"dic",
"factory",
"ioc",
"nette",
"static"
],
"time": "2019-01-30T13:26:05+00:00"
},
{
"name": "nette/finder",
"version": "v2.5.0",
"source": {
"type": "git",
"url": "https://github.com/nette/finder.git",
"reference": "6be1b83ea68ac558aff189d640abe242e0306fe2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/finder/zipball/6be1b83ea68ac558aff189d640abe242e0306fe2",
"reference": "6be1b83ea68ac558aff189d640abe242e0306fe2",
"shasum": ""
},
"require": {
"nette/utils": "^2.4 || ~3.0.0",
"php": ">=7.1"
},
"conflict": {
"nette/nette": "<2.2"
},
"require-dev": {
"nette/tester": "^2.0",
"tracy/tracy": "^2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.5-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "🔍 Nette Finder: find files and directories with an intuitive API.",
"homepage": "https://nette.org",
"keywords": [
"filesystem",
"glob",
"iterator",
"nette"
],
"time": "2019-02-28T18:13:25+00:00"
},
{
"name": "nette/neon",
"version": "v3.0.0",
"source": {
"type": "git",
"url": "https://github.com/nette/neon.git",
"reference": "cbff32059cbdd8720deccf9e9eace6ee516f02eb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/neon/zipball/cbff32059cbdd8720deccf9e9eace6ee516f02eb",
"reference": "cbff32059cbdd8720deccf9e9eace6ee516f02eb",
"shasum": ""
},
"require": {
"ext-iconv": "*",
"ext-json": "*",
"php": ">=7.0"
},
"require-dev": {
"nette/tester": "^2.0",
"tracy/tracy": "^2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "🍸 Nette NEON: encodes and decodes NEON file format.",
"homepage": "http://ne-on.org",
"keywords": [
"export",
"import",
"neon",
"nette",
"yaml"
],
"time": "2019-02-05T21:30:40+00:00"
},
{
"name": "nette/php-generator",
"version": "v3.2.1",
"source": {
"type": "git",
"url": "https://github.com/nette/php-generator.git",
"reference": "9de4e093a130f7a1bd175198799ebc0efbac6924"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/php-generator/zipball/9de4e093a130f7a1bd175198799ebc0efbac6924",
"reference": "9de4e093a130f7a1bd175198799ebc0efbac6924",
"shasum": ""
},
"require": {
"nette/utils": "^2.4.2 || ~3.0.0",
"php": ">=7.1"
},
"conflict": {
"nette/nette": "<2.2"
},
"require-dev": {
"nette/tester": "^2.0",
"tracy/tracy": "^2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.2-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.3 features.",
"homepage": "https://nette.org",
"keywords": [
"code",
"nette",
"php",
"scaffolding"
],
"time": "2018-11-27T19:00:14+00:00"
},
{
"name": "nette/robot-loader",
"version": "v3.1.1",
"source": {
"type": "git",
"url": "https://github.com/nette/robot-loader.git",
"reference": "3e8d75d6d976e191bdf46752ca40a286671219d2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/robot-loader/zipball/3e8d75d6d976e191bdf46752ca40a286671219d2",
"reference": "3e8d75d6d976e191bdf46752ca40a286671219d2",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"nette/finder": "^2.3 || ^3.0",
"nette/utils": "^2.4 || ^3.0",
"php": ">=5.6.0"
},
"conflict": {
"nette/nette": "<2.2"
},
"require-dev": {
"nette/tester": "^2.0",
"tracy/tracy": "^2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.1-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.",
"homepage": "https://nette.org",
"keywords": [
"autoload",
"class",
"interface",
"nette",
"trait"
],
"time": "2019-03-01T20:23:02+00:00"
},
{
"name": "nette/utils",
"version": "v2.5.3",
"source": {
"type": "git",
"url": "https://github.com/nette/utils.git",
"reference": "17b9f76f2abd0c943adfb556e56f2165460b15ce"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/utils/zipball/17b9f76f2abd0c943adfb556e56f2165460b15ce",
"reference": "17b9f76f2abd0c943adfb556e56f2165460b15ce",
"shasum": ""
},
"require": {
"php": ">=5.6.0"
},
"conflict": {
"nette/nette": "<2.2"
},
"require-dev": {
"nette/tester": "~2.0",
"tracy/tracy": "^2.3"
},
"suggest": {
"ext-gd": "to use Image",
"ext-iconv": "to use Strings::webalize() and toAscii()",
"ext-intl": "for script transliteration in Strings::webalize() and toAscii()",
"ext-json": "to use Nette\\Utils\\Json",
"ext-mbstring": "to use Strings::lower() etc...",
"ext-xml": "to use Strings::length() etc. when mbstring is not available"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.5-dev"
}
},
"autoload": {
"classmap": [
"src/"
],
"files": [
"src/loader.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.",
"homepage": "https://nette.org",
"keywords": [
"array",
"core",
"datetime",
"images",
"json",
"nette",
"paginator",
"password",
"slugify",
"string",
"unicode",
"utf-8",
"utility",
"validation"
],
"time": "2018-09-18T10:22:16+00:00"
},
{
"name": "nikic/php-parser",
"version": "v4.2.1",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "5221f49a608808c1e4d436df32884cbc1b821ac0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/5221f49a608808c1e4d436df32884cbc1b821ac0",
"reference": "5221f49a608808c1e4d436df32884cbc1b821ac0",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": ">=7.0"
},
"require-dev": {
"phpunit/phpunit": "^6.5 || ^7.0"
},
"bin": [
"bin/php-parse"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
}
},
"autoload": {
"psr-4": {
"PhpParser\\": "lib/PhpParser"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Nikita Popov"
}
],
"description": "A PHP parser written in PHP",
"keywords": [
"parser",
"php"
],
"time": "2019-02-16T20:54:15+00:00"
},
{
"name": "ocramius/package-versions",
"version": "1.4.0",
"source": {
"type": "git",
"url": "https://github.com/Ocramius/PackageVersions.git",
"reference": "a4d4b60d0e60da2487bd21a2c6ac089f85570dbb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/a4d4b60d0e60da2487bd21a2c6ac089f85570dbb",
"reference": "a4d4b60d0e60da2487bd21a2c6ac089f85570dbb",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0.0",
"php": "^7.1.0"
},
"require-dev": {
"composer/composer": "^1.6.3",
"doctrine/coding-standard": "^5.0.1",
"ext-zip": "*",
"infection/infection": "^0.7.1",
"phpunit/phpunit": "^7.0.0"
},
"type": "composer-plugin",
"extra": {
"class": "PackageVersions\\Installer",
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"PackageVersions\\": "src/PackageVersions"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com"
}
],
"description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
"time": "2019-02-21T12:16:21+00:00"
},
{
"name": "phar-io/manifest",
"version": "1.0.3",
@ -3432,6 +4105,171 @@
],
"time": "2018-08-05T17:53:17+00:00"
},
{
"name": "phpstan/phpdoc-parser",
"version": "0.3.1",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "2cc49f47c69b023eaf05b48e6529389893b13d74"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/2cc49f47c69b023eaf05b48e6529389893b13d74",
"reference": "2cc49f47c69b023eaf05b48e6529389893b13d74",
"shasum": ""
},
"require": {
"php": "~7.1"
},
"require-dev": {
"consistence/coding-standard": "^2.0.0",
"jakub-onderka/php-parallel-lint": "^0.9.2",
"phing/phing": "^2.16.0",
"phpstan/phpstan": "^0.10",
"phpunit/phpunit": "^6.3",
"slevomat/coding-standard": "^3.3.0",
"symfony/process": "^3.4 || ^4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.3-dev"
}
},
"autoload": {
"psr-4": {
"PHPStan\\PhpDocParser\\": [
"src/"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPDoc parser with support for nullable, intersection and generic types",
"time": "2019-01-14T12:26:23+00:00"
},
{
"name": "phpstan/phpstan",
"version": "0.11.2",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "8e185a74004920419ee97bf9dc62e6a175e8dca5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/8e185a74004920419ee97bf9dc62e6a175e8dca5",
"reference": "8e185a74004920419ee97bf9dc62e6a175e8dca5",
"shasum": ""
},
"require": {
"composer/xdebug-handler": "^1.3.0",
"jean85/pretty-package-versions": "^1.0.3",
"nette/bootstrap": "^2.4 || ^3.0",
"nette/di": "^2.4.7 || ^3.0",
"nette/robot-loader": "^3.0.1",
"nette/utils": "^2.4.5 || ^3.0",
"nikic/php-parser": "^4.0.2",
"php": "~7.1",
"phpstan/phpdoc-parser": "^0.3",
"symfony/console": "~3.2 || ~4.0",
"symfony/finder": "~3.2 || ~4.0"
},
"conflict": {
"symfony/console": "3.4.16 || 4.1.5"
},
"require-dev": {
"brianium/paratest": "^2.0",
"consistence/coding-standard": "^3.5",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
"ext-intl": "*",
"ext-mysqli": "*",
"ext-soap": "*",
"ext-zip": "*",
"jakub-onderka/php-parallel-lint": "^1.0",
"localheinz/composer-normalize": "^1.1.0",
"phing/phing": "^2.16.0",
"phpstan/phpstan-deprecation-rules": "^0.11",
"phpstan/phpstan-php-parser": "^0.11",
"phpstan/phpstan-phpunit": "^0.11",
"phpstan/phpstan-strict-rules": "^0.11",
"phpunit/phpunit": "^7.0",
"slevomat/coding-standard": "^4.7.2",
"squizlabs/php_codesniffer": "^3.3.2"
},
"bin": [
"bin/phpstan"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.11-dev"
}
},
"autoload": {
"psr-4": {
"PHPStan\\": [
"src/",
"build/PHPStan"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPStan - PHP Static Analysis Tool",
"time": "2019-02-12T14:54:38+00:00"
},
{
"name": "phpstan/phpstan-strict-rules",
"version": "0.11",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-strict-rules.git",
"reference": "747a742b26a35ef4e4ebef5ec4490ad74eebcbc0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/747a742b26a35ef4e4ebef5ec4490ad74eebcbc0",
"reference": "747a742b26a35ef4e4ebef5ec4490ad74eebcbc0",
"shasum": ""
},
"require": {
"nikic/php-parser": "^4.0",
"php": "~7.1",
"phpstan/phpstan": "^0.11"
},
"require-dev": {
"consistence/coding-standard": "^3.0.1",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
"jakub-onderka/php-parallel-lint": "^1.0",
"phing/phing": "^2.16.0",
"phpstan/phpstan-phpunit": "^0.11",
"phpunit/phpunit": "^7.0",
"slevomat/coding-standard": "^4.5.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.11-dev"
}
},
"autoload": {
"psr-4": {
"PHPStan\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Extra strict and opinionated rules for PHPStan",
"time": "2019-01-14T09:56:55+00:00"
},
{
"name": "phpunit/php-code-coverage",
"version": "6.1.4",

View File

@ -14,6 +14,22 @@ use Grav\Common\Utils;
class Languages extends Data
{
/**
* @var string|null
*/
protected $checksum;
/**
* @var string|null
*/
protected $modified;
/**
* @var string|null
*/
protected $timestamp;
public function checksum($checksum = null)
{
if ($checksum !== null) {

View File

@ -17,6 +17,7 @@ class CachedCollection extends Iterator {
public function __construct($items)
{
parent::__construct();
// local cache to speed things up
if (!isset(self::$cache[get_called_class() . __METHOD__])) {
self::$cache[get_called_class() . __METHOD__] = $items;

View File

@ -13,6 +13,9 @@ use Grav\Common\Data\Data;
class Package {
/**
* @var Data
*/
protected $data;
public function __construct(Data $package, $type = null)
@ -24,6 +27,9 @@ class Package {
}
}
/**
* @return Data
*/
public function getData()
{
return $this->data;
@ -54,6 +60,9 @@ class Package {
return $this->data->toJson();
}
/**
* @return array
*/
public function toArray()
{
return $this->data->toArray();

View File

@ -54,6 +54,7 @@ class GPM extends Iterator
*/
public function __construct($refresh = false, $callback = null)
{
parent::__construct();
$this->installed = new Local\Packages();
try {
$this->repository = new Remote\Packages($refresh, $callback);

View File

@ -15,6 +15,7 @@ abstract class AbstractPackageCollection extends BaseCollection
{
public function __construct($items)
{
parent::__construct();
foreach ($items as $name => $data) {
$data->set('slug', $name);
$this->items[$name] = new Package($data, $this->type);

View File

@ -41,6 +41,7 @@ class AbstractPackageCollection extends BaseCollection
*/
public function __construct($repository = null, $refresh = false, $callback = null)
{
parent::__construct();
if ($repository === null) {
throw new \RuntimeException("A repository is required to indicate the origin of the remote collection");
}

View File

@ -303,7 +303,7 @@ class Response
if ($content === false) {
$code = null;
if (isset($http_response_header)) {
$code = explode(' ', $http_response_header[0])[1];
$code = explode(' ', $http_response_header[0] ?? '')[1] ?? null;
}
switch ($code) {

View File

@ -17,6 +17,9 @@ class Language
{
protected $grav;
protected $enabled = true;
/**
* @var array
*/
protected $languages = [];
protected $page_extensions = [];
protected $fallback_languages = [];
@ -78,7 +81,7 @@ class Language
/**
* Sets the current supported languages manually
*
* @param $langs
* @param array $langs
*/
public function setLanguages($langs)
{
@ -488,6 +491,8 @@ class Language
return $accept_langs;
}
$langs = [];
foreach (explode(',', $accept_langs) as $k => $pref) {
// split $pref again by ';q='
// and decorate the language entries by inverted position

View File

@ -17,6 +17,9 @@ abstract class ProcessorBase implements ProcessorInterface
/** @var Grav */
protected $container;
public $id = 'processorbase';
public $title = 'ProcessorBase';
public function __construct(Grav $container)
{
$this->container = $container;

View File

@ -134,7 +134,7 @@ class TwigExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
new \Twig_SimpleFunction('array_key_exists', 'array_key_exists'),
new \Twig_SimpleFunction('array_unique', 'array_unique'),
new \Twig_SimpleFunction('array_intersect', [$this, 'arrayIntersectFunc']),
new \Twig_simpleFunction('authorize', [$this, 'authorize']),
new \Twig_SimpleFunction('authorize', [$this, 'authorize']),
new \Twig_SimpleFunction('debug', [$this, 'dump'], ['needs_context' => true, 'needs_environment' => true]),
new \Twig_SimpleFunction('dump', [$this, 'dump'], ['needs_context' => true, 'needs_environment' => true]),
new \Twig_SimpleFunction('vardump', [$this, 'vardumpFunc']),
@ -145,7 +145,7 @@ class TwigExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
new \Twig_SimpleFunction('gist', [$this, 'gistFunc']),
new \Twig_SimpleFunction('nonce_field', [$this, 'nonceFieldFunc']),
new \Twig_SimpleFunction('pathinfo', 'pathinfo'),
new \Twig_simpleFunction('random_string', [$this, 'randomStringFunc']),
new \Twig_SimpleFunction('random_string', [$this, 'randomStringFunc']),
new \Twig_SimpleFunction('repeat', [$this, 'repeatFunc']),
new \Twig_SimpleFunction('regex_replace', [$this, 'regexReplace']),
new \Twig_SimpleFunction('regex_filter', [$this, 'regexFilter']),
@ -170,13 +170,13 @@ class TwigExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
// Translations
new \Twig_simpleFunction('t', [$this, 'translate'], ['needs_environment' => true]),
new \Twig_simpleFunction('tl', [$this, 'translateLanguage']),
new \Twig_simpleFunction('ta', [$this, 'translateArray']),
new \Twig_SimpleFunction('t', [$this, 'translate'], ['needs_environment' => true]),
new \Twig_SimpleFunction('tl', [$this, 'translateLanguage']),
new \Twig_SimpleFunction('ta', [$this, 'translateArray']),
// Object Types
new \Twig_simpleFunction('get_type', [$this, 'getTypeFunc']),
new \Twig_simpleFunction('of_type', [$this, 'ofTypeFunc'])
new \Twig_SimpleFunction('get_type', [$this, 'getTypeFunc']),
new \Twig_SimpleFunction('of_type', [$this, 'ofTypeFunc'])
];
}

View File

@ -57,6 +57,11 @@ class User extends FlexObject implements UserInterface, MediaManipulationInterfa
protected $_uploads_original;
/**
* @var FileInterface|null
*/
protected $storage;
/**
* @return array
*/
@ -399,7 +404,7 @@ class User extends FlexObject implements UserInterface, MediaManipulationInterfa
*/
public function file(FileInterface $storage = null)
{
if ($storage) {
if (null !== $storage) {
$this->storage = $storage;
}

View File

@ -139,7 +139,7 @@ class FileCache extends AbstractCache
* @param string $directory
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
private function init($namespace, $directory)
protected function init($namespace, $directory)
{
if (!isset($directory[0])) {
$directory = sys_get_temp_dir() . '/grav-cache';

View File

@ -23,7 +23,7 @@ use Grav\Framework\Object\Interfaces\ObjectCollectionInterface;
use Grav\Framework\Object\Interfaces\ObjectInterface;
use Grav\Framework\Object\ObjectIndex;
use Monolog\Logger;
use PSR\SimpleCache\InvalidArgumentException;
use Psr\SimpleCache\InvalidArgumentException;
class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexIndexInterface
{

View File

@ -32,6 +32,8 @@ class FormFlash implements \JsonSerializable
protected $files;
/** @var array */
protected $uploadedFiles;
/** @var array<string, mixed> */
protected $uploadObjects;
/** @var bool */
protected $exists;

View File

@ -0,0 +1,6 @@
<?php declare(strict_types=1);
/**
*To help phpstan dealing with LogicException in Common\User\User.php
*/
define('GRAV_USER_INSTANCE', 'FLEX');

View File

@ -0,0 +1,54 @@
includes:
#- vendor/phpstan/phpstan-strict-rules/rules.neon
parameters:
fileExtensions:
- php
- dist
bootstrap: tests/phpstan/phpstan-bootstrap.php
excludes_analyse:
- system/src/Grav/Common/Errors/Resources/layout.html.php
reportUnmatchedIgnoredErrors: true
ignoreErrors:
# Errors that needs some more thinking (design...)
# Needed: full coverage (probably with admin plugin...) then redesign constructor
-
message: '#Grav\\Common\\GPM\\Remote\\GravCore::__construct\(\) does not call parent constructor from Grav\\Common\\GPM\\Remote\\AbstractPackageCollection#'
path: system/src/Grav/Common/GPM/Remote/GravCore.php
# Needed: psr-17 (http-factories) support (through decorator or further investigations)
-
message: '#Call to an undefined static method Grav\\Framework\\Psr7\\Stream::create\(\).#'
path: system/src/Grav/Framework/Form/FormFlashFile.php
# Those errors are about plugins (need to find a better solution)
-
message: '#Call to static method sendEmail\(\) on an unknown class Grav\\Plugin\\Email\\Utils.#'
path: system/src/Grav/Common/Scheduler/Job.php
# Can be ignored, after fopen there's always an $http_response_header locally available
-
message: '#Variable \$http_response_header in isset\(\) always exists and is not nullable.#'
path: system/src/Grav/Common/GPM/Response.php
# Those errors can be ignored (they depends on installed extensions)
-
message: '#Instantiated class Memcache not found#'
path: system/src/Grav/Common/Cache.php
-
message: '#Instantiated class Redis not found#'
path: system/src/Grav/Common/Cache.php
-
message: '#Instantiated class RedisException not found#'
path: system/src/Grav/Common/Cache.php

View File

@ -13,7 +13,7 @@ class InflectorTest extends \Codeception\TestCase\Test
/** @var Grav $grav */
protected $grav;
/** @var Uri $uri */
/** @var Inflector $uri */
protected $inflector;
protected function _before()