mirror of
				https://github.com/getgrav/grav.git
				synced 2025-10-31 18:36:12 +01:00 
			
		
		
		
	Updated phpstan to v1.0
This commit is contained in:
		| @@ -1,11 +1,13 @@ | |||||||
| # v1.7.25 | # v1.7.25 | ||||||
| ## mm/dd/2021 | ## 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 |     * Use Symfony `dump` instead of PHP's `vardump` in side the `{{ vardump(x) }}` Twig vardump function | ||||||
|     * Added `route` and `request` to `onPagesInitialized` event |     * Added `route` and `request` to `onPagesInitialized` event | ||||||
|     * Improved page cloning, added method `Page::initialize()` |     * Improved page cloning, added method `Page::initialize()` | ||||||
| 2. [](#bugfix) | 3. [](#bugfix) | ||||||
|     * Fixed path traversal vulnerability when using `bin/grav server` |     * Fixed path traversal vulnerability when using `bin/grav server` | ||||||
|     * Fixed unescaped error messages in JSON error responses |     * Fixed unescaped error messages in JSON error responses | ||||||
|     * Fixed `|t(variable)` twig filter in admin |     * Fixed `|t(variable)` twig filter in admin | ||||||
|   | |||||||
| @@ -63,8 +63,8 @@ | |||||||
|     }, |     }, | ||||||
|     "require-dev": { |     "require-dev": { | ||||||
|         "codeception/codeception": "^4.1", |         "codeception/codeception": "^4.1", | ||||||
|         "phpstan/phpstan": "^0.12", |         "phpstan/phpstan": "^1.0", | ||||||
|         "phpstan/phpstan-deprecation-rules": "^0.12", |         "phpstan/phpstan-deprecation-rules": "^1.0", | ||||||
|         "phpunit/php-code-coverage": "~9.2", |         "phpunit/php-code-coverage": "~9.2", | ||||||
|         "getgrav/markdowndocs": "^2.0", |         "getgrav/markdowndocs": "^2.0", | ||||||
|         "codeception/module-asserts": "^1.3", |         "codeception/module-asserts": "^1.3", | ||||||
|   | |||||||
							
								
								
									
										49
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										49
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							| @@ -4,7 +4,7 @@ | |||||||
|         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", |         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", | ||||||
|         "This file is @generated automatically" |         "This file is @generated automatically" | ||||||
|     ], |     ], | ||||||
|     "content-hash": "23dd68cea2a3f2d963e57638131f1122", |     "content-hash": "88527e29c63574c4fdb788ff8ed34245", | ||||||
|     "packages": [ |     "packages": [ | ||||||
|         { |         { | ||||||
|             "name": "antoligy/dom-string-iterators", |             "name": "antoligy/dom-string-iterators", | ||||||
| @@ -4207,16 +4207,16 @@ | |||||||
|         }, |         }, | ||||||
|         { |         { | ||||||
|             "name": "nikic/php-parser", |             "name": "nikic/php-parser", | ||||||
|             "version": "v4.13.0", |             "version": "v4.13.1", | ||||||
|             "source": { |             "source": { | ||||||
|                 "type": "git", |                 "type": "git", | ||||||
|                 "url": "https://github.com/nikic/PHP-Parser.git", |                 "url": "https://github.com/nikic/PHP-Parser.git", | ||||||
|                 "reference": "50953a2691a922aa1769461637869a0a2faa3f53" |                 "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd" | ||||||
|             }, |             }, | ||||||
|             "dist": { |             "dist": { | ||||||
|                 "type": "zip", |                 "type": "zip", | ||||||
|                 "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/50953a2691a922aa1769461637869a0a2faa3f53", |                 "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/63a79e8daa781cac14e5195e63ed8ae231dd10fd", | ||||||
|                 "reference": "50953a2691a922aa1769461637869a0a2faa3f53", |                 "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd", | ||||||
|                 "shasum": "" |                 "shasum": "" | ||||||
|             }, |             }, | ||||||
|             "require": { |             "require": { | ||||||
| @@ -4257,9 +4257,9 @@ | |||||||
|             ], |             ], | ||||||
|             "support": { |             "support": { | ||||||
|                 "issues": "https://github.com/nikic/PHP-Parser/issues", |                 "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", |             "name": "phar-io/manifest", | ||||||
| @@ -4601,16 +4601,16 @@ | |||||||
|         }, |         }, | ||||||
|         { |         { | ||||||
|             "name": "phpstan/phpstan", |             "name": "phpstan/phpstan", | ||||||
|             "version": "0.12.99", |             "version": "1.0.2", | ||||||
|             "source": { |             "source": { | ||||||
|                 "type": "git", |                 "type": "git", | ||||||
|                 "url": "https://github.com/phpstan/phpstan.git", |                 "url": "https://github.com/phpstan/phpstan.git", | ||||||
|                 "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7" |                 "reference": "e9e2a501102ba0b126b2f63a7f0a3b151056fe91" | ||||||
|             }, |             }, | ||||||
|             "dist": { |             "dist": { | ||||||
|                 "type": "zip", |                 "type": "zip", | ||||||
|                 "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b4d40f1d759942f523be267a1bab6884f46ca3f7", |                 "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e9e2a501102ba0b126b2f63a7f0a3b151056fe91", | ||||||
|                 "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7", |                 "reference": "e9e2a501102ba0b126b2f63a7f0a3b151056fe91", | ||||||
|                 "shasum": "" |                 "shasum": "" | ||||||
|             }, |             }, | ||||||
|             "require": { |             "require": { | ||||||
| @@ -4626,7 +4626,7 @@ | |||||||
|             "type": "library", |             "type": "library", | ||||||
|             "extra": { |             "extra": { | ||||||
|                 "branch-alias": { |                 "branch-alias": { | ||||||
|                     "dev-master": "0.12-dev" |                     "dev-master": "1.0-dev" | ||||||
|                 } |                 } | ||||||
|             }, |             }, | ||||||
|             "autoload": { |             "autoload": { | ||||||
| @@ -4641,7 +4641,7 @@ | |||||||
|             "description": "PHPStan - PHP Static Analysis Tool", |             "description": "PHPStan - PHP Static Analysis Tool", | ||||||
|             "support": { |             "support": { | ||||||
|                 "issues": "https://github.com/phpstan/phpstan/issues", |                 "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": [ |             "funding": [ | ||||||
|                 { |                 { | ||||||
| @@ -4661,36 +4661,35 @@ | |||||||
|                     "type": "tidelift" |                     "type": "tidelift" | ||||||
|                 } |                 } | ||||||
|             ], |             ], | ||||||
|             "time": "2021-09-12T20:09:55+00:00" |             "time": "2021-11-03T16:09:51+00:00" | ||||||
|         }, |         }, | ||||||
|         { |         { | ||||||
|             "name": "phpstan/phpstan-deprecation-rules", |             "name": "phpstan/phpstan-deprecation-rules", | ||||||
|             "version": "0.12.6", |             "version": "1.0.0", | ||||||
|             "source": { |             "source": { | ||||||
|                 "type": "git", |                 "type": "git", | ||||||
|                 "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", |                 "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", | ||||||
|                 "reference": "46dbd43c2db973d2876d6653e53f5c2cc3a01fbb" |                 "reference": "e5ccafb0dd8d835dd65d8d7a1a0d2b1b75414682" | ||||||
|             }, |             }, | ||||||
|             "dist": { |             "dist": { | ||||||
|                 "type": "zip", |                 "type": "zip", | ||||||
|                 "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/46dbd43c2db973d2876d6653e53f5c2cc3a01fbb", |                 "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/e5ccafb0dd8d835dd65d8d7a1a0d2b1b75414682", | ||||||
|                 "reference": "46dbd43c2db973d2876d6653e53f5c2cc3a01fbb", |                 "reference": "e5ccafb0dd8d835dd65d8d7a1a0d2b1b75414682", | ||||||
|                 "shasum": "" |                 "shasum": "" | ||||||
|             }, |             }, | ||||||
|             "require": { |             "require": { | ||||||
|                 "php": "^7.1 || ^8.0", |                 "php": "^7.1 || ^8.0", | ||||||
|                 "phpstan/phpstan": "^0.12.60" |                 "phpstan/phpstan": "^1.0" | ||||||
|             }, |             }, | ||||||
|             "require-dev": { |             "require-dev": { | ||||||
|                 "phing/phing": "^2.16.3", |  | ||||||
|                 "php-parallel-lint/php-parallel-lint": "^1.2", |                 "php-parallel-lint/php-parallel-lint": "^1.2", | ||||||
|                 "phpstan/phpstan-phpunit": "^0.12", |                 "phpstan/phpstan-phpunit": "^1.0", | ||||||
|                 "phpunit/phpunit": "^7.5.20" |                 "phpunit/phpunit": "^9.5" | ||||||
|             }, |             }, | ||||||
|             "type": "phpstan-extension", |             "type": "phpstan-extension", | ||||||
|             "extra": { |             "extra": { | ||||||
|                 "branch-alias": { |                 "branch-alias": { | ||||||
|                     "dev-master": "0.12-dev" |                     "dev-master": "1.0-dev" | ||||||
|                 }, |                 }, | ||||||
|                 "phpstan": { |                 "phpstan": { | ||||||
|                     "includes": [ |                     "includes": [ | ||||||
| @@ -4710,9 +4709,9 @@ | |||||||
|             "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", |             "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", | ||||||
|             "support": { |             "support": { | ||||||
|                 "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", |                 "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", |             "name": "phpunit/php-code-coverage", | ||||||
|   | |||||||
| @@ -144,9 +144,8 @@ class Backups | |||||||
|     public static function getTotalBackupsSize() |     public static function getTotalBackupsSize() | ||||||
|     { |     { | ||||||
|         $backups = static::getAvailableBackups(); |         $backups = static::getAvailableBackups(); | ||||||
|         $size = array_sum(array_column($backups, 'size')); |  | ||||||
|  |  | ||||||
|         return $size ?? 0; |         return array_sum(array_column($backups, 'size')); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -554,6 +554,9 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface | |||||||
|         $filters = array_filter($filters, static function($val) { return $val !== null && $val !== ''; }); |         $filters = array_filter($filters, static function($val) { return $val !== null && $val !== ''; }); | ||||||
|  |  | ||||||
|         if ($page) { |         if ($page) { | ||||||
|  |             $status = 'success'; | ||||||
|  |             $msg = 'PLUGIN_ADMIN.PAGE_ROUTE_FOUND'; | ||||||
|  |  | ||||||
|             if ($page->root() && (!$filter_type || in_array('root', $filter_type, true))) { |             if ($page->root() && (!$filter_type || in_array('root', $filter_type, true))) { | ||||||
|                 if ($field) { |                 if ($field) { | ||||||
|                     $response[] = [ |                     $response[] = [ | ||||||
| @@ -593,9 +596,6 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             $status = 'success'; |  | ||||||
|             $msg = 'PLUGIN_ADMIN.PAGE_ROUTE_FOUND'; |  | ||||||
|  |  | ||||||
|             /** @var PageIndex $children */ |             /** @var PageIndex $children */ | ||||||
|             $children = $page->children()->getIndex(); |             $children = $page->children()->getIndex(); | ||||||
|             $selectedChildren = $children->filterBy($filters, true); |             $selectedChildren = $children->filterBy($filters, true); | ||||||
| @@ -721,7 +721,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface | |||||||
|             $response = Utils::arrayFlatten($sorted); |             $response = Utils::arrayFlatten($sorted); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return [$status, $msg ?? 'PLUGIN_ADMIN.NO_ROUTE_PROVIDED', $response, $path]; |         return [$status, $msg, $response, $path]; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -774,11 +774,9 @@ class Grav extends Container | |||||||
|                 } |                 } | ||||||
|                 Utils::download($page->path() . DIRECTORY_SEPARATOR . $uri->basename(), $download); |                 Utils::download($page->path() . DIRECTORY_SEPARATOR . $uri->basename(), $download); | ||||||
|             } |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|         // Nothing found |         // Nothing found | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|         return $page ?? false; |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -58,7 +58,7 @@ interface PageContentInterface | |||||||
|     /** |     /** | ||||||
|      * Needed by the onPageContentProcessed event to set the raw page content |      * Needed by the onPageContentProcessed event to set the raw page content | ||||||
|      * |      * | ||||||
|      * @param string $content |      * @param string|null $content | ||||||
|      */ |      */ | ||||||
|     public function setRawContent($content); |     public function setRawContent($content); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -994,7 +994,7 @@ class Page implements PageInterface | |||||||
|     /** |     /** | ||||||
|      * Needed by the onPageContentProcessed event to set the raw page content |      * Needed by the onPageContentProcessed event to set the raw page content | ||||||
|      * |      * | ||||||
|      * @param string $content |      * @param string|null $content | ||||||
|      * @return void |      * @return void | ||||||
|      */ |      */ | ||||||
|     public function setRawContent($content) |     public function setRawContent($content) | ||||||
|   | |||||||
| @@ -44,7 +44,7 @@ class InitializeProcessor extends ProcessorBase | |||||||
|     public $title = 'Initialize'; |     public $title = 'Initialize'; | ||||||
|  |  | ||||||
|     /** @var bool */ |     /** @var bool */ | ||||||
|     private static $cli_initialized = false; |     protected static $cli_initialized = false; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * @param Grav $grav |      * @param Grav $grav | ||||||
|   | |||||||
| @@ -179,7 +179,7 @@ class ConfigServiceProvider implements ServiceProviderInterface | |||||||
|      * @param string $folder_path |      * @param string $folder_path | ||||||
|      * @return array |      * @return array | ||||||
|      */ |      */ | ||||||
|     private static function pluginFolderPaths($plugins, $folder_path) |     protected static function pluginFolderPaths($plugins, $folder_path) | ||||||
|     { |     { | ||||||
|         $paths = []; |         $paths = []; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1424,7 +1424,7 @@ class GravExtension extends AbstractExtension implements GlobalsInterface | |||||||
|      * @param array $context      Twig Context |      * @param array $context      Twig Context | ||||||
|      * @param string $var variable to be found (using dot notation) |      * @param string $var variable to be found (using dot notation) | ||||||
|      * @param null $default the default value to be used as last resort |      * @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 |      * @param bool $exists toggle to simply return the page where the variable is set, else null | ||||||
|      * @return mixed |      * @return mixed | ||||||
|      */ |      */ | ||||||
|   | |||||||
| @@ -27,7 +27,7 @@ class Group extends Data | |||||||
|      * @return array |      * @return array | ||||||
|      * @deprecated 1.7, use $grav['user_groups'] Flex UserGroupCollection instead |      * @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); |         user_error(__METHOD__ . '() is deprecated since Grav 1.7, use $grav[\'user_groups\'] Flex UserGroupCollection instead', E_USER_DEPRECATED); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ use Grav\Common\Page\Markdown\Excerpts; | |||||||
| use Grav\Common\Page\Pages; | use Grav\Common\Page\Pages; | ||||||
| use Grav\Framework\Flex\Flex; | use Grav\Framework\Flex\Flex; | ||||||
| use Grav\Framework\Flex\Interfaces\FlexObjectInterface; | use Grav\Framework\Flex\Interfaces\FlexObjectInterface; | ||||||
|  | use Grav\Framework\Media\Interfaces\MediaInterface; | ||||||
| use InvalidArgumentException; | use InvalidArgumentException; | ||||||
| use Negotiation\Accept; | use Negotiation\Accept; | ||||||
| use Negotiation\Negotiator; | use Negotiation\Negotiator; | ||||||
| @@ -150,7 +151,7 @@ abstract class Utils | |||||||
|  |  | ||||||
|         $domain = $domain ?: $grav['config']->get('system.absolute_urls', false); |         $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]) { |         switch ($matches[0]) { | ||||||
|             case 'self': |             case 'self': | ||||||
|                 if (null === $object) { |                 if (!$object instanceof MediaInterface) { | ||||||
|                     throw new RuntimeException(sprintf('Page not available for self@ reference: %s', $path)); |                     throw new RuntimeException(sprintf('Page not available for self@ reference: %s', $path)); | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
| @@ -1640,7 +1641,7 @@ abstract class Utils | |||||||
|      * @param string $path |      * @param string $path | ||||||
|      * @return string[]|null |      * @return string[]|null | ||||||
|      */ |      */ | ||||||
|     private static function resolveTokenPath(string $path): ?array |     protected static function resolveTokenPath(string $path): ?array | ||||||
|     { |     { | ||||||
|         if (strpos($path, '@') !== false) { |         if (strpos($path, '@') !== false) { | ||||||
|             $regex = '/^(@\w+|\w+@|@\w+@)([^:]*)(.*)$/u'; |             $regex = '/^(@\w+|\w+@|@\w+@)([^:]*)(.*)$/u'; | ||||||
| @@ -1774,7 +1775,7 @@ abstract class Utils | |||||||
|      * |      * | ||||||
|      * @param string $string |      * @param string $string | ||||||
|      * @param bool $block Block or Line processing |      * @param bool $block Block or Line processing | ||||||
|      * @param null $page |      * @param PageInterface|null $page | ||||||
|      * @return string |      * @return string | ||||||
|      * @throws Exception |      * @throws Exception | ||||||
|      */ |      */ | ||||||
|   | |||||||
| @@ -17,8 +17,8 @@ use Grav\Framework\File\Formatter\YamlFormatter; | |||||||
|  */ |  */ | ||||||
| abstract class Yaml | abstract class Yaml | ||||||
| { | { | ||||||
|     /** @var YamlFormatter */ |     /** @var YamlFormatter|null */ | ||||||
|     private static $yaml; |     protected static $yaml; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * @param string $data |      * @param string $data | ||||||
| @@ -51,7 +51,7 @@ abstract class Yaml | |||||||
|     /** |     /** | ||||||
|      * @return void |      * @return void | ||||||
|      */ |      */ | ||||||
|     private static function init() |     protected static function init() | ||||||
|     { |     { | ||||||
|         $config = [ |         $config = [ | ||||||
|             'inline' => 5, |             'inline' => 5, | ||||||
|   | |||||||
| @@ -200,7 +200,6 @@ class IndexCommand extends GpmCommand | |||||||
|      */ |      */ | ||||||
|     private function installed(Package $package): string |     private function installed(Package $package): string | ||||||
|     { |     { | ||||||
|         $package   = $list[$package->slug] ?? $package; |  | ||||||
|         $type      = ucfirst(preg_replace('/s$/', '', $package->package_type)); |         $type      = ucfirst(preg_replace('/s$/', '', $package->package_type)); | ||||||
|         $method = 'is' . $type . 'Installed'; |         $method = 'is' . $type . 'Installed'; | ||||||
|         $installed = $this->gpm->{$method}($package->slug); |         $installed = $this->gpm->{$method}($package->slug); | ||||||
| @@ -214,7 +213,6 @@ class IndexCommand extends GpmCommand | |||||||
|      */ |      */ | ||||||
|     private function enabled(Package $package): string |     private function enabled(Package $package): string | ||||||
|     { |     { | ||||||
|         $package   = $list[$package->slug] ?? $package; |  | ||||||
|         $type      = ucfirst(preg_replace('/s$/', '', $package->package_type)); |         $type      = ucfirst(preg_replace('/s$/', '', $package->package_type)); | ||||||
|         $method = 'is' . $type . 'Installed'; |         $method = 'is' . $type . 'Installed'; | ||||||
|         $installed = $this->gpm->{$method}($package->slug); |         $installed = $this->gpm->{$method}($package->slug); | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ use function is_array; | |||||||
| class PermissionsReader | class PermissionsReader | ||||||
| { | { | ||||||
|     /** @var array */ |     /** @var array */ | ||||||
|     private static $types; |     protected static $types; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * @param string $filename |      * @param string $filename | ||||||
|   | |||||||
| @@ -25,9 +25,9 @@ use function array_slice; | |||||||
|  * |  * | ||||||
|  * @package Grav\Framework\Collection |  * @package Grav\Framework\Collection | ||||||
|  * @template TKey of array-key |  * @template TKey of array-key | ||||||
|  * @template T |  * @template T of object | ||||||
|  * @extends AbstractLazyCollection<TKey,T> |  * @extends AbstractLazyCollection<TKey,T> | ||||||
|  * @mplements FileCollectionInterface<TKey,T> |  * @implements FileCollectionInterface<TKey,T> | ||||||
|  */ |  */ | ||||||
| class AbstractFileCollection extends AbstractLazyCollection implements FileCollectionInterface | class AbstractFileCollection extends AbstractLazyCollection implements FileCollectionInterface | ||||||
| { | { | ||||||
|   | |||||||
| @@ -22,6 +22,7 @@ use function count; | |||||||
|  * Abstract Index Collection. |  * Abstract Index Collection. | ||||||
|  * @template TKey of array-key |  * @template TKey of array-key | ||||||
|  * @template T |  * @template T | ||||||
|  |  * @template C of CollectionInterface | ||||||
|  * @implements CollectionInterface<TKey,T> |  * @implements CollectionInterface<TKey,T> | ||||||
|  */ |  */ | ||||||
| abstract class AbstractIndexCollection implements CollectionInterface | abstract class AbstractIndexCollection implements CollectionInterface | ||||||
| @@ -184,7 +185,7 @@ abstract class AbstractIndexCollection implements CollectionInterface | |||||||
|     #[\ReturnTypeWillChange] |     #[\ReturnTypeWillChange] | ||||||
|     public function offsetUnset($offset) |     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 $start | ||||||
|      * @param int|null $limit |      * @param int|null $limit | ||||||
|      * @return static |      * @return static | ||||||
|      * @phpstan-return static<TKey,T> |      * @phpstan-return static<TKey,T,C> | ||||||
|      */ |      */ | ||||||
|     public function limit($start, $limit = null) |     public function limit($start, $limit = null) | ||||||
|     { |     { | ||||||
| @@ -376,7 +377,7 @@ abstract class AbstractIndexCollection implements CollectionInterface | |||||||
|      * Reverse the order of the items. |      * Reverse the order of the items. | ||||||
|      * |      * | ||||||
|      * @return static |      * @return static | ||||||
|      * @phpstan-return static<TKey,T> |      * @phpstan-return static<TKey,T,C> | ||||||
|      */ |      */ | ||||||
|     public function reverse() |     public function reverse() | ||||||
|     { |     { | ||||||
| @@ -387,7 +388,7 @@ abstract class AbstractIndexCollection implements CollectionInterface | |||||||
|      * Shuffle items. |      * Shuffle items. | ||||||
|      * |      * | ||||||
|      * @return static |      * @return static | ||||||
|      * @phpstan-return static<TKey,T> |      * @phpstan-return static<TKey,T,C> | ||||||
|      */ |      */ | ||||||
|     public function shuffle() |     public function shuffle() | ||||||
|     { |     { | ||||||
| @@ -404,7 +405,7 @@ abstract class AbstractIndexCollection implements CollectionInterface | |||||||
|      * |      * | ||||||
|      * @param array $keys |      * @param array $keys | ||||||
|      * @return static |      * @return static | ||||||
|      * @phpstan-return static<TKey,T> |      * @phpstan-return static<TKey,T,C> | ||||||
|      */ |      */ | ||||||
|     public function select(array $keys) |     public function select(array $keys) | ||||||
|     { |     { | ||||||
| @@ -423,7 +424,7 @@ abstract class AbstractIndexCollection implements CollectionInterface | |||||||
|      * |      * | ||||||
|      * @param array $keys |      * @param array $keys | ||||||
|      * @return static |      * @return static | ||||||
|      * @phpstan-return static<TKey,T> |      * @phpstan-return static<TKey,T,C> | ||||||
|      */ |      */ | ||||||
|     public function unselect(array $keys) |     public function unselect(array $keys) | ||||||
|     { |     { | ||||||
| @@ -478,7 +479,7 @@ abstract class AbstractIndexCollection implements CollectionInterface | |||||||
|      * |      * | ||||||
|      * @param array $entries Elements. |      * @param array $entries Elements. | ||||||
|      * @return static |      * @return static | ||||||
|      * @phpstan-return static<TKey,T> |      * @phpstan-return static<TKey,T,C> | ||||||
|      */ |      */ | ||||||
|     protected function createFrom(array $entries) |     protected function createFrom(array $entries) | ||||||
|     { |     { | ||||||
| @@ -531,7 +532,7 @@ abstract class AbstractIndexCollection implements CollectionInterface | |||||||
|     /** |     /** | ||||||
|      * @param array|null $entries |      * @param array|null $entries | ||||||
|      * @return CollectionInterface |      * @return CollectionInterface | ||||||
|      * @phpstan-return T |      * @phpstan-return C | ||||||
|      */ |      */ | ||||||
|     abstract protected function loadCollection(array $entries = null): CollectionInterface; |     abstract protected function loadCollection(array $entries = null): CollectionInterface; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -26,7 +26,7 @@ interface CollectionInterface extends Collection, JsonSerializable | |||||||
|      * Reverse the order of the items. |      * Reverse the order of the items. | ||||||
|      * |      * | ||||||
|      * @return CollectionInterface |      * @return CollectionInterface | ||||||
|      * @phpstan-return CollectionInterface<TKey,T> |      * @phpstan-return static<TKey,T> | ||||||
|      */ |      */ | ||||||
|     public function reverse(); |     public function reverse(); | ||||||
|  |  | ||||||
| @@ -34,7 +34,7 @@ interface CollectionInterface extends Collection, JsonSerializable | |||||||
|      * Shuffle items. |      * Shuffle items. | ||||||
|      * |      * | ||||||
|      * @return CollectionInterface |      * @return CollectionInterface | ||||||
|      * @phpstan-return CollectionInterface<TKey,T> |      * @phpstan-return static<TKey,T> | ||||||
|      */ |      */ | ||||||
|     public function shuffle(); |     public function shuffle(); | ||||||
|  |  | ||||||
| @@ -53,7 +53,7 @@ interface CollectionInterface extends Collection, JsonSerializable | |||||||
|      * |      * | ||||||
|      * @param array<int|string> $keys |      * @param array<int|string> $keys | ||||||
|      * @return CollectionInterface |      * @return CollectionInterface | ||||||
|      * @phpstan-return CollectionInterface<TKey,T> |      * @phpstan-return static<TKey,T> | ||||||
|      */ |      */ | ||||||
|     public function select(array $keys); |     public function select(array $keys); | ||||||
|  |  | ||||||
| @@ -62,7 +62,7 @@ interface CollectionInterface extends Collection, JsonSerializable | |||||||
|      * |      * | ||||||
|      * @param array<int|string> $keys |      * @param array<int|string> $keys | ||||||
|      * @return CollectionInterface |      * @return CollectionInterface | ||||||
|      * @phpstan-return CollectionInterface<TKey,T> |      * @phpstan-return static<TKey,T> | ||||||
|      */ |      */ | ||||||
|     public function unselect(array $keys); |     public function unselect(array $keys); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -9,13 +9,13 @@ | |||||||
|  |  | ||||||
| namespace Grav\Framework\Collection; | namespace Grav\Framework\Collection; | ||||||
|  |  | ||||||
|  | use stdClass; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Collection of objects stored into a filesystem. |  * Collection of objects stored into a filesystem. | ||||||
|  * |  * | ||||||
|  * @package Grav\Framework\Collection |  * @package Grav\Framework\Collection | ||||||
|  * @template TKey of array-key |  * @extends AbstractFileCollection<array-key,stdClass> | ||||||
|  * @template T |  | ||||||
|  * @extends AbstractFileCollection<TKey,T> |  | ||||||
|  */ |  */ | ||||||
| class FileCollection extends AbstractFileCollection | class FileCollection extends AbstractFileCollection | ||||||
| { | { | ||||||
|   | |||||||
| @@ -256,7 +256,7 @@ class Flex implements FlexInterface | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         // Remove missing objects if not asked to keep them. |         // Remove missing objects if not asked to keep them. | ||||||
|         if (empty($option['keep_missing'])) { |         if (empty($options['keep_missing'])) { | ||||||
|             $list = array_filter($list); |             $list = array_filter($list); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -99,7 +99,7 @@ class FlexDirectoryForm implements FlexDirectoryFormInterface, JsonSerializable | |||||||
|         $this->setFlashLookupFolder($directory->getDirectoryBlueprint()->get('form/flash_folder') ?? 'tmp://forms/[SESSIONID]'); |         $this->setFlashLookupFolder($directory->getDirectoryBlueprint()->get('form/flash_folder') ?? 'tmp://forms/[SESSIONID]'); | ||||||
|         $this->form = $options['form'] ?? null; |         $this->form = $options['form'] ?? null; | ||||||
|  |  | ||||||
|         if (Utils::isPositive($this->items['disabled'] ?? $this->form['disabled'] ?? false)) { |         if (Utils::isPositive($this->form['disabled'] ?? false)) { | ||||||
|             $this->disable(); |             $this->disable(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -35,7 +35,7 @@ use function in_array; | |||||||
|  * @package Grav\Framework\Flex |  * @package Grav\Framework\Flex | ||||||
|  * @template T of FlexObjectInterface |  * @template T of FlexObjectInterface | ||||||
|  * @template C of FlexCollectionInterface |  * @template C of FlexCollectionInterface | ||||||
|  * @extends ObjectIndex<string,T> |  * @extends ObjectIndex<string,T,C> | ||||||
|  * @implements FlexIndexInterface<T> |  * @implements FlexIndexInterface<T> | ||||||
|  * @mixin C |  * @mixin C | ||||||
|  */ |  */ | ||||||
|   | |||||||
| @@ -224,6 +224,7 @@ class FolderStorage extends AbstractFilesystemStorage | |||||||
|      * @param string $src |      * @param string $src | ||||||
|      * @param string $dst |      * @param string $dst | ||||||
|      * @return bool |      * @return bool | ||||||
|  |      * @throws RuntimeException | ||||||
|      */ |      */ | ||||||
|     public function copyRow(string $src, string $dst): bool |     public function copyRow(string $src, string $dst): bool | ||||||
|     { |     { | ||||||
| @@ -247,6 +248,7 @@ class FolderStorage extends AbstractFilesystemStorage | |||||||
|     /** |     /** | ||||||
|      * {@inheritdoc} |      * {@inheritdoc} | ||||||
|      * @see FlexStorageInterface::renameRow() |      * @see FlexStorageInterface::renameRow() | ||||||
|  |      * @throws RuntimeException | ||||||
|      */ |      */ | ||||||
|     public function renameRow(string $src, string $dst): bool |     public function renameRow(string $src, string $dst): bool | ||||||
|     { |     { | ||||||
|   | |||||||
| @@ -711,7 +711,7 @@ trait FormTrait | |||||||
|  |  | ||||||
|         return [ |         return [ | ||||||
|             $data, |             $data, | ||||||
|             $files ?? [] |             $files | ||||||
|         ]; |         ]; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -0,0 +1,34 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * @package    Grav\Framework\Logger | ||||||
|  |  * | ||||||
|  |  * @copyright  Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. | ||||||
|  |  * @license    MIT License; see LICENSE file for details. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | namespace Grav\Framework\Logger\Processors; | ||||||
|  |  | ||||||
|  | use Grav\Common\Grav; | ||||||
|  | use Grav\Common\User\Interfaces\UserInterface; | ||||||
|  | use Monolog\Processor\ProcessorInterface; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Adds username and email to log messages. | ||||||
|  |  */ | ||||||
|  | class UserProcessor implements ProcessorInterface | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * {@inheritDoc} | ||||||
|  |      */ | ||||||
|  |     public function __invoke(array $record): array | ||||||
|  |     { | ||||||
|  |         /** @var UserInterface|null $user */ | ||||||
|  |         $user = Grav::instance()['user'] ?? null; | ||||||
|  |         if ($user && $user->exists()) { | ||||||
|  |             $record['extra']['user'] = ['username' => $user->username, 'email' => $user->email]; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return $record; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -24,8 +24,9 @@ use function is_object; | |||||||
|  * order to use the class. |  * order to use the class. | ||||||
|  * |  * | ||||||
|  * @template TKey of array-key |  * @template TKey of array-key | ||||||
|  * @template T |  * @template T of \Grav\Framework\Object\Interfaces\ObjectInterface | ||||||
|  * @extends AbstractIndexCollection<TKey,T> |  * @template C of \Grav\Framework\Collection\CollectionInterface | ||||||
|  |  * @extends AbstractIndexCollection<TKey,T,C> | ||||||
|  * @implements NestedObjectCollectionInterface<TKey,T> |  * @implements NestedObjectCollectionInterface<TKey,T> | ||||||
|  */ |  */ | ||||||
| abstract class ObjectIndex 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. |      * Create a copy from this collection by cloning all objects in the collection. | ||||||
|      * |      * | ||||||
|      * @return static |      * @return static | ||||||
|      * @return static<TKey,T> |      * @return static<TKey,T,C> | ||||||
|      */ |      */ | ||||||
|     public function copy() |     public function copy() | ||||||
|     { |     { | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ parameters: | |||||||
|         - dist |         - dist | ||||||
|     bootstrapFiles: |     bootstrapFiles: | ||||||
|         - phpstan-bootstrap.php |         - phpstan-bootstrap.php | ||||||
|     excludes_analyse: |     excludePaths: | ||||||
|         - */system/src/Grav/Common/Errors/Resources/layout.html.php |         - */system/src/Grav/Common/Errors/Resources/layout.html.php | ||||||
|         - */system/src/Twig/DeferredExtension/DeferredNodeVisitor.php |         - */system/src/Twig/DeferredExtension/DeferredNodeVisitor.php | ||||||
|  |  | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ includes: | |||||||
| parameters: | parameters: | ||||||
|     fileExtensions: |     fileExtensions: | ||||||
|         - php |         - php | ||||||
|     excludes_analyse: |     excludePaths: | ||||||
|         - %currentWorkingDirectory%/user/plugins/*/vendor/* |         - %currentWorkingDirectory%/user/plugins/*/vendor/* | ||||||
|         - %currentWorkingDirectory%/user/plugins/*/tests/* |         - %currentWorkingDirectory%/user/plugins/*/tests/* | ||||||
|         - %currentWorkingDirectory%/user/plugins/gantry5/src/platforms |         - %currentWorkingDirectory%/user/plugins/gantry5/src/platforms | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user