From ad003a0fc41b2a1ff51a23cee53e085e13580bbb Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Thu, 4 Nov 2021 08:55:53 +0200 Subject: [PATCH] Updated phpstan to v1.0 --- CHANGELOG.md | 6 ++- composer.json | 4 +- composer.lock | 49 +++++++++---------- system/src/Grav/Common/Backup/Backups.php | 3 +- .../Common/Flex/Types/Pages/PageIndex.php | 8 +-- system/src/Grav/Common/Grav.php | 6 +-- .../Page/Interfaces/PageContentInterface.php | 2 +- system/src/Grav/Common/Page/Page.php | 2 +- .../Common/Processors/InitializeProcessor.php | 2 +- .../Common/Service/ConfigServiceProvider.php | 2 +- .../Common/Twig/Extension/GravExtension.php | 2 +- system/src/Grav/Common/User/Group.php | 2 +- system/src/Grav/Common/Utils.php | 9 ++-- system/src/Grav/Common/Yaml.php | 6 +-- system/src/Grav/Console/Gpm/IndexCommand.php | 2 - .../Grav/Framework/Acl/PermissionsReader.php | 2 +- .../Collection/AbstractFileCollection.php | 4 +- .../Collection/AbstractIndexCollection.php | 17 ++++--- .../Collection/CollectionInterface.php | 8 +-- .../Framework/Collection/FileCollection.php | 6 +-- system/src/Grav/Framework/Flex/Flex.php | 2 +- .../Grav/Framework/Flex/FlexDirectoryForm.php | 2 +- system/src/Grav/Framework/Flex/FlexIndex.php | 2 +- .../Framework/Flex/Storage/FolderStorage.php | 2 + .../Grav/Framework/Form/Traits/FormTrait.php | 2 +- .../Logger/Processors/UserProcessor.php | 34 +++++++++++++ .../src/Grav/Framework/Object/ObjectIndex.php | 7 +-- tests/phpstan/phpstan.neon | 2 +- tests/phpstan/plugins.neon | 2 +- 29 files changed, 116 insertions(+), 81 deletions(-) create mode 100644 system/src/Grav/Framework/Logger/Processors/UserProcessor.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 28dc8dbe6..e5a896fda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,13 @@ # v1.7.25 ## mm/dd/2021 -1. [](#improved) +1. [](#new) + * Updated phpstan to v1.0 +2. [](#improved) * Use Symfony `dump` instead of PHP's `vardump` in side the `{{ vardump(x) }}` Twig vardump function * Added `route` and `request` to `onPagesInitialized` event * Improved page cloning, added method `Page::initialize()` -2. [](#bugfix) +3. [](#bugfix) * Fixed path traversal vulnerability when using `bin/grav server` * Fixed unescaped error messages in JSON error responses * Fixed `|t(variable)` twig filter in admin diff --git a/composer.json b/composer.json index e86c6aa06..2067b6957 100644 --- a/composer.json +++ b/composer.json @@ -63,8 +63,8 @@ }, "require-dev": { "codeception/codeception": "^4.1", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-deprecation-rules": "^0.12", + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-deprecation-rules": "^1.0", "phpunit/php-code-coverage": "~9.2", "getgrav/markdowndocs": "^2.0", "codeception/module-asserts": "^1.3", diff --git a/composer.lock b/composer.lock index dd87621f4..dbf6a6065 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": "23dd68cea2a3f2d963e57638131f1122", + "content-hash": "88527e29c63574c4fdb788ff8ed34245", "packages": [ { "name": "antoligy/dom-string-iterators", @@ -4207,16 +4207,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.13.0", + "version": "v4.13.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "50953a2691a922aa1769461637869a0a2faa3f53" + "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/50953a2691a922aa1769461637869a0a2faa3f53", - "reference": "50953a2691a922aa1769461637869a0a2faa3f53", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/63a79e8daa781cac14e5195e63ed8ae231dd10fd", + "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd", "shasum": "" }, "require": { @@ -4257,9 +4257,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.1" }, - "time": "2021-09-20T12:20:58+00:00" + "time": "2021-11-03T20:52:16+00:00" }, { "name": "phar-io/manifest", @@ -4601,16 +4601,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.99", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7" + "reference": "e9e2a501102ba0b126b2f63a7f0a3b151056fe91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b4d40f1d759942f523be267a1bab6884f46ca3f7", - "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e9e2a501102ba0b126b2f63a7f0a3b151056fe91", + "reference": "e9e2a501102ba0b126b2f63a7f0a3b151056fe91", "shasum": "" }, "require": { @@ -4626,7 +4626,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "0.12-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -4641,7 +4641,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.99" + "source": "https://github.com/phpstan/phpstan/tree/1.0.2" }, "funding": [ { @@ -4661,36 +4661,35 @@ "type": "tidelift" } ], - "time": "2021-09-12T20:09:55+00:00" + "time": "2021-11-03T16:09:51+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", - "version": "0.12.6", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", - "reference": "46dbd43c2db973d2876d6653e53f5c2cc3a01fbb" + "reference": "e5ccafb0dd8d835dd65d8d7a1a0d2b1b75414682" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/46dbd43c2db973d2876d6653e53f5c2cc3a01fbb", - "reference": "46dbd43c2db973d2876d6653e53f5c2cc3a01fbb", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/e5ccafb0dd8d835dd65d8d7a1a0d2b1b75414682", + "reference": "e5ccafb0dd8d835dd65d8d7a1a0d2b1b75414682", "shasum": "" }, "require": { "php": "^7.1 || ^8.0", - "phpstan/phpstan": "^0.12.60" + "phpstan/phpstan": "^1.0" }, "require-dev": { - "phing/phing": "^2.16.3", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-phpunit": "^0.12", - "phpunit/phpunit": "^7.5.20" + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^9.5" }, "type": "phpstan-extension", "extra": { "branch-alias": { - "dev-master": "0.12-dev" + "dev-master": "1.0-dev" }, "phpstan": { "includes": [ @@ -4710,9 +4709,9 @@ "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", "support": { "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", - "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/0.12.6" + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/1.0.0" }, - "time": "2020-12-13T10:20:54+00:00" + "time": "2021-09-23T11:02:21+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/system/src/Grav/Common/Backup/Backups.php b/system/src/Grav/Common/Backup/Backups.php index b70def96f..4680f8546 100644 --- a/system/src/Grav/Common/Backup/Backups.php +++ b/system/src/Grav/Common/Backup/Backups.php @@ -144,9 +144,8 @@ class Backups public static function getTotalBackupsSize() { $backups = static::getAvailableBackups(); - $size = array_sum(array_column($backups, 'size')); - return $size ?? 0; + return array_sum(array_column($backups, 'size')); } /** diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php b/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php index f02a64866..5a7d773a4 100644 --- a/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php +++ b/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php @@ -554,6 +554,9 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface $filters = array_filter($filters, static function($val) { return $val !== null && $val !== ''; }); if ($page) { + $status = 'success'; + $msg = 'PLUGIN_ADMIN.PAGE_ROUTE_FOUND'; + if ($page->root() && (!$filter_type || in_array('root', $filter_type, true))) { if ($field) { $response[] = [ @@ -593,9 +596,6 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface } } - $status = 'success'; - $msg = 'PLUGIN_ADMIN.PAGE_ROUTE_FOUND'; - /** @var PageIndex $children */ $children = $page->children()->getIndex(); $selectedChildren = $children->filterBy($filters, true); @@ -721,7 +721,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface $response = Utils::arrayFlatten($sorted); } - return [$status, $msg ?? 'PLUGIN_ADMIN.NO_ROUTE_PROVIDED', $response, $path]; + return [$status, $msg, $response, $path]; } /** diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index f5919613b..1169b74f6 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -774,11 +774,9 @@ class Grav extends Container } Utils::download($page->path() . DIRECTORY_SEPARATOR . $uri->basename(), $download); } - - // Nothing found - return false; } - return $page ?? false; + // Nothing found + return false; } } diff --git a/system/src/Grav/Common/Page/Interfaces/PageContentInterface.php b/system/src/Grav/Common/Page/Interfaces/PageContentInterface.php index 5156ede29..d9d3105b6 100644 --- a/system/src/Grav/Common/Page/Interfaces/PageContentInterface.php +++ b/system/src/Grav/Common/Page/Interfaces/PageContentInterface.php @@ -58,7 +58,7 @@ interface PageContentInterface /** * Needed by the onPageContentProcessed event to set the raw page content * - * @param string $content + * @param string|null $content */ public function setRawContent($content); diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 11b9790cc..9e68a44f8 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -994,7 +994,7 @@ class Page implements PageInterface /** * Needed by the onPageContentProcessed event to set the raw page content * - * @param string $content + * @param string|null $content * @return void */ public function setRawContent($content) diff --git a/system/src/Grav/Common/Processors/InitializeProcessor.php b/system/src/Grav/Common/Processors/InitializeProcessor.php index 55cba033c..b31530e80 100644 --- a/system/src/Grav/Common/Processors/InitializeProcessor.php +++ b/system/src/Grav/Common/Processors/InitializeProcessor.php @@ -44,7 +44,7 @@ class InitializeProcessor extends ProcessorBase public $title = 'Initialize'; /** @var bool */ - private static $cli_initialized = false; + protected static $cli_initialized = false; /** * @param Grav $grav diff --git a/system/src/Grav/Common/Service/ConfigServiceProvider.php b/system/src/Grav/Common/Service/ConfigServiceProvider.php index b56f62fde..3a5c2e27b 100644 --- a/system/src/Grav/Common/Service/ConfigServiceProvider.php +++ b/system/src/Grav/Common/Service/ConfigServiceProvider.php @@ -179,7 +179,7 @@ class ConfigServiceProvider implements ServiceProviderInterface * @param string $folder_path * @return array */ - private static function pluginFolderPaths($plugins, $folder_path) + protected static function pluginFolderPaths($plugins, $folder_path) { $paths = []; diff --git a/system/src/Grav/Common/Twig/Extension/GravExtension.php b/system/src/Grav/Common/Twig/Extension/GravExtension.php index 20d264808..4c0d9fe46 100644 --- a/system/src/Grav/Common/Twig/Extension/GravExtension.php +++ b/system/src/Grav/Common/Twig/Extension/GravExtension.php @@ -1424,7 +1424,7 @@ class GravExtension extends AbstractExtension implements GlobalsInterface * @param array $context Twig Context * @param string $var variable to be found (using dot notation) * @param null $default the default value to be used as last resort - * @param null $page an optional page to use for the current page + * @param PageInterface|null $page an optional page to use for the current page * @param bool $exists toggle to simply return the page where the variable is set, else null * @return mixed */ diff --git a/system/src/Grav/Common/User/Group.php b/system/src/Grav/Common/User/Group.php index 5be53869e..7dd6d650c 100644 --- a/system/src/Grav/Common/User/Group.php +++ b/system/src/Grav/Common/User/Group.php @@ -27,7 +27,7 @@ class Group extends Data * @return array * @deprecated 1.7, use $grav['user_groups'] Flex UserGroupCollection instead */ - private static function groups() + protected static function groups() { user_error(__METHOD__ . '() is deprecated since Grav 1.7, use $grav[\'user_groups\'] Flex UserGroupCollection instead', E_USER_DEPRECATED); diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index f843a0c66..5295a6400 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -21,6 +21,7 @@ use Grav\Common\Page\Markdown\Excerpts; use Grav\Common\Page\Pages; use Grav\Framework\Flex\Flex; use Grav\Framework\Flex\Interfaces\FlexObjectInterface; +use Grav\Framework\Media\Interfaces\MediaInterface; use InvalidArgumentException; use Negotiation\Accept; use Negotiation\Negotiator; @@ -150,7 +151,7 @@ abstract class Utils $domain = $domain ?: $grav['config']->get('system.absolute_urls', false); - return rtrim($uri->rootUrl($domain), '/') . '/' . ($resource ?? ''); + return rtrim($uri->rootUrl($domain), '/') . '/' . ($resource ?: ''); } /** @@ -1566,7 +1567,7 @@ abstract class Utils switch ($matches[0]) { case 'self': - if (null === $object) { + if (!$object instanceof MediaInterface) { throw new RuntimeException(sprintf('Page not available for self@ reference: %s', $path)); } @@ -1640,7 +1641,7 @@ abstract class Utils * @param string $path * @return string[]|null */ - private static function resolveTokenPath(string $path): ?array + protected static function resolveTokenPath(string $path): ?array { if (strpos($path, '@') !== false) { $regex = '/^(@\w+|\w+@|@\w+@)([^:]*)(.*)$/u'; @@ -1774,7 +1775,7 @@ abstract class Utils * * @param string $string * @param bool $block Block or Line processing - * @param null $page + * @param PageInterface|null $page * @return string * @throws Exception */ diff --git a/system/src/Grav/Common/Yaml.php b/system/src/Grav/Common/Yaml.php index 5adbd0c10..330b6c383 100644 --- a/system/src/Grav/Common/Yaml.php +++ b/system/src/Grav/Common/Yaml.php @@ -17,8 +17,8 @@ use Grav\Framework\File\Formatter\YamlFormatter; */ abstract class Yaml { - /** @var YamlFormatter */ - private static $yaml; + /** @var YamlFormatter|null */ + protected static $yaml; /** * @param string $data @@ -51,7 +51,7 @@ abstract class Yaml /** * @return void */ - private static function init() + protected static function init() { $config = [ 'inline' => 5, diff --git a/system/src/Grav/Console/Gpm/IndexCommand.php b/system/src/Grav/Console/Gpm/IndexCommand.php index 64d359781..ecc91feb0 100644 --- a/system/src/Grav/Console/Gpm/IndexCommand.php +++ b/system/src/Grav/Console/Gpm/IndexCommand.php @@ -200,7 +200,6 @@ class IndexCommand extends GpmCommand */ private function installed(Package $package): string { - $package = $list[$package->slug] ?? $package; $type = ucfirst(preg_replace('/s$/', '', $package->package_type)); $method = 'is' . $type . 'Installed'; $installed = $this->gpm->{$method}($package->slug); @@ -214,7 +213,6 @@ class IndexCommand extends GpmCommand */ private function enabled(Package $package): string { - $package = $list[$package->slug] ?? $package; $type = ucfirst(preg_replace('/s$/', '', $package->package_type)); $method = 'is' . $type . 'Installed'; $installed = $this->gpm->{$method}($package->slug); diff --git a/system/src/Grav/Framework/Acl/PermissionsReader.php b/system/src/Grav/Framework/Acl/PermissionsReader.php index 4f4a6a317..b157a5d3b 100644 --- a/system/src/Grav/Framework/Acl/PermissionsReader.php +++ b/system/src/Grav/Framework/Acl/PermissionsReader.php @@ -21,7 +21,7 @@ use function is_array; class PermissionsReader { /** @var array */ - private static $types; + protected static $types; /** * @param string $filename diff --git a/system/src/Grav/Framework/Collection/AbstractFileCollection.php b/system/src/Grav/Framework/Collection/AbstractFileCollection.php index f89226747..1be8d129a 100644 --- a/system/src/Grav/Framework/Collection/AbstractFileCollection.php +++ b/system/src/Grav/Framework/Collection/AbstractFileCollection.php @@ -25,9 +25,9 @@ use function array_slice; * * @package Grav\Framework\Collection * @template TKey of array-key - * @template T + * @template T of object * @extends AbstractLazyCollection - * @mplements FileCollectionInterface + * @implements FileCollectionInterface */ class AbstractFileCollection extends AbstractLazyCollection implements FileCollectionInterface { diff --git a/system/src/Grav/Framework/Collection/AbstractIndexCollection.php b/system/src/Grav/Framework/Collection/AbstractIndexCollection.php index 38d3ab51e..25d8672c0 100644 --- a/system/src/Grav/Framework/Collection/AbstractIndexCollection.php +++ b/system/src/Grav/Framework/Collection/AbstractIndexCollection.php @@ -22,6 +22,7 @@ use function count; * Abstract Index Collection. * @template TKey of array-key * @template T + * @template C of CollectionInterface * @implements CollectionInterface */ abstract class AbstractIndexCollection implements CollectionInterface @@ -184,7 +185,7 @@ abstract class AbstractIndexCollection implements CollectionInterface #[\ReturnTypeWillChange] public function offsetUnset($offset) { - return $this->remove($offset); + $this->remove($offset); } /** @@ -365,7 +366,7 @@ abstract class AbstractIndexCollection implements CollectionInterface * @param int $start * @param int|null $limit * @return static - * @phpstan-return static + * @phpstan-return static */ public function limit($start, $limit = null) { @@ -376,7 +377,7 @@ abstract class AbstractIndexCollection implements CollectionInterface * Reverse the order of the items. * * @return static - * @phpstan-return static + * @phpstan-return static */ public function reverse() { @@ -387,7 +388,7 @@ abstract class AbstractIndexCollection implements CollectionInterface * Shuffle items. * * @return static - * @phpstan-return static + * @phpstan-return static */ public function shuffle() { @@ -404,7 +405,7 @@ abstract class AbstractIndexCollection implements CollectionInterface * * @param array $keys * @return static - * @phpstan-return static + * @phpstan-return static */ public function select(array $keys) { @@ -423,7 +424,7 @@ abstract class AbstractIndexCollection implements CollectionInterface * * @param array $keys * @return static - * @phpstan-return static + * @phpstan-return static */ public function unselect(array $keys) { @@ -478,7 +479,7 @@ abstract class AbstractIndexCollection implements CollectionInterface * * @param array $entries Elements. * @return static - * @phpstan-return static + * @phpstan-return static */ protected function createFrom(array $entries) { @@ -531,7 +532,7 @@ abstract class AbstractIndexCollection implements CollectionInterface /** * @param array|null $entries * @return CollectionInterface - * @phpstan-return T + * @phpstan-return C */ abstract protected function loadCollection(array $entries = null): CollectionInterface; diff --git a/system/src/Grav/Framework/Collection/CollectionInterface.php b/system/src/Grav/Framework/Collection/CollectionInterface.php index 42414cecd..0739109ba 100644 --- a/system/src/Grav/Framework/Collection/CollectionInterface.php +++ b/system/src/Grav/Framework/Collection/CollectionInterface.php @@ -26,7 +26,7 @@ interface CollectionInterface extends Collection, JsonSerializable * Reverse the order of the items. * * @return CollectionInterface - * @phpstan-return CollectionInterface + * @phpstan-return static */ public function reverse(); @@ -34,7 +34,7 @@ interface CollectionInterface extends Collection, JsonSerializable * Shuffle items. * * @return CollectionInterface - * @phpstan-return CollectionInterface + * @phpstan-return static */ public function shuffle(); @@ -53,7 +53,7 @@ interface CollectionInterface extends Collection, JsonSerializable * * @param array $keys * @return CollectionInterface - * @phpstan-return CollectionInterface + * @phpstan-return static */ public function select(array $keys); @@ -62,7 +62,7 @@ interface CollectionInterface extends Collection, JsonSerializable * * @param array $keys * @return CollectionInterface - * @phpstan-return CollectionInterface + * @phpstan-return static */ public function unselect(array $keys); } diff --git a/system/src/Grav/Framework/Collection/FileCollection.php b/system/src/Grav/Framework/Collection/FileCollection.php index 59df2210e..f7b4f258b 100644 --- a/system/src/Grav/Framework/Collection/FileCollection.php +++ b/system/src/Grav/Framework/Collection/FileCollection.php @@ -9,13 +9,13 @@ namespace Grav\Framework\Collection; +use stdClass; + /** * Collection of objects stored into a filesystem. * * @package Grav\Framework\Collection - * @template TKey of array-key - * @template T - * @extends AbstractFileCollection + * @extends AbstractFileCollection */ class FileCollection extends AbstractFileCollection { diff --git a/system/src/Grav/Framework/Flex/Flex.php b/system/src/Grav/Framework/Flex/Flex.php index 87392823d..ce285215c 100644 --- a/system/src/Grav/Framework/Flex/Flex.php +++ b/system/src/Grav/Framework/Flex/Flex.php @@ -256,7 +256,7 @@ class Flex implements FlexInterface } // Remove missing objects if not asked to keep them. - if (empty($option['keep_missing'])) { + if (empty($options['keep_missing'])) { $list = array_filter($list); } diff --git a/system/src/Grav/Framework/Flex/FlexDirectoryForm.php b/system/src/Grav/Framework/Flex/FlexDirectoryForm.php index 66b6f3e14..8d608fdf8 100644 --- a/system/src/Grav/Framework/Flex/FlexDirectoryForm.php +++ b/system/src/Grav/Framework/Flex/FlexDirectoryForm.php @@ -99,7 +99,7 @@ class FlexDirectoryForm implements FlexDirectoryFormInterface, JsonSerializable $this->setFlashLookupFolder($directory->getDirectoryBlueprint()->get('form/flash_folder') ?? 'tmp://forms/[SESSIONID]'); $this->form = $options['form'] ?? null; - if (Utils::isPositive($this->items['disabled'] ?? $this->form['disabled'] ?? false)) { + if (Utils::isPositive($this->form['disabled'] ?? false)) { $this->disable(); } diff --git a/system/src/Grav/Framework/Flex/FlexIndex.php b/system/src/Grav/Framework/Flex/FlexIndex.php index 1df5c4d0d..3ce0a46c4 100644 --- a/system/src/Grav/Framework/Flex/FlexIndex.php +++ b/system/src/Grav/Framework/Flex/FlexIndex.php @@ -35,7 +35,7 @@ use function in_array; * @package Grav\Framework\Flex * @template T of FlexObjectInterface * @template C of FlexCollectionInterface - * @extends ObjectIndex + * @extends ObjectIndex * @implements FlexIndexInterface * @mixin C */ diff --git a/system/src/Grav/Framework/Flex/Storage/FolderStorage.php b/system/src/Grav/Framework/Flex/Storage/FolderStorage.php index ff2c94d7a..b2b9533a2 100644 --- a/system/src/Grav/Framework/Flex/Storage/FolderStorage.php +++ b/system/src/Grav/Framework/Flex/Storage/FolderStorage.php @@ -224,6 +224,7 @@ class FolderStorage extends AbstractFilesystemStorage * @param string $src * @param string $dst * @return bool + * @throws RuntimeException */ public function copyRow(string $src, string $dst): bool { @@ -247,6 +248,7 @@ class FolderStorage extends AbstractFilesystemStorage /** * {@inheritdoc} * @see FlexStorageInterface::renameRow() + * @throws RuntimeException */ public function renameRow(string $src, string $dst): bool { diff --git a/system/src/Grav/Framework/Form/Traits/FormTrait.php b/system/src/Grav/Framework/Form/Traits/FormTrait.php index 4362cf5e4..d77a40274 100644 --- a/system/src/Grav/Framework/Form/Traits/FormTrait.php +++ b/system/src/Grav/Framework/Form/Traits/FormTrait.php @@ -711,7 +711,7 @@ trait FormTrait return [ $data, - $files ?? [] + $files ]; } diff --git a/system/src/Grav/Framework/Logger/Processors/UserProcessor.php b/system/src/Grav/Framework/Logger/Processors/UserProcessor.php new file mode 100644 index 000000000..885b4f0a8 --- /dev/null +++ b/system/src/Grav/Framework/Logger/Processors/UserProcessor.php @@ -0,0 +1,34 @@ +exists()) { + $record['extra']['user'] = ['username' => $user->username, 'email' => $user->email]; + } + + return $record; + } +} diff --git a/system/src/Grav/Framework/Object/ObjectIndex.php b/system/src/Grav/Framework/Object/ObjectIndex.php index b7b416d0a..50ac4271b 100644 --- a/system/src/Grav/Framework/Object/ObjectIndex.php +++ b/system/src/Grav/Framework/Object/ObjectIndex.php @@ -24,8 +24,9 @@ use function is_object; * order to use the class. * * @template TKey of array-key - * @template T - * @extends AbstractIndexCollection + * @template T of \Grav\Framework\Object\Interfaces\ObjectInterface + * @template C of \Grav\Framework\Collection\CollectionInterface + * @extends AbstractIndexCollection * @implements NestedObjectCollectionInterface */ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObjectCollectionInterface @@ -176,7 +177,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje * Create a copy from this collection by cloning all objects in the collection. * * @return static - * @return static + * @return static */ public function copy() { diff --git a/tests/phpstan/phpstan.neon b/tests/phpstan/phpstan.neon index c41ae9bfe..12dc402a2 100644 --- a/tests/phpstan/phpstan.neon +++ b/tests/phpstan/phpstan.neon @@ -8,7 +8,7 @@ parameters: - dist bootstrapFiles: - phpstan-bootstrap.php - excludes_analyse: + excludePaths: - */system/src/Grav/Common/Errors/Resources/layout.html.php - */system/src/Twig/DeferredExtension/DeferredNodeVisitor.php diff --git a/tests/phpstan/plugins.neon b/tests/phpstan/plugins.neon index 8ef5700f6..ae257f80e 100644 --- a/tests/phpstan/plugins.neon +++ b/tests/phpstan/plugins.neon @@ -4,7 +4,7 @@ includes: parameters: fileExtensions: - php - excludes_analyse: + excludePaths: - %currentWorkingDirectory%/user/plugins/*/vendor/* - %currentWorkingDirectory%/user/plugins/*/tests/* - %currentWorkingDirectory%/user/plugins/gantry5/src/platforms