diff --git a/.htaccess b/.htaccess
index 83063ae2e..098c58244 100644
--- a/.htaccess
+++ b/.htaccess
@@ -59,9 +59,9 @@ RewriteRule .* index.php [L]
# Block all direct access for these folders
RewriteRule ^(\.git|cache|bin|logs|backup|webserver-configs|tests)/(.*) error [F]
# Block access to specific file types for these system folders
-RewriteRule ^(system|vendor)/(.*)\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
+RewriteRule ^(system|vendor)/(.*)\.(txt|xml|md|html|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
# Block access to specific file types for these user folders
-RewriteRule ^(user)/(.*)\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
+RewriteRule ^(user)/(.*)\.(txt|md|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
# Block all direct access to .md files:
RewriteRule \.md$ error [F]
# Block all direct access to files and folders beginning with a dot
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b0c0eb3e8..571eda6ac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,30 @@
+# v1.7.26
+## 01/03/2022
+
+1. [](#new)
+ * Made `Grav::redirect()` to accept `Route` class
+ * Added `translated()` method to `PageTranslateInterface`
+ * Added second parameter to `UserObject::isMyself()` method
+ * Added `UserObject::$isAuthorizedCallable` to allow `$user->isAuthorized()` customization
+ * Use secure session cookies in HTTPS by default (`system.session.secure_https: true`)
+ * Added new `Plugin::inheritedConfigOption()` function to access plugin specific functions for page overrides
+2. [](#improved)
+ * Upgraded vendor libs for PHP 8.1 compatibility
+ * Upgraded to **composer v2.1.14** for PHP 8.1 compatibility
+ * Added third `$name` parameter to `Blueprint::flattenData()` method, useful for flattening repeating data
+ * `ControllerResponseTrait`: Redirect response should be json if the extension is .json
+ * When symlinking Grav install, include also tests
+ * Updated copyright year to `2022`
+3. [](#bugfix)
+ * Fixed bad key lookup in `FlexRelatedDirectoryTrait::getCollectionByProperty()`
+ * Fixed RequestHandlers `NotFoundException` having empty request
+ * Block `.json` files in web server configs
+ * Disabled pretty debug info for Flex as it slows down Twig rendering
+ * Fixed Twig being very slow when template overrides do not exist
+ * Fixed `UserObject::$authorizeCallable` binding to the user object
+ * Fixed `FlexIndex::call()` to return null instead of failing to call undefined method
+ * Fixed Flex directory configuration creating environment configuration when it should not
+
# v1.7.25
## 11/16/2021
diff --git a/README.md b/README.md
index 31a4a7e4b..5f0e679a9 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
[](https://github.com/phpstan/phpstan)
[](https://chat.getgrav.org)
- [](https://github.com/getgrav/grav/actions?query=workflow%3A%22PHP+Tests%22) [](#backers) [](#sponsors)
+ [](https://github.com/getgrav/grav/actions?query=workflow%3A%22PHP+Tests%22) [](#backers) [](#supporters) [](#sponsors)
Grav is a **Fast**, **Simple**, and **Flexible**, file-based Web-platform. There is **Zero** installation required. Just extract the ZIP archive, and you are already up and running. It follows similar principles to other flat-file CMS platforms, but has a different design philosophy than most. Grav comes with a powerful **Package Management System** to allow for simple installation and upgrading of plugins and themes, as well as simple updating of Grav itself.
@@ -117,12 +117,19 @@ If you discover a possible security issue related to Grav or one of its plugins,
* More [Awesome Grav Stuff](https://github.com/getgrav/awesome-grav)
# Backers
-Support Grav with a monthly donation to help us continue development. [[Become a backer](https://opencollective.com/grav#backer)]
+Support Grav with a monthly donation to help us continue development. [[Become a backer](https://opencollective.com/grav/contribute)]
+
+# Supporters
+Support Grav with a monthly donation to help us continue development. [[Become a supporter](https://opencollective.com/grav/contribute)]
+
+
+
+
# Sponsors
-Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/grav#sponsor)]
+Support Grav with a yearly donation to help us continue development. [[Become a sponsor](https://opencollective.com/grav/contribute)]
diff --git a/assets/.gitkeep b/assets/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/assets/.gitkeep
+++ b/assets/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/backup/.gitkeep b/backup/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/backup/.gitkeep
+++ b/backup/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/bin/composer.phar b/bin/composer.phar
index 3791ce36e..f0461904b 100755
Binary files a/bin/composer.phar and b/bin/composer.phar differ
diff --git a/bin/gpm b/bin/gpm
index a2eebc68c..9e58706f6 100755
--- a/bin/gpm
+++ b/bin/gpm
@@ -2,7 +2,7 @@
user/pages/14.api/default.17.md",
"post-create-project-cmd": "bin/grav install",
- "phpstan": "vendor/bin/phpstan analyse -l 1 -c ./tests/phpstan/phpstan.neon --memory-limit=520M system/src",
- "phpstan-framework": "vendor/bin/phpstan analyse -l 3 -c ./tests/phpstan/phpstan.neon --memory-limit=480M system/src/Grav/Framework system/src/Grav/Events system/src/Grav/Installer",
+ "phpstan": "vendor/bin/phpstan analyse -l 1 -c ./tests/phpstan/phpstan.neon --memory-limit=720M system/src",
+ "phpstan-framework": "vendor/bin/phpstan analyse -l 4 -c ./tests/phpstan/phpstan.neon --memory-limit=480M system/src/Grav/Framework system/src/Grav/Events system/src/Grav/Installer",
"phpstan-plugins": "vendor/bin/phpstan analyse -l 1 -c ./tests/phpstan/plugins.neon --memory-limit=400M user/plugins",
"test": "vendor/bin/codecept run unit",
"test-windows": "vendor\\bin\\codecept run unit"
diff --git a/composer.lock b/composer.lock
index 3b66c8a46..25fad88cc 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,56 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "072f00e1bf64b4ef43f7125fe80b15a7",
+ "content-hash": "1067938388862c52927c6450e8a36df0",
"packages": [
- {
- "name": "antoligy/dom-string-iterators",
- "version": "v1.0.1",
- "source": {
- "type": "git",
- "url": "https://github.com/antoligy/dom-string-iterators.git",
- "reference": "fae88f66e1970d68c5585fc42db44f1217bf74e6"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/antoligy/dom-string-iterators/zipball/fae88f66e1970d68c5585fc42db44f1217bf74e6",
- "reference": "fae88f66e1970d68c5585fc42db44f1217bf74e6",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.0"
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "CC0-1.0"
- ],
- "authors": [
- {
- "name": "Alex Wilson",
- "email": "a@ax.gy"
- },
- {
- "name": "Kornel Lesinski",
- "email": "pornel@pornel.net"
- },
- {
- "name": "Patrick Galbraith",
- "email": "patrick.j.galbraith@gmail.com"
- }
- ],
- "description": "Composer package for DOMWordsIterator and DOMLettersIterator",
- "support": {
- "issues": "https://github.com/antoligy/dom-string-iterators/issues",
- "source": "https://github.com/antoligy/dom-string-iterators/tree/v1.0.1"
- },
- "time": "2018-02-03T16:01:11+00:00"
- },
{
"name": "composer/ca-bundle",
"version": "1.3.1",
@@ -888,16 +840,16 @@
},
{
"name": "itsgoingd/clockwork",
- "version": "v5.1.1",
+ "version": "v5.1.2",
"source": {
"type": "git",
"url": "https://github.com/itsgoingd/clockwork.git",
- "reference": "2daf30fa6dfc5a1ccfdb2142df59243a72c473d8"
+ "reference": "4f46a69b123635ba2910a3ca8d100edfadc924e1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/itsgoingd/clockwork/zipball/2daf30fa6dfc5a1ccfdb2142df59243a72c473d8",
- "reference": "2daf30fa6dfc5a1ccfdb2142df59243a72c473d8",
+ "url": "https://api.github.com/repos/itsgoingd/clockwork/zipball/4f46a69b123635ba2910a3ca8d100edfadc924e1",
+ "reference": "4f46a69b123635ba2910a3ca8d100edfadc924e1",
"shasum": ""
},
"require": {
@@ -945,7 +897,7 @@
],
"support": {
"issues": "https://github.com/itsgoingd/clockwork/issues",
- "source": "https://github.com/itsgoingd/clockwork/tree/v5.1.1"
+ "source": "https://github.com/itsgoingd/clockwork/tree/v5.1.2"
},
"funding": [
{
@@ -953,7 +905,7 @@
"type": "github"
}
],
- "time": "2021-11-01T17:38:35+00:00"
+ "time": "2021-12-07T18:24:19+00:00"
},
{
"name": "league/climate",
@@ -1561,29 +1513,29 @@
},
{
"name": "pimple/pimple",
- "version": "v3.3.1",
+ "version": "v3.5.0",
"source": {
"type": "git",
"url": "https://github.com/silexphp/Pimple.git",
- "reference": "21e45061c3429b1e06233475cc0e1f6fc774d5b0"
+ "reference": "a94b3a4db7fb774b3d78dad2315ddc07629e1bed"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/silexphp/Pimple/zipball/21e45061c3429b1e06233475cc0e1f6fc774d5b0",
- "reference": "21e45061c3429b1e06233475cc0e1f6fc774d5b0",
+ "url": "https://api.github.com/repos/silexphp/Pimple/zipball/a94b3a4db7fb774b3d78dad2315ddc07629e1bed",
+ "reference": "a94b3a4db7fb774b3d78dad2315ddc07629e1bed",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
- "psr/container": "^1.0"
+ "psr/container": "^1.1 || ^2.0"
},
"require-dev": {
- "symfony/phpunit-bridge": "^5.0"
+ "symfony/phpunit-bridge": "^5.4@dev"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "3.3.x-dev"
+ "dev-master": "3.4.x-dev"
}
},
"autoload": {
@@ -1608,9 +1560,9 @@
"dependency injection"
],
"support": {
- "source": "https://github.com/silexphp/Pimple/tree/v3.3.1"
+ "source": "https://github.com/silexphp/Pimple/tree/v3.5.0"
},
- "time": "2020-11-24T20:35:42+00:00"
+ "time": "2021-10-28T11:13:42+00:00"
},
{
"name": "psr/cache",
@@ -1663,27 +1615,22 @@
},
{
"name": "psr/container",
- "version": "1.0.0",
+ "version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
- "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
+ "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
- "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
+ "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
+ "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
"shasum": ""
},
"require": {
- "php": ">=5.3.0"
+ "php": ">=7.2.0"
},
"type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
@@ -1696,7 +1643,7 @@
"authors": [
{
"name": "PHP-FIG",
- "homepage": "http://www.php-fig.org/"
+ "homepage": "https://www.php-fig.org/"
}
],
"description": "Common Container Interface (PHP FIG PSR-11)",
@@ -1710,9 +1657,9 @@
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
- "source": "https://github.com/php-fig/container/tree/master"
+ "source": "https://github.com/php-fig/container/tree/1.1.1"
},
- "time": "2017-02-14T16:28:37+00:00"
+ "time": "2021-03-05T17:36:06+00:00"
},
{
"name": "psr/http-factory",
@@ -2128,16 +2075,16 @@
},
{
"name": "rockettheme/toolbox",
- "version": "1.5.10",
+ "version": "1.6.0",
"source": {
"type": "git",
"url": "https://github.com/rockettheme/toolbox.git",
- "reference": "d9738de013fa12df77754a0f11dded220b246efb"
+ "reference": "a0eb328b9c416e526c8264b48ccbc1a7519e8618"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/rockettheme/toolbox/zipball/d9738de013fa12df77754a0f11dded220b246efb",
- "reference": "d9738de013fa12df77754a0f11dded220b246efb",
+ "url": "https://api.github.com/repos/rockettheme/toolbox/zipball/a0eb328b9c416e526c8264b48ccbc1a7519e8618",
+ "reference": "a0eb328b9c416e526c8264b48ccbc1a7519e8618",
"shasum": ""
},
"require": {
@@ -2145,12 +2092,14 @@
"php": ">=5.6.0",
"pimple/pimple": "~3.0",
"symfony/event-dispatcher": "^3.4|^4.0",
+ "symfony/polyfill-php80": "^1.23",
+ "symfony/polyfill-php81": "^1.23",
"symfony/yaml": "^3.4|^4.0"
},
"require-dev": {
- "phpstan/phpstan": "^0.12",
- "phpstan/phpstan-deprecation-rules": "^0.12",
- "phpunit/phpunit": "~7.0"
+ "phpstan/phpstan": "^1.2",
+ "phpstan/phpstan-deprecation-rules": "^1.0",
+ "phpunit/phpunit": "^8.0"
},
"type": "library",
"autoload": {
@@ -2164,7 +2113,10 @@
"RocketTheme\\Toolbox\\ResourceLocator\\": "ResourceLocator/src",
"RocketTheme\\Toolbox\\Session\\": "Session/src",
"RocketTheme\\Toolbox\\StreamWrapper\\": "StreamWrapper/src"
- }
+ },
+ "exclude-from-classmap": [
+ "**/tests/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -2178,9 +2130,9 @@
],
"support": {
"issues": "https://github.com/rockettheme/toolbox/issues",
- "source": "https://github.com/rockettheme/toolbox/tree/1.5.10"
+ "source": "https://github.com/rockettheme/toolbox/tree/1.6.0"
},
- "time": "2021-09-29T16:50:13+00:00"
+ "time": "2021-12-15T19:20:00+00:00"
},
{
"name": "seld/cli-prompt",
@@ -2239,16 +2191,16 @@
},
{
"name": "symfony/console",
- "version": "v4.4.33",
+ "version": "v4.4.34",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
- "reference": "8dbd23ef7a8884051482183ddee8d9061b5feed0"
+ "reference": "329b3a75cc6b16d435ba1b1a41df54a53382a3f0"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/8dbd23ef7a8884051482183ddee8d9061b5feed0",
- "reference": "8dbd23ef7a8884051482183ddee8d9061b5feed0",
+ "url": "https://api.github.com/repos/symfony/console/zipball/329b3a75cc6b16d435ba1b1a41df54a53382a3f0",
+ "reference": "329b3a75cc6b16d435ba1b1a41df54a53382a3f0",
"shasum": ""
},
"require": {
@@ -2309,7 +2261,7 @@
"description": "Eases the creation of beautiful and testable command line interfaces",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/console/tree/v4.4.33"
+ "source": "https://github.com/symfony/console/tree/v4.4.34"
},
"funding": [
{
@@ -2325,25 +2277,25 @@
"type": "tidelift"
}
],
- "time": "2021-10-25T16:36:08+00:00"
+ "time": "2021-11-04T12:23:33+00:00"
},
{
"name": "symfony/contracts",
- "version": "v1.1.10",
+ "version": "v1.1.11",
"source": {
"type": "git",
"url": "https://github.com/symfony/contracts.git",
- "reference": "011c20407c4b99d454f44021d023fb39ce23b73d"
+ "reference": "cf2984f7a99bfae197f9c96f5a16a4041ff6ffb1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/contracts/zipball/011c20407c4b99d454f44021d023fb39ce23b73d",
- "reference": "011c20407c4b99d454f44021d023fb39ce23b73d",
+ "url": "https://api.github.com/repos/symfony/contracts/zipball/cf2984f7a99bfae197f9c96f5a16a4041ff6ffb1",
+ "reference": "cf2984f7a99bfae197f9c96f5a16a4041ff6ffb1",
"shasum": ""
},
"require": {
"php": ">=7.1.3",
- "psr/cache": "^1.0",
+ "psr/cache": "^1.0|^2.0|^3.0",
"psr/container": "^1.0"
},
"replace": {
@@ -2367,7 +2319,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.1-dev"
+ "dev-main": "1.1-dev"
}
},
"autoload": {
@@ -2403,7 +2355,7 @@
"standards"
],
"support": {
- "source": "https://github.com/symfony/contracts/tree/v1.1.10"
+ "source": "https://github.com/symfony/contracts/tree/v1.1.11"
},
"funding": [
{
@@ -2419,20 +2371,20 @@
"type": "tidelift"
}
],
- "time": "2020-09-02T16:08:58+00:00"
+ "time": "2021-11-04T13:32:43+00:00"
},
{
"name": "symfony/event-dispatcher",
- "version": "v4.4.30",
+ "version": "v4.4.34",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
- "reference": "2fe81680070043c4c80e7cedceb797e34f377bac"
+ "reference": "1a024b45369c9d55d76b6b8a241bd20c9ea1cbd8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/2fe81680070043c4c80e7cedceb797e34f377bac",
- "reference": "2fe81680070043c4c80e7cedceb797e34f377bac",
+ "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/1a024b45369c9d55d76b6b8a241bd20c9ea1cbd8",
+ "reference": "1a024b45369c9d55d76b6b8a241bd20c9ea1cbd8",
"shasum": ""
},
"require": {
@@ -2487,7 +2439,7 @@
"description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/event-dispatcher/tree/v4.4.30"
+ "source": "https://github.com/symfony/event-dispatcher/tree/v4.4.34"
},
"funding": [
{
@@ -2503,20 +2455,20 @@
"type": "tidelift"
}
],
- "time": "2021-08-04T20:31:23+00:00"
+ "time": "2021-11-15T14:42:25+00:00"
},
{
"name": "symfony/http-client",
- "version": "v4.4.33",
+ "version": "v4.4.35",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-client.git",
- "reference": "9a5fdf129b522a06a46d13400500d326c41d8a73"
+ "reference": "6ed0c02fdc21a76966f19b9000de18e688d9ca68"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/http-client/zipball/9a5fdf129b522a06a46d13400500d326c41d8a73",
- "reference": "9a5fdf129b522a06a46d13400500d326c41d8a73",
+ "url": "https://api.github.com/repos/symfony/http-client/zipball/6ed0c02fdc21a76966f19b9000de18e688d9ca68",
+ "reference": "6ed0c02fdc21a76966f19b9000de18e688d9ca68",
"shasum": ""
},
"require": {
@@ -2568,7 +2520,7 @@
"description": "Provides powerful methods to fetch HTTP resources synchronously or asynchronously",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/http-client/tree/v4.4.33"
+ "source": "https://github.com/symfony/http-client/tree/v4.4.35"
},
"funding": [
{
@@ -2584,7 +2536,7 @@
"type": "tidelift"
}
],
- "time": "2021-10-18T16:39:13+00:00"
+ "time": "2021-11-22T21:43:45+00:00"
},
{
"name": "symfony/polyfill-ctype",
@@ -3069,16 +3021,16 @@
},
{
"name": "symfony/process",
- "version": "v4.4.30",
+ "version": "v4.4.35",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
- "reference": "13d3161ef63a8ec21eeccaaf9a4d7f784a87a97d"
+ "reference": "c2098705326addae6e6742151dfade47ac71da1b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/process/zipball/13d3161ef63a8ec21eeccaaf9a4d7f784a87a97d",
- "reference": "13d3161ef63a8ec21eeccaaf9a4d7f784a87a97d",
+ "url": "https://api.github.com/repos/symfony/process/zipball/c2098705326addae6e6742151dfade47ac71da1b",
+ "reference": "c2098705326addae6e6742151dfade47ac71da1b",
"shasum": ""
},
"require": {
@@ -3111,7 +3063,7 @@
"description": "Executes commands in sub-processes",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/process/tree/v4.4.30"
+ "source": "https://github.com/symfony/process/tree/v4.4.35"
},
"funding": [
{
@@ -3127,20 +3079,20 @@
"type": "tidelift"
}
],
- "time": "2021-08-04T20:31:23+00:00"
+ "time": "2021-11-22T22:36:24+00:00"
},
{
"name": "symfony/var-dumper",
- "version": "v4.4.33",
+ "version": "v4.4.34",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
- "reference": "50286e2b7189bfb4f419c0731e86632cddf7c5ee"
+ "reference": "2d0c056b2faaa3d785bdbd5adecc593a5be9c16e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/var-dumper/zipball/50286e2b7189bfb4f419c0731e86632cddf7c5ee",
- "reference": "50286e2b7189bfb4f419c0731e86632cddf7c5ee",
+ "url": "https://api.github.com/repos/symfony/var-dumper/zipball/2d0c056b2faaa3d785bdbd5adecc593a5be9c16e",
+ "reference": "2d0c056b2faaa3d785bdbd5adecc593a5be9c16e",
"shasum": ""
},
"require": {
@@ -3200,7 +3152,7 @@
"dump"
],
"support": {
- "source": "https://github.com/symfony/var-dumper/tree/v4.4.33"
+ "source": "https://github.com/symfony/var-dumper/tree/v4.4.34"
},
"funding": [
{
@@ -3216,20 +3168,20 @@
"type": "tidelift"
}
],
- "time": "2021-10-25T20:24:58+00:00"
+ "time": "2021-11-12T10:50:54+00:00"
},
{
"name": "symfony/yaml",
- "version": "v4.4.29",
+ "version": "v4.4.34",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
- "reference": "3abcc4db06d4e776825eaa3ed8ad924d5bc7432a"
+ "reference": "2c309e258adeb9970229042be39b360d34986fad"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/yaml/zipball/3abcc4db06d4e776825eaa3ed8ad924d5bc7432a",
- "reference": "3abcc4db06d4e776825eaa3ed8ad924d5bc7432a",
+ "url": "https://api.github.com/repos/symfony/yaml/zipball/2c309e258adeb9970229042be39b360d34986fad",
+ "reference": "2c309e258adeb9970229042be39b360d34986fad",
"shasum": ""
},
"require": {
@@ -3271,7 +3223,7 @@
"description": "Loads and dumps YAML files",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/yaml/tree/v4.4.29"
+ "source": "https://github.com/symfony/yaml/tree/v4.4.34"
},
"funding": [
{
@@ -3287,20 +3239,20 @@
"type": "tidelift"
}
],
- "time": "2021-07-27T16:19:30+00:00"
+ "time": "2021-11-18T18:49:23+00:00"
},
{
"name": "twig/twig",
- "version": "v1.44.5",
+ "version": "v1.44.6",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
- "reference": "dd4353357c5a116322e92a00d16043a31881a81e"
+ "reference": "ae39480f010ef88adc7938503c9b02d3baf2f3b3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/twigphp/Twig/zipball/dd4353357c5a116322e92a00d16043a31881a81e",
- "reference": "dd4353357c5a116322e92a00d16043a31881a81e",
+ "url": "https://api.github.com/repos/twigphp/Twig/zipball/ae39480f010ef88adc7938503c9b02d3baf2f3b3",
+ "reference": "ae39480f010ef88adc7938503c9b02d3baf2f3b3",
"shasum": ""
},
"require": {
@@ -3353,7 +3305,7 @@
],
"support": {
"issues": "https://github.com/twigphp/Twig/issues",
- "source": "https://github.com/twigphp/Twig/tree/v1.44.5"
+ "source": "https://github.com/twigphp/Twig/tree/v1.44.6"
},
"funding": [
{
@@ -3365,7 +3317,7 @@
"type": "tidelift"
}
],
- "time": "2021-09-17T08:35:19+00:00"
+ "time": "2021-11-25T13:31:46+00:00"
},
{
"name": "willdurand/negotiation",
@@ -3490,16 +3442,16 @@
},
{
"name": "codeception/codeception",
- "version": "4.1.22",
+ "version": "4.1.23",
"source": {
"type": "git",
"url": "https://github.com/Codeception/Codeception.git",
- "reference": "9777ec3690ceedc4bce2ed13af7af4ca4ee3088f"
+ "reference": "27d18cd5d5a1d77d3f1b01ea776238676faf5dcc"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/Codeception/Codeception/zipball/9777ec3690ceedc4bce2ed13af7af4ca4ee3088f",
- "reference": "9777ec3690ceedc4bce2ed13af7af4ca4ee3088f",
+ "url": "https://api.github.com/repos/Codeception/Codeception/zipball/27d18cd5d5a1d77d3f1b01ea776238676faf5dcc",
+ "reference": "27d18cd5d5a1d77d3f1b01ea776238676faf5dcc",
"shasum": ""
},
"require": {
@@ -3549,7 +3501,10 @@
"psr-4": {
"Codeception\\": "src/Codeception",
"Codeception\\Extension\\": "ext"
- }
+ },
+ "files": [
+ "functions.php"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -3573,7 +3528,7 @@
],
"support": {
"issues": "https://github.com/Codeception/Codeception/issues",
- "source": "https://github.com/Codeception/Codeception/tree/4.1.22"
+ "source": "https://github.com/Codeception/Codeception/tree/4.1.23"
},
"funding": [
{
@@ -3581,7 +3536,7 @@
"type": "open_collective"
}
],
- "time": "2021-08-06T17:15:34+00:00"
+ "time": "2021-12-11T18:05:26+00:00"
},
{
"name": "codeception/lib-asserts",
@@ -4020,16 +3975,16 @@
},
{
"name": "guzzlehttp/guzzle",
- "version": "7.4.0",
+ "version": "7.4.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
- "reference": "868b3571a039f0ebc11ac8f344f4080babe2cb94"
+ "reference": "ee0a041b1760e6a53d2a39c8c34115adc2af2c79"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/guzzle/zipball/868b3571a039f0ebc11ac8f344f4080babe2cb94",
- "reference": "868b3571a039f0ebc11ac8f344f4080babe2cb94",
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/ee0a041b1760e6a53d2a39c8c34115adc2af2c79",
+ "reference": "ee0a041b1760e6a53d2a39c8c34115adc2af2c79",
"shasum": ""
},
"require": {
@@ -4038,7 +3993,7 @@
"guzzlehttp/psr7": "^1.8.3 || ^2.1",
"php": "^7.2.5 || ^8.0",
"psr/http-client": "^1.0",
- "symfony/deprecation-contracts": "^2.2"
+ "symfony/deprecation-contracts": "^2.2 || ^3.0"
},
"provide": {
"psr/http-client-implementation": "1.0"
@@ -4124,7 +4079,7 @@
],
"support": {
"issues": "https://github.com/guzzle/guzzle/issues",
- "source": "https://github.com/guzzle/guzzle/tree/7.4.0"
+ "source": "https://github.com/guzzle/guzzle/tree/7.4.1"
},
"funding": [
{
@@ -4140,7 +4095,7 @@
"type": "tidelift"
}
],
- "time": "2021-10-18T09:52:00+00:00"
+ "time": "2021-12-06T18:43:05+00:00"
},
{
"name": "guzzlehttp/promises",
@@ -4286,16 +4241,16 @@
},
{
"name": "nikic/php-parser",
- "version": "v4.13.1",
+ "version": "v4.13.2",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
- "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd"
+ "reference": "210577fe3cf7badcc5814d99455df46564f3c077"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/63a79e8daa781cac14e5195e63ed8ae231dd10fd",
- "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd",
+ "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077",
+ "reference": "210577fe3cf7badcc5814d99455df46564f3c077",
"shasum": ""
},
"require": {
@@ -4336,9 +4291,9 @@
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
- "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.1"
+ "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.2"
},
- "time": "2021-11-03T20:52:16+00:00"
+ "time": "2021-11-30T19:35:32+00:00"
},
{
"name": "phar-io/manifest",
@@ -4613,16 +4568,16 @@
},
{
"name": "phpspec/prophecy",
- "version": "1.14.0",
+ "version": "v1.15.0",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
- "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e"
+ "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpspec/prophecy/zipball/d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e",
- "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e",
+ "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13",
+ "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13",
"shasum": ""
},
"require": {
@@ -4674,22 +4629,22 @@
],
"support": {
"issues": "https://github.com/phpspec/prophecy/issues",
- "source": "https://github.com/phpspec/prophecy/tree/1.14.0"
+ "source": "https://github.com/phpspec/prophecy/tree/v1.15.0"
},
- "time": "2021-09-10T09:02:12+00:00"
+ "time": "2021-12-08T12:19:24+00:00"
},
{
"name": "phpstan/phpstan",
- "version": "1.1.2",
+ "version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
- "reference": "bcea0ae85868a89d5789c75f012c93129f842934"
+ "reference": "cbe085f9fdead5b6d62e4c022ca52dc9427a10ee"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpstan/phpstan/zipball/bcea0ae85868a89d5789c75f012c93129f842934",
- "reference": "bcea0ae85868a89d5789c75f012c93129f842934",
+ "url": "https://api.github.com/repos/phpstan/phpstan/zipball/cbe085f9fdead5b6d62e4c022ca52dc9427a10ee",
+ "reference": "cbe085f9fdead5b6d62e4c022ca52dc9427a10ee",
"shasum": ""
},
"require": {
@@ -4705,7 +4660,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.0-dev"
+ "dev-master": "1.2-dev"
}
},
"autoload": {
@@ -4720,7 +4675,7 @@
"description": "PHPStan - PHP Static Analysis Tool",
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
- "source": "https://github.com/phpstan/phpstan/tree/1.1.2"
+ "source": "https://github.com/phpstan/phpstan/tree/1.2.0"
},
"funding": [
{
@@ -4740,7 +4695,7 @@
"type": "tidelift"
}
],
- "time": "2021-11-09T12:41:09+00:00"
+ "time": "2021-11-18T14:09:01+00:00"
},
{
"name": "phpstan/phpstan-deprecation-rules",
@@ -4794,16 +4749,16 @@
},
{
"name": "phpunit/php-code-coverage",
- "version": "9.2.8",
+ "version": "9.2.10",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "cf04e88a2e3c56fc1a65488afd493325b4c1bc3e"
+ "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/cf04e88a2e3c56fc1a65488afd493325b4c1bc3e",
- "reference": "cf04e88a2e3c56fc1a65488afd493325b4c1bc3e",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d5850aaf931743067f4bfc1ae4cbd06468400687",
+ "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687",
"shasum": ""
},
"require": {
@@ -4859,7 +4814,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
- "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.8"
+ "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.10"
},
"funding": [
{
@@ -4867,20 +4822,20 @@
"type": "github"
}
],
- "time": "2021-10-30T08:01:38+00:00"
+ "time": "2021-12-05T09:12:13+00:00"
},
{
"name": "phpunit/php-file-iterator",
- "version": "3.0.5",
+ "version": "3.0.6",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
- "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8"
+ "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8",
- "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf",
+ "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf",
"shasum": ""
},
"require": {
@@ -4919,7 +4874,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
- "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5"
+ "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6"
},
"funding": [
{
@@ -4927,7 +4882,7 @@
"type": "github"
}
],
- "time": "2020-09-28T05:57:25+00:00"
+ "time": "2021-12-02T12:48:52+00:00"
},
{
"name": "phpunit/php-invoker",
@@ -6231,28 +6186,28 @@
},
{
"name": "symfony/browser-kit",
- "version": "v5.3.4",
+ "version": "v5.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/browser-kit.git",
- "reference": "c1e3f64fcc631c96e2c5843b666db66679ced11c"
+ "reference": "d250db364a35ba5d60626b2a6f10f2eaf2073bde"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/browser-kit/zipball/c1e3f64fcc631c96e2c5843b666db66679ced11c",
- "reference": "c1e3f64fcc631c96e2c5843b666db66679ced11c",
+ "url": "https://api.github.com/repos/symfony/browser-kit/zipball/d250db364a35ba5d60626b2a6f10f2eaf2073bde",
+ "reference": "d250db364a35ba5d60626b2a6f10f2eaf2073bde",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
- "symfony/dom-crawler": "^4.4|^5.0",
+ "symfony/dom-crawler": "^4.4|^5.0|^6.0",
"symfony/polyfill-php80": "^1.16"
},
"require-dev": {
- "symfony/css-selector": "^4.4|^5.0",
- "symfony/http-client": "^4.4|^5.0",
- "symfony/mime": "^4.4|^5.0",
- "symfony/process": "^4.4|^5.0"
+ "symfony/css-selector": "^4.4|^5.0|^6.0",
+ "symfony/http-client": "^4.4|^5.0|^6.0",
+ "symfony/mime": "^4.4|^5.0|^6.0",
+ "symfony/process": "^4.4|^5.0|^6.0"
},
"suggest": {
"symfony/process": ""
@@ -6283,7 +6238,7 @@
"description": "Simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms programmatically",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/browser-kit/tree/v5.3.4"
+ "source": "https://github.com/symfony/browser-kit/tree/v5.4.0"
},
"funding": [
{
@@ -6299,20 +6254,20 @@
"type": "tidelift"
}
],
- "time": "2021-07-21T12:40:44+00:00"
+ "time": "2021-10-26T22:29:18+00:00"
},
{
"name": "symfony/css-selector",
- "version": "v5.3.4",
+ "version": "v5.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
- "reference": "7fb120adc7f600a59027775b224c13a33530dd90"
+ "reference": "44b933f98bb4b5220d10bed9ce5662f8c2d13dcc"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/css-selector/zipball/7fb120adc7f600a59027775b224c13a33530dd90",
- "reference": "7fb120adc7f600a59027775b224c13a33530dd90",
+ "url": "https://api.github.com/repos/symfony/css-selector/zipball/44b933f98bb4b5220d10bed9ce5662f8c2d13dcc",
+ "reference": "44b933f98bb4b5220d10bed9ce5662f8c2d13dcc",
"shasum": ""
},
"require": {
@@ -6349,7 +6304,7 @@
"description": "Converts CSS selectors to XPath expressions",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/css-selector/tree/v5.3.4"
+ "source": "https://github.com/symfony/css-selector/tree/v5.4.0"
},
"funding": [
{
@@ -6365,20 +6320,20 @@
"type": "tidelift"
}
],
- "time": "2021-07-21T12:38:00+00:00"
+ "time": "2021-09-09T08:06:01+00:00"
},
{
"name": "symfony/deprecation-contracts",
- "version": "v2.4.0",
+ "version": "v2.5.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
- "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627"
+ "reference": "6f981ee24cf69ee7ce9736146d1c57c2780598a8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627",
- "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627",
+ "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/6f981ee24cf69ee7ce9736146d1c57c2780598a8",
+ "reference": "6f981ee24cf69ee7ce9736146d1c57c2780598a8",
"shasum": ""
},
"require": {
@@ -6387,7 +6342,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "2.4-dev"
+ "dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
@@ -6416,7 +6371,7 @@
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0"
+ "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.0"
},
"funding": [
{
@@ -6432,25 +6387,25 @@
"type": "tidelift"
}
],
- "time": "2021-03-23T23:28:01+00:00"
+ "time": "2021-07-12T14:48:14+00:00"
},
{
"name": "symfony/dom-crawler",
- "version": "v5.3.7",
+ "version": "v5.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
- "reference": "c7eef3a60ccfdd8eafe07f81652e769ac9c7146c"
+ "reference": "5b06626e940a3ad54e573511d64d4e00dc8d0fd8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/c7eef3a60ccfdd8eafe07f81652e769ac9c7146c",
- "reference": "c7eef3a60ccfdd8eafe07f81652e769ac9c7146c",
+ "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/5b06626e940a3ad54e573511d64d4e00dc8d0fd8",
+ "reference": "5b06626e940a3ad54e573511d64d4e00dc8d0fd8",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1",
+ "symfony/deprecation-contracts": "^2.1|^3",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php80": "^1.16"
@@ -6460,7 +6415,7 @@
},
"require-dev": {
"masterminds/html5": "^2.6",
- "symfony/css-selector": "^4.4|^5.0"
+ "symfony/css-selector": "^4.4|^5.0|^6.0"
},
"suggest": {
"symfony/css-selector": ""
@@ -6491,7 +6446,7 @@
"description": "Eases DOM navigation for HTML and XML documents",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/dom-crawler/tree/v5.3.7"
+ "source": "https://github.com/symfony/dom-crawler/tree/v5.4.0"
},
"funding": [
{
@@ -6507,24 +6462,25 @@
"type": "tidelift"
}
],
- "time": "2021-08-29T19:32:13+00:00"
+ "time": "2021-11-23T10:19:22+00:00"
},
{
"name": "symfony/finder",
- "version": "v5.3.7",
+ "version": "v5.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
- "reference": "a10000ada1e600d109a6c7632e9ac42e8bf2fb93"
+ "reference": "d2f29dac98e96a98be467627bd49c2efb1bc2590"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/finder/zipball/a10000ada1e600d109a6c7632e9ac42e8bf2fb93",
- "reference": "a10000ada1e600d109a6c7632e9ac42e8bf2fb93",
+ "url": "https://api.github.com/repos/symfony/finder/zipball/d2f29dac98e96a98be467627bd49c2efb1bc2590",
+ "reference": "d2f29dac98e96a98be467627bd49c2efb1bc2590",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
+ "symfony/deprecation-contracts": "^2.1|^3",
"symfony/polyfill-php80": "^1.16"
},
"type": "library",
@@ -6553,7 +6509,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/finder/tree/v5.3.7"
+ "source": "https://github.com/symfony/finder/tree/v5.4.0"
},
"funding": [
{
@@ -6569,7 +6525,7 @@
"type": "tidelift"
}
],
- "time": "2021-08-04T21:20:46+00:00"
+ "time": "2021-11-28T15:25:38+00:00"
},
{
"name": "theseer/tokenizer",
@@ -6698,5 +6654,5 @@
"platform-overrides": {
"php": "7.3.6"
},
- "plugin-api-version": "2.0.0"
+ "plugin-api-version": "2.1.0"
}
diff --git a/images/.gitkeep b/images/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/images/.gitkeep
+++ b/images/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/index.php b/index.php
index 091e9a824..3e308312f 100644
--- a/index.php
+++ b/index.php
@@ -3,7 +3,7 @@
/**
* @package Grav.Core
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -12,10 +12,6 @@ namespace Grav;
\define('GRAV_REQUEST_TIME', microtime(true));
\define('GRAV_PHP_MIN', '7.3.6');
-if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) {
- die(sprintf('You are running PHP %s, but Grav needs at least PHP %s to run.', $ver, $req));
-}
-
if (PHP_SAPI === 'cli-server') {
$symfony_server = stripos(getenv('_'), 'symfony') !== false || stripos($_SERVER['SERVER_SOFTWARE'] ?? '', 'symfony') !== false || stripos($_ENV['SERVER_SOFTWARE'] ?? '', 'symfony') !== false;
diff --git a/logs/.gitkeep b/logs/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/logs/.gitkeep
+++ b/logs/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml
index 1aeaf2bf2..aff54b46c 100644
--- a/system/blueprints/config/system.yaml
+++ b/system/blueprints/config/system.yaml
@@ -1394,6 +1394,18 @@ form:
validate:
type: bool
+ session.secure_https:
+ type: toggle
+ label: PLUGIN_ADMIN.SESSION_SECURE_HTTPS
+ help: PLUGIN_ADMIN.SESSION_SECURE_HTTPS_HELP
+ highlight: 1
+ options:
+ 1: PLUGIN_ADMIN.YES
+ 0: PLUGIN_ADMIN.NO
+ default: true
+ validate:
+ type: bool
+
session.httponly:
type: toggle
label: PLUGIN_ADMIN.SESSION_HTTPONLY
diff --git a/system/blueprints/flex/pages.yaml b/system/blueprints/flex/pages.yaml
index 5c6ed8eb5..89dab6a56 100644
--- a/system/blueprints/flex/pages.yaml
+++ b/system/blueprints/flex/pages.yaml
@@ -104,7 +104,7 @@ config:
edit:
title:
- template: "{% if object.root %}Root ( <root> ){% else %}{{ (form.value('header.title') ?? form.value('folder'))|e }} ( {{ (object.getRoute().toString(false) ?: '/')|e }} ){% endif %}"
+ template: "{% if object.root %}Root ( <root> ){% else %}{{ (form.value('header.title') ?? form.value('folder'))|e }} ( {{ (object.getRoute().toString(false) ?: '/')|e }} ){% endif %}"
# TODO: not used yet
buttons:
diff --git a/system/blueprints/pages/external.yaml b/system/blueprints/pages/external.yaml
index df1d7b0aa..d3bb57ac9 100644
--- a/system/blueprints/pages/external.yaml
+++ b/system/blueprints/pages/external.yaml
@@ -1,7 +1,7 @@
-title: PLUGIN_ADMIN:EXTERNAL
+title: PLUGIN_ADMIN.EXTERNAL
extends@:
- type: default
- context: blueprints://pages
+ type: default
+ context: blueprints://pages
form:
validation: loose
@@ -29,16 +29,16 @@ form:
unset@: true
header.external_url:
- type: text
- label: PLUGIN_ADMIN.EXTERNAL_URL
- placeholder: https://getgrav.org
- validate:
- required: true
+ type: text
+ label: PLUGIN_ADMIN.EXTERNAL_URL
+ placeholder: https://getgrav.org
+ validate:
+ required: true
+
options:
fields:
publishing:
-
fields:
header.date:
diff --git a/system/config/system.yaml b/system/config/system.yaml
index 652910d86..60abcee34 100644
--- a/system/config/system.yaml
+++ b/system/config/system.yaml
@@ -182,6 +182,7 @@ session:
name: grav-site # Name prefix of the session cookie. Use alphanumeric, dashes or underscores only. Do not use dots in the session name
uniqueness: path # Should sessions be `path` based or `security.salt` based
secure: false # Set session secure. If true, indicates that communication for this cookie must be over an encrypted transmission. Enable this only on sites that run exclusively on HTTPS
+ secure_https: true # Set session secure on HTTPS but not on HTTP. Has no effect if you have `session.secure: true`. Set to false if your site jumps between HTTP and HTTPS.
httponly: true # Set session HTTP only. If true, indicates that cookies should be used only over HTTP, and JavaScript modification is not allowed.
samesite: Lax # Set session SameSite. Possible values are Lax, Strict and None. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
split: true # Sessions should be independent between site and plugins (such as admin)
diff --git a/system/defines.php b/system/defines.php
index f5ccba900..7cbae21b7 100644
--- a/system/defines.php
+++ b/system/defines.php
@@ -3,13 +3,13 @@
/**
* @package Grav\Core
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
// Some standard defines
define('GRAV', true);
-define('GRAV_VERSION', '1.7.25');
+define('GRAV_VERSION', '1.7.26');
define('GRAV_SCHEMA', '1.7.0_2020-11-20_1');
define('GRAV_TESTING', false);
diff --git a/system/install.php b/system/install.php
index e8cd5827d..5c9440f97 100644
--- a/system/install.php
+++ b/system/install.php
@@ -2,7 +2,7 @@
/**
* @package Grav\Core
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/languages/es.yaml b/system/languages/es.yaml
index 95827ee2b..a8a47aa38 100644
--- a/system/languages/es.yaml
+++ b/system/languages/es.yaml
@@ -44,7 +44,7 @@ GRAV:
WK: sem
MO: mes
YR: año
- DEC: dic
+ DEC: déc
SECOND_PLURAL: segundos
MINUTE_PLURAL: minutos
HOUR_PLURAL: horas
@@ -64,7 +64,7 @@ GRAV:
VALIDATION_FAIL: 'Falló la validación: '
INVALID_INPUT: 'Dato inválido en: '
MISSING_REQUIRED_FIELD: 'Falta el campo requerido: '
- XSS_ISSUES: "Se detectaron problemas XSS potenciales en el campo '%s'"
+ XSS_ISSUES: "Se detectaron potenciales problemas XSS en el campo '%s'"
MONTHS_OF_THE_YEAR:
- 'Enero'
- 'Febrero'
@@ -86,7 +86,7 @@ GRAV:
- 'Viernes'
- 'Sábado'
- 'Domingo'
- YES: "Si"
+ YES: "Sí"
NO: "No"
CRON:
EVERY: cada
@@ -96,12 +96,12 @@ GRAV:
EVERY_DAY_OF_MONTH: cada día del mes
EVERY_MONTH: cada mes
TEXT_PERIOD: Cada
- TEXT_MINS: ' a minuto(s) despues de la hora'
+ TEXT_MINS: ' a minuto(s) después de la hora'
TEXT_TIME: ' a :'
TEXT_DOW: ' en '
TEXT_MONTH: ' de'
TEXT_DOM: ' en'
- ERROR1: La etiqueta %s no está soportada!
- ERROR2: El número de elementos es erroneo
+ ERROR1: '¡La etiqueta %s no está soportada!'
+ ERROR2: El número de elementos es erróneo
ERROR3: El jquery_element debería establecerse en la configuración del jqCron
ERROR4: Expresión no reconocida
diff --git a/system/router.php b/system/router.php
index d58609c83..c19f814ba 100644
--- a/system/router.php
+++ b/system/router.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Core
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -22,9 +22,9 @@ if ($path !== '/index.php' && is_file($root . $path)) {
// Block all direct access for these folders
|| preg_match('`^/(\.git|cache|bin|logs|backup|webserver-configs|tests)/`ui', $path)
// Block access to specific file types for these system folders
- || preg_match('`^/(system|vendor)/(.*)\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$`ui', $path)
+ || preg_match('`^/(system|vendor)/(.*)\.(txt|xml|md|html|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$`ui', $path)
// Block access to specific file types for these user folders
- || preg_match('`^/(user)/(.*)\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$`ui', $path)
+ || preg_match('`^/(user)/(.*)\.(txt|md|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$`ui', $path)
// Block all direct access to .md files
|| preg_match('`\.md$`ui', $path)
// Block access to specific files in the root folder
diff --git a/system/src/DOMLettersIterator.php b/system/src/DOMLettersIterator.php
new file mode 100644
index 000000000..e3c2c4ad9
--- /dev/null
+++ b/system/src/DOMLettersIterator.php
@@ -0,0 +1,165 @@
+load('example.xml');
+ * foreach(new DOMLettersIterator($doc) as $letter) echo $letter;
+ *
+ * NB: If you only need characters without their position
+ * in the document, use DOMNode->textContent instead.
+ *
+ * @author porneL http://pornel.net
+ * @license Public Domain
+ * @url https://github.com/antoligy/dom-string-iterators
+ *
+ * @implements Iterator
+ */
+final class DOMLettersIterator implements Iterator
+{
+ /** @var DOMElement */
+ private $start;
+ /** @var DOMElement|null */
+ private $current;
+ /** @var int */
+ private $offset = -1;
+ /** @var int|null */
+ private $key;
+ /** @var array|null */
+ private $letters;
+
+ /**
+ * expects DOMElement or DOMDocument (see DOMDocument::load and DOMDocument::loadHTML)
+ *
+ * @param DOMNode $el
+ */
+ public function __construct(DOMNode $el)
+ {
+ if ($el instanceof DOMDocument) {
+ $el = $el->documentElement;
+ }
+
+ if (!$el instanceof DOMElement) {
+ throw new InvalidArgumentException('Invalid arguments, expected DOMElement or DOMDocument');
+ }
+
+ $this->start = $el;
+ }
+
+ /**
+ * Returns position in text as DOMText node and character offset.
+ * (it's NOT a byte offset, you must use mb_substr() or similar to use this offset properly).
+ * node may be NULL if iterator has finished.
+ *
+ * @return array
+ */
+ public function currentTextPosition(): array
+ {
+ return [$this->current, $this->offset];
+ }
+
+ /**
+ * Returns DOMElement that is currently being iterated or NULL if iterator has finished.
+ *
+ * @return DOMElement|null
+ */
+ public function currentElement(): ?DOMElement
+ {
+ return $this->current ? $this->current->parentNode : null;
+ }
+
+ // Implementation of Iterator interface
+
+ /**
+ * @return int|null
+ */
+ public function key(): ?int
+ {
+ return $this->key;
+ }
+
+ /**
+ * @return void
+ */
+ public function next(): void
+ {
+ if (null === $this->current) {
+ return;
+ }
+
+ if ($this->current->nodeType === XML_TEXT_NODE || $this->current->nodeType === XML_CDATA_SECTION_NODE) {
+ if ($this->offset === -1) {
+ preg_match_all('/./us', $this->current->textContent, $m);
+ $this->letters = $m[0];
+ }
+
+ $this->offset++;
+ $this->key++;
+ if ($this->letters && $this->offset < count($this->letters)) {
+ return;
+ }
+
+ $this->offset = -1;
+ }
+
+ while ($this->current->nodeType === XML_ELEMENT_NODE && $this->current->firstChild) {
+ $this->current = $this->current->firstChild;
+ if ($this->current->nodeType === XML_TEXT_NODE || $this->current->nodeType === XML_CDATA_SECTION_NODE) {
+ $this->next();
+ return;
+ }
+ }
+
+ while (!$this->current->nextSibling && $this->current->parentNode) {
+ $this->current = $this->current->parentNode;
+ if ($this->current === $this->start) {
+ $this->current = null;
+ return;
+ }
+ }
+
+ $this->current = $this->current->nextSibling;
+
+ $this->next();
+ }
+
+ /**
+ * Return the current element
+ * @link https://php.net/manual/en/iterator.current.php
+ *
+ * @return string|null
+ */
+ public function current(): ?string
+ {
+ return $this->letters ? $this->letters[$this->offset] : null;
+ }
+
+ /**
+ * Checks if current position is valid
+ * @link https://php.net/manual/en/iterator.valid.php
+ *
+ * @return bool
+ */
+ public function valid(): bool
+ {
+ return (bool)$this->current;
+ }
+
+ /**
+ * @return void
+ */
+ public function rewind(): void
+ {
+ $this->current = $this->start;
+ $this->offset = -1;
+ $this->key = 0;
+ $this->letters = [];
+
+ $this->next();
+ }
+}
+
diff --git a/system/src/DOMWordsIterator.php b/system/src/DOMWordsIterator.php
new file mode 100644
index 000000000..fb7c2e374
--- /dev/null
+++ b/system/src/DOMWordsIterator.php
@@ -0,0 +1,158 @@
+load('example.xml');
+ * foreach(new DOMWordsIterator($doc) as $word) echo $word;
+ *
+ * @author pjgalbraith http://www.pjgalbraith.com
+ * @author porneL http://pornel.net (based on DOMLettersIterator available at http://pornel.net/source/domlettersiterator.php)
+ * @license Public Domain
+ * @url https://github.com/antoligy/dom-string-iterators
+ *
+ * @implements Iterator
+ */
+
+final class DOMWordsIterator implements Iterator
+{
+ /** @var DOMElement */
+ private $start;
+ /** @var DOMElement|null */
+ private $current;
+ /** @var int */
+ private $offset = -1;
+ /** @var int|null */
+ private $key;
+ /** @var array>|null */
+ private $words;
+
+ /**
+ * expects DOMElement or DOMDocument (see DOMDocument::load and DOMDocument::loadHTML)
+ *
+ * @param DOMNode $el
+ */
+ public function __construct(DOMNode $el)
+ {
+ if ($el instanceof DOMDocument) {
+ $el = $el->documentElement;
+ }
+
+ if (!$el instanceof DOMElement) {
+ throw new InvalidArgumentException('Invalid arguments, expected DOMElement or DOMDocument');
+ }
+
+ $this->start = $el;
+ }
+
+ /**
+ * Returns position in text as DOMText node and character offset.
+ * (it's NOT a byte offset, you must use mb_substr() or similar to use this offset properly).
+ * node may be NULL if iterator has finished.
+ *
+ * @return array
+ */
+ public function currentWordPosition(): array
+ {
+ return [$this->current, $this->offset, $this->words];
+ }
+
+ /**
+ * Returns DOMElement that is currently being iterated or NULL if iterator has finished.
+ *
+ * @return DOMElement|null
+ */
+ public function currentElement(): ?DOMElement
+ {
+ return $this->current ? $this->current->parentNode : null;
+ }
+
+ // Implementation of Iterator interface
+
+ /**
+ * Return the key of the current element
+ * @link https://php.net/manual/en/iterator.key.php
+ * @return int|null
+ */
+ public function key(): ?int
+ {
+ return $this->key;
+ }
+
+ /**
+ * @return void
+ */
+ public function next(): void
+ {
+ if (null === $this->current) {
+ return;
+ }
+
+ if ($this->current->nodeType === XML_TEXT_NODE || $this->current->nodeType === XML_CDATA_SECTION_NODE) {
+ if ($this->offset === -1) {
+ $this->words = preg_split("/[\n\r\t ]+/", $this->current->textContent, -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_OFFSET_CAPTURE) ?: [];
+ }
+ $this->offset++;
+
+ if ($this->words && $this->offset < count($this->words)) {
+ $this->key++;
+ return;
+ }
+ $this->offset = -1;
+ }
+
+ while ($this->current->nodeType === XML_ELEMENT_NODE && $this->current->firstChild) {
+ $this->current = $this->current->firstChild;
+ if ($this->current->nodeType === XML_TEXT_NODE || $this->current->nodeType === XML_CDATA_SECTION_NODE) {
+ $this->next();
+ return;
+ }
+ }
+
+ while (!$this->current->nextSibling && $this->current->parentNode) {
+ $this->current = $this->current->parentNode;
+ if ($this->current === $this->start) {
+ $this->current = null;
+ return;
+ }
+ }
+
+ $this->current = $this->current->nextSibling;
+
+ $this->next();
+ }
+
+ /**
+ * Return the current element
+ * @link https://php.net/manual/en/iterator.current.php
+ * @return string|null
+ */
+ public function current(): ?string
+ {
+ return $this->words ? (string)$this->words[$this->offset][0] : null;
+ }
+
+ /**
+ * Checks if current position is valid
+ * @link https://php.net/manual/en/iterator.valid.php
+ * @return bool
+ */
+ public function valid(): bool
+ {
+ return (bool)$this->current;
+ }
+
+ public function rewind(): void
+ {
+ $this->current = $this->start;
+ $this->offset = -1;
+ $this->key = 0;
+ $this->words = [];
+
+ $this->next();
+ }
+}
diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php
index a9b930b13..36dc79dd0 100644
--- a/system/src/Grav/Common/Assets.php
+++ b/system/src/Grav/Common/Assets.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Assets/BaseAsset.php b/system/src/Grav/Common/Assets/BaseAsset.php
index a115ce9ec..21d9eef63 100644
--- a/system/src/Grav/Common/Assets/BaseAsset.php
+++ b/system/src/Grav/Common/Assets/BaseAsset.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -248,6 +248,7 @@ abstract class BaseAsset extends PropertyObject
*
* @return array
*/
+ #[\ReturnTypeWillChange]
public function jsonSerialize()
{
return ['type' => $this->getType(), 'elements' => $this->getElements()];
diff --git a/system/src/Grav/Common/Assets/Css.php b/system/src/Grav/Common/Assets/Css.php
index 4c6a9c9b0..701c94235 100644
--- a/system/src/Grav/Common/Assets/Css.php
+++ b/system/src/Grav/Common/Assets/Css.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Assets/InlineCss.php b/system/src/Grav/Common/Assets/InlineCss.php
index f024a95a4..943cef6b6 100644
--- a/system/src/Grav/Common/Assets/InlineCss.php
+++ b/system/src/Grav/Common/Assets/InlineCss.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Assets/InlineJs.php b/system/src/Grav/Common/Assets/InlineJs.php
index 6787608d6..9ad365574 100644
--- a/system/src/Grav/Common/Assets/InlineJs.php
+++ b/system/src/Grav/Common/Assets/InlineJs.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Assets/Js.php b/system/src/Grav/Common/Assets/Js.php
index fc2a472fd..fb67491f3 100644
--- a/system/src/Grav/Common/Assets/Js.php
+++ b/system/src/Grav/Common/Assets/Js.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Assets/Pipeline.php b/system/src/Grav/Common/Assets/Pipeline.php
index 948104ab9..a41e924a5 100644
--- a/system/src/Grav/Common/Assets/Pipeline.php
+++ b/system/src/Grav/Common/Assets/Pipeline.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -122,7 +122,7 @@ class Pipeline extends PropertyObject
// Compute uid based on assets and timestamp
$json_assets = json_encode($assets);
- $uid = md5($json_assets . $this->css_minify . $this->css_rewrite . $group);
+ $uid = md5($json_assets . (int)$this->css_minify . (int)$this->css_rewrite . $group);
$file = $uid . '.css';
$relative_path = "{$this->base_url}{$this->assets_url}/{$file}";
diff --git a/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php b/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php
index 3f5a690fb..5b1087d6c 100644
--- a/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php
+++ b/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets\Traits
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php b/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php
index 36b21522d..c1ef0a3c3 100644
--- a/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php
+++ b/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets\Traits
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php b/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php
index 15dc00e3d..ec00a6079 100644
--- a/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php
+++ b/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets\Traits
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Backup/Backups.php b/system/src/Grav/Common/Backup/Backups.php
index 4680f8546..0465fe705 100644
--- a/system/src/Grav/Common/Backup/Backups.php
+++ b/system/src/Grav/Common/Backup/Backups.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Backup
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -145,7 +145,7 @@ class Backups
{
$backups = static::getAvailableBackups();
- return array_sum(array_column($backups, 'size'));
+ return $backups ? array_sum(array_column($backups, 'size')) : 0;
}
/**
diff --git a/system/src/Grav/Common/Browser.php b/system/src/Grav/Common/Browser.php
index e4a6513ea..ffc8da313 100644
--- a/system/src/Grav/Common/Browser.php
+++ b/system/src/Grav/Common/Browser.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php
index a50351836..c7b550cb9 100644
--- a/system/src/Grav/Common/Cache.php
+++ b/system/src/Grav/Common/Cache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Composer.php b/system/src/Grav/Common/Composer.php
index f1f6e5d3e..667edf25c 100644
--- a/system/src/Grav/Common/Composer.php
+++ b/system/src/Grav/Common/Composer.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Config/CompiledBase.php b/system/src/Grav/Common/Config/CompiledBase.php
index 0764189d2..b462b4cfd 100644
--- a/system/src/Grav/Common/Config/CompiledBase.php
+++ b/system/src/Grav/Common/Config/CompiledBase.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Config
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Config/CompiledBlueprints.php b/system/src/Grav/Common/Config/CompiledBlueprints.php
index 774305425..e83859144 100644
--- a/system/src/Grav/Common/Config/CompiledBlueprints.php
+++ b/system/src/Grav/Common/Config/CompiledBlueprints.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Config
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Config/CompiledConfig.php b/system/src/Grav/Common/Config/CompiledConfig.php
index 22225bce5..2db6de5a6 100644
--- a/system/src/Grav/Common/Config/CompiledConfig.php
+++ b/system/src/Grav/Common/Config/CompiledConfig.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Config
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Config/CompiledLanguages.php b/system/src/Grav/Common/Config/CompiledLanguages.php
index 6674389ac..0a2668638 100644
--- a/system/src/Grav/Common/Config/CompiledLanguages.php
+++ b/system/src/Grav/Common/Config/CompiledLanguages.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Config
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Config/Config.php b/system/src/Grav/Common/Config/Config.php
index 7adb523e8..ca027bf46 100644
--- a/system/src/Grav/Common/Config/Config.php
+++ b/system/src/Grav/Common/Config/Config.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Config
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Config/ConfigFileFinder.php b/system/src/Grav/Common/Config/ConfigFileFinder.php
index e6b1afeaf..28f9dc11a 100644
--- a/system/src/Grav/Common/Config/ConfigFileFinder.php
+++ b/system/src/Grav/Common/Config/ConfigFileFinder.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Config
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Config/Languages.php b/system/src/Grav/Common/Config/Languages.php
index 4a863a1b6..05798c573 100644
--- a/system/src/Grav/Common/Config/Languages.php
+++ b/system/src/Grav/Common/Config/Languages.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Config
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Config/Setup.php b/system/src/Grav/Common/Config/Setup.php
index 6ff7372d0..8ffd63762 100644
--- a/system/src/Grav/Common/Config/Setup.php
+++ b/system/src/Grav/Common/Config/Setup.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Config
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Data/Blueprint.php b/system/src/Grav/Common/Data/Blueprint.php
index 287819939..ef6aef50d 100644
--- a/system/src/Grav/Common/Data/Blueprint.php
+++ b/system/src/Grav/Common/Data/Blueprint.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Data
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -99,7 +99,7 @@ class Blueprint extends BlueprintForm
*/
public function getDefaultValue(string $name)
{
- $path = explode('.', $name) ?: [];
+ $path = explode('.', $name);
$current = $this->getDefaults();
foreach ($path as $field) {
@@ -293,15 +293,16 @@ class Blueprint extends BlueprintForm
/**
* Flatten data by using blueprints.
*
- * @param array $data
- * @param bool $includeAll
+ * @param array $data Data to be flattened.
+ * @param bool $includeAll True if undefined properties should also be included.
+ * @param string $name Property which will be flattened, useful for flattening repeating data.
* @return array
*/
- public function flattenData(array $data, bool $includeAll = false)
+ public function flattenData(array $data, bool $includeAll = false, string $name = '')
{
$this->initInternals();
- return $this->blueprintSchema->flattenData($data, $includeAll);
+ return $this->blueprintSchema->flattenData($data, $includeAll, $name);
}
diff --git a/system/src/Grav/Common/Data/BlueprintSchema.php b/system/src/Grav/Common/Data/BlueprintSchema.php
index db5e6af7d..8cc63036e 100644
--- a/system/src/Grav/Common/Data/BlueprintSchema.php
+++ b/system/src/Grav/Common/Data/BlueprintSchema.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Data
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -115,23 +115,29 @@ class BlueprintSchema extends BlueprintSchemaBase implements ExportInterface
/**
* Flatten data by using blueprints.
*
- * @param array $data Data to be flattened.
- * @param bool $includeAll
+ * @param array $data Data to be flattened.
+ * @param bool $includeAll True if undefined properties should also be included.
+ * @param string $name Property which will be flattened, useful for flattening repeating data.
* @return array
*/
- public function flattenData(array $data, bool $includeAll = false)
+ public function flattenData(array $data, bool $includeAll = false, string $name = '')
{
+ $prefix = $name !== '' ? $name . '.' : '';
+
$list = [];
if ($includeAll) {
- foreach ($this->items as $key => $rules) {
+ $items = $name !== '' ? $this->getProperty($name)['fields'] ?? [] : $this->items;
+ foreach ($items as $key => $rules) {
$type = $rules['type'] ?? '';
if (!str_starts_with($type, '_') && !str_contains($key, '*')) {
- $list[$key] = null;
+ $list[$prefix . $key] = null;
}
}
}
- return array_replace($list, $this->flattenArray($data, $this->nested, ''));
+ $nested = $this->getNestedRules($name);
+
+ return array_replace($list, $this->flattenArray($data, $nested, $prefix));
}
/**
diff --git a/system/src/Grav/Common/Data/Blueprints.php b/system/src/Grav/Common/Data/Blueprints.php
index abe153f14..dfdd46f72 100644
--- a/system/src/Grav/Common/Data/Blueprints.php
+++ b/system/src/Grav/Common/Data/Blueprints.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Data
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Data/Data.php b/system/src/Grav/Common/Data/Data.php
index 4de437dcb..0f09b2d26 100644
--- a/system/src/Grav/Common/Data/Data.php
+++ b/system/src/Grav/Common/Data/Data.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Data
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -335,6 +335,7 @@ class Data implements DataInterface, ArrayAccess, \Countable, JsonSerializable,
/**
* @return array
*/
+ #[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->items;
diff --git a/system/src/Grav/Common/Data/DataInterface.php b/system/src/Grav/Common/Data/DataInterface.php
index b4452bb85..a4bc2140d 100644
--- a/system/src/Grav/Common/Data/DataInterface.php
+++ b/system/src/Grav/Common/Data/DataInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Data
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Data/Validation.php b/system/src/Grav/Common/Data/Validation.php
index bfb40578d..569ea512a 100644
--- a/system/src/Grav/Common/Data/Validation.php
+++ b/system/src/Grav/Common/Data/Validation.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Data
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -816,7 +816,7 @@ class Validation
{
$value = static::filterArray($value, $params, $field);
- return Utils::arrayUnflattenDotNotation($value);
+ return is_array($value) ? Utils::arrayUnflattenDotNotation($value) : null;
}
/**
diff --git a/system/src/Grav/Common/Data/ValidationException.php b/system/src/Grav/Common/Data/ValidationException.php
index be6a674d7..9a3d900d1 100644
--- a/system/src/Grav/Common/Data/ValidationException.php
+++ b/system/src/Grav/Common/Data/ValidationException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Data
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Debugger.php b/system/src/Grav/Common/Debugger.php
index b8143f68b..e7b162454 100644
--- a/system/src/Grav/Common/Debugger.php
+++ b/system/src/Grav/Common/Debugger.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -856,6 +856,10 @@ class Debugger
$scope = 'grav';
} elseif (strpos($errfile, '/twig/') !== false) {
$scope = 'twig';
+ // TODO: remove when upgrading to Twig 2+
+ if (str_contains($errstr, '#[\ReturnTypeWillChange]') || str_contains($errstr, 'Passing null to parameter')) {
+ return true;
+ }
} elseif (stripos($errfile, '/yaml/') !== false) {
$scope = 'yaml';
} elseif (strpos($errfile, '/vendor/') !== false) {
diff --git a/system/src/Grav/Common/Errors/BareHandler.php b/system/src/Grav/Common/Errors/BareHandler.php
index 206b57e85..909382717 100644
--- a/system/src/Grav/Common/Errors/BareHandler.php
+++ b/system/src/Grav/Common/Errors/BareHandler.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Errors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Errors/Errors.php b/system/src/Grav/Common/Errors/Errors.php
index 3dc99c665..92f885bfd 100644
--- a/system/src/Grav/Common/Errors/Errors.php
+++ b/system/src/Grav/Common/Errors/Errors.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Errors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Errors/SimplePageHandler.php b/system/src/Grav/Common/Errors/SimplePageHandler.php
index 0118929aa..80c4f9676 100644
--- a/system/src/Grav/Common/Errors/SimplePageHandler.php
+++ b/system/src/Grav/Common/Errors/SimplePageHandler.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Errors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Errors/SystemFacade.php b/system/src/Grav/Common/Errors/SystemFacade.php
index 8a7f1ceb2..edf2b5338 100644
--- a/system/src/Grav/Common/Errors/SystemFacade.php
+++ b/system/src/Grav/Common/Errors/SystemFacade.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Errors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/File/CompiledFile.php b/system/src/Grav/Common/File/CompiledFile.php
index 66fa6201d..e55a4a5d8 100644
--- a/system/src/Grav/Common/File/CompiledFile.php
+++ b/system/src/Grav/Common/File/CompiledFile.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/File/CompiledJsonFile.php b/system/src/Grav/Common/File/CompiledJsonFile.php
index dae95baaa..e8347bb07 100644
--- a/system/src/Grav/Common/File/CompiledJsonFile.php
+++ b/system/src/Grav/Common/File/CompiledJsonFile.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/File/CompiledMarkdownFile.php b/system/src/Grav/Common/File/CompiledMarkdownFile.php
index 1107417db..108311177 100644
--- a/system/src/Grav/Common/File/CompiledMarkdownFile.php
+++ b/system/src/Grav/Common/File/CompiledMarkdownFile.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/File/CompiledYamlFile.php b/system/src/Grav/Common/File/CompiledYamlFile.php
index 0fedeb717..0f0c64fd6 100644
--- a/system/src/Grav/Common/File/CompiledYamlFile.php
+++ b/system/src/Grav/Common/File/CompiledYamlFile.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Filesystem/Archiver.php b/system/src/Grav/Common/Filesystem/Archiver.php
index 090bc13fa..4c291a569 100644
--- a/system/src/Grav/Common/Filesystem/Archiver.php
+++ b/system/src/Grav/Common/Filesystem/Archiver.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Filesystem
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Filesystem/Folder.php b/system/src/Grav/Common/Filesystem/Folder.php
index ecbc6ceac..8dac2e578 100644
--- a/system/src/Grav/Common/Filesystem/Folder.php
+++ b/system/src/Grav/Common/Filesystem/Folder.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Filesystem
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -513,7 +513,7 @@ abstract class Folder
}
$directories = glob($directory . '/*', GLOB_ONLYDIR);
- return count($directories);
+ return $directories ? count($directories) : false;
}
/**
@@ -530,7 +530,8 @@ abstract class Folder
}
// Go through all items in filesystem and recursively remove everything.
- $files = array_diff(scandir($folder, SCANDIR_SORT_NONE), array('.', '..'));
+ $files = scandir($folder, SCANDIR_SORT_NONE);
+ $files = $files ? array_diff($files, ['.', '..']) : [];
foreach ($files as $file) {
$path = "{$folder}/{$file}";
is_dir($path) ? self::doDelete($path) : @unlink($path);
diff --git a/system/src/Grav/Common/Filesystem/RecursiveDirectoryFilterIterator.php b/system/src/Grav/Common/Filesystem/RecursiveDirectoryFilterIterator.php
index 0dac81c18..75c19bcc0 100644
--- a/system/src/Grav/Common/Filesystem/RecursiveDirectoryFilterIterator.php
+++ b/system/src/Grav/Common/Filesystem/RecursiveDirectoryFilterIterator.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Filesystem
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Filesystem/RecursiveFolderFilterIterator.php b/system/src/Grav/Common/Filesystem/RecursiveFolderFilterIterator.php
index ded0259cc..12d6c6b0f 100644
--- a/system/src/Grav/Common/Filesystem/RecursiveFolderFilterIterator.php
+++ b/system/src/Grav/Common/Filesystem/RecursiveFolderFilterIterator.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Filesystem
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Filesystem/ZipArchiver.php b/system/src/Grav/Common/Filesystem/ZipArchiver.php
index 6e53e70a3..4f2a9eed6 100644
--- a/system/src/Grav/Common/Filesystem/ZipArchiver.php
+++ b/system/src/Grav/Common/Filesystem/ZipArchiver.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Filesystem
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/FlexCollection.php b/system/src/Grav/Common/Flex/FlexCollection.php
index 6429c9e1e..704e21f5e 100644
--- a/system/src/Grav/Common/Flex/FlexCollection.php
+++ b/system/src/Grav/Common/Flex/FlexCollection.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/FlexIndex.php b/system/src/Grav/Common/Flex/FlexIndex.php
index 44b6fdd6e..f903c88b2 100644
--- a/system/src/Grav/Common/Flex/FlexIndex.php
+++ b/system/src/Grav/Common/Flex/FlexIndex.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/FlexObject.php b/system/src/Grav/Common/Flex/FlexObject.php
index b64aea1df..887d7a3f2 100644
--- a/system/src/Grav/Common/Flex/FlexObject.php
+++ b/system/src/Grav/Common/Flex/FlexObject.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Traits/FlexCollectionTrait.php b/system/src/Grav/Common/Flex/Traits/FlexCollectionTrait.php
index 29b640e75..b919b40c3 100644
--- a/system/src/Grav/Common/Flex/Traits/FlexCollectionTrait.php
+++ b/system/src/Grav/Common/Flex/Traits/FlexCollectionTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Traits/FlexCommonTrait.php b/system/src/Grav/Common/Flex/Traits/FlexCommonTrait.php
index 1077e0089..9291a4257 100644
--- a/system/src/Grav/Common/Flex/Traits/FlexCommonTrait.php
+++ b/system/src/Grav/Common/Flex/Traits/FlexCommonTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Traits/FlexGravTrait.php b/system/src/Grav/Common/Flex/Traits/FlexGravTrait.php
index 9d5c9e081..c34b89da9 100644
--- a/system/src/Grav/Common/Flex/Traits/FlexGravTrait.php
+++ b/system/src/Grav/Common/Flex/Traits/FlexGravTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Traits/FlexIndexTrait.php b/system/src/Grav/Common/Flex/Traits/FlexIndexTrait.php
index 1d0ee5cc6..a71eb991d 100644
--- a/system/src/Grav/Common/Flex/Traits/FlexIndexTrait.php
+++ b/system/src/Grav/Common/Flex/Traits/FlexIndexTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Traits/FlexObjectTrait.php b/system/src/Grav/Common/Flex/Traits/FlexObjectTrait.php
index 1175a3b47..3c81f07e8 100644
--- a/system/src/Grav/Common/Flex/Traits/FlexObjectTrait.php
+++ b/system/src/Grav/Common/Flex/Traits/FlexObjectTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Generic/GenericCollection.php b/system/src/Grav/Common/Flex/Types/Generic/GenericCollection.php
index 6b2fbc1e6..e4ec3d459 100644
--- a/system/src/Grav/Common/Flex/Types/Generic/GenericCollection.php
+++ b/system/src/Grav/Common/Flex/Types/Generic/GenericCollection.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Generic/GenericIndex.php b/system/src/Grav/Common/Flex/Types/Generic/GenericIndex.php
index 81dbf9544..fdba5039c 100644
--- a/system/src/Grav/Common/Flex/Types/Generic/GenericIndex.php
+++ b/system/src/Grav/Common/Flex/Types/Generic/GenericIndex.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Generic/GenericObject.php b/system/src/Grav/Common/Flex/Types/Generic/GenericObject.php
index 4a5675287..eba642be9 100644
--- a/system/src/Grav/Common/Flex/Types/Generic/GenericObject.php
+++ b/system/src/Grav/Common/Flex/Types/Generic/GenericObject.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php b/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php
index 7503653b8..c23a6e954 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -34,7 +34,9 @@ use function is_string;
* Class GravPageCollection
* @package Grav\Plugin\FlexObjects\Types\GravPages
*
- * @extends FlexPageCollection
+ * @template T as PageObject
+ * @extends FlexPageCollection
+ * @implements PageCollectionInterface
*
* Incompatibilities with Grav\Common\Page\Collection:
* $page = $collection->key() will not work at all
@@ -46,10 +48,6 @@ use function is_string;
* $collection->prev() does not rewind the internal pointer
* AND most methods are immutable; they do not update the current collection, but return updated one
*
- * @method static shuffle()
- * @method static select(array $keys)
- * @method static unselect(array $keys)
- * @method static createFrom(array $elements, string $keyField = null)
* @method PageIndex getIndex()
*/
class PageCollection extends FlexPageCollection implements PageCollectionInterface
@@ -108,13 +106,11 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
}
/**
- * @return PageObject
+ * @return PageInterface
*/
public function getRoot()
{
- $index = $this->getIndex();
-
- return $index->getRoot();
+ return $this->getIndex()->getRoot();
}
/**
@@ -154,7 +150,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* Add a single page to a collection
*
* @param PageInterface $page
- * @return static
+ * @return $this
*/
public function addPage(PageInterface $page)
{
@@ -174,6 +170,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
*
* @param PageCollectionInterface $collection
* @return static
+ * @phpstan-return static
*/
public function merge(PageCollectionInterface $collection)
{
@@ -185,6 +182,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
*
* @param PageCollectionInterface $collection
* @return static
+ * @phpstan-return static
*/
public function intersect(PageCollectionInterface $collection)
{
@@ -203,7 +201,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* Return previous item.
*
* @return PageInterface|false
- * @phpstan-return PageObject|false
+ * @phpstan-return T|false
*/
public function prev()
{
@@ -218,7 +216,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* Return nth item.
* @param int $key
* @return PageInterface|bool
- * @phpstan-return PageObject|false
+ * @phpstan-return T|false
*/
public function nth($key)
{
@@ -230,6 +228,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
*
* @param int $num Specifies how many entries should be picked.
* @return static
+ * @phpstan-return static
*/
public function random($num = 1)
{
@@ -241,6 +240,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
*
* @param array $items Items to be appended. Existing keys will be overridden with the new values.
* @return static
+ * @phpstan-return static
*/
public function append($items)
{
@@ -252,6 +252,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
*
* @param int $size
* @return static[]
+ * @phpstan-return static[]
*/
public function batch($size): array
{
@@ -273,6 +274,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* @param array|null $manual
* @param int|null $sort_flags
* @return static
+ * @phpstan-return static
*/
public function order($by, $dir = 'asc', $manual = null, $sort_flags = null)
{
@@ -441,6 +443,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* @param string|null $endDate
* @param string|null $field
* @return static
+ * @phpstan-return static
* @throws Exception
*/
public function dateRange($startDate = null, $endDate = null, $field = null)
@@ -468,6 +471,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* Creates new collection with only visible pages
*
* @return static The collection with only visible pages
+ * @phpstan-return static
*/
public function visible()
{
@@ -485,6 +489,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* Creates new collection with only non-visible pages
*
* @return static The collection with only non-visible pages
+ * @phpstan-return static
*/
public function nonVisible()
{
@@ -502,6 +507,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* Creates new collection with only pages
*
* @return static The collection with only pages
+ * @phpstan-return static
*/
public function pages()
{
@@ -523,6 +529,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* Creates new collection with only modules
*
* @return static The collection with only modules
+ * @phpstan-return static
*/
public function modules()
{
@@ -544,6 +551,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* Alias of modules()
*
* @return static
+ * @phpstan-return static
*/
public function modular()
{
@@ -554,6 +562,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* Alias of pages()
*
* @return static
+ * @phpstan-return static
*/
public function nonModular()
{
@@ -564,6 +573,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* Creates new collection with only published pages
*
* @return static The collection with only published pages
+ * @phpstan-return static
*/
public function published()
{
@@ -581,6 +591,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* Creates new collection with only non-published pages
*
* @return static The collection with only non-published pages
+ * @phpstan-return static
*/
public function nonPublished()
{
@@ -598,6 +609,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* Creates new collection with only routable pages
*
* @return static The collection with only routable pages
+ * @phpstan-return static
*/
public function routable()
{
@@ -615,6 +627,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* Creates new collection with only non-routable pages
*
* @return static The collection with only non-routable pages
+ * @phpstan-return static
*/
public function nonRoutable()
{
@@ -633,6 +646,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
*
* @param string $type
* @return static The collection
+ * @phpstan-return static
*/
public function ofType($type)
{
@@ -651,6 +665,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
*
* @param string[] $types
* @return static The collection
+ * @phpstan-return static
*/
public function ofOneOfTheseTypes($types)
{
@@ -669,6 +684,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
*
* @param array $accessLevels
* @return static The collection
+ * @phpstan-return static
*/
public function ofOneOfTheseAccessLevels($accessLevels)
{
@@ -710,6 +726,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
/**
* @param bool $bool
* @return static
+ * @phpstan-return static
*/
public function withOrdered(bool $bool = true)
{
@@ -721,6 +738,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
/**
* @param bool $bool
* @return static
+ * @phpstan-return static
*/
public function withModules(bool $bool = true)
{
@@ -732,6 +750,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
/**
* @param bool $bool
* @return static
+ * @phpstan-return static
*/
public function withPages(bool $bool = true)
{
@@ -745,6 +764,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* @param string|null $languageCode
* @param bool|null $fallback
* @return static
+ * @phpstan-return static
*/
public function withTranslation(bool $bool = true, string $languageCode = null, bool $fallback = null)
{
@@ -778,6 +798,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* @param array $filters
* @param bool $recursive
* @return static
+ * @phpstan-return static
*/
public function filterBy(array $filters, bool $recursive = false)
{
diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php b/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php
index 5a7d773a4..25440a96a 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -39,7 +39,10 @@ use function is_string;
* Class GravPageObject
* @package Grav\Plugin\FlexObjects\Types\GravPages
*
- * @extends FlexPageIndex
+ * @template T of PageObject
+ * @template C of PageCollection
+ * @extends FlexPageIndex
+ * @implements PageCollectionInterface
*
* @method PageIndex withModules(bool $bool = true)
* @method PageIndex withPages(bool $bool = true)
@@ -101,6 +104,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
/**
* @param string $key
* @return PageObject|null
+ * @phpstan-return T|null
*/
public function get($key)
{
@@ -117,11 +121,13 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
$element = $element->getTranslation(ltrim($params, '.'));
}
+ \assert(null === $element || $element instanceof PageObject);
+
return $element;
}
/**
- * @return PageObject
+ * @return PageInterface
*/
public function getRoot()
{
@@ -172,7 +178,8 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
/**
* @param string|null $languageCode
* @param bool|null $fallback
- * @return PageIndex
+ * @return static
+ * @phpstan-return static
*/
public function withTranslated(string $languageCode = null, bool $fallback = null)
{
@@ -276,6 +283,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* @param array $filters
* @param bool $recursive
* @return static
+ * @phpstan-return static
*/
public function filterBy(array $filters, bool $recursive = false)
{
@@ -332,6 +340,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
/**
* @param array $filters
* @return static
+ * @phpstan-return static
*/
protected function filterByParent(array $filters)
{
@@ -402,6 +411,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* @param array $entries
* @param string|null $keyField
* @return static
+ * @phpstan-return static
*/
protected function createFrom(array $entries, string $keyField = null)
{
@@ -787,6 +797,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
*
* @param PageInterface $page
* @return PageCollection
+ * @phpstan-return C
*/
public function addPage(PageInterface $page)
{
@@ -798,6 +809,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* Create a copy of this collection
*
* @return static
+ * @phpstan-return static
*/
public function copy()
{
@@ -810,6 +822,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
*
* @param PageCollectionInterface $collection
* @return PageCollection
+ * @phpstan-return C
*/
public function merge(PageCollectionInterface $collection)
{
@@ -822,6 +835,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
*
* @param PageCollectionInterface $collection
* @return PageCollection
+ * @phpstan-return C
*/
public function intersect(PageCollectionInterface $collection)
{
@@ -833,6 +847,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
*
* @param int $size
* @return PageCollection[]
+ * @phpstan-return C[]
*/
public function batch($size)
{
@@ -844,6 +859,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
*
* @param string $key
* @return PageObject|null
+ * @phpstan-return T|null
* @throws InvalidArgumentException
*/
public function remove($key)
@@ -859,6 +875,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* @param array $manual
* @param string $sort_flags
* @return static
+ * @phpstan-return static
*/
public function order($by, $dir = 'asc', $manual = null, $sort_flags = null)
{
@@ -902,6 +919,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
*
* @param string $path
* @return PageObject|null The previous item.
+ * @phpstan-return T|null
*/
public function prevSibling($path)
{
@@ -916,6 +934,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
*
* @param string $path
* @return PageObject|null The next item.
+ * @phpstan-return T|null
*/
public function nextSibling($path)
{
@@ -931,6 +950,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* @param string $path
* @param int $direction either -1 or +1
* @return PageObject|false The sibling item.
+ * @phpstan-return T|false
*/
public function adjacentSibling($path, $direction = 1)
{
@@ -964,6 +984,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* @param string|null $endDate
* @param string|null $field
* @return static
+ * @phpstan-return static
* @throws Exception
*/
public function dateRange($startDate = null, $endDate = null, $field = null)
@@ -988,6 +1009,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* Creates new collection with only visible pages
*
* @return static The collection with only visible pages
+ * @phpstan-return static
*/
public function visible()
{
@@ -1000,6 +1022,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* Creates new collection with only non-visible pages
*
* @return static The collection with only non-visible pages
+ * @phpstan-return static
*/
public function nonVisible()
{
@@ -1012,6 +1035,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* Creates new collection with only non-modular pages
*
* @return static The collection with only non-modular pages
+ * @phpstan-return static
*/
public function pages()
{
@@ -1024,6 +1048,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* Creates new collection with only modular pages
*
* @return static The collection with only modular pages
+ * @phpstan-return static
*/
public function modules()
{
@@ -1036,6 +1061,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* Creates new collection with only modular pages
*
* @return static The collection with only modular pages
+ * @phpstan-return static
*/
public function modular()
{
@@ -1046,6 +1072,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* Creates new collection with only non-modular pages
*
* @return static The collection with only non-modular pages
+ * @phpstan-return static
*/
public function nonModular()
{
@@ -1056,6 +1083,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* Creates new collection with only published pages
*
* @return static The collection with only published pages
+ * @phpstan-return static
*/
public function published()
{
@@ -1068,6 +1096,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* Creates new collection with only non-published pages
*
* @return static The collection with only non-published pages
+ * @phpstan-return static
*/
public function nonPublished()
{
@@ -1080,6 +1109,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* Creates new collection with only routable pages
*
* @return static The collection with only routable pages
+ * @phpstan-return static
*/
public function routable()
{
@@ -1092,6 +1122,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* Creates new collection with only non-routable pages
*
* @return static The collection with only non-routable pages
+ * @phpstan-return static
*/
public function nonRoutable()
{
@@ -1105,6 +1136,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
*
* @param string $type
* @return static The collection
+ * @phpstan-return static
*/
public function ofType($type)
{
@@ -1118,6 +1150,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
*
* @param string[] $types
* @return static The collection
+ * @phpstan-return static
*/
public function ofOneOfTheseTypes($types)
{
@@ -1131,6 +1164,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
*
* @param array $accessLevels
* @return static The collection
+ * @phpstan-return static
*/
public function ofOneOfTheseAccessLevels($accessLevels)
{
diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageObject.php b/system/src/Grav/Common/Flex/Types/Pages/PageObject.php
index 4c83f959b..fed11b437 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/PageObject.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/PageObject.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -25,9 +25,9 @@ use Grav\Common\Page\Pages;
use Grav\Common\User\Interfaces\UserInterface;
use Grav\Common\Utils;
use Grav\Framework\Filesystem\Filesystem;
-use Grav\Framework\Flex\FlexObject;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
use Grav\Framework\Flex\Pages\FlexPageObject;
+use Grav\Framework\Object\ObjectCollection;
use Grav\Framework\Route\Route;
use Grav\Framework\Route\RouteFactory;
use Grav\Plugin\Admin\Admin;
@@ -93,11 +93,6 @@ class PageObject extends FlexPageObject
}
}
- public function translated(): bool
- {
- return $this->translatedLanguages(true) ? true : false;
- }
-
/**
* @param string|array $query
* @return Route|null
@@ -282,7 +277,7 @@ class PageObject extends FlexPageObject
/**
* @param array|bool $reorder
- * @return FlexObject|FlexObjectInterface
+ * @return static
*/
public function save($reorder = true)
{
@@ -317,7 +312,7 @@ class PageObject extends FlexPageObject
}
/**
- * @return PageObject
+ * @return static
*/
public function delete()
{
@@ -391,6 +386,7 @@ class PageObject extends FlexPageObject
/**
* @param array $ordering
* @return PageCollection|null
+ * @phpstan-return ObjectCollection|null
*/
protected function reorderSiblings(array $ordering)
{
@@ -466,7 +462,9 @@ class PageObject extends FlexPageObject
if ($isMoved && $this->order() !== false) {
$parentKey = $this->getProperty('parent_key');
if ($parentKey === '') {
- $newParent = $this->getFlexDirectory()->getIndex()->getRoot();
+ /** @var PageIndex $index */
+ $index = $this->getFlexDirectory()->getIndex();
+ $newParent = $index->getRoot();
} else {
$newParent = $this->getFlexDirectory()->getObject($parentKey, 'storage_key');
if (!$newParent instanceof PageInterface) {
diff --git a/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php b/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php
index ba7fa067e..613b1ec73 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageContentTrait.php b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageContentTrait.php
index 1bde7b003..9a2c7c338 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageContentTrait.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageContentTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageLegacyTrait.php b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageLegacyTrait.php
index 589ea881a..98f394924 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageLegacyTrait.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageLegacyTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageRoutableTrait.php b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageRoutableTrait.php
index 3b490a596..ace74dc38 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageRoutableTrait.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageRoutableTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageTranslateTrait.php b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageTranslateTrait.php
index dff42c95b..a30ae1a3e 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageTranslateTrait.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageTranslateTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupCollection.php b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupCollection.php
index 93abbf886..3a91d77cc 100644
--- a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupCollection.php
+++ b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupCollection.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -27,7 +27,7 @@ class UserGroupCollection extends FlexCollection
public static function getCachedMethods(): array
{
return [
- 'authorize' => 'session',
+ 'authorize' => false,
] + parent::getCachedMethods();
}
diff --git a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupIndex.php b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupIndex.php
index 4bee5ac3d..66de52e73 100644
--- a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupIndex.php
+++ b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupIndex.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupObject.php b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupObject.php
index ea68fa1bf..4a59d520a 100644
--- a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupObject.php
+++ b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupObject.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -37,7 +37,7 @@ class UserGroupObject extends FlexObject implements UserGroupInterface
public static function getCachedMethods(): array
{
return [
- 'authorize' => 'session',
+ 'authorize' => false,
] + parent::getCachedMethods();
}
diff --git a/system/src/Grav/Common/Flex/Types/Users/Storage/UserFileStorage.php b/system/src/Grav/Common/Flex/Types/Users/Storage/UserFileStorage.php
index f565c9f17..664f24faa 100644
--- a/system/src/Grav/Common/Flex/Types/Users/Storage/UserFileStorage.php
+++ b/system/src/Grav/Common/Flex/Types/Users/Storage/UserFileStorage.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Users/Storage/UserFolderStorage.php b/system/src/Grav/Common/Flex/Types/Users/Storage/UserFolderStorage.php
index 7d9924e0d..a037f0ef7 100644
--- a/system/src/Grav/Common/Flex/Types/Users/Storage/UserFolderStorage.php
+++ b/system/src/Grav/Common/Flex/Types/Users/Storage/UserFolderStorage.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Users/Traits/UserObjectLegacyTrait.php b/system/src/Grav/Common/Flex/Types/Users/Traits/UserObjectLegacyTrait.php
index b0fc0c4ca..07acf66a5 100644
--- a/system/src/Grav/Common/Flex/Types/Users/Traits/UserObjectLegacyTrait.php
+++ b/system/src/Grav/Common/Flex/Types/Users/Traits/UserObjectLegacyTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -84,6 +84,7 @@ trait UserObjectLegacyTrait
* @return int
* @deprecated 1.6 Method makes no sense for user account.
*/
+ #[\ReturnTypeWillChange]
public function count()
{
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6', E_USER_DEPRECATED);
diff --git a/system/src/Grav/Common/Flex/Types/Users/UserCollection.php b/system/src/Grav/Common/Flex/Types/Users/UserCollection.php
index 9b6490a8a..f5641e732 100644
--- a/system/src/Grav/Common/Flex/Types/Users/UserCollection.php
+++ b/system/src/Grav/Common/Flex/Types/Users/UserCollection.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Users/UserIndex.php b/system/src/Grav/Common/Flex/Types/Users/UserIndex.php
index 6e0bc65fe..4a33b7304 100644
--- a/system/src/Grav/Common/Flex/Types/Users/UserIndex.php
+++ b/system/src/Grav/Common/Flex/Types/Users/UserIndex.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -164,7 +164,7 @@ class UserIndex extends FlexIndex implements UserCollectionInterface
*/
protected static function filterUsername(string $key, FlexStorageInterface $storage): string
{
- return $storage->normalizeKey($key);
+ return method_exists($storage, 'normalizeKey') ? $storage->normalizeKey($key) : $key;
}
/**
diff --git a/system/src/Grav/Common/Flex/Types/Users/UserObject.php b/system/src/Grav/Common/Flex/Types/Users/UserObject.php
index 424e5ebef..434a4a828 100644
--- a/system/src/Grav/Common/Flex/Types/Users/UserObject.php
+++ b/system/src/Grav/Common/Flex/Types/Users/UserObject.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -79,6 +79,8 @@ class UserObject extends FlexObject implements UserInterface, Countable
/** @var Closure|null */
static public $authorizeCallable;
+ /** @var Closure|null */
+ static public $isAuthorizedCallable;
/** @var array|null */
protected $_uploads_original;
@@ -123,7 +125,8 @@ class UserObject extends FlexObject implements UserInterface, Countable
// Define username if it's not set.
if (!isset($elements['username'])) {
$storageKey = $elements['__META']['storage_key'] ?? null;
- if (null !== $storageKey && $key === $directory->getStorage()->normalizeKey($storageKey)) {
+ $storage = $directory->getStorage();
+ if (null !== $storageKey && method_exists($storage, 'normalizeKey') && $key === $storage->normalizeKey($storageKey)) {
$elements['username'] = $storageKey;
} else {
$elements['username'] = $key;
@@ -138,6 +141,14 @@ class UserObject extends FlexObject implements UserInterface, Countable
parent::__construct($elements, $key, $directory, $validate);
}
+ public function __clone()
+ {
+ $this->_access = null;
+ $this->_groups = null;
+
+ parent::__clone();
+ }
+
/**
* @return void
*/
@@ -231,13 +242,19 @@ class UserObject extends FlexObject implements UserInterface, Countable
}
/**
+ * @param UserInterface|null $user
* @return bool
*/
- public function isMyself(): bool
+ public function isMyself(?UserInterface $user = null): bool
{
- $me = $this->getActiveUser();
+ if (null === $user) {
+ $user = $this->getActiveUser();
+ if ($user && !$user->authenticated) {
+ $user = null;
+ }
+ }
- return $me && $me->authenticated && $this->username === $me->username;
+ return $user && $this->username === $user->username;
}
/**
@@ -277,8 +294,8 @@ class UserObject extends FlexObject implements UserInterface, Countable
// Check custom application access.
$authorizeCallable = static::$authorizeCallable;
if ($authorizeCallable instanceof Closure) {
- $authorizeCallable->bindTo($this);
- $authorized = $authorizeCallable($action, $scope);
+ $callable = $authorizeCallable->bindTo($this, $this);
+ $authorized = $callable($action, $scope);
if (is_bool($authorized)) {
return $authorized;
}
@@ -683,6 +700,16 @@ class UserObject extends FlexObject implements UserInterface, Countable
*/
protected function isAuthorizedOverride(UserInterface $user, string $action, string $scope, bool $isMe = false): ?bool
{
+ // Check custom application access.
+ $isAuthorizedCallable = static::$isAuthorizedCallable;
+ if ($isAuthorizedCallable instanceof Closure) {
+ $callable = $isAuthorizedCallable->bindTo($this, $this);
+ $authorized = $callable($user, $action, $scope, $isMe);
+ if (is_bool($authorized)) {
+ return $authorized;
+ }
+ }
+
if ($user instanceof self && $user->getStorageKey() === $this->getStorageKey()) {
// User cannot delete his own account, otherwise he has full access.
return $action !== 'delete';
@@ -898,7 +925,9 @@ class UserObject extends FlexObject implements UserInterface, Countable
protected function getGroups()
{
if (null === $this->_groups) {
- $this->_groups = $this->getUserGroups()->select((array)$this->getProperty('groups'));
+ /** @var UserGroupIndex $groups */
+ $groups = $this->getUserGroups()->select((array)$this->getProperty('groups'));
+ $this->_groups = $groups;
}
return $this->_groups;
diff --git a/system/src/Grav/Common/Form/FormFlash.php b/system/src/Grav/Common/Form/FormFlash.php
index 430f15e09..b2c619e1c 100644
--- a/system/src/Grav/Common/Form/FormFlash.php
+++ b/system/src/Grav/Common/Form/FormFlash.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Form
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/AbstractCollection.php b/system/src/Grav/Common/GPM/AbstractCollection.php
index b5b867ef7..91fa69eb4 100644
--- a/system/src/Grav/Common/GPM/AbstractCollection.php
+++ b/system/src/Grav/Common/GPM/AbstractCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Common/AbstractPackageCollection.php b/system/src/Grav/Common/GPM/Common/AbstractPackageCollection.php
index 5d6ad9fb8..7b918e0ef 100644
--- a/system/src/Grav/Common/GPM/Common/AbstractPackageCollection.php
+++ b/system/src/Grav/Common/GPM/Common/AbstractPackageCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Common/CachedCollection.php b/system/src/Grav/Common/GPM/Common/CachedCollection.php
index 172ba939f..c3b62e5cd 100644
--- a/system/src/Grav/Common/GPM/Common/CachedCollection.php
+++ b/system/src/Grav/Common/GPM/Common/CachedCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Common/Package.php b/system/src/Grav/Common/GPM/Common/Package.php
index e06ebb60d..5d960117c 100644
--- a/system/src/Grav/Common/GPM/Common/Package.php
+++ b/system/src/Grav/Common/GPM/Common/Package.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -45,6 +45,7 @@ class Package
* @param string $key
* @return mixed
*/
+ #[\ReturnTypeWillChange]
public function __get($key)
{
return $this->data->get($key);
@@ -55,6 +56,7 @@ class Package
* @param mixed $value
* @return void
*/
+ #[\ReturnTypeWillChange]
public function __set($key, $value)
{
$this->data->set($key, $value);
@@ -64,6 +66,7 @@ class Package
* @param string $key
* @return bool
*/
+ #[\ReturnTypeWillChange]
public function __isset($key)
{
return isset($this->data->{$key});
@@ -72,6 +75,7 @@ class Package
/**
* @return string
*/
+ #[\ReturnTypeWillChange]
public function __toString()
{
return $this->toJson();
diff --git a/system/src/Grav/Common/GPM/GPM.php b/system/src/Grav/Common/GPM/GPM.php
index 450569632..2b18255fa 100644
--- a/system/src/Grav/Common/GPM/GPM.php
+++ b/system/src/Grav/Common/GPM/GPM.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -74,6 +74,7 @@ class GPM extends Iterator
* @param string $offset Asset name value
* @return mixed Asset value
*/
+ #[\ReturnTypeWillChange]
public function __get($offset)
{
switch ($offset) {
@@ -90,6 +91,7 @@ class GPM extends Iterator
* @param string $offset Asset name value
* @return bool True if the value is set
*/
+ #[\ReturnTypeWillChange]
public function __isset($offset)
{
switch ($offset) {
diff --git a/system/src/Grav/Common/GPM/Installer.php b/system/src/Grav/Common/GPM/Installer.php
index 639240be6..1eed5b4de 100644
--- a/system/src/Grav/Common/GPM/Installer.php
+++ b/system/src/Grav/Common/GPM/Installer.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Licenses.php b/system/src/Grav/Common/GPM/Licenses.php
index 825343dd8..e932bd4f7 100644
--- a/system/src/Grav/Common/GPM/Licenses.php
+++ b/system/src/Grav/Common/GPM/Licenses.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Local/AbstractPackageCollection.php b/system/src/Grav/Common/GPM/Local/AbstractPackageCollection.php
index d1f3e4671..bc7ceab5e 100644
--- a/system/src/Grav/Common/GPM/Local/AbstractPackageCollection.php
+++ b/system/src/Grav/Common/GPM/Local/AbstractPackageCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Local/Package.php b/system/src/Grav/Common/GPM/Local/Package.php
index ffe2c63cc..08444a76d 100644
--- a/system/src/Grav/Common/GPM/Local/Package.php
+++ b/system/src/Grav/Common/GPM/Local/Package.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Local/Packages.php b/system/src/Grav/Common/GPM/Local/Packages.php
index 0290296c4..b63b93b54 100644
--- a/system/src/Grav/Common/GPM/Local/Packages.php
+++ b/system/src/Grav/Common/GPM/Local/Packages.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Local/Plugins.php b/system/src/Grav/Common/GPM/Local/Plugins.php
index 8a6574b58..a1626f8ba 100644
--- a/system/src/Grav/Common/GPM/Local/Plugins.php
+++ b/system/src/Grav/Common/GPM/Local/Plugins.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Local/Themes.php b/system/src/Grav/Common/GPM/Local/Themes.php
index 73253ccd8..d15379439 100644
--- a/system/src/Grav/Common/GPM/Local/Themes.php
+++ b/system/src/Grav/Common/GPM/Local/Themes.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Remote/AbstractPackageCollection.php b/system/src/Grav/Common/GPM/Remote/AbstractPackageCollection.php
index 9e68d6660..02e98e759 100644
--- a/system/src/Grav/Common/GPM/Remote/AbstractPackageCollection.php
+++ b/system/src/Grav/Common/GPM/Remote/AbstractPackageCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Remote/GravCore.php b/system/src/Grav/Common/GPM/Remote/GravCore.php
index f93209edd..2998975cf 100644
--- a/system/src/Grav/Common/GPM/Remote/GravCore.php
+++ b/system/src/Grav/Common/GPM/Remote/GravCore.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Remote/Package.php b/system/src/Grav/Common/GPM/Remote/Package.php
index c37d6a00d..519325551 100644
--- a/system/src/Grav/Common/GPM/Remote/Package.php
+++ b/system/src/Grav/Common/GPM/Remote/Package.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -32,6 +32,7 @@ class Package extends BasePackage implements \JsonSerializable
/**
* @return array
*/
+ #[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->data->toArray();
diff --git a/system/src/Grav/Common/GPM/Remote/Packages.php b/system/src/Grav/Common/GPM/Remote/Packages.php
index f55c12dc0..0ac2ef967 100644
--- a/system/src/Grav/Common/GPM/Remote/Packages.php
+++ b/system/src/Grav/Common/GPM/Remote/Packages.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Remote/Plugins.php b/system/src/Grav/Common/GPM/Remote/Plugins.php
index a134a104b..8383cd782 100644
--- a/system/src/Grav/Common/GPM/Remote/Plugins.php
+++ b/system/src/Grav/Common/GPM/Remote/Plugins.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Remote/Themes.php b/system/src/Grav/Common/GPM/Remote/Themes.php
index 160ac97ac..a8ee9fae2 100644
--- a/system/src/Grav/Common/GPM/Remote/Themes.php
+++ b/system/src/Grav/Common/GPM/Remote/Themes.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Upgrader.php b/system/src/Grav/Common/GPM/Upgrader.php
index dfa6eb133..b3e68696d 100644
--- a/system/src/Grav/Common/GPM/Upgrader.php
+++ b/system/src/Grav/Common/GPM/Upgrader.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Getters.php b/system/src/Grav/Common/Getters.php
index 916d5249a..ed03499d1 100644
--- a/system/src/Grav/Common/Getters.php
+++ b/system/src/Grav/Common/Getters.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -28,6 +28,7 @@ abstract class Getters implements ArrayAccess, Countable
* @param int|string $offset Medium name value
* @param mixed $value Medium value
*/
+ #[\ReturnTypeWillChange]
public function __set($offset, $value)
{
$this->offsetSet($offset, $value);
@@ -39,6 +40,7 @@ abstract class Getters implements ArrayAccess, Countable
* @param int|string $offset Medium name value
* @return mixed Medium value
*/
+ #[\ReturnTypeWillChange]
public function __get($offset)
{
return $this->offsetGet($offset);
@@ -50,6 +52,7 @@ abstract class Getters implements ArrayAccess, Countable
* @param int|string $offset Medium name value
* @return boolean True if the value is set
*/
+ #[\ReturnTypeWillChange]
public function __isset($offset)
{
return $this->offsetExists($offset);
@@ -60,6 +63,7 @@ abstract class Getters implements ArrayAccess, Countable
*
* @param int|string $offset The name value to unset
*/
+ #[\ReturnTypeWillChange]
public function __unset($offset)
{
$this->offsetUnset($offset);
@@ -129,6 +133,7 @@ abstract class Getters implements ArrayAccess, Countable
/**
* @return int
*/
+ #[\ReturnTypeWillChange]
public function count()
{
if ($this->gettersVariable) {
diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php
index 2398c116c..ca6112548 100644
--- a/system/src/Grav/Common/Grav.php
+++ b/system/src/Grav/Common/Grav.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -49,7 +49,9 @@ use Grav\Common\Twig\Twig;
use Grav\Framework\DI\Container;
use Grav\Framework\Psr7\Response;
use Grav\Framework\RequestHandler\RequestHandler;
+use Grav\Framework\Route\Route;
use Grav\Framework\Session\Messages;
+use InvalidArgumentException;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use RocketTheme\Toolbox\Event\Event;
@@ -62,6 +64,7 @@ use function get_class;
use function in_array;
use function is_callable;
use function is_int;
+use function is_string;
use function strlen;
/**
@@ -343,7 +346,7 @@ class Grav extends Container
* Please use this method instead of calling `die();` or `exit();`. Note that you need to create a response object.
*
* @param ResponseInterface $response
- * @return void
+ * @return never-return
*/
public function close(ResponseInterface $response): void
{
@@ -395,7 +398,7 @@ class Grav extends Container
/**
* @param ResponseInterface $response
- * @return void
+ * @return never-return
* @deprecated 1.7 Do not use
*/
public function exit(ResponseInterface $response): void
@@ -408,9 +411,9 @@ class Grav extends Container
*
* Please use this method instead of calling `header("Location: {$url}", true, 302); exit();`.
*
- * @param string $route Internal route.
+ * @param Route|string $route Internal route.
* @param int|null $code Redirection code (30x)
- * @return void
+ * @return never-return
*/
public function redirect($route, $code = null): void
{
@@ -422,7 +425,7 @@ class Grav extends Container
/**
* Returns redirect response object from Grav.
*
- * @param string $route Internal route.
+ * @param Route|string $route Internal route.
* @param int|null $code Redirection code (30x)
* @return ResponseInterface
*/
@@ -431,39 +434,45 @@ class Grav extends Container
/** @var Uri $uri */
$uri = $this['uri'];
- // Clean route for redirect
- $route = preg_replace("#^\/[\\\/]+\/#", '/', $route);
+ if (is_string($route)) {
+ // Clean route for redirect
+ $route = preg_replace("#^\/[\\\/]+\/#", '/', $route);
+
+ if (null === $code) {
+ // Check for redirect code in the route: e.g. /new/[301], /new[301]/route or /new[301].html
+ $regex = '/.*(\[(30[1-7])\])(.\w+|\/.*?)?$/';
+ preg_match($regex, $route, $matches);
+ if ($matches) {
+ $route = str_replace($matches[1], '', $matches[0]);
+ $code = $matches[2];
+ }
+ }
+
+ if ($uri::isExternal($route)) {
+ $url = $route;
+ } else {
+ $url = rtrim($uri->rootUrl(), '/') . '/';
+
+ if ($this['config']->get('system.pages.redirect_trailing_slash', true)) {
+ $url .= trim($route, '/'); // Remove trailing slash
+ } else {
+ $url .= ltrim($route, '/'); // Support trailing slash default routes
+ }
+ }
+ } elseif ($route instanceof Route) {
+ $url = $route->toString(true);
+ } else {
+ throw new InvalidArgumentException('Bad $route');
+ }
if ($code < 300 || $code > 399) {
$code = null;
}
- if (null === $code) {
- // Check for redirect code in the route: e.g. /new/[301], /new[301]/route or /new[301].html
- $regex = '/.*(\[(30[1-7])\])(.\w+|\/.*?)?$/';
- preg_match($regex, $route, $matches);
- if ($matches) {
- $route = str_replace($matches[1], '', $matches[0]);
- $code = $matches[2];
- }
- }
-
if ($code === null) {
$code = $this['config']->get('system.pages.redirect_default_code', 302);
}
- if ($uri::isExternal($route)) {
- $url = $route;
- } else {
- $url = rtrim($uri->rootUrl(), '/') . '/';
-
- if ($this['config']->get('system.pages.redirect_trailing_slash', true)) {
- $url .= trim($route, '/'); // Remove trailing slash
- } else {
- $url .= ltrim($route, '/'); // Support trailing slash default routes
- }
- }
-
if ($uri->extension() === 'json') {
return new Response(200, ['Content-Type' => 'application/json'], json_encode(['code' => $code, 'redirect' => $url], JSON_THROW_ON_ERROR));
}
@@ -643,6 +652,7 @@ class Grav extends Container
* @param array $args
* @return mixed|null
*/
+ #[\ReturnTypeWillChange]
public function __call($method, $args)
{
$closure = $this->{$method} ?? null;
@@ -727,7 +737,7 @@ class Grav extends Container
/** @var Config $config */
$config = $this['config'];
- $uri_extension = strtolower($uri->extension());
+ $uri_extension = strtolower($uri->extension() ?? '');
$fallback_types = $config->get('system.media.allowed_fallback_types', null);
$supported_types = $config->get('media.types');
diff --git a/system/src/Grav/Common/GravTrait.php b/system/src/Grav/Common/GravTrait.php
index 463890572..541628612 100644
--- a/system/src/Grav/Common/GravTrait.php
+++ b/system/src/Grav/Common/GravTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/HTTP/Client.php b/system/src/Grav/Common/HTTP/Client.php
index cd4f8dbb2..c85d6b295 100644
--- a/system/src/Grav/Common/HTTP/Client.php
+++ b/system/src/Grav/Common/HTTP/Client.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\HTTP
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/HTTP/Response.php b/system/src/Grav/Common/HTTP/Response.php
index 4a0513667..4a5bc8bb2 100644
--- a/system/src/Grav/Common/HTTP/Response.php
+++ b/system/src/Grav/Common/HTTP/Response.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\HTTP
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Helpers/Base32.php b/system/src/Grav/Common/Helpers/Base32.php
index 825c1eca3..0d1c21ae0 100644
--- a/system/src/Grav/Common/Helpers/Base32.php
+++ b/system/src/Grav/Common/Helpers/Base32.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Helpers
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Helpers/Excerpts.php b/system/src/Grav/Common/Helpers/Excerpts.php
index 173850a53..a62c7e5f4 100644
--- a/system/src/Grav/Common/Helpers/Excerpts.php
+++ b/system/src/Grav/Common/Helpers/Excerpts.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Helpers
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Helpers/Exif.php b/system/src/Grav/Common/Helpers/Exif.php
index 36e391fe7..a7dc97330 100644
--- a/system/src/Grav/Common/Helpers/Exif.php
+++ b/system/src/Grav/Common/Helpers/Exif.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Helpers
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Helpers/LogViewer.php b/system/src/Grav/Common/Helpers/LogViewer.php
index 187828ae3..cf5ffe9af 100644
--- a/system/src/Grav/Common/Helpers/LogViewer.php
+++ b/system/src/Grav/Common/Helpers/LogViewer.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Helpers
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -145,7 +145,7 @@ class LogViewer
'logger' => $data['logger'],
'level' => $data['level'],
'message' => $data['message'],
- 'trace' => isset($data['trace']) ? $this->parseTrace($data['trace']) : null,
+ 'trace' => isset($data['trace']) ? self::parseTrace($data['trace']) : null,
'context' => json_decode($data['context'], true),
'extra' => json_decode($data['extra'], true)
];
diff --git a/system/src/Grav/Common/Helpers/Truncator.php b/system/src/Grav/Common/Helpers/Truncator.php
index 0a701b694..03c3eeaab 100644
--- a/system/src/Grav/Common/Helpers/Truncator.php
+++ b/system/src/Grav/Common/Helpers/Truncator.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Helpers
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Helpers/YamlLinter.php b/system/src/Grav/Common/Helpers/YamlLinter.php
index 45b5144ef..71f0e873c 100644
--- a/system/src/Grav/Common/Helpers/YamlLinter.php
+++ b/system/src/Grav/Common/Helpers/YamlLinter.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Helpers
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Inflector.php b/system/src/Grav/Common/Inflector.php
index 50c218f1b..216b73350 100644
--- a/system/src/Grav/Common/Inflector.php
+++ b/system/src/Grav/Common/Inflector.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Iterator.php b/system/src/Grav/Common/Iterator.php
index 6e80b947e..5db7bd045 100644
--- a/system/src/Grav/Common/Iterator.php
+++ b/system/src/Grav/Common/Iterator.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -38,6 +38,7 @@ class Iterator implements \ArrayAccess, \Iterator, \Countable, \Serializable
* @param mixed $args
* @return mixed
*/
+ #[\ReturnTypeWillChange]
public function __call($key, $args)
{
return $this->items[$key] ?? null;
@@ -46,6 +47,7 @@ class Iterator implements \ArrayAccess, \Iterator, \Countable, \Serializable
/**
* Clone the iterator.
*/
+ #[\ReturnTypeWillChange]
public function __clone()
{
foreach ($this as $key => $value) {
@@ -60,6 +62,7 @@ class Iterator implements \ArrayAccess, \Iterator, \Countable, \Serializable
*
* @return string
*/
+ #[\ReturnTypeWillChange]
public function __toString()
{
return implode(',', $this->items);
diff --git a/system/src/Grav/Common/Language/Language.php b/system/src/Grav/Common/Language/Language.php
index 670975424..fe006ed2c 100644
--- a/system/src/Grav/Common/Language/Language.php
+++ b/system/src/Grav/Common/Language/Language.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Language
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -636,6 +636,7 @@ class Language
/**
* @return array
*/
+ #[\ReturnTypeWillChange]
public function __debugInfo()
{
$vars = get_object_vars($this);
diff --git a/system/src/Grav/Common/Language/LanguageCodes.php b/system/src/Grav/Common/Language/LanguageCodes.php
index e637bddaf..3fa494859 100644
--- a/system/src/Grav/Common/Language/LanguageCodes.php
+++ b/system/src/Grav/Common/Language/LanguageCodes.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Language
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -93,7 +93,7 @@ class LanguageCodes
'la' => [ 'name' => 'Latin', 'nativeName' => 'Latina' ],
'lb' => [ 'name' => 'Luxembourgish', 'nativeName' => 'Lëtzebuergesch' ],
'lg' => [ 'name' => 'Luganda', 'nativeName' => 'Luganda' ],
- 'lo' => [ 'name' => 'Lao', 'nativeName' => 'Lao' ],
+ 'lo' => [ 'name' => 'Lao', 'nativeName' => 'Lao' ],
'lt' => [ 'name' => 'Lithuanian', 'nativeName' => 'Lietuvių' ],
'lv' => [ 'name' => 'Latvian', 'nativeName' => 'Latviešu' ],
'mai' => [ 'name' => 'Maithili', 'nativeName' => 'मैथिली মৈথিলী' ],
@@ -103,7 +103,7 @@ class LanguageCodes
'ml' => [ 'name' => 'Malayalam', 'nativeName' => 'മലയാളം' ],
'mn' => [ 'name' => 'Mongolian', 'nativeName' => 'Монгол' ],
'mr' => [ 'name' => 'Marathi', 'nativeName' => 'मराठी' ],
- 'my' => [ 'name' => 'Myanmar (Burmese)', 'nativeName' => 'ဗမာी' ],
+ 'my' => [ 'name' => 'Myanmar (Burmese)', 'nativeName' => 'ဗမာी' ],
'no' => [ 'name' => 'Norwegian', 'nativeName' => 'Norsk' ],
'nb' => [ 'name' => 'Norwegian', 'nativeName' => 'Norsk' ],
'nb-NO' => [ 'name' => 'Norwegian (Bokmål)', 'nativeName' => 'Norsk bokmål' ],
diff --git a/system/src/Grav/Common/Markdown/Parsedown.php b/system/src/Grav/Common/Markdown/Parsedown.php
index bdc5bdcd2..f0d8a48ff 100644
--- a/system/src/Grav/Common/Markdown/Parsedown.php
+++ b/system/src/Grav/Common/Markdown/Parsedown.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Markdown
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Markdown/ParsedownExtra.php b/system/src/Grav/Common/Markdown/ParsedownExtra.php
index b8e760efd..ef450feaf 100644
--- a/system/src/Grav/Common/Markdown/ParsedownExtra.php
+++ b/system/src/Grav/Common/Markdown/ParsedownExtra.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Markdown
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php
index 7c2b0d667..a593dd749 100644
--- a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php
+++ b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Markdown
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -289,6 +289,7 @@ trait ParsedownGravTrait
* @param array $args
* @return mixed|null
*/
+ #[\ReturnTypeWillChange]
public function __call($method, $args)
{
if (isset($this->{$method}) === true) {
diff --git a/system/src/Grav/Common/Media/Interfaces/AudioMediaInterface.php b/system/src/Grav/Common/Media/Interfaces/AudioMediaInterface.php
index d9c69d281..6465d6b9c 100644
--- a/system/src/Grav/Common/Media/Interfaces/AudioMediaInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/AudioMediaInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/ImageManipulateInterface.php b/system/src/Grav/Common/Media/Interfaces/ImageManipulateInterface.php
index 702cfda9b..eb38ea83b 100644
--- a/system/src/Grav/Common/Media/Interfaces/ImageManipulateInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/ImageManipulateInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/ImageMediaInterface.php b/system/src/Grav/Common/Media/Interfaces/ImageMediaInterface.php
index 377258c9e..cbf8f1de3 100644
--- a/system/src/Grav/Common/Media/Interfaces/ImageMediaInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/ImageMediaInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/MediaCollectionInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaCollectionInterface.php
index ad9fe96c3..62c531c89 100644
--- a/system/src/Grav/Common/Media/Interfaces/MediaCollectionInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/MediaCollectionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/MediaFileInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaFileInterface.php
index 07a5c26df..c20e4de99 100644
--- a/system/src/Grav/Common/Media/Interfaces/MediaFileInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/MediaFileInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/MediaInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaInterface.php
index 436fe1681..273556a6d 100644
--- a/system/src/Grav/Common/Media/Interfaces/MediaInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/MediaInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/MediaLinkInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaLinkInterface.php
index 4f229c2b5..41747be67 100644
--- a/system/src/Grav/Common/Media/Interfaces/MediaLinkInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/MediaLinkInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/MediaObjectInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaObjectInterface.php
index 64388817a..c46dd38c7 100644
--- a/system/src/Grav/Common/Media/Interfaces/MediaObjectInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/MediaObjectInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -208,6 +208,7 @@ interface MediaObjectInterface extends \Grav\Framework\Media\Interfaces\MediaObj
* @param mixed $args
* @return $this
*/
+ #[\ReturnTypeWillChange]
public function __call($method, $args);
/**
diff --git a/system/src/Grav/Common/Media/Interfaces/MediaPlayerInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaPlayerInterface.php
index 9307915c4..fbe6f656f 100644
--- a/system/src/Grav/Common/Media/Interfaces/MediaPlayerInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/MediaPlayerInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/MediaUploadInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaUploadInterface.php
index 8bfef845e..73625999a 100644
--- a/system/src/Grav/Common/Media/Interfaces/MediaUploadInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/MediaUploadInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/VideoMediaInterface.php b/system/src/Grav/Common/Media/Interfaces/VideoMediaInterface.php
index ff0655a62..6d42feff2 100644
--- a/system/src/Grav/Common/Media/Interfaces/VideoMediaInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/VideoMediaInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/AudioMediaTrait.php b/system/src/Grav/Common/Media/Traits/AudioMediaTrait.php
index 160837dec..a0834721d 100644
--- a/system/src/Grav/Common/Media/Traits/AudioMediaTrait.php
+++ b/system/src/Grav/Common/Media/Traits/AudioMediaTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/ImageLoadingTrait.php b/system/src/Grav/Common/Media/Traits/ImageLoadingTrait.php
index c0237638e..75e23cab8 100644
--- a/system/src/Grav/Common/Media/Traits/ImageLoadingTrait.php
+++ b/system/src/Grav/Common/Media/Traits/ImageLoadingTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/ImageMediaTrait.php b/system/src/Grav/Common/Media/Traits/ImageMediaTrait.php
index f6e22224e..c1c46dc94 100644
--- a/system/src/Grav/Common/Media/Traits/ImageMediaTrait.php
+++ b/system/src/Grav/Common/Media/Traits/ImageMediaTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/MediaFileTrait.php b/system/src/Grav/Common/Media/Traits/MediaFileTrait.php
index 71981331d..63906fc4a 100644
--- a/system/src/Grav/Common/Media/Traits/MediaFileTrait.php
+++ b/system/src/Grav/Common/Media/Traits/MediaFileTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/MediaObjectTrait.php b/system/src/Grav/Common/Media/Traits/MediaObjectTrait.php
index 3c2a38baf..492b3af85 100644
--- a/system/src/Grav/Common/Media/Traits/MediaObjectTrait.php
+++ b/system/src/Grav/Common/Media/Traits/MediaObjectTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -138,6 +138,7 @@ trait MediaObjectTrait
*
* @return string
*/
+ #[\ReturnTypeWillChange]
abstract public function __toString();
/**
@@ -478,6 +479,7 @@ trait MediaObjectTrait
* @param array $args
* @return $this
*/
+ #[\ReturnTypeWillChange]
public function __call($method, $args)
{
$count = count($args);
diff --git a/system/src/Grav/Common/Media/Traits/MediaPlayerTrait.php b/system/src/Grav/Common/Media/Traits/MediaPlayerTrait.php
index 66e9f47d9..06cb99ad9 100644
--- a/system/src/Grav/Common/Media/Traits/MediaPlayerTrait.php
+++ b/system/src/Grav/Common/Media/Traits/MediaPlayerTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/MediaTrait.php b/system/src/Grav/Common/Media/Traits/MediaTrait.php
index 5faba826b..14bfa9072 100644
--- a/system/src/Grav/Common/Media/Traits/MediaTrait.php
+++ b/system/src/Grav/Common/Media/Traits/MediaTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/MediaUploadTrait.php b/system/src/Grav/Common/Media/Traits/MediaUploadTrait.php
index 7a1f55d6e..98885e06c 100644
--- a/system/src/Grav/Common/Media/Traits/MediaUploadTrait.php
+++ b/system/src/Grav/Common/Media/Traits/MediaUploadTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/StaticResizeTrait.php b/system/src/Grav/Common/Media/Traits/StaticResizeTrait.php
index 49d75be67..d8a4b0831 100644
--- a/system/src/Grav/Common/Media/Traits/StaticResizeTrait.php
+++ b/system/src/Grav/Common/Media/Traits/StaticResizeTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/ThumbnailMediaTrait.php b/system/src/Grav/Common/Media/Traits/ThumbnailMediaTrait.php
index eab732004..100b5321c 100644
--- a/system/src/Grav/Common/Media/Traits/ThumbnailMediaTrait.php
+++ b/system/src/Grav/Common/Media/Traits/ThumbnailMediaTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/VideoMediaTrait.php b/system/src/Grav/Common/Media/Traits/VideoMediaTrait.php
index e03fbbd81..b16bb53c7 100644
--- a/system/src/Grav/Common/Media/Traits/VideoMediaTrait.php
+++ b/system/src/Grav/Common/Media/Traits/VideoMediaTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Collection.php b/system/src/Grav/Common/Page/Collection.php
index 930aeda2b..987b8d931 100644
--- a/system/src/Grav/Common/Page/Collection.php
+++ b/system/src/Grav/Common/Page/Collection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -27,6 +27,7 @@ use function is_string;
/**
* Class Collection
* @package Grav\Common\Page
+ * @implements PageCollectionInterface
*/
class Collection extends Iterator implements PageCollectionInterface
{
@@ -162,6 +163,7 @@ class Collection extends Iterator implements PageCollectionInterface
*
* @return PageInterface
*/
+ #[\ReturnTypeWillChange]
public function current()
{
$current = parent::key();
@@ -174,6 +176,7 @@ class Collection extends Iterator implements PageCollectionInterface
*
* @return mixed
*/
+ #[\ReturnTypeWillChange]
public function key()
{
$current = parent::current();
diff --git a/system/src/Grav/Common/Page/Header.php b/system/src/Grav/Common/Page/Header.php
index 71c7b16c3..c18b58d37 100644
--- a/system/src/Grav/Common/Page/Header.php
+++ b/system/src/Grav/Common/Page/Header.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -30,6 +30,7 @@ class Header implements ArrayAccess, ExportInterface, JsonSerializable
/**
* @return array
*/
+ #[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->toArray();
diff --git a/system/src/Grav/Common/Page/Interfaces/PageCollectionInterface.php b/system/src/Grav/Common/Page/Interfaces/PageCollectionInterface.php
index 50029118f..493ab4398 100644
--- a/system/src/Grav/Common/Page/Interfaces/PageCollectionInterface.php
+++ b/system/src/Grav/Common/Page/Interfaces/PageCollectionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -19,6 +19,11 @@ use Traversable;
/**
* Interface PageCollectionInterface
* @package Grav\Common\Page\Interfaces
+ *
+ * @template TKey of array-key
+ * @template T
+ * @extends Traversable
+ * @extends ArrayAccess
*/
interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, Serializable
{
@@ -68,6 +73,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
*
* @param PageCollectionInterface $collection
* @return PageCollectionInterface
+ * @phpstan-return PageCollectionInterface
*/
public function merge(PageCollectionInterface $collection);
@@ -76,6 +82,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
*
* @param PageCollectionInterface $collection
* @return PageCollectionInterface
+ * @phpstan-return PageCollectionInterface
*/
public function intersect(PageCollectionInterface $collection);
@@ -84,6 +91,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
*
* @param int $size
* @return PageCollectionInterface[]
+ * @phpstan-return array>
*/
public function batch($size);
@@ -92,6 +100,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
*
* @param PageInterface|string|null $key
* @return PageCollectionInterface
+ * @phpstan-return PageCollectionInterface
* @throws InvalidArgumentException
*/
//public function remove($key = null);
@@ -104,6 +113,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
* @param array|null $manual
* @param string|null $sort_flags
* @return PageCollectionInterface
+ * @phpstan-return PageCollectionInterface
*/
public function order($by, $dir = 'asc', $manual = null, $sort_flags = null);
@@ -128,6 +138,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
*
* @param string $path
* @return PageInterface The previous item.
+ * @phpstan-return T
*/
public function prevSibling($path);
@@ -136,6 +147,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
*
* @param string $path
* @return PageInterface The next item.
+ * @phpstan-return T
*/
public function nextSibling($path);
@@ -145,6 +157,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
* @param string $path
* @param int $direction either -1 or +1
* @return PageInterface|PageCollectionInterface|false The sibling item.
+ * @phpstan-return T|false
*/
public function adjacentSibling($path, $direction = 1);
@@ -166,6 +179,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
* @param string|null $endDate
* @param string|null $field
* @return PageCollectionInterface
+ * @phpstan-return PageCollectionInterface
* @throws Exception
*/
public function dateRange($startDate = null, $endDate = null, $field = null);
@@ -174,6 +188,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
* Creates new collection with only visible pages
*
* @return PageCollectionInterface The collection with only visible pages
+ * @phpstan-return PageCollectionInterface
*/
public function visible();
@@ -181,6 +196,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
* Creates new collection with only non-visible pages
*
* @return PageCollectionInterface The collection with only non-visible pages
+ * @phpstan-return PageCollectionInterface
*/
public function nonVisible();
@@ -188,6 +204,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
* Creates new collection with only pages
*
* @return PageCollectionInterface The collection with only pages
+ * @phpstan-return PageCollectionInterface
*/
public function pages();
@@ -195,6 +212,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
* Creates new collection with only modules
*
* @return PageCollectionInterface The collection with only modules
+ * @phpstan-return PageCollectionInterface
*/
public function modules();
@@ -202,6 +220,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
* Creates new collection with only modules
*
* @return PageCollectionInterface The collection with only modules
+ * @phpstan-return PageCollectionInterface
* @deprecated 1.7 Use $this->modules() instead
*/
public function modular();
@@ -210,6 +229,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
* Creates new collection with only non-module pages
*
* @return PageCollectionInterface The collection with only non-module pages
+ * @phpstan-return PageCollectionInterface
* @deprecated 1.7 Use $this->pages() instead
*/
public function nonModular();
@@ -218,6 +238,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
* Creates new collection with only published pages
*
* @return PageCollectionInterface The collection with only published pages
+ * @phpstan-return PageCollectionInterface
*/
public function published();
@@ -225,6 +246,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
* Creates new collection with only non-published pages
*
* @return PageCollectionInterface The collection with only non-published pages
+ * @phpstan-return PageCollectionInterface
*/
public function nonPublished();
@@ -232,6 +254,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
* Creates new collection with only routable pages
*
* @return PageCollectionInterface The collection with only routable pages
+ * @phpstan-return PageCollectionInterface
*/
public function routable();
@@ -239,6 +262,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
* Creates new collection with only non-routable pages
*
* @return PageCollectionInterface The collection with only non-routable pages
+ * @phpstan-return PageCollectionInterface
*/
public function nonRoutable();
@@ -247,6 +271,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
*
* @param string $type
* @return PageCollectionInterface The collection
+ * @phpstan-return PageCollectionInterface
*/
public function ofType($type);
@@ -255,6 +280,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
*
* @param string[] $types
* @return PageCollectionInterface The collection
+ * @phpstan-return PageCollectionInterface
*/
public function ofOneOfTheseTypes($types);
@@ -263,6 +289,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
*
* @param array $accessLevels
* @return PageCollectionInterface The collection
+ * @phpstan-return PageCollectionInterface
*/
public function ofOneOfTheseAccessLevels($accessLevels);
diff --git a/system/src/Grav/Common/Page/Interfaces/PageContentInterface.php b/system/src/Grav/Common/Page/Interfaces/PageContentInterface.php
index d9d3105b6..a80972b6b 100644
--- a/system/src/Grav/Common/Page/Interfaces/PageContentInterface.php
+++ b/system/src/Grav/Common/Page/Interfaces/PageContentInterface.php
@@ -3,13 +3,15 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Common\Page\Interfaces;
+use Grav\Common\Data\Blueprint;
use Grav\Common\Media\Interfaces\MediaCollectionInterface;
+use Grav\Common\Page\Header;
/**
* Methods currently implemented in Flex Page emulation layer.
@@ -20,7 +22,7 @@ interface PageContentInterface
* Gets and Sets the header based on the YAML configuration at the top of the .md file
*
* @param object|array|null $var a YAML object representing the configuration for the file
- * @return object the current YAML configuration
+ * @return \stdClass|Header The current YAML configuration
*/
public function header($var = null);
@@ -254,4 +256,12 @@ interface PageContentInterface
* @return bool
*/
public function exists();
+
+ /**
+ * Returns the blueprint from the page.
+ *
+ * @param string $name Name of the Blueprint form. Used by flex only.
+ * @return Blueprint Returns a Blueprint.
+ */
+ public function getBlueprint(string $name = '');
}
diff --git a/system/src/Grav/Common/Page/Interfaces/PageInterface.php b/system/src/Grav/Common/Page/Interfaces/PageInterface.php
index e5ea20c4f..56fc891b9 100644
--- a/system/src/Grav/Common/Page/Interfaces/PageInterface.php
+++ b/system/src/Grav/Common/Page/Interfaces/PageInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Interfaces/PageTranslateInterface.php b/system/src/Grav/Common/Page/Interfaces/PageTranslateInterface.php
index be7ba15de..5fba7512c 100644
--- a/system/src/Grav/Common/Page/Interfaces/PageTranslateInterface.php
+++ b/system/src/Grav/Common/Page/Interfaces/PageTranslateInterface.php
@@ -7,6 +7,11 @@ namespace Grav\Common\Page\Interfaces;
*/
interface PageTranslateInterface
{
+ /**
+ * @return bool
+ */
+ public function translated(): bool;
+
/**
* Return an array with the routes of other translated languages
*
diff --git a/system/src/Grav/Common/Page/Interfaces/PagesSourceInterface.php b/system/src/Grav/Common/Page/Interfaces/PagesSourceInterface.php
index ef5cfba11..ff4ebdae3 100644
--- a/system/src/Grav/Common/Page/Interfaces/PagesSourceInterface.php
+++ b/system/src/Grav/Common/Page/Interfaces/PagesSourceInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Markdown/Excerpts.php b/system/src/Grav/Common/Page/Markdown/Excerpts.php
index 9b0b9963c..f500f4abe 100644
--- a/system/src/Grav/Common/Page/Markdown/Excerpts.php
+++ b/system/src/Grav/Common/Page/Markdown/Excerpts.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Media.php b/system/src/Grav/Common/Page/Media.php
index e18201420..24bc2a6c3 100644
--- a/system/src/Grav/Common/Page/Media.php
+++ b/system/src/Grav/Common/Page/Media.php
@@ -3,13 +3,14 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Common\Page;
use FilesystemIterator;
+use Grav\Common\Config\Config;
use Grav\Common\Grav;
use Grav\Common\Media\Interfaces\MediaObjectInterface;
use Grav\Common\Yaml;
@@ -86,11 +87,6 @@ class Media extends AbstractMedia
*/
protected function init()
{
- /** @var UniformResourceLocator $locator */
- $locator = Grav::instance()['locator'];
- $config = Grav::instance()['config'];
- $exif_reader = isset(Grav::instance()['exif']) ? Grav::instance()['exif']->getReader() : false;
- $media_types = array_keys(Grav::instance()['config']->get('media.types'));
$path = $this->getPath();
// Handle special cases where page doesn't exist in filesystem.
@@ -98,6 +94,17 @@ class Media extends AbstractMedia
return;
}
+ $grav = Grav::instance();
+
+ /** @var UniformResourceLocator $locator */
+ $locator = $grav['locator'];
+
+ /** @var Config $config */
+ $config = $grav['config'];
+
+ $exif_reader = isset($grav['exif']) ? $grav['exif']->getReader() : null;
+ $media_types = array_keys($config->get('media.types', []));
+
$iterator = new FilesystemIterator($path, FilesystemIterator::UNIX_PATHS | FilesystemIterator::SKIP_DOTS);
$media = [];
diff --git a/system/src/Grav/Common/Page/Medium/AbstractMedia.php b/system/src/Grav/Common/Page/Medium/AbstractMedia.php
index db81ddd4a..9b3650b8d 100644
--- a/system/src/Grav/Common/Page/Medium/AbstractMedia.php
+++ b/system/src/Grav/Common/Page/Medium/AbstractMedia.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -90,6 +90,7 @@ abstract class AbstractMedia implements ExportInterface, MediaCollectionInterfac
* @param string $filename
* @return mixed
*/
+ #[\ReturnTypeWillChange]
public function __invoke($filename)
{
return $this->offsetGet($filename);
diff --git a/system/src/Grav/Common/Page/Medium/AudioMedium.php b/system/src/Grav/Common/Page/Medium/AudioMedium.php
index f34f0a9c2..cc53f8198 100644
--- a/system/src/Grav/Common/Page/Medium/AudioMedium.php
+++ b/system/src/Grav/Common/Page/Medium/AudioMedium.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Medium/GlobalMedia.php b/system/src/Grav/Common/Page/Medium/GlobalMedia.php
index 50d69c747..af8ee841e 100644
--- a/system/src/Grav/Common/Page/Medium/GlobalMedia.php
+++ b/system/src/Grav/Common/Page/Medium/GlobalMedia.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Medium/ImageFile.php b/system/src/Grav/Common/Page/Medium/ImageFile.php
index bd853bfc0..1aae7eeb6 100644
--- a/system/src/Grav/Common/Page/Medium/ImageFile.php
+++ b/system/src/Grav/Common/Page/Medium/ImageFile.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -34,6 +34,7 @@ class ImageFile extends Image
/**
* Destruct also image object.
*/
+ #[\ReturnTypeWillChange]
public function __destruct()
{
$adapter = $this->adapter;
diff --git a/system/src/Grav/Common/Page/Medium/ImageMedium.php b/system/src/Grav/Common/Page/Medium/ImageMedium.php
index 46c832ee9..42d8f0e75 100644
--- a/system/src/Grav/Common/Page/Medium/ImageMedium.php
+++ b/system/src/Grav/Common/Page/Medium/ImageMedium.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -89,6 +89,7 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
/**
* Also unset the image on destruct.
*/
+ #[\ReturnTypeWillChange]
public function __destruct()
{
unset($this->image);
@@ -97,6 +98,7 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
/**
* Also clone image.
*/
+ #[\ReturnTypeWillChange]
public function __clone()
{
if ($this->image) {
@@ -247,12 +249,12 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
if ($this->saved_image_path && $this->auto_sizes) {
if (!array_key_exists('height', $this->attributes) && !array_key_exists('width', $this->attributes)) {
$info = getimagesize($this->saved_image_path);
- $width = intval($info[0]);
- $height = intval($info[1]);
+ $width = (int)$info[0];
+ $height = (int)$info[1];
$scaling_factor = $this->retina_scale > 0 ? $this->retina_scale : 1;
- $attributes['width'] = intval($width / $scaling_factor);
- $attributes['height'] = intval($height / $scaling_factor);
+ $attributes['width'] = (int)($width / $scaling_factor);
+ $attributes['height'] = (int)($height / $scaling_factor);
if ($this->aspect_ratio) {
$style = ($attributes['style'] ?? ' ') . "--aspect-ratio: $width/$height;";
@@ -303,29 +305,45 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
return parent::lightbox($width, $height, $reset);
}
+ /**
+ * @param string $enabled
+ * @return $this
+ */
public function autoSizes($enabled = 'true')
{
- $enabled = $enabled === 'true' ?: false;
- $this->auto_sizes = $enabled;
+ $this->auto_sizes = $enabled === 'true' ?: false;
return $this;
}
+ /**
+ * @param string $enabled
+ * @return $this
+ */
public function aspectRatio($enabled = 'true')
{
- $enabled = $enabled === 'true' ?: false;
- $this->aspect_ratio = $enabled;
+ $this->aspect_ratio = $enabled === 'true' ?: false;
return $this;
}
+ /**
+ * @param int $scale
+ * @return $this
+ */
public function retinaScale($scale = 1)
{
- $this->retina_scale = intval($scale);
+ $this->retina_scale = (int)$scale;
return $this;
}
+ /**
+ * @param string|null $image
+ * @param string|null $position
+ * @param int|float|null $scale
+ * @return $this
+ */
public function watermark($image = null, $position = null, $scale = null)
{
$grav = $this->getGrav();
@@ -406,7 +424,7 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
*/
public function addFrame(int $border = 10, string $color = '0x000000')
{
- if(is_int(intval($border)) && $border>0 && preg_match('/^0x[a-f0-9]{6}$/i', $color)) { // $border must be an integer and bigger than 0; $color must be formatted as an HEX value (0x??????).
+ if($border > 0 && preg_match('/^0x[a-f0-9]{6}$/i', $color)) { // $border must be an integer and bigger than 0; $color must be formatted as an HEX value (0x??????).
$image = ImageFile::open($this->path());
}
else {
@@ -437,7 +455,7 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
* @param mixed $args
* @return $this|mixed
*/
-
+ #[\ReturnTypeWillChange]
public function __call($method, $args)
{
if (!in_array($method, static::$magic_actions, true)) {
diff --git a/system/src/Grav/Common/Page/Medium/Link.php b/system/src/Grav/Common/Page/Medium/Link.php
index d57687573..c76d8c191 100644
--- a/system/src/Grav/Common/Page/Medium/Link.php
+++ b/system/src/Grav/Common/Page/Medium/Link.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -28,7 +28,7 @@ class Link implements RenderableInterface, MediaLinkInterface
/** @var array */
protected $attributes = [];
- /** @var MediaObjectInterface */
+ /** @var MediaObjectInterface|MediaLinkInterface */
protected $source;
/**
@@ -79,6 +79,7 @@ class Link implements RenderableInterface, MediaLinkInterface
* @param mixed $args
* @return mixed
*/
+ #[\ReturnTypeWillChange]
public function __call($method, $args)
{
$object = $this->source;
diff --git a/system/src/Grav/Common/Page/Medium/Medium.php b/system/src/Grav/Common/Page/Medium/Medium.php
index 87009ac80..1fe882e98 100644
--- a/system/src/Grav/Common/Page/Medium/Medium.php
+++ b/system/src/Grav/Common/Page/Medium/Medium.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -22,7 +22,12 @@ use Grav\Common\Media\Traits\MediaObjectTrait;
* Class Medium
* @package Grav\Common\Page\Medium
*
+ * @property string $filepath
* @property string $mime
+ * @property int $size
+ * @property int $modified
+ * @property array $metadata
+ * @property int|string $timestamp
*/
class Medium extends Data implements RenderableInterface, MediaFileInterface
{
@@ -57,6 +62,7 @@ class Medium extends Data implements RenderableInterface, MediaFileInterface
/**
* Clone medium.
*/
+ #[\ReturnTypeWillChange]
public function __clone()
{
// Allows future compatibility as parent::__clone() works.
@@ -90,6 +96,7 @@ class Medium extends Data implements RenderableInterface, MediaFileInterface
*
* @return string
*/
+ #[\ReturnTypeWillChange]
public function __toString()
{
return $this->html();
diff --git a/system/src/Grav/Common/Page/Medium/MediumFactory.php b/system/src/Grav/Common/Page/Medium/MediumFactory.php
index 7dee4ea18..cf25f22cf 100644
--- a/system/src/Grav/Common/Page/Medium/MediumFactory.php
+++ b/system/src/Grav/Common/Page/Medium/MediumFactory.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php b/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php
index 44ab95292..4ab2fb58f 100644
--- a/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php
+++ b/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Medium/RenderableInterface.php b/system/src/Grav/Common/Page/Medium/RenderableInterface.php
index ac7244700..1ee6a9660 100644
--- a/system/src/Grav/Common/Page/Medium/RenderableInterface.php
+++ b/system/src/Grav/Common/Page/Medium/RenderableInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Medium/StaticImageMedium.php b/system/src/Grav/Common/Page/Medium/StaticImageMedium.php
index ba92fa1ca..5c5bf8c73 100644
--- a/system/src/Grav/Common/Page/Medium/StaticImageMedium.php
+++ b/system/src/Grav/Common/Page/Medium/StaticImageMedium.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Medium/StaticResizeTrait.php b/system/src/Grav/Common/Page/Medium/StaticResizeTrait.php
index d95b2d634..caaa7e2d6 100644
--- a/system/src/Grav/Common/Page/Medium/StaticResizeTrait.php
+++ b/system/src/Grav/Common/Page/Medium/StaticResizeTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php b/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php
index a56a20d15..1e4d862f9 100644
--- a/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php
+++ b/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Medium/VideoMedium.php b/system/src/Grav/Common/Page/Medium/VideoMedium.php
index bfcf550c4..0e629dc89 100644
--- a/system/src/Grav/Common/Page/Medium/VideoMedium.php
+++ b/system/src/Grav/Common/Page/Medium/VideoMedium.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php
index 9e68a44f8..abda49bfe 100644
--- a/system/src/Grav/Common/Page/Page.php
+++ b/system/src/Grav/Common/Page/Page.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -84,7 +84,7 @@ class Page implements PageInterface
protected $unpublish_date;
/** @var string */
protected $slug;
- /** @var string */
+ /** @var string|null */
protected $route;
/** @var string|null */
protected $raw_route;
@@ -218,6 +218,7 @@ class Page implements PageInterface
return $this;
}
+ #[\ReturnTypeWillChange]
public function __clone()
{
$this->initialized = false;
@@ -387,7 +388,7 @@ class Page implements PageInterface
* Gets and Sets the header based on the YAML configuration at the top of the .md file
*
* @param object|array|null $var a YAML object representing the configuration for the file
- * @return object the current YAML configuration
+ * @return \stdClass the current YAML configuration
*/
public function header($var = null)
{
@@ -1246,6 +1247,17 @@ class Page implements PageInterface
return $blueprint;
}
+ /**
+ * Returns the blueprint from the page.
+ *
+ * @param string $name Not used.
+ * @return Blueprint Returns a Blueprint.
+ */
+ public function getBlueprint(string $name = '')
+ {
+ return $this->blueprints();
+ }
+
/**
* Get the blueprint name for this page. Use the blueprint form field if set
*
diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php
index 9e5d47db0..c4029fe9f 100644
--- a/system/src/Grav/Common/Page/Pages.php
+++ b/system/src/Grav/Common/Page/Pages.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Types.php b/system/src/Grav/Common/Page/Types.php
index c7183680e..43fe0fb64 100644
--- a/system/src/Grav/Common/Page/Types.php
+++ b/system/src/Grav/Common/Page/Types.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Plugin.php b/system/src/Grav/Common/Plugin.php
index 3b0d3fb14..30e5344f6 100644
--- a/system/src/Grav/Common/Plugin.php
+++ b/system/src/Grav/Common/Plugin.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -118,7 +118,7 @@ class Plugin implements EventSubscriberInterface, ArrayAccess
*/
public function config()
{
- return null !== $this->config ? $this->config["plugins.{$this->name}"] : [];
+ return $this->config["plugins.{$this->name}"] ?? [];
}
/**
@@ -414,6 +414,30 @@ class Plugin implements EventSubscriberInterface, ArrayAccess
return true;
}
+ public static function inheritedConfigOption(string $plugin, string $var, PageInterface $page = null, $default = null)
+ {
+ if (Utils::isAdminPlugin()) {
+ $page = Grav::instance()['admin']->page() ?? null;
+ } else {
+ $page = $page ?? Grav::instance()['page'] ?? null;
+ }
+
+ // Try to find var in the page headers
+ if ($page instanceof PageInterface && $page->exists()) {
+ // Loop over pages and look for header vars
+ while ($page && !$page->root()) {
+ $header = new Data((array)$page->header());
+ $value = $header->get("$plugin.$var");
+ if (isset($value)) {
+ return $value;
+ }
+ $page = $page->parent();
+ }
+ }
+
+ return Grav::instance()['config']->get("plugins.$plugin.$var", $default);
+ }
+
/**
* Simpler getter for the plugin blueprint
*
diff --git a/system/src/Grav/Common/Plugins.php b/system/src/Grav/Common/Plugins.php
index 88b5e524e..42b1593c2 100644
--- a/system/src/Grav/Common/Plugins.php
+++ b/system/src/Grav/Common/Plugins.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/AssetsProcessor.php b/system/src/Grav/Common/Processors/AssetsProcessor.php
index 66bb5e3ff..e460fb002 100644
--- a/system/src/Grav/Common/Processors/AssetsProcessor.php
+++ b/system/src/Grav/Common/Processors/AssetsProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/BackupsProcessor.php b/system/src/Grav/Common/Processors/BackupsProcessor.php
index 6e960b493..83e8a0c21 100644
--- a/system/src/Grav/Common/Processors/BackupsProcessor.php
+++ b/system/src/Grav/Common/Processors/BackupsProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php b/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php
index de7cafcfc..a3d5a5152 100644
--- a/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php
+++ b/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/Events/RequestHandlerEvent.php b/system/src/Grav/Common/Processors/Events/RequestHandlerEvent.php
index 32908bad7..30f6195b6 100644
--- a/system/src/Grav/Common/Processors/Events/RequestHandlerEvent.php
+++ b/system/src/Grav/Common/Processors/Events/RequestHandlerEvent.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/InitializeProcessor.php b/system/src/Grav/Common/Processors/InitializeProcessor.php
index b31530e80..04e06edf3 100644
--- a/system/src/Grav/Common/Processors/InitializeProcessor.php
+++ b/system/src/Grav/Common/Processors/InitializeProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/PagesProcessor.php b/system/src/Grav/Common/Processors/PagesProcessor.php
index 36f6718d2..3338e0c63 100644
--- a/system/src/Grav/Common/Processors/PagesProcessor.php
+++ b/system/src/Grav/Common/Processors/PagesProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/PluginsProcessor.php b/system/src/Grav/Common/Processors/PluginsProcessor.php
index 485578e49..ae8790104 100644
--- a/system/src/Grav/Common/Processors/PluginsProcessor.php
+++ b/system/src/Grav/Common/Processors/PluginsProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/ProcessorBase.php b/system/src/Grav/Common/Processors/ProcessorBase.php
index a3506f599..935339144 100644
--- a/system/src/Grav/Common/Processors/ProcessorBase.php
+++ b/system/src/Grav/Common/Processors/ProcessorBase.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/ProcessorInterface.php b/system/src/Grav/Common/Processors/ProcessorInterface.php
index 8a6edbe18..0aed19504 100644
--- a/system/src/Grav/Common/Processors/ProcessorInterface.php
+++ b/system/src/Grav/Common/Processors/ProcessorInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/RenderProcessor.php b/system/src/Grav/Common/Processors/RenderProcessor.php
index 329da22a3..e12cc45a3 100644
--- a/system/src/Grav/Common/Processors/RenderProcessor.php
+++ b/system/src/Grav/Common/Processors/RenderProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/RequestProcessor.php b/system/src/Grav/Common/Processors/RequestProcessor.php
index 971fb6747..358e81b42 100644
--- a/system/src/Grav/Common/Processors/RequestProcessor.php
+++ b/system/src/Grav/Common/Processors/RequestProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/SchedulerProcessor.php b/system/src/Grav/Common/Processors/SchedulerProcessor.php
index 69cc16385..722bfcc92 100644
--- a/system/src/Grav/Common/Processors/SchedulerProcessor.php
+++ b/system/src/Grav/Common/Processors/SchedulerProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/TasksProcessor.php b/system/src/Grav/Common/Processors/TasksProcessor.php
index 07e0934af..29f3458ee 100644
--- a/system/src/Grav/Common/Processors/TasksProcessor.php
+++ b/system/src/Grav/Common/Processors/TasksProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/ThemesProcessor.php b/system/src/Grav/Common/Processors/ThemesProcessor.php
index 951dc79e5..60d089e8b 100644
--- a/system/src/Grav/Common/Processors/ThemesProcessor.php
+++ b/system/src/Grav/Common/Processors/ThemesProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/TwigProcessor.php b/system/src/Grav/Common/Processors/TwigProcessor.php
index 6604b5c05..ffc1032ea 100644
--- a/system/src/Grav/Common/Processors/TwigProcessor.php
+++ b/system/src/Grav/Common/Processors/TwigProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Scheduler/Cron.php b/system/src/Grav/Common/Scheduler/Cron.php
index 5127a997f..0103839d3 100644
--- a/system/src/Grav/Common/Scheduler/Cron.php
+++ b/system/src/Grav/Common/Scheduler/Cron.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Scheduler
* @author Originally based on jqCron by Arnaud Buathier modified for Grav integration
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Scheduler/IntervalTrait.php b/system/src/Grav/Common/Scheduler/IntervalTrait.php
index cc5c1654c..5f7406b8e 100644
--- a/system/src/Grav/Common/Scheduler/IntervalTrait.php
+++ b/system/src/Grav/Common/Scheduler/IntervalTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Scheduler
* @author Originally based on peppeocchi/php-cron-scheduler modified for Grav integration
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Scheduler/Job.php b/system/src/Grav/Common/Scheduler/Job.php
index 13059a572..41561192e 100644
--- a/system/src/Grav/Common/Scheduler/Job.php
+++ b/system/src/Grav/Common/Scheduler/Job.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Scheduler
* @author Originally based on peppeocchi/php-cron-scheduler modified for Grav integration
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Scheduler/Scheduler.php b/system/src/Grav/Common/Scheduler/Scheduler.php
index 73a071225..19eb9eac3 100644
--- a/system/src/Grav/Common/Scheduler/Scheduler.php
+++ b/system/src/Grav/Common/Scheduler/Scheduler.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Scheduler
* @author Originally based on peppeocchi/php-cron-scheduler modified for Grav integration
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Security.php b/system/src/Grav/Common/Security.php
index fe259d8ba..a3ca3bb62 100644
--- a/system/src/Grav/Common/Security.php
+++ b/system/src/Grav/Common/Security.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/AccountsServiceProvider.php b/system/src/Grav/Common/Service/AccountsServiceProvider.php
index 8b158c93c..60f26e5b0 100644
--- a/system/src/Grav/Common/Service/AccountsServiceProvider.php
+++ b/system/src/Grav/Common/Service/AccountsServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/AssetsServiceProvider.php b/system/src/Grav/Common/Service/AssetsServiceProvider.php
index 1e4e647ca..54a44a1c8 100644
--- a/system/src/Grav/Common/Service/AssetsServiceProvider.php
+++ b/system/src/Grav/Common/Service/AssetsServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/BackupsServiceProvider.php b/system/src/Grav/Common/Service/BackupsServiceProvider.php
index 00fa9631a..58f5021a3 100644
--- a/system/src/Grav/Common/Service/BackupsServiceProvider.php
+++ b/system/src/Grav/Common/Service/BackupsServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/ConfigServiceProvider.php b/system/src/Grav/Common/Service/ConfigServiceProvider.php
index 3a5c2e27b..e65e22850 100644
--- a/system/src/Grav/Common/Service/ConfigServiceProvider.php
+++ b/system/src/Grav/Common/Service/ConfigServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/ErrorServiceProvider.php b/system/src/Grav/Common/Service/ErrorServiceProvider.php
index 322736584..02d38c930 100644
--- a/system/src/Grav/Common/Service/ErrorServiceProvider.php
+++ b/system/src/Grav/Common/Service/ErrorServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/FilesystemServiceProvider.php b/system/src/Grav/Common/Service/FilesystemServiceProvider.php
index 62dad5d81..1dde5b3e5 100644
--- a/system/src/Grav/Common/Service/FilesystemServiceProvider.php
+++ b/system/src/Grav/Common/Service/FilesystemServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/FlexServiceProvider.php b/system/src/Grav/Common/Service/FlexServiceProvider.php
index 9c8cd49b1..e7b283ab0 100644
--- a/system/src/Grav/Common/Service/FlexServiceProvider.php
+++ b/system/src/Grav/Common/Service/FlexServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/InflectorServiceProvider.php b/system/src/Grav/Common/Service/InflectorServiceProvider.php
index 861a69e04..f43a4461d 100644
--- a/system/src/Grav/Common/Service/InflectorServiceProvider.php
+++ b/system/src/Grav/Common/Service/InflectorServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/LoggerServiceProvider.php b/system/src/Grav/Common/Service/LoggerServiceProvider.php
index 5043cfbd0..43a67cadf 100644
--- a/system/src/Grav/Common/Service/LoggerServiceProvider.php
+++ b/system/src/Grav/Common/Service/LoggerServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/OutputServiceProvider.php b/system/src/Grav/Common/Service/OutputServiceProvider.php
index 9a49185a8..2dbd3436f 100644
--- a/system/src/Grav/Common/Service/OutputServiceProvider.php
+++ b/system/src/Grav/Common/Service/OutputServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/PagesServiceProvider.php b/system/src/Grav/Common/Service/PagesServiceProvider.php
index 55f6a450d..bec635ac8 100644
--- a/system/src/Grav/Common/Service/PagesServiceProvider.php
+++ b/system/src/Grav/Common/Service/PagesServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/RequestServiceProvider.php b/system/src/Grav/Common/Service/RequestServiceProvider.php
index 17b3149e5..a44c73564 100644
--- a/system/src/Grav/Common/Service/RequestServiceProvider.php
+++ b/system/src/Grav/Common/Service/RequestServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/SchedulerServiceProvider.php b/system/src/Grav/Common/Service/SchedulerServiceProvider.php
index a95272544..13918fbc2 100644
--- a/system/src/Grav/Common/Service/SchedulerServiceProvider.php
+++ b/system/src/Grav/Common/Service/SchedulerServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/SessionServiceProvider.php b/system/src/Grav/Common/Service/SessionServiceProvider.php
index 88c833f26..80e24b4c7 100644
--- a/system/src/Grav/Common/Service/SessionServiceProvider.php
+++ b/system/src/Grav/Common/Service/SessionServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -40,7 +40,8 @@ class SessionServiceProvider implements ServiceProviderInterface
// Get session options.
$enabled = (bool)$config->get('system.session.enabled', false);
- $cookie_secure = (bool)$config->get('system.session.secure', false);
+ $cookie_secure = $config->get('system.session.secure', false)
+ || ($config->get('system.session.secure_https', true) && $uri->scheme(true) === 'https');
$cookie_httponly = (bool)$config->get('system.session.httponly', true);
$cookie_lifetime = (int)$config->get('system.session.timeout', 1800);
$cookie_domain = $config->get('system.session.domain');
diff --git a/system/src/Grav/Common/Service/StreamsServiceProvider.php b/system/src/Grav/Common/Service/StreamsServiceProvider.php
index edde09ad5..f501b4903 100644
--- a/system/src/Grav/Common/Service/StreamsServiceProvider.php
+++ b/system/src/Grav/Common/Service/StreamsServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/TaskServiceProvider.php b/system/src/Grav/Common/Service/TaskServiceProvider.php
index 49ce147e9..2989e9d27 100644
--- a/system/src/Grav/Common/Service/TaskServiceProvider.php
+++ b/system/src/Grav/Common/Service/TaskServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Session.php b/system/src/Grav/Common/Session.php
index 322162705..513143e09 100644
--- a/system/src/Grav/Common/Session.php
+++ b/system/src/Grav/Common/Session.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Taxonomy.php b/system/src/Grav/Common/Taxonomy.php
index 0d0a450b0..5079a2572 100644
--- a/system/src/Grav/Common/Taxonomy.php
+++ b/system/src/Grav/Common/Taxonomy.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Theme.php b/system/src/Grav/Common/Theme.php
index a5006a215..60131292a 100644
--- a/system/src/Grav/Common/Theme.php
+++ b/system/src/Grav/Common/Theme.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Themes.php b/system/src/Grav/Common/Themes.php
index 6126841cf..3567ccadd 100644
--- a/system/src/Grav/Common/Themes.php
+++ b/system/src/Grav/Common/Themes.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Exception/TwigException.php b/system/src/Grav/Common/Twig/Exception/TwigException.php
index 8f543dcc1..7605de4c4 100644
--- a/system/src/Grav/Common/Twig/Exception/TwigException.php
+++ b/system/src/Grav/Common/Twig/Exception/TwigException.php
@@ -3,17 +3,19 @@
/**
* @package Grav\Common\Twig\Exception
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Common\Twig\Exception;
+use RuntimeException;
+
/**
* TwigException gets thrown when you use {% throw code message %} in twig.
*
* This allows Grav to catch 401, 403 and 404 exceptions and display proper error page.
*/
-class TwigException extends \RuntimeException
+class TwigException extends RuntimeException
{
}
diff --git a/system/src/Grav/Common/Twig/Extension/FilesystemExtension.php b/system/src/Grav/Common/Twig/Extension/FilesystemExtension.php
index dfd5fdd90..f60fa12c2 100644
--- a/system/src/Grav/Common/Twig/Extension/FilesystemExtension.php
+++ b/system/src/Grav/Common/Twig/Extension/FilesystemExtension.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Extension/GravExtension.php b/system/src/Grav/Common/Twig/Extension/GravExtension.php
index 4c0d9fe46..b6f30906b 100644
--- a/system/src/Grav/Common/Twig/Extension/GravExtension.php
+++ b/system/src/Grav/Common/Twig/Extension/GravExtension.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeCache.php b/system/src/Grav/Common/Twig/Node/TwigNodeCache.php
index 0ed1fff0c..e05e37248 100644
--- a/system/src/Grav/Common/Twig/Node/TwigNodeCache.php
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeCache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeMarkdown.php b/system/src/Grav/Common/Twig/Node/TwigNodeMarkdown.php
index 81cecaeaf..4637db774 100644
--- a/system/src/Grav/Common/Twig/Node/TwigNodeMarkdown.php
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeMarkdown.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeRender.php b/system/src/Grav/Common/Twig/Node/TwigNodeRender.php
index 798c6baa6..1aeb616b1 100644
--- a/system/src/Grav/Common/Twig/Node/TwigNodeRender.php
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeRender.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeScript.php b/system/src/Grav/Common/Twig/Node/TwigNodeScript.php
index 46a08703b..d7b4ae79f 100644
--- a/system/src/Grav/Common/Twig/Node/TwigNodeScript.php
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeScript.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php b/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php
index 05355f904..8710bf531 100644
--- a/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php b/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php
index 43ae56f18..7bd368e6d 100644
--- a/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeThrow.php b/system/src/Grav/Common/Twig/Node/TwigNodeThrow.php
index 3bfe6124e..41ca15dc2 100644
--- a/system/src/Grav/Common/Twig/Node/TwigNodeThrow.php
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeThrow.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php b/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php
index 40e9240f3..1213b7c64 100644
--- a/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserCache.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserCache.php
index 371e89ae6..1cf21918b 100644
--- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserCache.php
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserCache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserMarkdown.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserMarkdown.php
index 9dab4ae5c..49e34e693 100644
--- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserMarkdown.php
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserMarkdown.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserRender.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserRender.php
index ab2bdde0f..de16266b0 100644
--- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserRender.php
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserRender.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserScript.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserScript.php
index b86063165..e98365b94 100644
--- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserScript.php
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserScript.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserStyle.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserStyle.php
index c8d9544ce..0687395ad 100644
--- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserStyle.php
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserStyle.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserSwitch.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserSwitch.php
index 4540bbf7e..c63fe9565 100644
--- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserSwitch.php
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserSwitch.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
* @origin https://gist.github.com/maxgalbu/9409182
*/
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserThrow.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserThrow.php
index bd4adab97..41f415d2a 100644
--- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserThrow.php
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserThrow.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserTryCatch.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserTryCatch.php
index 46af1767a..993063283 100644
--- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserTryCatch.php
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserTryCatch.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Twig.php b/system/src/Grav/Common/Twig/Twig.php
index 19bad01b1..39ae3c6f6 100644
--- a/system/src/Grav/Common/Twig/Twig.php
+++ b/system/src/Grav/Common/Twig/Twig.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -33,6 +33,7 @@ use Twig\Extension\DebugExtension;
use Twig\Extension\StringLoaderExtension;
use Twig\Loader\ArrayLoader;
use Twig\Loader\ChainLoader;
+use Twig\Loader\ExistsLoaderInterface;
use Twig\Loader\FilesystemLoader;
use Twig\Profiler\Profile;
use Twig\TwigFilter;
@@ -160,7 +161,7 @@ class Twig
$this->twig = new TwigEnvironment($loader_chain, $params);
- $this->twig->registerUndefinedFunctionCallback(function ($name) use ($config) {
+ $this->twig->registerUndefinedFunctionCallback(function (string $name) use ($config) {
$allowed = $config->get('system.twig.safe_functions');
if (is_array($allowed) && in_array($name, $allowed, true) && function_exists($name)) {
return new TwigFunction($name, $name);
@@ -184,7 +185,7 @@ class Twig
return false;
});
- $this->twig->registerUndefinedFilterCallback(function ($name) use ($config) {
+ $this->twig->registerUndefinedFilterCallback(function (string $name) use ($config) {
$allowed = $config->get('system.twig.safe_filters');
if (is_array($allowed) && in_array($name, $allowed, true) && function_exists($name)) {
return new TwigFilter($name, $name);
@@ -514,6 +515,8 @@ class Twig
$twig_extension = $extension ? '.'. $extension .TWIG_EXT : TEMPLATE_EXT;
$template_file = $this->template($page->template() . $twig_extension);
+ // TODO: no longer needed in Twig 3.
+ /** @var ExistsLoaderInterface $loader */
$loader = $this->twig->getLoader();
if ($loader->exists($template_file)) {
// template.xxx.twig
diff --git a/system/src/Grav/Common/Twig/TwigClockworkDataSource.php b/system/src/Grav/Common/Twig/TwigClockworkDataSource.php
index 11127b87c..407a05ef4 100644
--- a/system/src/Grav/Common/Twig/TwigClockworkDataSource.php
+++ b/system/src/Grav/Common/Twig/TwigClockworkDataSource.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TwigClockworkDumper.php b/system/src/Grav/Common/Twig/TwigClockworkDumper.php
index 2c1f4be02..c960cf2cd 100644
--- a/system/src/Grav/Common/Twig/TwigClockworkDumper.php
+++ b/system/src/Grav/Common/Twig/TwigClockworkDumper.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TwigEnvironment.php b/system/src/Grav/Common/Twig/TwigEnvironment.php
index bebbdf16e..6b2a86bef 100644
--- a/system/src/Grav/Common/Twig/TwigEnvironment.php
+++ b/system/src/Grav/Common/Twig/TwigEnvironment.php
@@ -3,13 +3,16 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Common\Twig;
use Twig\Environment;
+use Twig\Error\LoaderError;
+use Twig\Template;
+use Twig\TemplateWrapper;
/**
* Class TwigEnvironment
@@ -18,4 +21,34 @@ use Twig\Environment;
class TwigEnvironment extends Environment
{
use WriteCacheFileTrait;
+
+ /**
+ * @inheritDoc
+ */
+ public function resolveTemplate($names)
+ {
+ if (!\is_array($names)) {
+ $names = [$names];
+ }
+
+ $count = \count($names);
+ foreach ($names as $name) {
+ if ($name instanceof Template) {
+ return $name;
+ }
+ if ($name instanceof TemplateWrapper) {
+ return $name;
+ }
+
+ // Optimization: Avoid throwing an exception when it would be ignored anyway.
+ if (1 !== $count && !$this->getLoader()->exists($name)) {
+ continue;
+ }
+
+ // Throws LoaderError: Unable to find template "%s".
+ return $this->loadTemplate($name);
+ }
+
+ throw new LoaderError(sprintf('Unable to find one of the following templates: "%s".', implode('", "', $names)));
+ }
}
diff --git a/system/src/Grav/Common/Twig/TwigExtension.php b/system/src/Grav/Common/Twig/TwigExtension.php
index 698858b56..07c442e8e 100644
--- a/system/src/Grav/Common/Twig/TwigExtension.php
+++ b/system/src/Grav/Common/Twig/TwigExtension.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/WriteCacheFileTrait.php b/system/src/Grav/Common/Twig/WriteCacheFileTrait.php
index edab8e5b8..575a28163 100644
--- a/system/src/Grav/Common/Twig/WriteCacheFileTrait.php
+++ b/system/src/Grav/Common/Twig/WriteCacheFileTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php
index 7bef09759..cd339d3d6 100644
--- a/system/src/Grav/Common/Uri.php
+++ b/system/src/Grav/Common/Uri.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -165,7 +165,7 @@ class Uri
}
// Handle custom base
- $custom_base = rtrim($grav['config']->get('system.custom_base_url'), '/');
+ $custom_base = rtrim($grav['config']->get('system.custom_base_url', ''), '/');
if ($custom_base) {
$custom_parts = parse_url($custom_base);
if ($custom_parts === false) {
@@ -337,9 +337,9 @@ class Uri
/**
* Get URI parameter.
*
- * @param string|null $id
- * @param string|bool|null $default
- * @return bool|string
+ * @param string $id
+ * @param string|false|null $default
+ * @return string|false|null
*/
public function param($id, $default = false)
{
@@ -623,6 +623,7 @@ class Uri
/**
* @return string
*/
+ #[\ReturnTypeWillChange]
public function __toString()
{
return static::buildUrl($this->toArray());
@@ -1272,9 +1273,9 @@ class Uri
$this->path = rawurldecode(parse_url('http://example.com' . $request_uri, PHP_URL_PATH));
// Build query string.
- $this->query = $env['QUERY_STRING'] ?? '';
+ $this->query = $env['QUERY_STRING'] ?? '';
if ($this->query === '') {
- $this->query = parse_url('http://example.com' . $request_uri, PHP_URL_QUERY);
+ $this->query = parse_url('http://example.com' . $request_uri, PHP_URL_QUERY) ?? '';
}
// Support ngnix routes.
diff --git a/system/src/Grav/Common/User/Access.php b/system/src/Grav/Common/User/Access.php
index 6503c891f..96f4d96d6 100644
--- a/system/src/Grav/Common/User/Access.php
+++ b/system/src/Grav/Common/User/Access.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/Authentication.php b/system/src/Grav/Common/User/Authentication.php
index 6ff95e7bf..c32fd62e6 100644
--- a/system/src/Grav/Common/User/Authentication.php
+++ b/system/src/Grav/Common/User/Authentication.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/DataUser/User.php b/system/src/Grav/Common/User/DataUser/User.php
index 8fcdbbbd6..b442cc3e5 100644
--- a/system/src/Grav/Common/User/DataUser/User.php
+++ b/system/src/Grav/Common/User/DataUser/User.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -295,6 +295,7 @@ class User extends Data implements UserInterface
* @return int
* @deprecated 1.6 Method makes no sense for user account.
*/
+ #[\ReturnTypeWillChange]
public function count()
{
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6', E_USER_DEPRECATED);
diff --git a/system/src/Grav/Common/User/DataUser/UserCollection.php b/system/src/Grav/Common/User/DataUser/UserCollection.php
index 3da7e2dde..9f35e37e6 100644
--- a/system/src/Grav/Common/User/DataUser/UserCollection.php
+++ b/system/src/Grav/Common/User/DataUser/UserCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/Group.php b/system/src/Grav/Common/User/Group.php
index 7dd6d650c..9be619a1c 100644
--- a/system/src/Grav/Common/User/Group.php
+++ b/system/src/Grav/Common/User/Group.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/Interfaces/AuthorizeInterface.php b/system/src/Grav/Common/User/Interfaces/AuthorizeInterface.php
index 3ad8d2cc5..1aeb004e6 100644
--- a/system/src/Grav/Common/User/Interfaces/AuthorizeInterface.php
+++ b/system/src/Grav/Common/User/Interfaces/AuthorizeInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/Interfaces/UserCollectionInterface.php b/system/src/Grav/Common/User/Interfaces/UserCollectionInterface.php
index d892e820f..5bcfbc0f2 100644
--- a/system/src/Grav/Common/User/Interfaces/UserCollectionInterface.php
+++ b/system/src/Grav/Common/User/Interfaces/UserCollectionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/Interfaces/UserGroupInterface.php b/system/src/Grav/Common/User/Interfaces/UserGroupInterface.php
index c345c4b38..c18388ce9 100644
--- a/system/src/Grav/Common/User/Interfaces/UserGroupInterface.php
+++ b/system/src/Grav/Common/User/Interfaces/UserGroupInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/Interfaces/UserInterface.php b/system/src/Grav/Common/User/Interfaces/UserInterface.php
index 02827e37c..dcd014c88 100644
--- a/system/src/Grav/Common/User/Interfaces/UserInterface.php
+++ b/system/src/Grav/Common/User/Interfaces/UserInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/Traits/UserTrait.php b/system/src/Grav/Common/User/Traits/UserTrait.php
index 5a6b74938..0608caf5e 100644
--- a/system/src/Grav/Common/User/Traits/UserTrait.php
+++ b/system/src/Grav/Common/User/Traits/UserTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/User.php b/system/src/Grav/Common/User/User.php
index 4b2319fc5..b38c72e26 100644
--- a/system/src/Grav/Common/User/User.php
+++ b/system/src/Grav/Common/User/User.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php
index 5295a6400..72cd1ceae 100644
--- a/system/src/Grav/Common/Utils.php
+++ b/system/src/Grav/Common/Utils.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Yaml.php b/system/src/Grav/Common/Yaml.php
index 330b6c383..0758599dc 100644
--- a/system/src/Grav/Common/Yaml.php
+++ b/system/src/Grav/Common/Yaml.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Application/Application.php b/system/src/Grav/Console/Application/Application.php
index 21cea8730..29c18f3f1 100644
--- a/system/src/Grav/Console/Application/Application.php
+++ b/system/src/Grav/Console/Application/Application.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Application/CommandLoader/PluginCommandLoader.php b/system/src/Grav/Console/Application/CommandLoader/PluginCommandLoader.php
index 9b7b568d9..adf644730 100644
--- a/system/src/Grav/Console/Application/CommandLoader/PluginCommandLoader.php
+++ b/system/src/Grav/Console/Application/CommandLoader/PluginCommandLoader.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Application/GpmApplication.php b/system/src/Grav/Console/Application/GpmApplication.php
index df383f2d2..f9e6b616e 100644
--- a/system/src/Grav/Console/Application/GpmApplication.php
+++ b/system/src/Grav/Console/Application/GpmApplication.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Application/GravApplication.php b/system/src/Grav/Console/Application/GravApplication.php
index 739ca396b..f06dae650 100644
--- a/system/src/Grav/Console/Application/GravApplication.php
+++ b/system/src/Grav/Console/Application/GravApplication.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Application/PluginApplication.php b/system/src/Grav/Console/Application/PluginApplication.php
index 75e9eb704..e365b1e08 100644
--- a/system/src/Grav/Console/Application/PluginApplication.php
+++ b/system/src/Grav/Console/Application/PluginApplication.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/BackupCommand.php b/system/src/Grav/Console/Cli/BackupCommand.php
index a8a025d2a..1fe84ea01 100644
--- a/system/src/Grav/Console/Cli/BackupCommand.php
+++ b/system/src/Grav/Console/Cli/BackupCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/CleanCommand.php b/system/src/Grav/Console/Cli/CleanCommand.php
index 84b46d6cc..e6b8f9875 100644
--- a/system/src/Grav/Console/Cli/CleanCommand.php
+++ b/system/src/Grav/Console/Cli/CleanCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/ClearCacheCommand.php b/system/src/Grav/Console/Cli/ClearCacheCommand.php
index daed2a533..7550dd938 100644
--- a/system/src/Grav/Console/Cli/ClearCacheCommand.php
+++ b/system/src/Grav/Console/Cli/ClearCacheCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/ComposerCommand.php b/system/src/Grav/Console/Cli/ComposerCommand.php
index 5075d1d0f..0dc9bcd15 100644
--- a/system/src/Grav/Console/Cli/ComposerCommand.php
+++ b/system/src/Grav/Console/Cli/ComposerCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/InstallCommand.php b/system/src/Grav/Console/Cli/InstallCommand.php
index 22258beb3..33198cb5f 100644
--- a/system/src/Grav/Console/Cli/InstallCommand.php
+++ b/system/src/Grav/Console/Cli/InstallCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/LogViewerCommand.php b/system/src/Grav/Console/Cli/LogViewerCommand.php
index d3924f88c..d7e127e5f 100644
--- a/system/src/Grav/Console/Cli/LogViewerCommand.php
+++ b/system/src/Grav/Console/Cli/LogViewerCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/NewProjectCommand.php b/system/src/Grav/Console/Cli/NewProjectCommand.php
index d67cb1c8d..7abbc4ed3 100644
--- a/system/src/Grav/Console/Cli/NewProjectCommand.php
+++ b/system/src/Grav/Console/Cli/NewProjectCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/PageSystemValidatorCommand.php b/system/src/Grav/Console/Cli/PageSystemValidatorCommand.php
index 4d234d75d..3a6960077 100644
--- a/system/src/Grav/Console/Cli/PageSystemValidatorCommand.php
+++ b/system/src/Grav/Console/Cli/PageSystemValidatorCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/SandboxCommand.php b/system/src/Grav/Console/Cli/SandboxCommand.php
index d865b4ae7..2ba562542 100644
--- a/system/src/Grav/Console/Cli/SandboxCommand.php
+++ b/system/src/Grav/Console/Cli/SandboxCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -200,6 +200,10 @@ class SandboxCommand extends GravCommand
$io->newLine();
$io->writeln('Resetting Symbolic Links');
+ // Symlink also tests if using git.
+ if (is_dir($this->source . '/tests')) {
+ $this->mappings['/tests'] = '/tests';
+ }
foreach ($this->mappings as $source => $target) {
if ((string)(int)$source === (string)$source) {
diff --git a/system/src/Grav/Console/Cli/SchedulerCommand.php b/system/src/Grav/Console/Cli/SchedulerCommand.php
index c5385aad2..8b8470a4c 100644
--- a/system/src/Grav/Console/Cli/SchedulerCommand.php
+++ b/system/src/Grav/Console/Cli/SchedulerCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/SecurityCommand.php b/system/src/Grav/Console/Cli/SecurityCommand.php
index 7f728b69f..b6cb662e0 100644
--- a/system/src/Grav/Console/Cli/SecurityCommand.php
+++ b/system/src/Grav/Console/Cli/SecurityCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/ServerCommand.php b/system/src/Grav/Console/Cli/ServerCommand.php
index 77bce8b1d..29b423ecd 100644
--- a/system/src/Grav/Console/Cli/ServerCommand.php
+++ b/system/src/Grav/Console/Cli/ServerCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/YamlLinterCommand.php b/system/src/Grav/Console/Cli/YamlLinterCommand.php
index a9628cdd1..75a75594f 100644
--- a/system/src/Grav/Console/Cli/YamlLinterCommand.php
+++ b/system/src/Grav/Console/Cli/YamlLinterCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/ConsoleCommand.php b/system/src/Grav/Console/ConsoleCommand.php
index 044f1b0ff..c522c88b3 100644
--- a/system/src/Grav/Console/ConsoleCommand.php
+++ b/system/src/Grav/Console/ConsoleCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/ConsoleTrait.php b/system/src/Grav/Console/ConsoleTrait.php
index feb10d32e..0af4075ab 100644
--- a/system/src/Grav/Console/ConsoleTrait.php
+++ b/system/src/Grav/Console/ConsoleTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Gpm/DirectInstallCommand.php b/system/src/Grav/Console/Gpm/DirectInstallCommand.php
index e5c662bcc..fbb02207c 100644
--- a/system/src/Grav/Console/Gpm/DirectInstallCommand.php
+++ b/system/src/Grav/Console/Gpm/DirectInstallCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Gpm
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Gpm/IndexCommand.php b/system/src/Grav/Console/Gpm/IndexCommand.php
index ecc91feb0..367322bb9 100644
--- a/system/src/Grav/Console/Gpm/IndexCommand.php
+++ b/system/src/Grav/Console/Gpm/IndexCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Gpm
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Gpm/InfoCommand.php b/system/src/Grav/Console/Gpm/InfoCommand.php
index 5dddd32b5..c6f855208 100644
--- a/system/src/Grav/Console/Gpm/InfoCommand.php
+++ b/system/src/Grav/Console/Gpm/InfoCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Gpm
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Gpm/InstallCommand.php b/system/src/Grav/Console/Gpm/InstallCommand.php
index 92c8e07d7..1df7803f6 100644
--- a/system/src/Grav/Console/Gpm/InstallCommand.php
+++ b/system/src/Grav/Console/Gpm/InstallCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Gpm
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php
index b84001698..a3d53ffee 100644
--- a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php
+++ b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Gpm
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Gpm/UninstallCommand.php b/system/src/Grav/Console/Gpm/UninstallCommand.php
index cb14c6552..a3db65709 100644
--- a/system/src/Grav/Console/Gpm/UninstallCommand.php
+++ b/system/src/Grav/Console/Gpm/UninstallCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Gpm
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Gpm/UpdateCommand.php b/system/src/Grav/Console/Gpm/UpdateCommand.php
index 300fe61d8..73c5c9e42 100644
--- a/system/src/Grav/Console/Gpm/UpdateCommand.php
+++ b/system/src/Grav/Console/Gpm/UpdateCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Gpm
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Gpm/VersionCommand.php b/system/src/Grav/Console/Gpm/VersionCommand.php
index 124aad3c0..862919648 100644
--- a/system/src/Grav/Console/Gpm/VersionCommand.php
+++ b/system/src/Grav/Console/Gpm/VersionCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Gpm
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/GpmCommand.php b/system/src/Grav/Console/GpmCommand.php
index 816e87223..a14eb4717 100644
--- a/system/src/Grav/Console/GpmCommand.php
+++ b/system/src/Grav/Console/GpmCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/GravCommand.php b/system/src/Grav/Console/GravCommand.php
index 0249f1427..7db18e219 100644
--- a/system/src/Grav/Console/GravCommand.php
+++ b/system/src/Grav/Console/GravCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Plugin/PluginListCommand.php b/system/src/Grav/Console/Plugin/PluginListCommand.php
index 81041c0e5..022661452 100644
--- a/system/src/Grav/Console/Plugin/PluginListCommand.php
+++ b/system/src/Grav/Console/Plugin/PluginListCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Plugin
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/TerminalObjects/Table.php b/system/src/Grav/Console/TerminalObjects/Table.php
index a71d7c0c8..153993dcd 100644
--- a/system/src/Grav/Console/TerminalObjects/Table.php
+++ b/system/src/Grav/Console/TerminalObjects/Table.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\TerminalObjects
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Events/FlexRegisterEvent.php b/system/src/Grav/Events/FlexRegisterEvent.php
index 13aebf386..b02ed1dae 100644
--- a/system/src/Grav/Events/FlexRegisterEvent.php
+++ b/system/src/Grav/Events/FlexRegisterEvent.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Events
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Events/PermissionsRegisterEvent.php b/system/src/Grav/Events/PermissionsRegisterEvent.php
index 5e63c85ab..434dcfaf2 100644
--- a/system/src/Grav/Events/PermissionsRegisterEvent.php
+++ b/system/src/Grav/Events/PermissionsRegisterEvent.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Events
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Events/PluginsLoadedEvent.php b/system/src/Grav/Events/PluginsLoadedEvent.php
index 9dfd18b4a..13e22264d 100644
--- a/system/src/Grav/Events/PluginsLoadedEvent.php
+++ b/system/src/Grav/Events/PluginsLoadedEvent.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Events
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Events/SessionStartEvent.php b/system/src/Grav/Events/SessionStartEvent.php
index e724a0922..fc4f3649c 100644
--- a/system/src/Grav/Events/SessionStartEvent.php
+++ b/system/src/Grav/Events/SessionStartEvent.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Events
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Acl/Access.php b/system/src/Grav/Framework/Acl/Access.php
index ccc22cf1f..45cf2bf9b 100644
--- a/system/src/Grav/Framework/Acl/Access.php
+++ b/system/src/Grav/Framework/Acl/Access.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Acl
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -14,7 +14,6 @@ use Countable;
use Grav\Common\Utils;
use IteratorAggregate;
use JsonSerializable;
-use RuntimeException;
use Traversable;
use function count;
use function is_array;
@@ -25,6 +24,7 @@ use function strlen;
/**
* Class Access
* @package Grav\Framework\Acl
+ * @implements IteratorAggregate
*/
class Access implements JsonSerializable, IteratorAggregate, Countable
{
@@ -34,7 +34,7 @@ class Access implements JsonSerializable, IteratorAggregate, Countable
private $rules;
/** @var array */
private $ops;
- /** @var array */
+ /** @var array */
private $acl = [];
/** @var array */
private $inherited = [];
@@ -78,12 +78,7 @@ class Access implements JsonSerializable, IteratorAggregate, Countable
$inherited = array_diff_key($parent->getAllActions(), $acl);
$this->inherited += $parent->inherited + array_fill_keys(array_keys($inherited), $name ?? $parent->getName());
- $acl = array_replace($acl, $inherited);
- if (null === $acl) {
- throw new RuntimeException('Internal error');
- }
-
- $this->acl = $acl;
+ $this->acl = array_replace($acl, $inherited);
}
/**
diff --git a/system/src/Grav/Framework/Acl/Action.php b/system/src/Grav/Framework/Acl/Action.php
index 1f883a054..6251c3c89 100644
--- a/system/src/Grav/Framework/Acl/Action.php
+++ b/system/src/Grav/Framework/Acl/Action.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Acl
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -16,11 +16,11 @@ use IteratorAggregate;
use RuntimeException;
use Traversable;
use function count;
-use function strlen;
/**
* Class Action
* @package Grav\Framework\Acl
+ * @implements IteratorAggregate
*/
class Action implements IteratorAggregate, Countable
{
@@ -37,7 +37,7 @@ class Action implements IteratorAggregate, Countable
/** @var Action|null */
protected $parent;
- /** @var Action[] */
+ /** @var array */
protected $children = [];
/**
@@ -48,8 +48,8 @@ class Action implements IteratorAggregate, Countable
{
$label = $action['label'] ?? null;
if (!$label) {
- if ($pos = strrpos($name, '.')) {
- $label = substr($name, $pos + 1);
+ if ($pos = mb_strrpos($name, '.')) {
+ $label = mb_substr($name, $pos + 1);
} else {
$label = $name;
}
@@ -114,9 +114,9 @@ class Action implements IteratorAggregate, Countable
*/
public function getScope(): string
{
- $pos = strpos($this->name, '.');
+ $pos = mb_strpos($this->name, '.');
if ($pos) {
- return substr($this->name, 0, $pos);
+ return mb_substr($this->name, 0, $pos);
}
return $this->name;
@@ -127,7 +127,7 @@ class Action implements IteratorAggregate, Countable
*/
public function getLevels(): int
{
- return substr_count($this->name, '.');
+ return mb_substr_count($this->name, '.');
}
/**
@@ -161,12 +161,12 @@ class Action implements IteratorAggregate, Countable
*/
public function addChild(Action $child): void
{
- if (strpos($child->name, "{$this->name}.") !== 0) {
+ if (mb_strpos($child->name, "{$this->name}.") !== 0) {
throw new RuntimeException('Bad child');
}
$child->setParent($this);
- $name = substr($child->name, strlen($this->name) + 1);
+ $name = mb_substr($child->name, mb_strlen($this->name) + 1);
$this->children[$name] = $child;
}
@@ -190,6 +190,7 @@ class Action implements IteratorAggregate, Countable
/**
* @return array
*/
+ #[\ReturnTypeWillChange]
public function __debugInfo()
{
return [
diff --git a/system/src/Grav/Framework/Acl/Permissions.php b/system/src/Grav/Framework/Acl/Permissions.php
index 037571675..e54590a0d 100644
--- a/system/src/Grav/Framework/Acl/Permissions.php
+++ b/system/src/Grav/Framework/Acl/Permissions.php
@@ -3,26 +3,32 @@
/**
* @package Grav\Framework\Acl
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Acl;
+use ArrayAccess;
use ArrayIterator;
+use Countable;
+use IteratorAggregate;
use RecursiveIteratorIterator;
use RuntimeException;
use Traversable;
+use function count;
/**
* Class Permissions
* @package Grav\Framework\Acl
+ * @implements ArrayAccess
+ * @implements IteratorAggregate
*/
-class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
+class Permissions implements ArrayAccess, Countable, IteratorAggregate
{
- /** @var Action[] */
+ /** @var array */
protected $instances = [];
- /** @var Action[] */
+ /** @var array */
protected $actions = [];
/** @var array */
protected $nested = [];
@@ -142,9 +148,6 @@ class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
public function addTypes(array $types): void
{
$types = array_replace($this->types, $types);
- if (null === $types) {
- throw new RuntimeException('Internal error');
- }
$this->types = $types;
}
@@ -206,6 +209,7 @@ class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
/**
* @return ArrayIterator|Traversable
*/
+ #[\ReturnTypeWillChange]
public function getIterator()
{
return new ArrayIterator($this->actions);
@@ -214,6 +218,7 @@ class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
/**
* @return array
*/
+ #[\ReturnTypeWillChange]
public function __debugInfo()
{
return [
diff --git a/system/src/Grav/Framework/Acl/PermissionsReader.php b/system/src/Grav/Framework/Acl/PermissionsReader.php
index b157a5d3b..350fc967a 100644
--- a/system/src/Grav/Framework/Acl/PermissionsReader.php
+++ b/system/src/Grav/Framework/Acl/PermissionsReader.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Acl
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -62,12 +62,14 @@ class PermissionsReader
{
$list = [];
foreach ($actions as $name => $action) {
- $prefixNname = $prefix . $name;
- $list[$prefixNname] = null;
+ $prefixName = $prefix . $name;
+ $list[$prefixName] = null;
// Support nested sets of actions.
if (isset($action['actions']) && is_array($action['actions'])) {
- $list += static::read($action['actions'], "{$prefixNname}.");
+ $innerList = static::read($action['actions'], "{$prefixName}.");
+
+ $list += $innerList;
}
unset($action['actions']);
@@ -76,7 +78,7 @@ class PermissionsReader
$action = static::addDefaults($action);
// Build flat list of actions.
- $list[$prefixNname] = $action;
+ $list[$prefixName] = $action;
}
return $list;
@@ -172,9 +174,6 @@ class PermissionsReader
$scopes[] = $action;
$action = array_replace_recursive(...$scopes);
- if (null === $action) {
- throw new RuntimeException('Internal error');
- }
$newType = $defaults['type'] ?? null;
if ($newType && $newType !== $type) {
diff --git a/system/src/Grav/Framework/Acl/RecursiveActionIterator.php b/system/src/Grav/Framework/Acl/RecursiveActionIterator.php
index ac219da38..1fb9a60ba 100644
--- a/system/src/Grav/Framework/Acl/RecursiveActionIterator.php
+++ b/system/src/Grav/Framework/Acl/RecursiveActionIterator.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Acl
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -17,6 +17,7 @@ use RocketTheme\Toolbox\ArrayTraits\Iterator;
/**
* Class Action
* @package Grav\Framework\Acl
+ * @implements RecursiveIterator
*/
class RecursiveActionIterator implements RecursiveIterator, \Countable
{
@@ -26,6 +27,7 @@ class RecursiveActionIterator implements RecursiveIterator, \Countable
* @see \Iterator::key()
* @return string
*/
+ #[\ReturnTypeWillChange]
public function key()
{
/** @var Action $current */
diff --git a/system/src/Grav/Framework/Cache/AbstractCache.php b/system/src/Grav/Framework/Cache/AbstractCache.php
index bfb5125ec..b6d00a3b8 100644
--- a/system/src/Grav/Framework/Cache/AbstractCache.php
+++ b/system/src/Grav/Framework/Cache/AbstractCache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Cache/Adapter/ChainCache.php b/system/src/Grav/Framework/Cache/Adapter/ChainCache.php
index 76f518541..bca940fa0 100644
--- a/system/src/Grav/Framework/Cache/Adapter/ChainCache.php
+++ b/system/src/Grav/Framework/Cache/Adapter/ChainCache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -33,11 +33,15 @@ class ChainCache extends AbstractCache
* Chain Cache constructor.
* @param array $caches
* @param null|int|DateInterval $defaultLifetime
- * @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public function __construct(array $caches, $defaultLifetime = null)
{
- parent::__construct('', $defaultLifetime);
+ try {
+ parent::__construct('', $defaultLifetime);
+ } catch (\Psr\SimpleCache\InvalidArgumentException $e) {
+ throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
+ }
if (!$caches) {
throw new InvalidArgumentException('At least one cache must be specified');
diff --git a/system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php b/system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php
index 29e9e3b52..15afed380 100644
--- a/system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php
+++ b/system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -29,12 +29,16 @@ class DoctrineCache extends AbstractCache
* @param CacheProvider $doctrineCache
* @param string $namespace
* @param null|int|DateInterval $defaultLifetime
- * @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public function __construct(CacheProvider $doctrineCache, $namespace = '', $defaultLifetime = null)
{
// Do not use $namespace or $defaultLifetime directly, store them with constructor and fetch with methods.
- parent::__construct($namespace, $defaultLifetime);
+ try {
+ parent::__construct($namespace, $defaultLifetime);
+ } catch (\Psr\SimpleCache\InvalidArgumentException $e) {
+ throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
+ }
// Set namespace to Doctrine Cache provider if it was given.
$namespace = $this->getNamespace();
diff --git a/system/src/Grav/Framework/Cache/Adapter/FileCache.php b/system/src/Grav/Framework/Cache/Adapter/FileCache.php
index 1995e159d..7f1d5e7b0 100644
--- a/system/src/Grav/Framework/Cache/Adapter/FileCache.php
+++ b/system/src/Grav/Framework/Cache/Adapter/FileCache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -42,9 +42,13 @@ class FileCache extends AbstractCache
*/
public function __construct($namespace = '', $defaultLifetime = null, $folder = null)
{
- parent::__construct($namespace, $defaultLifetime ?: 31557600); // = 1 year
+ try {
+ parent::__construct($namespace, $defaultLifetime ?: 31557600); // = 1 year
- $this->initFileCache($namespace, $folder ?? '');
+ $this->initFileCache($namespace, $folder ?? '');
+ } catch (\Psr\SimpleCache\InvalidArgumentException $e) {
+ throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
+ }
}
/**
@@ -103,7 +107,13 @@ class FileCache extends AbstractCache
{
$file = $this->getFile($key);
- return (!file_exists($file) || @unlink($file) || !file_exists($file));
+ $result = false;
+ if (file_exists($file)) {
+ $result = @unlink($file);
+ $result &= !file_exists($file);
+ }
+
+ return $result;
}
/**
@@ -156,7 +166,7 @@ class FileCache extends AbstractCache
*/
protected function initFileCache($namespace, $directory)
{
- if (!isset($directory[0])) {
+ if ($directory === '') {
$directory = sys_get_temp_dir() . '/grav-cache';
} else {
$directory = realpath($directory) ?: $directory;
@@ -246,6 +256,7 @@ class FileCache extends AbstractCache
/**
* @return void
*/
+ #[\ReturnTypeWillChange]
public function __destruct()
{
if ($this->tmp !== null && file_exists($this->tmp)) {
diff --git a/system/src/Grav/Framework/Cache/Adapter/MemoryCache.php b/system/src/Grav/Framework/Cache/Adapter/MemoryCache.php
index c043bf9e6..21cd89c1c 100644
--- a/system/src/Grav/Framework/Cache/Adapter/MemoryCache.php
+++ b/system/src/Grav/Framework/Cache/Adapter/MemoryCache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Cache/Adapter/SessionCache.php b/system/src/Grav/Framework/Cache/Adapter/SessionCache.php
index e189e3e7e..02fe7c9e3 100644
--- a/system/src/Grav/Framework/Cache/Adapter/SessionCache.php
+++ b/system/src/Grav/Framework/Cache/Adapter/SessionCache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Cache/CacheInterface.php b/system/src/Grav/Framework/Cache/CacheInterface.php
index efd9d3122..03dfa7a14 100644
--- a/system/src/Grav/Framework/Cache/CacheInterface.php
+++ b/system/src/Grav/Framework/Cache/CacheInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Cache/CacheTrait.php b/system/src/Grav/Framework/Cache/CacheTrait.php
index 287f92462..37dd6c955 100644
--- a/system/src/Grav/Framework/Cache/CacheTrait.php
+++ b/system/src/Grav/Framework/Cache/CacheTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Cache/Exception/CacheException.php b/system/src/Grav/Framework/Cache/Exception/CacheException.php
index 1db325694..db33883b0 100644
--- a/system/src/Grav/Framework/Cache/Exception/CacheException.php
+++ b/system/src/Grav/Framework/Cache/Exception/CacheException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Cache/Exception/InvalidArgumentException.php b/system/src/Grav/Framework/Cache/Exception/InvalidArgumentException.php
index 08a343504..70c041885 100644
--- a/system/src/Grav/Framework/Cache/Exception/InvalidArgumentException.php
+++ b/system/src/Grav/Framework/Cache/Exception/InvalidArgumentException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Collection/AbstractFileCollection.php b/system/src/Grav/Framework/Collection/AbstractFileCollection.php
index 1be8d129a..500aea8e4 100644
--- a/system/src/Grav/Framework/Collection/AbstractFileCollection.php
+++ b/system/src/Grav/Framework/Collection/AbstractFileCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Collection
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -68,6 +68,7 @@ class AbstractFileCollection extends AbstractLazyCollection implements FileColle
/**
* @param Criteria $criteria
* @return ArrayCollection
+ * @phpstan-return ArrayCollection
* @todo Implement lazy matching
*/
public function matching(Criteria $criteria)
@@ -93,6 +94,7 @@ class AbstractFileCollection extends AbstractLazyCollection implements FileColle
foreach (array_reverse($orderings) as $field => $ordering) {
$next = ClosureExpressionVisitor::sortByField($field, $ordering === Criteria::DESC ? -1 : 1, $next);
}
+ /** @phpstan-ignore-next-line */
if (null === $next) {
throw new RuntimeException('Criteria is missing orderings');
}
@@ -162,6 +164,7 @@ class AbstractFileCollection extends AbstractLazyCollection implements FileColle
* @param SeekableIterator $iterator
* @param int $nestingLimit
* @return array
+ * @phpstan-param SeekableIterator $iterator
*/
protected function doInitializeByIterator(SeekableIterator $iterator, $nestingLimit)
{
@@ -211,7 +214,6 @@ class AbstractFileCollection extends AbstractLazyCollection implements FileColle
protected function doInitializeChildren(array $children, $nestingLimit)
{
$objects = [];
-
foreach ($children as $iterator) {
$objects += $this->doInitializeByIterator($iterator, $nestingLimit);
}
diff --git a/system/src/Grav/Framework/Collection/AbstractIndexCollection.php b/system/src/Grav/Framework/Collection/AbstractIndexCollection.php
index 25d8672c0..02916d909 100644
--- a/system/src/Grav/Framework/Collection/AbstractIndexCollection.php
+++ b/system/src/Grav/Framework/Collection/AbstractIndexCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Collection
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -14,6 +14,7 @@ use Closure;
use Grav\Framework\Compat\Serializable;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
use InvalidArgumentException;
+use Iterator;
use function array_key_exists;
use function array_slice;
use function count;
@@ -79,17 +80,17 @@ abstract class AbstractIndexCollection implements CollectionInterface
/**
* {@inheritDoc}
*/
+ #[\ReturnTypeWillChange]
public function key()
{
- /** @phpstan-var TKey $key */
- $key = (string)key($this->entries);
-
- return $key;
+ /** @phpstan-var TKey */
+ return (string)key($this->entries);
}
/**
* {@inheritDoc}
*/
+ #[\ReturnTypeWillChange]
public function next()
{
$value = next($this->entries);
@@ -101,6 +102,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
/**
* {@inheritDoc}
*/
+ #[\ReturnTypeWillChange]
public function current()
{
$value = current($this->entries);
@@ -131,7 +133,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
{
$key = $this->isAllowedElement($element) ? $this->getCurrentKey($element) : null;
- if (!$key || !isset($this->entries[$key])) {
+ if (null !== $key || !isset($this->entries[$key])) {
return false;
}
@@ -143,49 +145,64 @@ abstract class AbstractIndexCollection implements CollectionInterface
/**
* Required by interface ArrayAccess.
*
- * {@inheritDoc}
+ * @param string|int|null $offset
+ * @return bool
+ * @phpstan-param TKey|null $offset
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
- return $this->containsKey($offset);
+ /** @phpstan-ignore-next-line phpstan bug? */
+ return $offset !== null ? $this->containsKey($offset) : false;
}
/**
* Required by interface ArrayAccess.
*
- * {@inheritDoc}
+ * @param string|int|null $offset
+ * @return mixed
+ * @phpstan-param TKey|null $offset
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
- return $this->get($offset);
+ /** @phpstan-ignore-next-line phpstan bug? */
+ return $offset !== null ? $this->get($offset) : null;
}
/**
* Required by interface ArrayAccess.
*
- * {@inheritDoc}
+ * @param string|int|null $offset
+ * @param mixed $value
+ * @return void
+ * @phpstan-param TKey|null $offset
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
if (null === $offset) {
$this->add($value);
+ } else {
+ /** @phpstan-ignore-next-line phpstan bug? */
+ $this->set($offset, $value);
}
-
- $this->set($offset, $value);
}
/**
* Required by interface ArrayAccess.
*
- * {@inheritDoc}
+ * @param string|int|null $offset
+ * @return void
+ * @phpstan-param TKey|null $offset
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
- $this->remove($offset);
+ if ($offset !== null) {
+ /** @phpstan-ignore-next-line phpstan bug? */
+ $this->remove($offset);
+ }
}
/**
@@ -255,6 +272,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
/**
* {@inheritDoc}
*/
+ #[\ReturnTypeWillChange]
public function count()
{
return count($this->entries);
@@ -298,7 +316,9 @@ abstract class AbstractIndexCollection implements CollectionInterface
* Required by interface IteratorAggregate.
*
* {@inheritDoc}
+ * @phpstan-return Iterator
*/
+ #[\ReturnTypeWillChange]
public function getIterator()
{
return new ArrayIterator($this->loadElements());
@@ -341,6 +361,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
*
* @return string
*/
+ #[\ReturnTypeWillChange]
public function __toString()
{
return __CLASS__ . '@' . spl_object_hash($this);
@@ -395,7 +416,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
$keys = $this->getKeys();
shuffle($keys);
- return $this->createFrom(array_replace(array_flip($keys), $this->entries) ?? []);
+ return $this->createFrom(array_replace(array_flip($keys), $this->entries));
}
/**
@@ -436,9 +457,11 @@ abstract class AbstractIndexCollection implements CollectionInterface
*
* @param int $size Size of each chunk.
* @return array
+ * @phpstan-return array>
*/
public function chunk($size)
{
+ /** @phpstan-var array> */
return $this->loadCollection($this->entries)->chunk($size);
}
@@ -466,6 +489,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
*
* @return array
*/
+ #[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->loadCollection()->jsonSerialize();
diff --git a/system/src/Grav/Framework/Collection/AbstractLazyCollection.php b/system/src/Grav/Framework/Collection/AbstractLazyCollection.php
index 9afaab131..b0a93f514 100644
--- a/system/src/Grav/Framework/Collection/AbstractLazyCollection.php
+++ b/system/src/Grav/Framework/Collection/AbstractLazyCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Collection
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -22,11 +22,15 @@ use Doctrine\Common\Collections\AbstractLazyCollection as BaseAbstractLazyCollec
*/
abstract class AbstractLazyCollection extends BaseAbstractLazyCollection implements CollectionInterface
{
- /** @var ArrayCollection The backed collection to use */
+ /**
+ * @par ArrayCollection
+ * @phpstan-var ArrayCollection
+ */
protected $collection;
/**
* {@inheritDoc}
+ * @phpstan-return ArrayCollection
*/
public function reverse()
{
@@ -37,6 +41,7 @@ abstract class AbstractLazyCollection extends BaseAbstractLazyCollection impleme
/**
* {@inheritDoc}
+ * @phpstan-return ArrayCollection
*/
public function shuffle()
{
@@ -57,6 +62,8 @@ abstract class AbstractLazyCollection extends BaseAbstractLazyCollection impleme
/**
* {@inheritDoc}
+ * @phpstan-param array $keys
+ * @phpstan-return ArrayCollection
*/
public function select(array $keys)
{
@@ -67,6 +74,8 @@ abstract class AbstractLazyCollection extends BaseAbstractLazyCollection impleme
/**
* {@inheritDoc}
+ * @phpstan-param array $keys
+ * @phpstan-return ArrayCollection
*/
public function unselect(array $keys)
{
@@ -78,6 +87,7 @@ abstract class AbstractLazyCollection extends BaseAbstractLazyCollection impleme
/**
* @return array
*/
+ #[\ReturnTypeWillChange]
public function jsonSerialize()
{
$this->initialize();
diff --git a/system/src/Grav/Framework/Collection/ArrayCollection.php b/system/src/Grav/Framework/Collection/ArrayCollection.php
index d76aa05dc..cad02f26d 100644
--- a/system/src/Grav/Framework/Collection/ArrayCollection.php
+++ b/system/src/Grav/Framework/Collection/ArrayCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Collection
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -30,7 +30,10 @@ class ArrayCollection extends BaseArrayCollection implements CollectionInterface
*/
public function reverse()
{
- return $this->createFrom(array_reverse($this->toArray()));
+ $keys = array_reverse($this->toArray());
+
+ /** @phpstan-var static */
+ return $this->createFrom($keys);
}
/**
@@ -43,8 +46,10 @@ class ArrayCollection extends BaseArrayCollection implements CollectionInterface
{
$keys = $this->getKeys();
shuffle($keys);
+ $keys = array_replace(array_flip($keys), $this->toArray());
- return $this->createFrom(array_replace(array_flip($keys), $this->toArray()) ?? []);
+ /** @phpstan-var static */
+ return $this->createFrom($keys);
}
/**
@@ -52,9 +57,11 @@ class ArrayCollection extends BaseArrayCollection implements CollectionInterface
*
* @param int $size Size of each chunk.
* @return array
+ * @phpstan-return array>
*/
public function chunk($size)
{
+ /** @phpstan-var array> */
return array_chunk($this->toArray(), $size, true);
}
@@ -63,9 +70,9 @@ class ArrayCollection extends BaseArrayCollection implements CollectionInterface
*
* Collection is returned in the order of $keys given to the function.
*
- * @param array $keys
+ * @param array $keys
* @return static
- * @phpstan-param array $keys
+ * @phpstan-param TKey[] $keys
* @phpstan-return static
*/
public function select(array $keys)
@@ -77,6 +84,7 @@ class ArrayCollection extends BaseArrayCollection implements CollectionInterface
}
}
+ /** @phpstan-var static */
return $this->createFrom($list);
}
@@ -85,11 +93,15 @@ class ArrayCollection extends BaseArrayCollection implements CollectionInterface
*
* @param array $keys
* @return static
+ * @phpstan-param TKey[] $keys
* @phpstan-return static
*/
public function unselect(array $keys)
{
- return $this->select(array_diff($this->getKeys(), $keys));
+ $list = array_diff($this->getKeys(), $keys);
+
+ /** @phpstan-var static */
+ return $this->select($list);
}
/**
@@ -97,6 +109,7 @@ class ArrayCollection extends BaseArrayCollection implements CollectionInterface
*
* @return array
*/
+ #[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->toArray();
diff --git a/system/src/Grav/Framework/Collection/CollectionInterface.php b/system/src/Grav/Framework/Collection/CollectionInterface.php
index 0739109ba..e098dd6a1 100644
--- a/system/src/Grav/Framework/Collection/CollectionInterface.php
+++ b/system/src/Grav/Framework/Collection/CollectionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Collection
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -43,6 +43,7 @@ interface CollectionInterface extends Collection, JsonSerializable
*
* @param int $size Size of each chunk.
* @return array
+ * @phpstan-return array>
*/
public function chunk($size);
diff --git a/system/src/Grav/Framework/Collection/FileCollection.php b/system/src/Grav/Framework/Collection/FileCollection.php
index f7b4f258b..bae0e7b2f 100644
--- a/system/src/Grav/Framework/Collection/FileCollection.php
+++ b/system/src/Grav/Framework/Collection/FileCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Collection
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Collection/FileCollectionInterface.php b/system/src/Grav/Framework/Collection/FileCollectionInterface.php
index 45c446c63..1b56da953 100644
--- a/system/src/Grav/Framework/Collection/FileCollectionInterface.php
+++ b/system/src/Grav/Framework/Collection/FileCollectionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Collection
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Compat/Serializable.php b/system/src/Grav/Framework/Compat/Serializable.php
index 3c9bf6a08..22e4648d8 100644
--- a/system/src/Grav/Framework/Compat/Serializable.php
+++ b/system/src/Grav/Framework/Compat/Serializable.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Compat
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/ContentBlock/ContentBlock.php b/system/src/Grav/Framework/ContentBlock/ContentBlock.php
index efcd5f3fd..7259df090 100644
--- a/system/src/Grav/Framework/ContentBlock/ContentBlock.php
+++ b/system/src/Grav/Framework/ContentBlock/ContentBlock.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\ContentBlock
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -161,6 +161,7 @@ class ContentBlock implements ContentBlockInterface
/**
* @return string
*/
+ #[\ReturnTypeWillChange]
public function __toString()
{
try {
diff --git a/system/src/Grav/Framework/ContentBlock/ContentBlockInterface.php b/system/src/Grav/Framework/ContentBlock/ContentBlockInterface.php
index fb445a398..bb0e46f8f 100644
--- a/system/src/Grav/Framework/ContentBlock/ContentBlockInterface.php
+++ b/system/src/Grav/Framework/ContentBlock/ContentBlockInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\ContentBlock
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/ContentBlock/HtmlBlock.php b/system/src/Grav/Framework/ContentBlock/HtmlBlock.php
index 5c5eb4342..734d5077f 100644
--- a/system/src/Grav/Framework/ContentBlock/HtmlBlock.php
+++ b/system/src/Grav/Framework/ContentBlock/HtmlBlock.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\ContentBlock
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/ContentBlock/HtmlBlockInterface.php b/system/src/Grav/Framework/ContentBlock/HtmlBlockInterface.php
index 616e4a2cc..686127f45 100644
--- a/system/src/Grav/Framework/ContentBlock/HtmlBlockInterface.php
+++ b/system/src/Grav/Framework/ContentBlock/HtmlBlockInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\ContentBlock
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php b/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php
index afa08aa42..efd9c7dbd 100644
--- a/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php
+++ b/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Controller
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -140,9 +140,9 @@ trait ControllerResponseTrait
$code = (int)$this->getConfig()->get('system.pages.redirect_default_code', 302);
}
+ $ext = pathinfo($url, PATHINFO_EXTENSION);
$accept = $this->getAccept(['application/json', 'text/html']);
-
- if ($accept === 'application/json') {
+ if ($ext === 'json' || $accept === 'application/json') {
return $this->createJsonResponse(['code' => $code, 'status' => 'redirect', 'redirect' => $url]);
}
@@ -217,6 +217,7 @@ trait ControllerResponseTrait
'code' => $code,
'status' => 'error',
'message' => $message,
+ 'redirect' => null,
'error' => [
'code' => $code,
'message' => $message
diff --git a/system/src/Grav/Framework/DI/Container.php b/system/src/Grav/Framework/DI/Container.php
index 76434a36a..dde0da3ca 100644
--- a/system/src/Grav/Framework/DI/Container.php
+++ b/system/src/Grav/Framework/DI/Container.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\DI
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/AbstractFile.php b/system/src/Grav/Framework/File/AbstractFile.php
index b82bb33d2..b216ea6c8 100644
--- a/system/src/Grav/Framework/File/AbstractFile.php
+++ b/system/src/Grav/Framework/File/AbstractFile.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -55,6 +55,7 @@ class AbstractFile implements FileInterface
/**
* Unlock file when the object gets destroyed.
*/
+ #[\ReturnTypeWillChange]
public function __destruct()
{
if ($this->isLocked()) {
@@ -65,6 +66,7 @@ class AbstractFile implements FileInterface
/**
* @return void
*/
+ #[\ReturnTypeWillChange]
public function __clone()
{
$this->handle = null;
@@ -191,15 +193,16 @@ class AbstractFile implements FileInterface
$this->handle = @fopen($this->filepath, 'cb+') ?: null;
if (!$this->handle) {
$error = error_get_last();
+ $message = $error['message'] ?? 'Unknown error';
- throw new RuntimeException("Opening file for writing failed on error {$error['message']}");
+ throw new RuntimeException("Opening file for writing failed on error {$message}");
}
}
$lock = $block ? LOCK_EX : LOCK_EX | LOCK_NB;
// Some filesystems do not support file locks, only fail if another process holds the lock.
- $this->locked = flock($this->handle, $lock, $wouldblock) || !$wouldblock;
+ $this->locked = flock($this->handle, $lock, $wouldBlock) || !$wouldBlock;
return $this->locked;
}
diff --git a/system/src/Grav/Framework/File/CsvFile.php b/system/src/Grav/Framework/File/CsvFile.php
index 999f88a52..7eba91e88 100644
--- a/system/src/Grav/Framework/File/CsvFile.php
+++ b/system/src/Grav/Framework/File/CsvFile.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -28,4 +28,13 @@ class CsvFile extends DataFile
{
parent::__construct($filepath, $formatter);
}
+
+ /**
+ * @return array
+ */
+ public function load(): array
+ {
+ /** @var array */
+ return parent::load();
+ }
}
diff --git a/system/src/Grav/Framework/File/DataFile.php b/system/src/Grav/Framework/File/DataFile.php
index 114146f94..189db53de 100644
--- a/system/src/Grav/Framework/File/DataFile.php
+++ b/system/src/Grav/Framework/File/DataFile.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/File.php b/system/src/Grav/Framework/File/File.php
index 1d4055aec..b1a1c4f67 100644
--- a/system/src/Grav/Framework/File/File.php
+++ b/system/src/Grav/Framework/File/File.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -20,15 +20,6 @@ use function is_string;
*/
class File extends AbstractFile
{
- /**
- * {@inheritdoc}
- * @see FileInterface::load()
- */
- public function load()
- {
- return parent::load();
- }
-
/**
* {@inheritdoc}
* @see FileInterface::save()
diff --git a/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php b/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php
index f5ff3f24a..6a6981bc0 100644
--- a/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File\Formatter
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/Formatter/CsvFormatter.php b/system/src/Grav/Framework/File/Formatter/CsvFormatter.php
index 9d0a9a882..37ab5bb25 100644
--- a/system/src/Grav/Framework/File/Formatter/CsvFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/CsvFormatter.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File\Formatter
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -16,6 +16,7 @@ use Grav\Framework\File\Interfaces\FileFormatterInterface;
use JsonSerializable;
use RuntimeException;
use stdClass;
+use function count;
use function is_array;
use function is_object;
use function is_scalar;
diff --git a/system/src/Grav/Framework/File/Formatter/IniFormatter.php b/system/src/Grav/Framework/File/Formatter/IniFormatter.php
index ec169598e..ecf67d1f2 100644
--- a/system/src/Grav/Framework/File/Formatter/IniFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/IniFormatter.php
@@ -5,13 +5,14 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File\Formatter
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\File\Formatter;
use Grav\Framework\File\Interfaces\FileFormatterInterface;
+use RuntimeException;
/**
* Class IniFormatter
@@ -59,7 +60,7 @@ class IniFormatter extends AbstractFormatter
$decoded = @parse_ini_string($data);
if ($decoded === false) {
- throw new \RuntimeException('Decoding INI failed');
+ throw new RuntimeException('Decoding INI failed');
}
return $decoded;
diff --git a/system/src/Grav/Framework/File/Formatter/JsonFormatter.php b/system/src/Grav/Framework/File/Formatter/JsonFormatter.php
index 6b19690c3..2bd6c79ad 100644
--- a/system/src/Grav/Framework/File/Formatter/JsonFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/JsonFormatter.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File\Formatter
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -75,9 +75,11 @@ class JsonFormatter extends AbstractFormatter
if (is_string($options)) {
$list = preg_split('/[\s,|]+/', $options);
$options = 0;
- foreach ($list as $option) {
- if (isset($this->encodeOptions[$option])) {
- $options += $this->encodeOptions[$option];
+ if ($list) {
+ foreach ($list as $option) {
+ if (isset($this->encodeOptions[$option])) {
+ $options += $this->encodeOptions[$option];
+ }
}
}
} else {
@@ -100,9 +102,11 @@ class JsonFormatter extends AbstractFormatter
if (is_string($options)) {
$list = preg_split('/[\s,|]+/', $options);
$options = 0;
- foreach ($list as $option) {
- if (isset($this->decodeOptions[$option])) {
- $options += $this->decodeOptions[$option];
+ if ($list) {
+ foreach ($list as $option) {
+ if (isset($this->decodeOptions[$option])) {
+ $options += $this->decodeOptions[$option];
+ }
}
}
} else {
@@ -117,6 +121,7 @@ class JsonFormatter extends AbstractFormatter
* Returns recursion depth used in decode() function.
*
* @return int
+ * @phpstan-return positive-int
*/
public function getDecodeDepth(): int
{
diff --git a/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php b/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php
index 8a624df55..e36276a81 100644
--- a/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php
@@ -5,13 +5,14 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File\Formatter
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\File\Formatter;
use Grav\Framework\File\Interfaces\FileFormatterInterface;
+use RuntimeException;
/**
* Class MarkdownFormatter
@@ -99,7 +100,7 @@ class MarkdownFormatter extends AbstractFormatter
// Normalize line endings to Unix style.
$encoded = preg_replace("/(\r\n|\r)/u", "\n", $encoded);
if (null === $encoded) {
- throw new \RuntimeException('Encoding markdown failed');
+ throw new RuntimeException('Encoding markdown failed');
}
return $encoded;
@@ -126,7 +127,7 @@ class MarkdownFormatter extends AbstractFormatter
// Normalize line endings to Unix style.
$data = preg_replace("/(\r\n|\r)/u", "\n", $data);
if (null === $data) {
- throw new \RuntimeException('Decoding markdown failed');
+ throw new RuntimeException('Decoding markdown failed');
}
// Parse header.
diff --git a/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php b/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php
index f045d71e3..25aee813b 100644
--- a/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File\Formatter
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/Formatter/YamlFormatter.php b/system/src/Grav/Framework/File/Formatter/YamlFormatter.php
index 32d4d296a..31aff2c67 100644
--- a/system/src/Grav/Framework/File/Formatter/YamlFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/YamlFormatter.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File\Formatter
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -107,7 +107,9 @@ class YamlFormatter extends AbstractFormatter
$saved = @ini_get('yaml.decode_php');
@ini_set('yaml.decode_php', '0');
$decoded = @yaml_parse($data);
- @ini_set('yaml.decode_php', $saved);
+ if ($saved !== false) {
+ @ini_set('yaml.decode_php', $saved);
+ }
if ($decoded !== false) {
return (array) $decoded;
diff --git a/system/src/Grav/Framework/File/IniFile.php b/system/src/Grav/Framework/File/IniFile.php
index 6cda6096c..0807ee3c2 100644
--- a/system/src/Grav/Framework/File/IniFile.php
+++ b/system/src/Grav/Framework/File/IniFile.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -28,4 +28,13 @@ class IniFile extends DataFile
{
parent::__construct($filepath, $formatter);
}
+
+ /**
+ * @return array
+ */
+ public function load(): array
+ {
+ /** @var array */
+ return parent::load();
+ }
}
diff --git a/system/src/Grav/Framework/File/Interfaces/FileFormatterInterface.php b/system/src/Grav/Framework/File/Interfaces/FileFormatterInterface.php
index 49eda4f1d..78714af7e 100644
--- a/system/src/Grav/Framework/File/Interfaces/FileFormatterInterface.php
+++ b/system/src/Grav/Framework/File/Interfaces/FileFormatterInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/Interfaces/FileInterface.php b/system/src/Grav/Framework/File/Interfaces/FileInterface.php
index 015b1ada2..f2cc288a9 100644
--- a/system/src/Grav/Framework/File/Interfaces/FileInterface.php
+++ b/system/src/Grav/Framework/File/Interfaces/FileInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/JsonFile.php b/system/src/Grav/Framework/File/JsonFile.php
index f3b0902c8..7751e84d6 100644
--- a/system/src/Grav/Framework/File/JsonFile.php
+++ b/system/src/Grav/Framework/File/JsonFile.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/MarkdownFile.php b/system/src/Grav/Framework/File/MarkdownFile.php
index 4ae3aa0de..a79d5ce77 100644
--- a/system/src/Grav/Framework/File/MarkdownFile.php
+++ b/system/src/Grav/Framework/File/MarkdownFile.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -28,4 +28,13 @@ class MarkdownFile extends DataFile
{
parent::__construct($filepath, $formatter);
}
+
+ /**
+ * @return array
+ */
+ public function load(): array
+ {
+ /** @var array */
+ return parent::load();
+ }
}
diff --git a/system/src/Grav/Framework/File/YamlFile.php b/system/src/Grav/Framework/File/YamlFile.php
index 29224ce78..c4300ade5 100644
--- a/system/src/Grav/Framework/File/YamlFile.php
+++ b/system/src/Grav/Framework/File/YamlFile.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -28,4 +28,13 @@ class YamlFile extends DataFile
{
parent::__construct($filepath, $formatter);
}
+
+ /**
+ * @return array
+ */
+ public function load(): array
+ {
+ /** @var array */
+ return parent::load();
+ }
}
diff --git a/system/src/Grav/Framework/Filesystem/Filesystem.php b/system/src/Grav/Framework/Filesystem/Filesystem.php
index 9b077d780..5000b6996 100644
--- a/system/src/Grav/Framework/Filesystem/Filesystem.php
+++ b/system/src/Grav/Framework/Filesystem/Filesystem.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Filesystem
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -176,6 +176,7 @@ class Filesystem implements FilesystemInterface
* @param string $path
* @param int $levels
* @return string
+ * @phpstan-param positive-int $levels
*/
public function pathname(string $path, int $levels = 1): string
{
@@ -204,6 +205,7 @@ class Filesystem implements FilesystemInterface
* @param string $path
* @param int $levels
* @return array
+ * @phpstan-param positive-int $levels
*/
protected function dirnameInternal(?string $scheme, string $path, int $levels = 1): array
{
@@ -237,12 +239,14 @@ class Filesystem implements FilesystemInterface
if (null !== $scheme) {
$info['scheme'] = $scheme;
- $dirname = isset($info['dirname']) && $info['dirname'] !== '.' ? $info['dirname'] : null;
- if (null !== $dirname) {
+ /** @phpstan-ignore-next-line because pathinfo('') doesn't have dirname */
+ $dirname = $info['dirname'] ?? '.';
+
+ if ('' !== $dirname && '.' !== $dirname) {
// In Windows dirname may be using backslashes, fix that.
if (DIRECTORY_SEPARATOR !== '/') {
- $dirname = str_replace('\\', '/', $dirname);
+ $dirname = str_replace(DIRECTORY_SEPARATOR, '/', $dirname);
}
$info['dirname'] = $scheme . '://' . $dirname;
diff --git a/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php b/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php
index 0e280a837..fa1000941 100644
--- a/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php
+++ b/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Filesystem
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -31,6 +31,7 @@ interface FilesystemInterface
* @param int $levels The number of parent directories to go up (>= 1).
* @return string Returns parent path.
* @throws RuntimeException
+ * @phpstan-param positive-int $levels
* @api
*/
public function parent(string $path, int $levels = 1): string;
@@ -64,6 +65,7 @@ interface FilesystemInterface
* @param int $levels The number of parent directories to go up (>= 1).
* @return string Returns path to the directory.
* @throws RuntimeException
+ * @phpstan-param positive-int $levels
* @api
*/
public function dirname(string $path, int $levels = 1): string;
diff --git a/system/src/Grav/Framework/Flex/Flex.php b/system/src/Grav/Framework/Flex/Flex.php
index ce285215c..4d662d192 100644
--- a/system/src/Grav/Framework/Flex/Flex.php
+++ b/system/src/Grav/Framework/Flex/Flex.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -62,7 +62,7 @@ class Flex implements FlexInterface
*/
public function addDirectoryType(string $type, string $blueprint, array $config = [])
{
- $config = array_replace_recursive(['enabled' => true], $this->config ?? [], $config);
+ $config = array_replace_recursive(['enabled' => true], $this->config, $config);
$this->types[$type] = new FlexDirectory($type, $blueprint, $config);
@@ -123,6 +123,7 @@ class Flex implements FlexInterface
* @param array|null $keys
* @param string|null $keyField
* @return FlexCollectionInterface|null
+ * @phpstan-return FlexCollectionInterface|null
*/
public function getCollection(string $type, array $keys = null, string $keyField = null): ?FlexCollectionInterface
{
@@ -137,11 +138,12 @@ class Flex implements FlexInterface
* collection_class: Class to be used to create the collection. Defaults to ObjectCollection.
* @return FlexCollectionInterface
* @throws RuntimeException
+ * @phpstan-return FlexCollectionInterface
*/
public function getMixedCollection(array $keys, array $options = []): FlexCollectionInterface
{
$collectionClass = $options['collection_class'] ?? ObjectCollection::class;
- if (!class_exists($collectionClass)) {
+ if (!is_a($collectionClass, FlexCollectionInterface::class, true)) {
throw new RuntimeException(sprintf('Cannot create collection: Class %s does not exist', $collectionClass));
}
@@ -231,7 +233,7 @@ class Flex implements FlexInterface
// Use the original key ordering.
if (!$guessed) {
- $list = array_replace(array_fill_keys($keys, null), $list) ?? [];
+ $list = array_replace(array_fill_keys($keys, null), $list);
} else {
// We have mixed keys, we need to map flex keys back to storage keys.
$results = [];
diff --git a/system/src/Grav/Framework/Flex/FlexCollection.php b/system/src/Grav/Framework/Flex/FlexCollection.php
index 54e06654a..186c60abc 100644
--- a/system/src/Grav/Framework/Flex/FlexCollection.php
+++ b/system/src/Grav/Framework/Flex/FlexCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -19,6 +19,7 @@ use Grav\Common\User\Interfaces\UserInterface;
use Grav\Common\Utils;
use Grav\Framework\Cache\CacheInterface;
use Grav\Framework\ContentBlock\HtmlBlock;
+use Grav\Framework\Flex\Interfaces\FlexIndexInterface;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
use Grav\Framework\Object\ObjectCollection;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
@@ -47,7 +48,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
private $_flexDirectory;
/** @var string */
- private $_keyField;
+ private $_keyField = 'storage_key';
/**
* Get list of cached methods.
@@ -124,6 +125,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
*/
public function getFlexFeatures(): array
{
+ /** @var array $implements */
$implements = class_implements($this);
$list = [];
@@ -152,7 +154,11 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
arsort($matching, SORT_NUMERIC);
}
- return $this->select(array_keys($matching));
+ /** @var string[] $array */
+ $array = array_keys($matching);
+
+ /** @phpstan-var static */
+ return $this->select($array);
}
/**
@@ -163,7 +169,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
{
$criteria = Criteria::create()->orderBy($order);
- /** @var FlexCollectionInterface $matching */
+ /** @phpstan-var FlexCollectionInterface $matching */
$matching = $this->matching($criteria);
return $matching;
@@ -171,7 +177,8 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
/**
* @param array $filters
- * @return FlexCollectionInterface|Collection
+ * @return static
+ * @phpstan-return static
*/
public function filterBy(array $filters)
{
@@ -182,6 +189,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
$criteria->andWhere($expr->eq($key, $value));
}
+ /** @phpstan-var static */
return $this->matching($criteria);
}
@@ -336,6 +344,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
*/
public function getIndex()
{
+ /** @phpstan-var FlexIndexInterface */
return $this->getFlexDirectory()->getIndex($this->getKeys(), $this->getKeyField());
}
@@ -460,7 +469,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
* @param string $key
* @return array
*/
- public function getMetaData(string $key): array
+ public function getMetaData($key): array
{
$object = $this->get($key);
@@ -481,7 +490,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
*/
public function getKeyField(): string
{
- return $this->_keyField ?? 'storage_key';
+ return $this->_keyField;
}
/**
@@ -496,13 +505,18 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
$list = $this->call('isAuthorized', [$action, $scope, $user]);
$list = array_filter($list);
- return $this->select(array_keys($list));
+ /** @var string[] $keys */
+ $keys = array_keys($list);
+
+ /** @phpstan-var static */
+ return $this->select($keys);
}
/**
* @param string $value
* @param string $field
- * @return T|null
+ * @return FlexObjectInterface|null
+ * @phpstan-return T|null
*/
public function find($value, $field = 'id')
{
@@ -520,6 +534,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
/**
* @return array
*/
+ #[\ReturnTypeWillChange]
public function jsonSerialize()
{
$elements = [];
@@ -538,6 +553,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
/**
* @return array
*/
+ #[\ReturnTypeWillChange]
public function __debugInfo()
{
return [
diff --git a/system/src/Grav/Framework/Flex/FlexDirectory.php b/system/src/Grav/Framework/Flex/FlexDirectory.php
index 29f1490f8..f96633b31 100644
--- a/system/src/Grav/Framework/Flex/FlexDirectory.php
+++ b/system/src/Grav/Framework/Flex/FlexDirectory.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -21,7 +21,7 @@ use Grav\Common\Utils;
use Grav\Framework\Cache\Adapter\DoctrineCache;
use Grav\Framework\Cache\Adapter\MemoryCache;
use Grav\Framework\Cache\CacheInterface;
-use Grav\Framework\Flex\Interfaces\FlexAuthorizeInterface;
+use Grav\Framework\Filesystem\Filesystem;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexDirectoryInterface;
use Grav\Framework\Flex\Interfaces\FlexFormInterface;
@@ -45,7 +45,6 @@ use function is_callable;
/**
* Class FlexDirectory
* @package Grav\Framework\Flex
- * @template T
*/
class FlexDirectory implements FlexDirectoryInterface
{
@@ -57,9 +56,15 @@ class FlexDirectory implements FlexDirectoryInterface
protected $blueprint_file;
/** @var Blueprint[] */
protected $blueprints;
- /** @var FlexIndexInterface[] */
+ /**
+ * @var FlexIndexInterface[]
+ * @phpstan-var FlexIndexInterface[]
+ */
protected $indexes = [];
- /** @var FlexCollectionInterface|null */
+ /**
+ * @var FlexCollectionInterface|null
+ * @phpstan-var FlexCollectionInterface|null
+ */
protected $collection;
/** @var bool */
protected $enabled;
@@ -213,8 +218,17 @@ class FlexDirectory implements FlexDirectoryInterface
/** @var UniformResourceLocator $locator */
$locator = $grav['locator'];
- /** @var string $filename Filename is always string */
- $filename = $locator->findResource($this->getDirectoryConfigUri($name), true, true);
+
+ $filename = $this->getDirectoryConfigUri($name);
+ if (file_exists($filename)) {
+ $filename = $locator->findResource($filename, true);
+ } else {
+ $filesystem = Filesystem::getInstance();
+ $dirname = $filesystem->dirname($filename);
+ $basename = $filesystem->basename($filename);
+ $dirname = $locator->findResource($dirname, true) ?: $locator->findResource($dirname, true, true);
+ $filename = "{$dirname}/{$basename}";
+ }
$file = YamlFile::instance($filename);
if (!empty($data)) {
@@ -318,7 +332,7 @@ class FlexDirectory implements FlexDirectoryInterface
* @param array|null $keys Array of keys.
* @param string|null $keyField Field to be used as the key.
* @return FlexCollectionInterface
- * @phpstan-return FlexCollectionInterface
+ * @phpstan-return FlexCollectionInterface
*/
public function getCollection(array $keys = null, string $keyField = null): FlexCollectionInterface
{
@@ -345,6 +359,7 @@ class FlexDirectory implements FlexDirectoryInterface
* @param array|null $keys Array of keys.
* @param string|null $keyField Field to be used as the key.
* @return FlexIndexInterface
+ * @phpstan-return FlexIndexInterface
*/
public function getIndex(array $keys = null, string $keyField = null): FlexIndexInterface
{
@@ -353,7 +368,7 @@ class FlexDirectory implements FlexDirectoryInterface
$index = clone $index;
if (null !== $keys) {
- /** @var FlexIndexInterface $index */
+ /** @var FlexIndexInterface $index */
$index = $index->select($keys);
}
@@ -487,8 +502,11 @@ class FlexDirectory implements FlexDirectoryInterface
*/
public function createObject(array $data, string $key = '', bool $validate = false): FlexObjectInterface
{
- /** @var string|FlexObjectInterface $className */
+ /** @phpstan-var class-string $className */
$className = $this->objectClassName ?: $this->getObjectClass();
+ if (!is_a($className, FlexObjectInterface::class, true)) {
+ throw new \RuntimeException('Bad object class: ' . $className);
+ }
return new $className($data, $key, $this, $validate);
}
@@ -497,11 +515,15 @@ class FlexDirectory implements FlexDirectoryInterface
* @param array $entries
* @param string|null $keyField
* @return FlexCollectionInterface
+ * @phpstan-return FlexCollectionInterface
*/
public function createCollection(array $entries, string $keyField = null): FlexCollectionInterface
{
- /** @var string|FlexCollectionInterface $className */
+ /** phpstan-var class-string $className */
$className = $this->collectionClassName ?: $this->getCollectionClass();
+ if (!is_a($className, FlexCollectionInterface::class, true)) {
+ throw new \RuntimeException('Bad collection class: ' . $className);
+ }
return $className::createFromArray($entries, $this, $keyField);
}
@@ -510,11 +532,15 @@ class FlexDirectory implements FlexDirectoryInterface
* @param array $entries
* @param string|null $keyField
* @return FlexIndexInterface
+ * @phpstan-return FlexIndexInterface
*/
public function createIndex(array $entries, string $keyField = null): FlexIndexInterface
{
- /** @var string|FlexIndexInterface $className */
+ /** @phpstan-var class-string $className */
$className = $this->indexClassName ?: $this->getIndexClass();
+ if (!is_a($className, FlexIndexInterface::class, true)) {
+ throw new \RuntimeException('Bad index class: ' . $className);
+ }
return $className::createFromArray($entries, $this, $keyField);
}
@@ -560,6 +586,7 @@ class FlexDirectory implements FlexDirectoryInterface
* @param array $entries
* @param string|null $keyField
* @return FlexCollectionInterface
+ * @phpstan-return FlexCollectionInterface
*/
public function loadCollection(array $entries, string $keyField = null): FlexCollectionInterface
{
@@ -889,12 +916,17 @@ class FlexDirectory implements FlexDirectoryInterface
$className = $storage['class'] ?? SimpleStorage::class;
$options = $storage['options'] ?? [];
+ if (!is_a($className, FlexStorageInterface::class, true)) {
+ throw new \RuntimeException('Bad storage class: ' . $className);
+ }
+
return new $className($options);
}
/**
* @param string $keyField
* @return FlexIndexInterface
+ * @phpstan-return FlexIndexInterface
*/
protected function loadIndex(string $keyField): FlexIndexInterface
{
@@ -924,7 +956,7 @@ class FlexDirectory implements FlexDirectoryInterface
}
if (!is_array($keys)) {
- /** @var string|FlexIndexInterface $className */
+ /** @phpstan-var class-string $className */
$className = $this->getIndexClass();
$keys = $className::loadEntriesFromStorage($storage);
if (!$cache instanceof MemoryCache) {
@@ -946,7 +978,7 @@ class FlexDirectory implements FlexDirectoryInterface
// We need to do this in two steps as orderBy() calls loadIndex() again and we do not want infinite loop.
$this->indexes['storage_key'] = $index = $this->createIndex($keys, 'storage_key');
if ($ordering) {
- /** @var FlexCollectionInterface $collection */
+ /** @var FlexCollectionInterface $collection */
$collection = $this->indexes['storage_key']->orderBy($ordering);
$this->indexes['storage_key'] = $index = $collection->getIndex();
}
@@ -1035,7 +1067,9 @@ class FlexDirectory implements FlexDirectoryInterface
$newKey = $object->getStorageKey();
if ($oldKey !== $newKey) {
- $object->triggerEvent('move');
+ if (method_exists($object, 'triggerEvent')) {
+ $object->triggerEvent('move');
+ }
$storage->renameRow($oldKey, $newKey);
// TODO: media support.
}
diff --git a/system/src/Grav/Framework/Flex/FlexDirectoryForm.php b/system/src/Grav/Framework/Flex/FlexDirectoryForm.php
index 8d608fdf8..709f41891 100644
--- a/system/src/Grav/Framework/Flex/FlexDirectoryForm.php
+++ b/system/src/Grav/Framework/Flex/FlexDirectoryForm.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -358,6 +358,7 @@ class FlexDirectoryForm implements FlexDirectoryFormInterface, JsonSerializable
* @param string $name
* @return mixed|null
*/
+ #[\ReturnTypeWillChange]
public function __get($name)
{
$method = "get{$name}";
@@ -375,6 +376,7 @@ class FlexDirectoryForm implements FlexDirectoryFormInterface, JsonSerializable
* @param mixed $value
* @return void
*/
+ #[\ReturnTypeWillChange]
public function __set($name, $value)
{
$method = "set{$name}";
@@ -387,6 +389,7 @@ class FlexDirectoryForm implements FlexDirectoryFormInterface, JsonSerializable
* @param string $name
* @return bool
*/
+ #[\ReturnTypeWillChange]
public function __isset($name)
{
$method = "get{$name}";
@@ -403,6 +406,7 @@ class FlexDirectoryForm implements FlexDirectoryFormInterface, JsonSerializable
* @param string $name
* @return void
*/
+ #[\ReturnTypeWillChange]
public function __unset($name)
{
}
@@ -493,6 +497,7 @@ class FlexDirectoryForm implements FlexDirectoryFormInterface, JsonSerializable
* Filter validated data.
*
* @param ArrayAccess|Data|null $data
+ * @phpstan-param ArrayAccess|Data|null $data
*/
protected function filterData($data = null): void
{
diff --git a/system/src/Grav/Framework/Flex/FlexForm.php b/system/src/Grav/Framework/Flex/FlexForm.php
index d25cefc40..a1263f67f 100644
--- a/system/src/Grav/Framework/Flex/FlexForm.php
+++ b/system/src/Grav/Framework/Flex/FlexForm.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -444,6 +444,7 @@ class FlexForm implements FlexObjectFormInterface, JsonSerializable
* @param string $name
* @return mixed|null
*/
+ #[\ReturnTypeWillChange]
public function __get($name)
{
$method = "get{$name}";
@@ -461,6 +462,7 @@ class FlexForm implements FlexObjectFormInterface, JsonSerializable
* @param mixed $value
* @return void
*/
+ #[\ReturnTypeWillChange]
public function __set($name, $value)
{
$method = "set{$name}";
@@ -473,6 +475,7 @@ class FlexForm implements FlexObjectFormInterface, JsonSerializable
* @param string $name
* @return bool
*/
+ #[\ReturnTypeWillChange]
public function __isset($name)
{
$method = "get{$name}";
@@ -489,6 +492,7 @@ class FlexForm implements FlexObjectFormInterface, JsonSerializable
* @param string $name
* @return void
*/
+ #[\ReturnTypeWillChange]
public function __unset($name)
{
}
@@ -594,6 +598,7 @@ class FlexForm implements FlexObjectFormInterface, JsonSerializable
*
* @param ArrayAccess|Data|null $data
* @return void
+ * @phpstan-param ArrayAccess|Data|null $data
*/
protected function filterData($data = null): void
{
diff --git a/system/src/Grav/Framework/Flex/FlexFormFlash.php b/system/src/Grav/Framework/Flex/FlexFormFlash.php
index feb7a9ee9..3f52cdb6f 100644
--- a/system/src/Grav/Framework/Flex/FlexFormFlash.php
+++ b/system/src/Grav/Framework/Flex/FlexFormFlash.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/FlexIndex.php b/system/src/Grav/Framework/Flex/FlexIndex.php
index 3ce0a46c4..54438af51 100644
--- a/system/src/Grav/Framework/Flex/FlexIndex.php
+++ b/system/src/Grav/Framework/Flex/FlexIndex.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -11,6 +11,7 @@ namespace Grav\Framework\Flex;
use Exception;
use Grav\Common\Debugger;
+use Grav\Common\File\CompiledJsonFile;
use Grav\Common\File\CompiledYamlFile;
use Grav\Common\Grav;
use Grav\Common\Inflector;
@@ -39,14 +40,14 @@ use function in_array;
* @implements FlexIndexInterface
* @mixin C
*/
-class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexIndexInterface
+class FlexIndex extends ObjectIndex implements FlexIndexInterface
{
const VERSION = 1;
/** @var FlexDirectory|null */
private $_flexDirectory;
/** @var string */
- private $_keyField;
+ private $_keyField = 'storage_key';
/** @var array */
private $_indexKeys;
@@ -117,6 +118,14 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
$this->setKeyField(null);
}
+ /**
+ * @return string
+ */
+ public function getKey()
+ {
+ return $this->_key ?: $this->getFlexType() . '@@' . spl_object_hash($this);
+ }
+
/**
* {@inheritdoc}
* @see FlexCommonInterface::hasFlexFeature()
@@ -132,6 +141,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
*/
public function getFlexFeatures(): array
{
+ /** @var array $implements */
$implements = class_implements($this->getFlexDirectory()->getCollectionClass());
$list = [];
@@ -164,7 +174,6 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
return $this->orderBy($orderings);
}
-
/**
* {@inheritdoc}
* @see FlexCollectionInterface::filterBy()
@@ -353,7 +362,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
*/
public function getKeyField(): string
{
- return $this->_keyField ?? 'storage_key';
+ return $this->_keyField;
}
/**
@@ -416,7 +425,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
$previous = $search;
}
- return $this->createFrom(array_replace($previous ?? [], $this->getEntries()) ?? []);
+ return $this->createFrom(array_replace($previous ?? [], $this->getEntries()));
}
/**
@@ -432,12 +441,13 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
* @param array $arguments
* @return mixed
*/
+ #[\ReturnTypeWillChange]
public function __call($name, $arguments)
{
/** @var Debugger $debugger */
$debugger = Grav::instance()['debugger'];
- /** @var FlexCollection $className */
+ /** @phpstan-var class-string $className */
$className = $this->getFlexDirectory()->getCollectionClass();
$cachedMethods = $className::getCachedMethods();
@@ -492,9 +502,13 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
}
} else {
$collection = $this->loadCollection();
- $result = $collection->{$name}(...$arguments);
- if (!isset($cachedMethods[$name])) {
- $debugger->addMessage("Call '{$flexType}:{$name}()' isn't cached", 'debug');
+ if (\is_callable([$collection, $name])) {
+ $result = $collection->{$name}(...$arguments);
+ if (!isset($cachedMethods[$name])) {
+ $debugger->addMessage("Call '{$flexType}:{$name}()' isn't cached", 'debug');
+ }
+ } else {
+ $result = null;
}
}
@@ -522,6 +536,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
/**
* @return array
*/
+ #[\ReturnTypeWillChange]
public function __debugInfo()
{
return [
@@ -607,9 +622,11 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
* @param string $key
* @param mixed $value
* @return ObjectInterface|null
+ * @phpstan-return T|null
*/
protected function loadElement($key, $value): ?ObjectInterface
{
+ /** @phpstan-var T[] $objects */
$objects = $this->getFlexDirectory()->loadObjects([$key => $value]);
return $objects ? reset($objects): null;
@@ -618,10 +635,14 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
/**
* @param array|null $entries
* @return ObjectInterface[]
+ * @phpstan-return T[]
*/
protected function loadElements(array $entries = null): array
{
- return $this->getFlexDirectory()->loadObjects($entries ?? $this->getEntries());
+ /** @phpstan-var T[] $objects */
+ $objects = $this->getFlexDirectory()->loadObjects($entries ?? $this->getEntries());
+
+ return $objects;
}
/**
@@ -824,7 +845,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
/**
* @param FlexStorageInterface $storage
- * @return CompiledYamlFile|null
+ * @return CompiledYamlFile|CompiledJsonFile|null
*/
protected static function getIndexFile(FlexStorageInterface $storage)
{
diff --git a/system/src/Grav/Framework/Flex/FlexObject.php b/system/src/Grav/Framework/Flex/FlexObject.php
index ac51b3461..afc656c04 100644
--- a/system/src/Grav/Framework/Flex/FlexObject.php
+++ b/system/src/Grav/Framework/Flex/FlexObject.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -69,13 +69,13 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
private $_forms = [];
/** @var Blueprint[] */
private $_blueprint = [];
- /** @var array */
+ /** @var array|null */
private $_meta;
- /** @var array */
+ /** @var array|null */
protected $_original;
- /** @var string */
+ /** @var string|null */
protected $storage_key;
- /** @var int */
+ /** @var int|null */
protected $storage_timestamp;
/**
@@ -163,6 +163,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
*/
public function getFlexFeatures(): array
{
+ /** @var array $implements */
$implements = class_implements($this);
$list = [];
@@ -656,6 +657,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
/**
* @return array
*/
+ #[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->getElements();
@@ -775,7 +777,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
$value = reset($result);
$meta = $value['__META'] ?? null;
if ($meta) {
- /** @var FlexIndex $indexClass */
+ /** @phpstan-var class-string $indexClass */
$indexClass = $this->getFlexDirectory()->getIndexClass();
$indexClass::updateObjectMeta($meta, $value, $storage);
$this->_meta = $meta;
@@ -887,8 +889,8 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
public function getDefaultValue(string $name, string $separator = null)
{
$separator = $separator ?: '.';
- $path = explode($separator, $name) ?: [];
- $offset = array_shift($path) ?? '';
+ $path = explode($separator, $name);
+ $offset = array_shift($path);
$current = $this->getDefaultValues();
@@ -950,6 +952,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
*
* @return string
*/
+ #[\ReturnTypeWillChange]
public function __toString()
{
return $this->getFlexKey();
@@ -958,6 +961,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
/**
* @return array
*/
+ #[\ReturnTypeWillChange]
public function __debugInfo()
{
return [
@@ -973,6 +977,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
/**
* Clone object.
*/
+ #[\ReturnTypeWillChange]
public function __clone()
{
// Allows future compatibility as parent::__clone() works.
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php
index 102dbf4a7..c1025a4b7 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexCollectionInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexCollectionInterface.php
index 16be3d5d6..d14b69f40 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexCollectionInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexCollectionInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -140,5 +140,5 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
* @param string $key Key.
* @return array
*/
- public function getMetaData(string $key): array;
+ public function getMetaData($key): array;
}
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php
index ed045e25f..7c1975f21 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryFormInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryFormInterface.php
index df6f7d6a6..203c76603 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryFormInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryFormInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryInterface.php
index 07eab014a..a77df958f 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -105,6 +105,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface
* @param array|null $keys Array of keys.
* @param string|null $keyField Field to be used as the key.
* @return FlexCollectionInterface
+ * @phpstan-return FlexCollectionInterface
*/
public function getCollection(array $keys = null, string $keyField = null): FlexCollectionInterface;
@@ -116,6 +117,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface
* @param array|null $keys Array of keys.
* @param string|null $keyField Field to be used as the key.
* @return FlexIndexInterface
+ * @phpstan-return FlexIndexInterface
*/
public function getIndex(array $keys = null, string $keyField = null): FlexIndexInterface;
@@ -170,6 +172,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface
* @param array $entries
* @param string|null $keyField
* @return FlexCollectionInterface
+ * @phpstan-return FlexCollectionInterface
*/
public function createCollection(array $entries, string $keyField = null): FlexCollectionInterface;
@@ -177,6 +180,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface
* @param array $entries
* @param string|null $keyField
* @return FlexIndexInterface
+ * @phpstan-return FlexIndexInterface
*/
public function createIndex(array $entries, string $keyField = null): FlexIndexInterface;
@@ -199,6 +203,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface
* @param array $entries
* @param string|null $keyField
* @return FlexCollectionInterface
+ * @phpstan-return FlexCollectionInterface
*/
public function loadCollection(array $entries, string $keyField = null): FlexCollectionInterface;
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php
index 32dab1968..ba9996afc 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -43,4 +43,9 @@ interface FlexFormInterface extends Serializable, FormInterface
* @return Route|null Returns Route object or null if file uploads are not enabled.
*/
public function getFileDeleteAjaxRoute($field, $filename);
+
+// /**
+// * @return FlexObjectInterface
+// */
+// public function getObject();
}
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexIndexInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexIndexInterface.php
index 71dd72770..d8f8ba3c9 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexIndexInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexIndexInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php
index 3c5a103d2..f1376a589 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -59,6 +59,7 @@ interface FlexInterface extends Countable
* @param array|null $keys
* @param string|null $keyField
* @return FlexCollectionInterface|null
+ * @phpstan-return FlexCollectionInterface|null
*/
public function getCollection(string $type, array $keys = null, string $keyField = null): ?FlexCollectionInterface;
@@ -68,6 +69,7 @@ interface FlexInterface extends Countable
* collection_class: Class to be used to create the collection. Defaults to ObjectCollection.
* @return FlexCollectionInterface
* @throws RuntimeException
+ * @phpstan-return FlexCollectionInterface
*/
public function getMixedCollection(array $keys, array $options = []): FlexCollectionInterface;
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexObjectFormInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexObjectFormInterface.php
index 044ee612d..190a9634a 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexObjectFormInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexObjectFormInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php
index a1e3e3b92..d02bc8b30 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -23,6 +23,7 @@ use RuntimeException;
/**
* Defines Flex Objects.
*
+ * @extends ArrayAccess
* @used-by \Grav\Framework\Flex\FlexObject
* @since 1.6
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexStorageInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexStorageInterface.php
index 08c433596..420992472 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexStorageInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexStorageInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexTranslateInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexTranslateInterface.php
index 28e488860..8df11fa23 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexTranslateInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexTranslateInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php b/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php
index 94825681c..5901557d7 100644
--- a/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php
+++ b/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -13,6 +13,7 @@ namespace Grav\Framework\Flex\Pages;
use Grav\Common\Page\Interfaces\PageInterface;
use Grav\Framework\Flex\FlexCollection;
+use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
use function array_search;
use function assert;
use function is_int;
@@ -20,7 +21,7 @@ use function is_int;
/**
* Class FlexPageCollection
* @package Grav\Plugin\FlexObjects\Types\FlexPages
- * @template T of \Grav\Framework\Flex\Interfaces\FlexObjectInterface
+ * @template T of FlexObjectInterface
* @extends FlexCollection
*/
class FlexPageCollection extends FlexCollection
@@ -56,8 +57,10 @@ class FlexPageCollection extends FlexCollection
*/
public function withPublished(bool $bool = true)
{
+ /** @var string[] $list */
$list = array_keys(array_filter($this->call('isPublished', [$bool])));
+ /** @phpstan-var static */
return $this->select($list);
}
@@ -68,8 +71,10 @@ class FlexPageCollection extends FlexCollection
*/
public function withVisible(bool $bool = true)
{
+ /** @var string[] $list */
$list = array_keys(array_filter($this->call('isVisible', [$bool])));
+ /** @phpstan-var static */
return $this->select($list);
}
@@ -80,8 +85,10 @@ class FlexPageCollection extends FlexCollection
*/
public function withRoutable(bool $bool = true)
{
+ /** @var string[] $list */
$list = array_keys(array_filter($this->call('isRoutable', [$bool])));
+ /** @phpstan-var static */
return $this->select($list);
}
@@ -148,9 +155,10 @@ class FlexPageCollection extends FlexCollection
public function adjacentSibling($path, $direction = 1)
{
$keys = $this->getKeys();
+ $direction = (int)$direction;
$pos = array_search($path, $keys, true);
- if ($pos !== false) {
+ if (is_int($pos)) {
$pos += $direction;
if (isset($keys[$pos])) {
return $this[$keys[$pos]];
@@ -170,7 +178,7 @@ class FlexPageCollection extends FlexCollection
{
$pos = array_search($path, $this->getKeys(), true);
- return $pos !== false ? $pos : null;
+ return is_int($pos) ? $pos : null;
}
/**
@@ -184,7 +192,6 @@ class FlexPageCollection extends FlexCollection
$keys = $collection->getStorageKeys();
// Assign next free order.
- /** @var FlexPageObject|null $last */
$last = null;
$order = 0;
foreach ($keys as $folder => $key) {
@@ -196,8 +203,9 @@ class FlexPageCollection extends FlexCollection
}
}
+ /** @var FlexPageObject|null $last */
$last = $collection[$last];
- return sprintf('%d.', $last ? $last->value('order') + 1 : 1);
+ return sprintf('%d.', $last ? $last->getFormValue('order') + 1 : 1);
}
}
diff --git a/system/src/Grav/Framework/Flex/Pages/FlexPageIndex.php b/system/src/Grav/Framework/Flex/Pages/FlexPageIndex.php
index 904d1f6da..5bb551797 100644
--- a/system/src/Grav/Framework/Flex/Pages/FlexPageIndex.php
+++ b/system/src/Grav/Framework/Flex/Pages/FlexPageIndex.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Pages/FlexPageObject.php b/system/src/Grav/Framework/Flex/Pages/FlexPageObject.php
index ebc26b45a..e700424b9 100644
--- a/system/src/Grav/Framework/Flex/Pages/FlexPageObject.php
+++ b/system/src/Grav/Framework/Flex/Pages/FlexPageObject.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -55,6 +55,7 @@ class FlexPageObject extends FlexObject implements PageInterface, FlexTranslateI
/**
* Clone page.
*/
+ #[\ReturnTypeWillChange]
public function __clone()
{
parent::__clone();
diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageAuthorsTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageAuthorsTrait.php
index 5d3e96803..d0934e12c 100644
--- a/system/src/Grav/Framework/Flex/Pages/Traits/PageAuthorsTrait.php
+++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageAuthorsTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageContentTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageContentTrait.php
index 6aff73277..43dfee116 100644
--- a/system/src/Grav/Framework/Flex/Pages/Traits/PageContentTrait.php
+++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageContentTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -75,13 +75,13 @@ trait PageContentTrait
'template' => 'template',
];
- /** @var object */
+ /** @var object|null */
protected $header;
- /** @var string */
+ /** @var string|null */
protected $_summary;
- /** @var string */
+ /** @var string|null */
protected $_content;
/**
@@ -100,6 +100,7 @@ trait PageContentTrait
/**
* @inheritdoc
+ * @return Header
*/
public function header($var = null)
{
@@ -288,7 +289,7 @@ trait PageContentTrait
'process',
$var,
function ($value) {
- $value = array_replace(Grav::instance()['config']->get('system.pages.process', []), is_array($value) ? $value : []) ?? [];
+ $value = array_replace(Grav::instance()['config']->get('system.pages.process', []), is_array($value) ? $value : []);
foreach ($value as $process => $status) {
$value[$process] = (bool)$status;
}
@@ -664,6 +665,7 @@ trait PageContentTrait
*/
protected function processContent($content): string
{
+ $content = is_string($content) ? $content : '';
$grav = Grav::instance();
/** @var Config $config */
@@ -676,7 +678,6 @@ trait PageContentTrait
$twig_first = $this->getNestedProperty('header.twig_first') ?? $config->get('system.pages.twig_first', false);
$never_cache_twig = $this->getNestedProperty('header.never_cache_twig') ?? $config->get('system.pages.never_cache_twig', false);
- $cached = null;
if ($cache_enable) {
$cache = $this->getCache('render');
$key = md5($this->getCacheKey() . '-content');
@@ -688,12 +689,10 @@ trait PageContentTrait
if ($process_twig && $never_cache_twig) {
$this->_content = $this->processTwig($this->_content);
}
- } else {
- $cached = null;
}
}
- if (!$cached) {
+ if (null === $this->_content) {
$markdown_options = [];
if ($process_markdown) {
// Build markdown options.
@@ -746,6 +745,7 @@ trait PageContentTrait
}
if ($process_twig) {
+ \assert(is_string($this->_content));
$this->_content = $this->processTwig($this->_content);
}
}
@@ -755,6 +755,8 @@ trait PageContentTrait
}
}
+ \assert(is_string($this->_content));
+
// Handle summary divider
$delimiter = $config->get('site.summary.delimiter', '===');
$divider_pos = mb_strpos($this->_content, "{$delimiter}
");
diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php
index 6453bcf5e..539b84c99 100644
--- a/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php
+++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -17,13 +17,12 @@ use Grav\Common\Page\Interfaces\PageInterface;
use Grav\Common\Page\Pages;
use Grav\Common\Utils;
use Grav\Common\Yaml;
-use Grav\Framework\Cache\CacheInterface;
use Grav\Framework\File\Formatter\MarkdownFormatter;
use Grav\Framework\File\Formatter\YamlFormatter;
use Grav\Framework\Filesystem\Filesystem;
-use Grav\Framework\Flex\FlexDirectory;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexIndexInterface;
+use Grav\Framework\Flex\Pages\FlexPageCollection;
use Grav\Framework\Flex\Pages\FlexPageIndex;
use Grav\Framework\Flex\Pages\FlexPageObject;
use InvalidArgumentException;
@@ -300,7 +299,7 @@ trait PageLegacyTrait
$parentStorageKey = ltrim($filesystem->dirname("/{$this->getMasterKey()}"), '/');
- /** @var FlexPageIndex $index */
+ /** @var FlexPageIndex> $index */
$index = $this->getFlexDirectory()->getIndex();
if ($parent) {
@@ -323,6 +322,7 @@ trait PageLegacyTrait
if ($this instanceof FlexPageObject) {
$key = trim($parentKey . '/' . $this->folder(), '/');
$key = preg_replace(static::PAGE_ORDER_PREFIX_REGEX, '', $key);
+ \assert(is_string($key));
} else {
$key = trim($parentKey . '/' . basename($this->getKey()), '/');
}
diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php
index 90773cdda..421cbec8c 100644
--- a/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php
+++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php
index 877fec10e..4bec685b4 100644
--- a/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php
+++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -26,6 +26,14 @@ trait PageTranslateTrait
/** @var PageInterface[] */
private $_translations = [];
+ /**
+ * @return bool
+ */
+ public function translated(): bool
+ {
+ return (bool)$this->translatedLanguages(true);
+ }
+
/**
* @param string|null $languageCode
* @param bool|null $fallback
diff --git a/system/src/Grav/Framework/Flex/Storage/AbstractFilesystemStorage.php b/system/src/Grav/Framework/Flex/Storage/AbstractFilesystemStorage.php
index 1934f50cf..ee04c519d 100644
--- a/system/src/Grav/Framework/Flex/Storage/AbstractFilesystemStorage.php
+++ b/system/src/Grav/Framework/Flex/Storage/AbstractFilesystemStorage.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -127,6 +127,10 @@ abstract class AbstractFilesystemStorage implements FlexStorageInterface
$formatterClassName = $formatter['class'] ?? JsonFormatter::class;
$formatterOptions = $formatter['options'] ?? [];
+ if (!is_a($formatterClassName, FileFormatterInterface::class, true)) {
+ throw new \InvalidArgumentException('Bad Data Formatter');
+ }
+
$this->dataFormatter = new $formatterClassName($formatterOptions);
}
diff --git a/system/src/Grav/Framework/Flex/Storage/FileStorage.php b/system/src/Grav/Framework/Flex/Storage/FileStorage.php
index eabd658fe..7a1764692 100644
--- a/system/src/Grav/Framework/Flex/Storage/FileStorage.php
+++ b/system/src/Grav/Framework/Flex/Storage/FileStorage.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Storage/FolderStorage.php b/system/src/Grav/Framework/Flex/Storage/FolderStorage.php
index b2b9533a2..4da59d73c 100644
--- a/system/src/Grav/Framework/Flex/Storage/FolderStorage.php
+++ b/system/src/Grav/Framework/Flex/Storage/FolderStorage.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php b/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php
index 6faac9d84..30da11e19 100644
--- a/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php
+++ b/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -30,7 +30,7 @@ class SimpleStorage extends AbstractFilesystemStorage
protected $dataFolder;
/** @var string */
protected $dataPattern;
- /** @var string */
+ /** @var string|null */
protected $prefix;
/** @var array|null */
protected $data;
diff --git a/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php b/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php
index 8cbd1d542..ef4c433a2 100644
--- a/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php
+++ b/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php b/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php
index dabfe17b7..05e3a4433 100644
--- a/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php
+++ b/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php
@@ -5,7 +5,7 @@ namespace Grav\Framework\Flex\Traits;
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -44,7 +44,7 @@ trait FlexMediaTrait
}
/** @var array */
- protected $_uploads;
+ protected $_uploads = [];
/**
* @return string|null
@@ -119,7 +119,7 @@ trait FlexMediaTrait
// Load settings for the field.
$schema = $this->getBlueprint()->schema();
- $settings = $field && is_object($schema) ? (array)$schema->getProperty($field) : null;
+ $settings = (array)$schema->getProperty($field);
if (!is_array($settings)) {
return null;
}
@@ -165,6 +165,9 @@ trait FlexMediaTrait
return $settings + ['accept' => '*', 'limit' => 1000, 'self' => true];
}
+ /**
+ * @return array
+ */
protected function getMediaFields(): array
{
// Load settings for the field.
@@ -286,6 +289,7 @@ trait FlexMediaTrait
/**
* @return array
*/
+ #[\ReturnTypeWillChange]
public function __debugInfo()
{
return parent::__debugInfo() + [
@@ -397,11 +401,11 @@ trait FlexMediaTrait
}
/**
- * @return array
+ * @return array
*/
protected function getUpdatedMedia(): array
{
- return $this->_uploads ?? [];
+ return $this->_uploads;
}
/**
diff --git a/system/src/Grav/Framework/Flex/Traits/FlexRelatedDirectoryTrait.php b/system/src/Grav/Framework/Flex/Traits/FlexRelatedDirectoryTrait.php
index 9f7380c03..de98359e7 100644
--- a/system/src/Grav/Framework/Flex/Traits/FlexRelatedDirectoryTrait.php
+++ b/system/src/Grav/Framework/Flex/Traits/FlexRelatedDirectoryTrait.php
@@ -5,15 +5,15 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Flex\Traits;
-use Grav\Framework\Flex\FlexCollection;
use Grav\Framework\Flex\FlexDirectory;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
+use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
use RuntimeException;
use function in_array;
@@ -26,7 +26,7 @@ trait FlexRelatedDirectoryTrait
/**
* @param string $type
* @param string $property
- * @return FlexCollectionInterface
+ * @return FlexCollectionInterface
*/
protected function getCollectionByProperty($type, $property)
{
@@ -34,9 +34,9 @@ trait FlexRelatedDirectoryTrait
$collection = $directory->getCollection();
$list = $this->getNestedProperty($property) ?: [];
- /** @var FlexCollection $collection */
+ /** @var FlexCollectionInterface $collection */
$collection = $collection->filter(static function ($object) use ($list) {
- return in_array($object->id, $list, true);
+ return in_array($object->getKey(), $list, true);
});
return $collection;
diff --git a/system/src/Grav/Framework/Form/FormFlash.php b/system/src/Grav/Framework/Form/FormFlash.php
index 864e992f3..06cc2eeea 100644
--- a/system/src/Grav/Framework/Form/FormFlash.php
+++ b/system/src/Grav/Framework/Form/FormFlash.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Form
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Form/FormFlashFile.php b/system/src/Grav/Framework/Form/FormFlashFile.php
index dc510e28f..6c995993e 100644
--- a/system/src/Grav/Framework/Form/FormFlashFile.php
+++ b/system/src/Grav/Framework/Form/FormFlashFile.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Form
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -11,6 +11,7 @@ namespace Grav\Framework\Form;
use Grav\Framework\Psr7\Stream;
use InvalidArgumentException;
+use JsonSerializable;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UploadedFileInterface;
use RuntimeException;
@@ -23,7 +24,7 @@ use function sprintf;
* Class FormFlashFile
* @package Grav\Framework\Form
*/
-class FormFlashFile implements UploadedFileInterface, \JsonSerializable
+class FormFlashFile implements UploadedFileInterface, JsonSerializable
{
/** @var string */
private $field;
@@ -175,6 +176,7 @@ class FormFlashFile implements UploadedFileInterface, \JsonSerializable
/**
* @return array
*/
+ #[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->upload;
@@ -199,6 +201,7 @@ class FormFlashFile implements UploadedFileInterface, \JsonSerializable
/**
* @return array
*/
+ #[\ReturnTypeWillChange]
public function __debugInfo()
{
return [
diff --git a/system/src/Grav/Framework/Form/Interfaces/FormFactoryInterface.php b/system/src/Grav/Framework/Form/Interfaces/FormFactoryInterface.php
index d21d4aa05..6a85f668c 100644
--- a/system/src/Grav/Framework/Form/Interfaces/FormFactoryInterface.php
+++ b/system/src/Grav/Framework/Form/Interfaces/FormFactoryInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Form
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Form/Interfaces/FormFlashInterface.php b/system/src/Grav/Framework/Form/Interfaces/FormFlashInterface.php
index d51bd8d9e..44bee025c 100644
--- a/system/src/Grav/Framework/Form/Interfaces/FormFlashInterface.php
+++ b/system/src/Grav/Framework/Form/Interfaces/FormFlashInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Form
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Form/Interfaces/FormInterface.php b/system/src/Grav/Framework/Form/Interfaces/FormInterface.php
index 98156469d..0edfc42a9 100644
--- a/system/src/Grav/Framework/Form/Interfaces/FormInterface.php
+++ b/system/src/Grav/Framework/Form/Interfaces/FormInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Form
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Form/Traits/FormTrait.php b/system/src/Grav/Framework/Form/Traits/FormTrait.php
index d77a40274..f4be9e7aa 100644
--- a/system/src/Grav/Framework/Form/Traits/FormTrait.php
+++ b/system/src/Grav/Framework/Form/Traits/FormTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Form
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -65,10 +65,10 @@ trait FormTrait
private $sessionid;
/** @var bool */
private $submitted;
- /** @var ArrayAccess|Data|null */
+ /** @var ArrayAccess|Data|null */
private $data;
- /** @var array|UploadedFileInterface[] */
- private $files;
+ /** @var UploadedFileInterface[] */
+ private $files = [];
/** @var FormFlashInterface|null */
private $flash;
/** @var string */
@@ -203,7 +203,7 @@ trait FormTrait
*/
public function getFiles(): array
{
- return $this->files ?? [];
+ return $this->files;
}
/**
@@ -221,8 +221,8 @@ trait FormTrait
*/
public function getDefaultValue(string $name)
{
- $path = explode('.', $name) ?: [];
- $offset = array_shift($path) ?? '';
+ $path = explode('.', $name);
+ $offset = array_shift($path);
$current = $this->getDefaultValues();
@@ -692,7 +692,7 @@ trait FormTrait
throw new RuntimeException(sprintf('FlexForm: Bad HTTP method %s', $method));
}
- $body = $request->getParsedBody();
+ $body = (array)$request->getParsedBody();
$data = isset($body['data']) ? $this->decodeData($body['data']) : null;
$flash = $this->getFlash();
@@ -721,6 +721,7 @@ trait FormTrait
* @param ArrayAccess|Data|null $data
* @return void
* @throws ValidationException
+ * @phpstan-param ArrayAccess|Data|null $data
* @throws Exception
*/
protected function validateData($data = null): void
@@ -735,6 +736,7 @@ trait FormTrait
*
* @param ArrayAccess|Data|null $data
* @return void
+ * @phpstan-param ArrayAccess|Data|null $data
*/
protected function filterData($data = null): void
{
@@ -797,9 +799,7 @@ trait FormTrait
// Decode JSON encoded fields and merge them to data.
if (isset($data['_json'])) {
$data = array_replace_recursive($data, $this->jsonDecode($data['_json']));
- if (null === $data) {
- throw new RuntimeException(__METHOD__ . '(): Unexpected error');
- }
+
unset($data['_json']);
}
diff --git a/system/src/Grav/Framework/Interfaces/RenderInterface.php b/system/src/Grav/Framework/Interfaces/RenderInterface.php
index 7a7d9d367..5bc6e5835 100644
--- a/system/src/Grav/Framework/Interfaces/RenderInterface.php
+++ b/system/src/Grav/Framework/Interfaces/RenderInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Interfaces
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Logger/Processors/UserProcessor.php b/system/src/Grav/Framework/Logger/Processors/UserProcessor.php
index 885b4f0a8..f0ebef10c 100644
--- a/system/src/Grav/Framework/Logger/Processors/UserProcessor.php
+++ b/system/src/Grav/Framework/Logger/Processors/UserProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Logger
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Media/Interfaces/MediaCollectionInterface.php b/system/src/Grav/Framework/Media/Interfaces/MediaCollectionInterface.php
index a3587d8cb..2bac98f15 100644
--- a/system/src/Grav/Framework/Media/Interfaces/MediaCollectionInterface.php
+++ b/system/src/Grav/Framework/Media/Interfaces/MediaCollectionInterface.php
@@ -3,15 +3,21 @@
/**
* @package Grav\Framework\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Media\Interfaces;
+use ArrayAccess;
+use Countable;
+use Iterator;
+
/**
* Class implements media collection interface.
+ * @extends ArrayAccess
+ * @extends Iterator
*/
-interface MediaCollectionInterface extends \ArrayAccess, \Countable, \Iterator
+interface MediaCollectionInterface extends ArrayAccess, Countable, Iterator
{
}
diff --git a/system/src/Grav/Framework/Media/Interfaces/MediaInterface.php b/system/src/Grav/Framework/Media/Interfaces/MediaInterface.php
index 2c5a4b374..8688ad1c3 100644
--- a/system/src/Grav/Framework/Media/Interfaces/MediaInterface.php
+++ b/system/src/Grav/Framework/Media/Interfaces/MediaInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Media/Interfaces/MediaManipulationInterface.php b/system/src/Grav/Framework/Media/Interfaces/MediaManipulationInterface.php
index fef475f8b..bca9a228d 100644
--- a/system/src/Grav/Framework/Media/Interfaces/MediaManipulationInterface.php
+++ b/system/src/Grav/Framework/Media/Interfaces/MediaManipulationInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Media/Interfaces/MediaObjectInterface.php b/system/src/Grav/Framework/Media/Interfaces/MediaObjectInterface.php
index dc7f1481d..f4409c5c9 100644
--- a/system/src/Grav/Framework/Media/Interfaces/MediaObjectInterface.php
+++ b/system/src/Grav/Framework/Media/Interfaces/MediaObjectInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Mime/MimeTypes.php b/system/src/Grav/Framework/Mime/MimeTypes.php
index dadcddf7a..e3a5ea8ca 100644
--- a/system/src/Grav/Framework/Mime/MimeTypes.php
+++ b/system/src/Grav/Framework/Mime/MimeTypes.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Mime
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Access/ArrayAccessTrait.php b/system/src/Grav/Framework/Object/Access/ArrayAccessTrait.php
index affff03b0..4b67599fb 100644
--- a/system/src/Grav/Framework/Object/Access/ArrayAccessTrait.php
+++ b/system/src/Grav/Framework/Object/Access/ArrayAccessTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Access/NestedArrayAccessTrait.php b/system/src/Grav/Framework/Object/Access/NestedArrayAccessTrait.php
index 83658753d..d9acb104f 100644
--- a/system/src/Grav/Framework/Object/Access/NestedArrayAccessTrait.php
+++ b/system/src/Grav/Framework/Object/Access/NestedArrayAccessTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Access/NestedPropertyCollectionTrait.php b/system/src/Grav/Framework/Object/Access/NestedPropertyCollectionTrait.php
index 120c1a49d..561b6fec3 100644
--- a/system/src/Grav/Framework/Object/Access/NestedPropertyCollectionTrait.php
+++ b/system/src/Grav/Framework/Object/Access/NestedPropertyCollectionTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php b/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php
index 7409f4c9e..64107e0d3 100644
--- a/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php
+++ b/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -42,8 +42,8 @@ trait NestedPropertyTrait
public function getNestedProperty($property, $default = null, $separator = null)
{
$separator = $separator ?: '.';
- $path = explode($separator, $property) ?: [];
- $offset = array_shift($path) ?? '';
+ $path = explode($separator, $property);
+ $offset = array_shift($path);
if (!$this->hasProperty($offset)) {
return $default;
@@ -85,8 +85,8 @@ trait NestedPropertyTrait
public function setNestedProperty($property, $value, $separator = null)
{
$separator = $separator ?: '.';
- $path = explode($separator, $property) ?: [];
- $offset = array_shift($path) ?? '';
+ $path = explode($separator, $property);
+ $offset = array_shift($path);
if (!$path) {
$this->setProperty($offset, $value);
@@ -127,8 +127,8 @@ trait NestedPropertyTrait
public function unsetNestedProperty($property, $separator = null)
{
$separator = $separator ?: '.';
- $path = explode($separator, $property) ?: [];
- $offset = array_shift($path) ?? '';
+ $path = explode($separator, $property);
+ $offset = array_shift($path);
if (!$path) {
$this->unsetProperty($offset);
diff --git a/system/src/Grav/Framework/Object/Access/OverloadedPropertyTrait.php b/system/src/Grav/Framework/Object/Access/OverloadedPropertyTrait.php
index 0f0f89f00..f417fba02 100644
--- a/system/src/Grav/Framework/Object/Access/OverloadedPropertyTrait.php
+++ b/system/src/Grav/Framework/Object/Access/OverloadedPropertyTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -21,6 +21,7 @@ trait OverloadedPropertyTrait
* @param mixed $offset An offset to check for.
* @return bool Returns TRUE on success or FALSE on failure.
*/
+ #[\ReturnTypeWillChange]
public function __isset($offset)
{
return $this->hasProperty($offset);
@@ -32,6 +33,7 @@ trait OverloadedPropertyTrait
* @param mixed $offset The offset to retrieve.
* @return mixed Can return all value types.
*/
+ #[\ReturnTypeWillChange]
public function __get($offset)
{
return $this->getProperty($offset);
@@ -44,6 +46,7 @@ trait OverloadedPropertyTrait
* @param mixed $value The value to set.
* @return void
*/
+ #[\ReturnTypeWillChange]
public function __set($offset, $value)
{
$this->setProperty($offset, $value);
@@ -55,6 +58,7 @@ trait OverloadedPropertyTrait
* @param mixed $offset The name value to unset
* @return void
*/
+ #[\ReturnTypeWillChange]
public function __unset($offset)
{
$this->unsetProperty($offset);
diff --git a/system/src/Grav/Framework/Object/ArrayObject.php b/system/src/Grav/Framework/Object/ArrayObject.php
index 2bbe93781..a38864c89 100644
--- a/system/src/Grav/Framework/Object/ArrayObject.php
+++ b/system/src/Grav/Framework/Object/ArrayObject.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -19,6 +19,7 @@ use Grav\Framework\Object\Property\ArrayPropertyTrait;
/**
* Array Objects keep the data in private array property.
+ * @implements ArrayAccess
*/
class ArrayObject implements NestedObjectInterface, ArrayAccess
{
diff --git a/system/src/Grav/Framework/Object/Base/ObjectCollectionTrait.php b/system/src/Grav/Framework/Object/Base/ObjectCollectionTrait.php
index 3c172fecd..e29370add 100644
--- a/system/src/Grav/Framework/Object/Base/ObjectCollectionTrait.php
+++ b/system/src/Grav/Framework/Object/Base/ObjectCollectionTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -11,6 +11,7 @@ namespace Grav\Framework\Object\Base;
use Grav\Framework\Compat\Serializable;
use Grav\Framework\Object\Interfaces\ObjectInterface;
+use InvalidArgumentException;
use function call_user_func_array;
use function get_class;
use function is_callable;
@@ -19,6 +20,9 @@ use function is_object;
/**
* ObjectCollection Trait
* @package Grav\Framework\Object
+ *
+ * @template TKey as array-key
+ * @template T as ObjectInterface
*/
trait ObjectCollectionTrait
{
@@ -51,6 +55,7 @@ trait ObjectCollectionTrait
}
$class = get_class($this);
+
return $type . strtolower(substr($class, strrpos($class, '\\') + 1));
}
@@ -167,7 +172,7 @@ trait ObjectCollectionTrait
protected function doUnserialize(array $data)
{
if (!isset($data['key'], $data['type'], $data['elements']) || $data['type'] !== $this->getType()) {
- throw new \InvalidArgumentException("Cannot unserialize '{$this->getType()}': Bad data");
+ throw new InvalidArgumentException("Cannot unserialize '{$this->getType()}': Bad data");
}
$this->setKey($data['key']);
@@ -179,6 +184,7 @@ trait ObjectCollectionTrait
*
* @return array
*/
+ #[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->doSerialize();
@@ -189,6 +195,7 @@ trait ObjectCollectionTrait
*
* @return string
*/
+ #[\ReturnTypeWillChange]
public function __toString()
{
return $this->getKey();
@@ -207,14 +214,18 @@ trait ObjectCollectionTrait
/**
* Create a copy from this collection by cloning all objects in the collection.
+ *
+ * @return static
*/
public function copy()
{
$list = [];
foreach ($this->getIterator() as $key => $value) {
+ /** @phpstan-ignore-next-line */
$list[$key] = is_object($value) ? clone $value : $value;
}
+ /** @phpstan-var static */
return $this->createFrom($list);
}
@@ -330,6 +341,7 @@ trait ObjectCollectionTrait
*
* @param string $property
* @return array
+ * @phpstan-return array
*/
public function group($property)
{
@@ -348,12 +360,13 @@ trait ObjectCollectionTrait
*
* @param string $property
* @return static[]
+ * @phpstan-return array>
*/
public function collectionGroup($property)
{
$collections = [];
foreach ($this->group($property) as $id => $elements) {
- /** @var static $collection */
+ /** @phpstan-var static $collection */
$collection = $this->createFrom($elements);
$collections[$id] = $collection;
diff --git a/system/src/Grav/Framework/Object/Base/ObjectTrait.php b/system/src/Grav/Framework/Object/Base/ObjectTrait.php
index d4e324b46..86df8c783 100644
--- a/system/src/Grav/Framework/Object/Base/ObjectTrait.php
+++ b/system/src/Grav/Framework/Object/Base/ObjectTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -172,6 +172,7 @@ trait ObjectTrait
*
* @return array
*/
+ #[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->doSerialize();
@@ -182,6 +183,7 @@ trait ObjectTrait
*
* @return string
*/
+ #[\ReturnTypeWillChange]
public function __toString()
{
return $this->getKey();
diff --git a/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php b/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php
index d8f152431..e8b12b7f4 100644
--- a/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php
+++ b/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php
@@ -3,12 +3,13 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Object\Collection;
+use ArrayAccess;
use Closure;
use Doctrine\Common\Collections\Expr\ClosureExpressionVisitor;
use Doctrine\Common\Collections\Expr\Comparison;
@@ -42,7 +43,7 @@ class ObjectExpressionVisitor extends ClosureExpressionVisitor
$field = rtrim($field, ')');
}
- if (isset($object[$field])) {
+ if ($object instanceof ArrayAccess && isset($object[$field])) {
$value = $object[$field];
} else {
$accessors = array('', 'get', 'is');
@@ -233,7 +234,7 @@ class ObjectExpressionVisitor extends ClosureExpressionVisitor
};
default:
- throw new RuntimeException("Unknown comparison operator: " . $comparison->getOperator());
+ throw new RuntimeException('Unknown comparison operator: ' . $comparison->getOperator());
}
}
}
diff --git a/system/src/Grav/Framework/Object/Interfaces/NestedObjectCollectionInterface.php b/system/src/Grav/Framework/Object/Interfaces/NestedObjectCollectionInterface.php
index a2431be31..9f00babbf 100644
--- a/system/src/Grav/Framework/Object/Interfaces/NestedObjectCollectionInterface.php
+++ b/system/src/Grav/Framework/Object/Interfaces/NestedObjectCollectionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Interfaces/NestedObjectInterface.php b/system/src/Grav/Framework/Object/Interfaces/NestedObjectInterface.php
index 4d7a880be..c144d8e92 100644
--- a/system/src/Grav/Framework/Object/Interfaces/NestedObjectInterface.php
+++ b/system/src/Grav/Framework/Object/Interfaces/NestedObjectInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Interfaces/ObjectCollectionInterface.php b/system/src/Grav/Framework/Object/Interfaces/ObjectCollectionInterface.php
index 8169c246e..bd25f6183 100644
--- a/system/src/Grav/Framework/Object/Interfaces/ObjectCollectionInterface.php
+++ b/system/src/Grav/Framework/Object/Interfaces/ObjectCollectionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Interfaces/ObjectInterface.php b/system/src/Grav/Framework/Object/Interfaces/ObjectInterface.php
index e8ec2c1e7..bc4d45df9 100644
--- a/system/src/Grav/Framework/Object/Interfaces/ObjectInterface.php
+++ b/system/src/Grav/Framework/Object/Interfaces/ObjectInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/LazyObject.php b/system/src/Grav/Framework/Object/LazyObject.php
index 309c0d6f6..6be255884 100644
--- a/system/src/Grav/Framework/Object/LazyObject.php
+++ b/system/src/Grav/Framework/Object/LazyObject.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -22,6 +22,7 @@ use Grav\Framework\Object\Property\LazyPropertyTrait;
* not exist or is not initialized.
*
* @package Grav\Framework\Object
+ * @implements ArrayAccess
*/
class LazyObject implements NestedObjectInterface, ArrayAccess
{
diff --git a/system/src/Grav/Framework/Object/ObjectCollection.php b/system/src/Grav/Framework/Object/ObjectCollection.php
index 3fdebce91..94392af89 100644
--- a/system/src/Grav/Framework/Object/ObjectCollection.php
+++ b/system/src/Grav/Framework/Object/ObjectCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -22,12 +22,13 @@ use function array_slice;
* Class contains a collection of objects.
*
* @template TKey of array-key
- * @template T
+ * @template T of \Grav\Framework\Object\Interfaces\ObjectInterface
* @extends ArrayCollection
* @implements NestedObjectCollectionInterface
*/
class ObjectCollection extends ArrayCollection implements NestedObjectCollectionInterface
{
+ /** @phpstan-use ObjectCollectionTrait */
use ObjectCollectionTrait;
use NestedPropertyCollectionTrait {
NestedPropertyCollectionTrait::group insteadof ObjectCollectionTrait;
@@ -65,6 +66,7 @@ class ObjectCollection extends ArrayCollection implements NestedObjectCollection
*/
public function limit($start, $limit = null)
{
+ /** @phpstan-var static */
return $this->createFrom($this->slice($start, $limit));
}
@@ -86,14 +88,11 @@ class ObjectCollection extends ArrayCollection implements NestedObjectCollection
if ($orderings = $criteria->getOrderings()) {
$next = null;
- /**
- * @var string $field
- * @var string $ordering
- */
foreach (array_reverse($orderings) as $field => $ordering) {
$next = ObjectExpressionVisitor::sortByField($field, $ordering === Criteria::DESC ? -1 : 1, $next);
}
+ /** @phpstan-ignore-next-line */
if ($next) {
uasort($filtered, $next);
}
@@ -106,11 +105,13 @@ class ObjectCollection extends ArrayCollection implements NestedObjectCollection
$filtered = array_slice($filtered, (int)$offset, $length);
}
+ /** @phpstan-var static */
return $this->createFrom($filtered);
}
/**
* @return array
+ * @phpstan-return array
*/
protected function getElements()
{
@@ -120,9 +121,11 @@ class ObjectCollection extends ArrayCollection implements NestedObjectCollection
/**
* @param array $elements
* @return array
+ * @phpstan-return array
*/
protected function setElements(array $elements)
{
+ /** @phpstan-var array $elements */
return $elements;
}
}
diff --git a/system/src/Grav/Framework/Object/ObjectIndex.php b/system/src/Grav/Framework/Object/ObjectIndex.php
index 50ac4271b..ab495bd76 100644
--- a/system/src/Grav/Framework/Object/ObjectIndex.php
+++ b/system/src/Grav/Framework/Object/ObjectIndex.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -25,7 +25,7 @@ use function is_object;
*
* @template TKey of array-key
* @template T of \Grav\Framework\Object\Interfaces\ObjectInterface
- * @template C of \Grav\Framework\Collection\CollectionInterface
+ * @template C of ObjectCollectionInterface
* @extends AbstractIndexCollection
* @implements NestedObjectCollectionInterface
*/
@@ -35,7 +35,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
protected static $type;
/** @var string */
- private $_key;
+ protected $_key;
/**
* @param bool $prefix
@@ -95,6 +95,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
* @param string $property Object property to be updated.
* @param string $value New value.
* @return ObjectCollectionInterface
+ * @phpstan-return C
*/
public function setProperty($property, $value)
{
@@ -105,6 +106,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
* @param string $property Object property to be defined.
* @param mixed $default Default value.
* @return ObjectCollectionInterface
+ * @phpstan-return C
*/
public function defProperty($property, $default)
{
@@ -114,6 +116,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
/**
* @param string $property Object property to be unset.
* @return ObjectCollectionInterface
+ * @phpstan-return C
*/
public function unsetProperty($property)
{
@@ -146,6 +149,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
* @param mixed $value New value.
* @param string|null $separator Separator, defaults to '.'
* @return ObjectCollectionInterface
+ * @phpstan-return C
*/
public function setNestedProperty($property, $value, $separator = null)
{
@@ -157,6 +161,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
* @param mixed $default Default value.
* @param string|null $separator Separator, defaults to '.'
* @return ObjectCollectionInterface
+ * @phpstan-return C
*/
public function defNestedProperty($property, $default, $separator = null)
{
@@ -167,6 +172,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
* @param string $property Object property to be unset.
* @param string|null $separator Separator, defaults to '.'
* @return ObjectCollectionInterface
+ * @phpstan-return C
*/
public function unsetNestedProperty($property, $separator = null)
{
@@ -183,9 +189,11 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
{
$list = [];
foreach ($this->getIterator() as $key => $value) {
+ /** @phpstan-ignore-next-line */
$list[$key] = is_object($value) ? clone $value : $value;
}
+ /** @phpstan-var static */
return $this->createFrom($list);
}
@@ -200,6 +208,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
/**
* @param array $ordering
* @return ObjectCollectionInterface
+ * @phpstan-return C
*/
public function orderBy(array $ordering)
{
@@ -232,6 +241,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
*
* @param string $property
* @return ObjectCollectionInterface[]
+ * @phpstan-return C[]
*/
public function collectionGroup($property)
{
@@ -239,14 +249,18 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
}
/**
- * {@inheritDoc}
+ * @param Criteria $criteria
+ * @return ObjectCollectionInterface
+ * @phpstan-return C
*/
public function matching(Criteria $criteria)
{
- /** @var ObjectCollectionInterface $collection */
$collection = $this->loadCollection($this->getEntries());
- return $collection->matching($criteria);
+ /** @phpstan-var C $matching */
+ $matching = $collection->matching($criteria);
+
+ return $matching;
}
/**
@@ -254,6 +268,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
* @param array $arguments
* @return mixed
*/
+ #[\ReturnTypeWillChange]
abstract public function __call($name, $arguments);
/**
diff --git a/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php b/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php
index fa3fed1d3..8ab4c41e4 100644
--- a/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php
+++ b/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -97,7 +97,7 @@ trait ArrayPropertyTrait
*/
protected function getElements()
{
- return array_filter($this->_elements, function ($val) {
+ return array_filter($this->_elements, static function ($val) {
return $val !== null;
});
}
diff --git a/system/src/Grav/Framework/Object/Property/LazyPropertyTrait.php b/system/src/Grav/Framework/Object/Property/LazyPropertyTrait.php
index d5baddbee..e6892596a 100644
--- a/system/src/Grav/Framework/Object/Property/LazyPropertyTrait.php
+++ b/system/src/Grav/Framework/Object/Property/LazyPropertyTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -87,8 +87,7 @@ trait LazyPropertyTrait
*/
protected function doUnsetProperty($property)
{
- $this->hasObjectProperty($property) ?
- $this->unsetObjectProperty($property) : $this->unsetArrayProperty($property);
+ $this->hasObjectProperty($property) ? $this->unsetObjectProperty($property) : $this->unsetArrayProperty($property);
}
/**
diff --git a/system/src/Grav/Framework/Object/Property/MixedPropertyTrait.php b/system/src/Grav/Framework/Object/Property/MixedPropertyTrait.php
index 584e812f3..1b57aab05 100644
--- a/system/src/Grav/Framework/Object/Property/MixedPropertyTrait.php
+++ b/system/src/Grav/Framework/Object/Property/MixedPropertyTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Property/ObjectPropertyTrait.php b/system/src/Grav/Framework/Object/Property/ObjectPropertyTrait.php
index 435220a19..bb0195d66 100644
--- a/system/src/Grav/Framework/Object/Property/ObjectPropertyTrait.php
+++ b/system/src/Grav/Framework/Object/Property/ObjectPropertyTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/PropertyObject.php b/system/src/Grav/Framework/Object/PropertyObject.php
index dbeb5c432..d9cdde83a 100644
--- a/system/src/Grav/Framework/Object/PropertyObject.php
+++ b/system/src/Grav/Framework/Object/PropertyObject.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -19,6 +19,8 @@ use Grav\Framework\Object\Property\ObjectPropertyTrait;
/**
* Property Objects keep their data in protected object properties.
+ *
+ * @implements ArrayAccess
*/
class PropertyObject implements NestedObjectInterface, ArrayAccess
{
diff --git a/system/src/Grav/Framework/Pagination/AbstractPagination.php b/system/src/Grav/Framework/Pagination/AbstractPagination.php
index 0be21ec3b..a4d902a2f 100644
--- a/system/src/Grav/Framework/Pagination/AbstractPagination.php
+++ b/system/src/Grav/Framework/Pagination/AbstractPagination.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Pagination
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -234,7 +234,9 @@ class AbstractPagination implements PaginationInterface
/**
* @return ArrayIterator
+ * @phpstan-return ArrayIterator
*/
+ #[\ReturnTypeWillChange]
public function getIterator()
{
$this->loadItems();
diff --git a/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php b/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php
index 95ff8af35..072fea767 100644
--- a/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php
+++ b/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Pagination
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -41,7 +41,7 @@ abstract class AbstractPaginationPage implements PaginationPageInterface
*/
public function getOptions(): array
{
- return $this->options ?? [];
+ return $this->options;
}
/**
diff --git a/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php b/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php
index 56d336195..1a82147a1 100644
--- a/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php
+++ b/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Pagination
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -16,6 +16,7 @@ use IteratorAggregate;
/**
* Interface PaginationInterface
* @package Grav\Framework\Pagination\Interfaces
+ * @extends IteratorAggregate
*/
interface PaginationInterface extends Countable, IteratorAggregate
{
diff --git a/system/src/Grav/Framework/Pagination/Interfaces/PaginationPageInterface.php b/system/src/Grav/Framework/Pagination/Interfaces/PaginationPageInterface.php
index b90594d71..26c069262 100644
--- a/system/src/Grav/Framework/Pagination/Interfaces/PaginationPageInterface.php
+++ b/system/src/Grav/Framework/Pagination/Interfaces/PaginationPageInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Pagination
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Pagination/Pagination.php b/system/src/Grav/Framework/Pagination/Pagination.php
index e602872d1..8f2fa203c 100644
--- a/system/src/Grav/Framework/Pagination/Pagination.php
+++ b/system/src/Grav/Framework/Pagination/Pagination.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Pagination
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Pagination/PaginationPage.php b/system/src/Grav/Framework/Pagination/PaginationPage.php
index 63ceb5f63..e64abe9c0 100644
--- a/system/src/Grav/Framework/Pagination/PaginationPage.php
+++ b/system/src/Grav/Framework/Pagination/PaginationPage.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Pagination
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/AbstractUri.php b/system/src/Grav/Framework/Psr7/AbstractUri.php
index 85d802f64..145437a58 100644
--- a/system/src/Grav/Framework/Psr7/AbstractUri.php
+++ b/system/src/Grav/Framework/Psr7/AbstractUri.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -263,6 +263,7 @@ abstract class AbstractUri implements UriInterface
/**
* @return string
*/
+ #[\ReturnTypeWillChange]
public function __toString()
{
return $this->getUrl();
diff --git a/system/src/Grav/Framework/Psr7/Request.php b/system/src/Grav/Framework/Psr7/Request.php
index cd65fd98f..795a1a46e 100644
--- a/system/src/Grav/Framework/Psr7/Request.php
+++ b/system/src/Grav/Framework/Psr7/Request.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Response.php b/system/src/Grav/Framework/Psr7/Response.php
index 6cb67e0e8..6189c4a6f 100644
--- a/system/src/Grav/Framework/Psr7/Response.php
+++ b/system/src/Grav/Framework/Psr7/Response.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -53,6 +53,7 @@ class Response implements ResponseInterface
* @param int $options Json encoding options
* @param int $depth Json encoding max depth
* @return static
+ * @phpstan-param positive-int $depth
*/
public function withJson($data, int $status = null, int $options = 0, int $depth = 512): ResponseInterface
{
@@ -257,7 +258,7 @@ class Response implements ResponseInterface
}
$output .= self::EOL;
- $output .= (string) $response->getBody();
+ $output .= $response->getBody();
return $output;
}
diff --git a/system/src/Grav/Framework/Psr7/ServerRequest.php b/system/src/Grav/Framework/Psr7/ServerRequest.php
index 40848345b..cb5bcbbd3 100644
--- a/system/src/Grav/Framework/Psr7/ServerRequest.php
+++ b/system/src/Grav/Framework/Psr7/ServerRequest.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -98,13 +98,8 @@ class ServerRequest implements ServerRequestInterface
public function getCookieParam($key, $default = null)
{
$cookies = $this->getRequest()->getCookieParams();
- $result = $default;
- if (isset($cookies[$key])) {
- $result = $cookies[$key];
- }
-
- return $result;
+ return $cookies[$key] ?? $default;
}
/**
@@ -238,13 +233,8 @@ class ServerRequest implements ServerRequestInterface
public function getQueryParam($key, $default = null)
{
$getParams = $this->getQueryParams();
- $result = $default;
- if (isset($getParams[$key])) {
- $result = $getParams[$key];
- }
-
- return $result;
+ return $getParams[$key] ?? $default;
}
/**
diff --git a/system/src/Grav/Framework/Psr7/Stream.php b/system/src/Grav/Framework/Psr7/Stream.php
index a5a104363..6546bdc3e 100644
--- a/system/src/Grav/Framework/Psr7/Stream.php
+++ b/system/src/Grav/Framework/Psr7/Stream.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Traits/MessageDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/MessageDecoratorTrait.php
index 39e3818ce..c09a03c28 100644
--- a/system/src/Grav/Framework/Psr7/Traits/MessageDecoratorTrait.php
+++ b/system/src/Grav/Framework/Psr7/Traits/MessageDecoratorTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Traits/RequestDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/RequestDecoratorTrait.php
index 13f4c6fd8..49f2a928a 100644
--- a/system/src/Grav/Framework/Psr7/Traits/RequestDecoratorTrait.php
+++ b/system/src/Grav/Framework/Psr7/Traits/RequestDecoratorTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Traits/ResponseDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/ResponseDecoratorTrait.php
index 7b62c3c05..4bbc73614 100644
--- a/system/src/Grav/Framework/Psr7/Traits/ResponseDecoratorTrait.php
+++ b/system/src/Grav/Framework/Psr7/Traits/ResponseDecoratorTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Traits/ServerRequestDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/ServerRequestDecoratorTrait.php
index 33c26e0c7..9222219e7 100644
--- a/system/src/Grav/Framework/Psr7/Traits/ServerRequestDecoratorTrait.php
+++ b/system/src/Grav/Framework/Psr7/Traits/ServerRequestDecoratorTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Traits/StreamDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/StreamDecoratorTrait.php
index db1e746d4..448323fdb 100644
--- a/system/src/Grav/Framework/Psr7/Traits/StreamDecoratorTrait.php
+++ b/system/src/Grav/Framework/Psr7/Traits/StreamDecoratorTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -33,6 +33,7 @@ trait StreamDecoratorTrait
/**
* @return void
*/
+ #[\ReturnTypeWillChange]
public function __destruct()
{
$this->stream->close();
diff --git a/system/src/Grav/Framework/Psr7/Traits/UploadedFileDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/UploadedFileDecoratorTrait.php
index e0c65bddd..eec3add23 100644
--- a/system/src/Grav/Framework/Psr7/Traits/UploadedFileDecoratorTrait.php
+++ b/system/src/Grav/Framework/Psr7/Traits/UploadedFileDecoratorTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php b/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php
index 607d7571f..73adb6470 100644
--- a/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php
+++ b/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/UploadedFile.php b/system/src/Grav/Framework/Psr7/UploadedFile.php
index bfa63cdf4..c3ed62e69 100644
--- a/system/src/Grav/Framework/Psr7/UploadedFile.php
+++ b/system/src/Grav/Framework/Psr7/UploadedFile.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Uri.php b/system/src/Grav/Framework/Psr7/Uri.php
index c920b3373..63fe04eff 100644
--- a/system/src/Grav/Framework/Psr7/Uri.php
+++ b/system/src/Grav/Framework/Psr7/Uri.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -24,9 +24,6 @@ class Uri implements UriInterface
{
use UriDecorationTrait;
- /** @var array Array of Uri query. */
- private $queryParams;
-
public function __construct(string $uri = '')
{
$this->uri = new \Nyholm\Psr7\Uri($uri);
diff --git a/system/src/Grav/Framework/RequestHandler/Exception/InvalidArgumentException.php b/system/src/Grav/Framework/RequestHandler/Exception/InvalidArgumentException.php
index 451e58642..2456ea1f5 100644
--- a/system/src/Grav/Framework/RequestHandler/Exception/InvalidArgumentException.php
+++ b/system/src/Grav/Framework/RequestHandler/Exception/InvalidArgumentException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\RequestHandler
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php b/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php
index 28a226a4e..ce79ab2ac 100644
--- a/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php
+++ b/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\RequestHandler
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -21,9 +21,6 @@ use function in_array;
*/
class NotFoundException extends RequestException
{
- /** @var ServerRequestInterface */
- private $request;
-
/**
* NotFoundException constructor.
* @param ServerRequestInterface $request
@@ -37,9 +34,4 @@ class NotFoundException extends RequestException
parent::__construct($request, 'Not Found', 404, $previous);
}
}
-
- public function getRequest(): ServerRequestInterface
- {
- return $this->request;
- }
}
diff --git a/system/src/Grav/Framework/RequestHandler/Exception/NotHandledException.php b/system/src/Grav/Framework/RequestHandler/Exception/NotHandledException.php
index 1b18473f5..7b4a0e7d3 100644
--- a/system/src/Grav/Framework/RequestHandler/Exception/NotHandledException.php
+++ b/system/src/Grav/Framework/RequestHandler/Exception/NotHandledException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\RequestHandler
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php b/system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php
index 747c0ca5a..f75216722 100644
--- a/system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php
+++ b/system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\RequestHandler
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/RequestHandler/Exception/RequestException.php b/system/src/Grav/Framework/RequestHandler/Exception/RequestException.php
index 60799644f..678b26786 100644
--- a/system/src/Grav/Framework/RequestHandler/Exception/RequestException.php
+++ b/system/src/Grav/Framework/RequestHandler/Exception/RequestException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\RequestHandler
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/RequestHandler/Middlewares/Exceptions.php b/system/src/Grav/Framework/RequestHandler/Middlewares/Exceptions.php
index 9eadf72e3..36ef3a53f 100644
--- a/system/src/Grav/Framework/RequestHandler/Middlewares/Exceptions.php
+++ b/system/src/Grav/Framework/RequestHandler/Middlewares/Exceptions.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\RequestHandler
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/RequestHandler/RequestHandler.php b/system/src/Grav/Framework/RequestHandler/RequestHandler.php
index 5b0380583..2ce2427f4 100644
--- a/system/src/Grav/Framework/RequestHandler/RequestHandler.php
+++ b/system/src/Grav/Framework/RequestHandler/RequestHandler.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\RequestHandler
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -12,9 +12,11 @@ declare(strict_types=1);
namespace Grav\Framework\RequestHandler;
use Grav\Framework\RequestHandler\Traits\RequestHandlerTrait;
+use Pimple\Container;
use Psr\Container\ContainerInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
+use function assert;
/**
* Class RequestHandler
@@ -47,7 +49,11 @@ class RequestHandler implements RequestHandlerInterface
*/
public function addCallable(string $name, callable $callable): self
{
- $this->container[$name] = $callable;
+ if (null !== $this->container) {
+ assert($this->container instanceof Container);
+ $this->container[$name] = $callable;
+ }
+
array_unshift($this->middleware, $name);
return $this;
@@ -62,7 +68,11 @@ class RequestHandler implements RequestHandlerInterface
*/
public function addMiddleware(string $name, MiddlewareInterface $middleware): self
{
- $this->container[$name] = $middleware;
+ if (null !== $this->container) {
+ assert($this->container instanceof Container);
+ $this->container[$name] = $middleware;
+ }
+
array_unshift($this->middleware, $name);
return $this;
diff --git a/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php b/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php
index 1b5a79e8d..ff82889d4 100644
--- a/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php
+++ b/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\RequestHandler
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Route/Route.php b/system/src/Grav/Framework/Route/Route.php
index f9a7fa722..d4d90780f 100644
--- a/system/src/Grav/Framework/Route/Route.php
+++ b/system/src/Grav/Framework/Route/Route.php
@@ -3,12 +3,13 @@
/**
* @package Grav\Framework\Route
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Route;
+use Grav\Framework\Uri\Uri;
use Grav\Framework\Uri\UriFactory;
use InvalidArgumentException;
use function array_slice;
@@ -318,7 +319,7 @@ class Route
}
/**
- * @return \Grav\Framework\Uri\Uri
+ * @return Uri
*/
public function getUri()
{
@@ -344,6 +345,7 @@ class Route
* @return string
* @deprecated 1.6 Use ->toString(true) or ->getUri() instead.
*/
+ #[\ReturnTypeWillChange]
public function __toString()
{
user_error(__CLASS__ . '::' . __FUNCTION__ . '() will change in the future to return route, not relative url: use ->toString(true) or ->getUri() instead.', E_USER_DEPRECATED);
diff --git a/system/src/Grav/Framework/Route/RouteFactory.php b/system/src/Grav/Framework/Route/RouteFactory.php
index 68baf55b6..fa1a76c30 100644
--- a/system/src/Grav/Framework/Route/RouteFactory.php
+++ b/system/src/Grav/Framework/Route/RouteFactory.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Route
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Session/Exceptions/SessionException.php b/system/src/Grav/Framework/Session/Exceptions/SessionException.php
index 5ad948b67..a07e87dc9 100644
--- a/system/src/Grav/Framework/Session/Exceptions/SessionException.php
+++ b/system/src/Grav/Framework/Session/Exceptions/SessionException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Session
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Session/Messages.php b/system/src/Grav/Framework/Session/Messages.php
index 5d854a218..37c62a9af 100644
--- a/system/src/Grav/Framework/Session/Messages.php
+++ b/system/src/Grav/Framework/Session/Messages.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Session
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Session/Session.php b/system/src/Grav/Framework/Session/Session.php
index 3feae5a2a..108563e37 100644
--- a/system/src/Grav/Framework/Session/Session.php
+++ b/system/src/Grav/Framework/Session/Session.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Session
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -189,7 +189,11 @@ class Session implements SessionInterface
return $this;
}
- $sessionName = session_name();
+ $sessionName = $this->getName();
+ if (null === $sessionName) {
+ return $this;
+ }
+
$sessionExists = isset($_COOKIE[$sessionName]);
// Protection against invalid session cookie names throwing exception: http://php.net/manual/en/function.session-id.php#116836
@@ -341,7 +345,7 @@ class Session implements SessionInterface
$this->removeCookie();
setcookie(
- session_name(),
+ $name,
'',
$this->getCookieOptions(-42000)
);
@@ -392,6 +396,7 @@ class Session implements SessionInterface
/**
* @inheritdoc
*/
+ #[\ReturnTypeWillChange]
public function getIterator()
{
return new ArrayIterator($_SESSION);
@@ -408,6 +413,7 @@ class Session implements SessionInterface
/**
* @inheritdoc
*/
+ #[\ReturnTypeWillChange]
public function __isset($name)
{
return isset($_SESSION[$name]);
@@ -416,6 +422,7 @@ class Session implements SessionInterface
/**
* @inheritdoc
*/
+ #[\ReturnTypeWillChange]
public function __get($name)
{
return $_SESSION[$name] ?? null;
@@ -424,6 +431,7 @@ class Session implements SessionInterface
/**
* @inheritdoc
*/
+ #[\ReturnTypeWillChange]
public function __set($name, $value)
{
$_SESSION[$name] = $value;
@@ -432,6 +440,7 @@ class Session implements SessionInterface
/**
* @inheritdoc
*/
+ #[\ReturnTypeWillChange]
public function __unset($name)
{
unset($_SESSION[$name]);
@@ -478,9 +487,15 @@ class Session implements SessionInterface
{
$this->removeCookie();
+ $sessionName = $this->getName();
+ $sessionId = $this->getId();
+ if (null === $sessionName || null === $sessionId) {
+ return;
+ }
+
setcookie(
- session_name(),
- session_id(),
+ $sessionName,
+ $sessionId,
$this->getCookieOptions()
);
}
diff --git a/system/src/Grav/Framework/Session/SessionInterface.php b/system/src/Grav/Framework/Session/SessionInterface.php
index 43ca40fd9..fa2873d9a 100644
--- a/system/src/Grav/Framework/Session/SessionInterface.php
+++ b/system/src/Grav/Framework/Session/SessionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Session
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -16,6 +16,7 @@ use RuntimeException;
/**
* Class Session
* @package Grav\Framework\Session
+ * @extends IteratorAggregate
*/
interface SessionInterface extends IteratorAggregate
{
@@ -107,7 +108,9 @@ interface SessionInterface extends IteratorAggregate
* Retrieve an external iterator
*
* @return ArrayIterator Return an ArrayIterator of $_SESSION
+ * @phpstan-return ArrayIterator
*/
+ #[\ReturnTypeWillChange]
public function getIterator();
/**
@@ -123,6 +126,7 @@ interface SessionInterface extends IteratorAggregate
* @param string $name
* @return bool
*/
+ #[\ReturnTypeWillChange]
public function __isset($name);
/**
@@ -131,6 +135,7 @@ interface SessionInterface extends IteratorAggregate
* @param string $name
* @return mixed
*/
+ #[\ReturnTypeWillChange]
public function __get($name);
/**
@@ -140,6 +145,7 @@ interface SessionInterface extends IteratorAggregate
* @param mixed $value
* @return void
*/
+ #[\ReturnTypeWillChange]
public function __set($name, $value);
/**
@@ -148,5 +154,6 @@ interface SessionInterface extends IteratorAggregate
* @param string $name
* @return void
*/
+ #[\ReturnTypeWillChange]
public function __unset($name);
}
diff --git a/system/src/Grav/Framework/Uri/Uri.php b/system/src/Grav/Framework/Uri/Uri.php
index c43496ea9..6355a1fc9 100644
--- a/system/src/Grav/Framework/Uri/Uri.php
+++ b/system/src/Grav/Framework/Uri/Uri.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Uri
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Uri/UriFactory.php b/system/src/Grav/Framework/Uri/UriFactory.php
index f7724b78d..ebfec0356 100644
--- a/system/src/Grav/Framework/Uri/UriFactory.php
+++ b/system/src/Grav/Framework/Uri/UriFactory.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Uri
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -125,7 +125,7 @@ class UriFactory
$encodedUrl = preg_replace_callback(
'%[^:/@?&=#]+%u',
- function ($matches) {
+ static function ($matches) {
return rawurlencode($matches[0]);
},
$url
diff --git a/system/src/Grav/Framework/Uri/UriPartsFilter.php b/system/src/Grav/Framework/Uri/UriPartsFilter.php
index 71a5135d6..260711bf4 100644
--- a/system/src/Grav/Framework/Uri/UriPartsFilter.php
+++ b/system/src/Grav/Framework/Uri/UriPartsFilter.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Uri
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Installer/Install.php b/system/src/Grav/Installer/Install.php
index 4df9dcd56..0f23e8963 100644
--- a/system/src/Grav/Installer/Install.php
+++ b/system/src/Grav/Installer/Install.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Installer
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -36,9 +36,11 @@ final class Install
'php' => [
'name' => 'PHP',
'versions' => [
- '7.4' => '7.4.0',
+ '8.1' => '8.1.0',
+ '8.0' => '8.0.0',
+ '7.4' => '7.4.1',
'7.3' => '7.3.6',
- '' => '7.4.12'
+ '' => '8.0.13'
]
],
'grav' => [
@@ -114,7 +116,7 @@ final class Install
/** @var string|null */
private $location;
- /** @var VersionUpdater */
+ /** @var VersionUpdater|null */
private $updater;
/** @var static */
@@ -151,6 +153,7 @@ final class Install
* @param string|null $zip
* @return void
*/
+ #[\ReturnTypeWillChange]
public function __invoke(?string $zip)
{
$this->zip = $zip;
@@ -249,6 +252,11 @@ ERR;
}
try {
+ if (null === $this->updater) {
+ $versions = Versions::instance(USER_DIR . 'config/versions.yaml');
+ $this->updater = new VersionUpdater('core/grav', __DIR__ . '/updates', $this->getVersion(), $versions);
+ }
+
// Update user/config/version.yaml before copying the files to avoid frontend from setting the version schema.
$this->updater->install();
@@ -279,7 +287,7 @@ ERR;
public function finalize(): void
{
// Finalize can be run without installing Grav first.
- if (!$this->updater) {
+ if (null === $this->updater) {
$versions = Versions::instance(USER_DIR . 'config/versions.yaml');
$this->updater = new VersionUpdater('core/grav', __DIR__ . '/updates', GRAV_VERSION, $versions);
$this->updater->install();
diff --git a/system/src/Grav/Installer/InstallException.php b/system/src/Grav/Installer/InstallException.php
index 145b7c9cc..cdd5b7afa 100644
--- a/system/src/Grav/Installer/InstallException.php
+++ b/system/src/Grav/Installer/InstallException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Installer
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Installer/VersionUpdate.php b/system/src/Grav/Installer/VersionUpdate.php
index faaf2a2d9..3efca1f31 100644
--- a/system/src/Grav/Installer/VersionUpdate.php
+++ b/system/src/Grav/Installer/VersionUpdate.php
@@ -50,7 +50,7 @@ final class VersionUpdate
public function getPatch(): string
{
- return $this->date;
+ return $this->patch;
}
public function getUpdater(): VersionUpdater
diff --git a/system/src/Grav/Installer/Versions.php b/system/src/Grav/Installer/Versions.php
index 03f3b0b0f..92a64ced7 100644
--- a/system/src/Grav/Installer/Versions.php
+++ b/system/src/Grav/Installer/Versions.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Installer
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Installer/YamlUpdater.php b/system/src/Grav/Installer/YamlUpdater.php
index 9af20558f..ac562495f 100644
--- a/system/src/Grav/Installer/YamlUpdater.php
+++ b/system/src/Grav/Installer/YamlUpdater.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Installer
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Twig/DeferredExtension/DeferredNodeVisitorCompat.php b/system/src/Twig/DeferredExtension/DeferredNodeVisitorCompat.php
index 8c441bb9a..1ff7fd421 100644
--- a/system/src/Twig/DeferredExtension/DeferredNodeVisitorCompat.php
+++ b/system/src/Twig/DeferredExtension/DeferredNodeVisitorCompat.php
@@ -22,16 +22,28 @@ final class DeferredNodeVisitorCompat implements NodeVisitorInterface
{
private $hasDeferred = false;
- public function enterNode(\Twig_NodeInterface $node, Environment $env) : Node
+ /**
+ * @param \Twig_NodeInterface $node
+ * @param Environment $env
+ * @return Node
+ */
+ public function enterNode(\Twig_NodeInterface $node, Environment $env): Node
{
if (!$this->hasDeferred && $node instanceof DeferredBlockNode) {
$this->hasDeferred = true;
}
+ \assert($node instanceof Node);
+
return $node;
}
- public function leaveNode(\Twig_NodeInterface $node, Environment $env) : ?Node
+ /**
+ * @param \Twig_NodeInterface $node
+ * @param Environment $env
+ * @return Node|null
+ */
+ public function leaveNode(\Twig_NodeInterface $node, Environment $env): ?Node
{
if ($this->hasDeferred && $node instanceof ModuleNode) {
$node->setNode('constructor_end', new Node([new DeferredExtensionNode(), $node->getNode('constructor_end')]));
@@ -39,9 +51,14 @@ final class DeferredNodeVisitorCompat implements NodeVisitorInterface
$this->hasDeferred = false;
}
+ \assert($node instanceof Node);
+
return $node;
}
+ /**
+ * @return int
+ */
public function getPriority() : int
{
return 0;
diff --git a/tests/phpstan/classes/Toolbox/UniformResourceLocatorExtension.php b/tests/phpstan/classes/Toolbox/UniformResourceLocatorExtension.php
new file mode 100644
index 000000000..98bbca8a9
--- /dev/null
+++ b/tests/phpstan/classes/Toolbox/UniformResourceLocatorExtension.php
@@ -0,0 +1,51 @@
+getName() === 'findResource';
+ }
+
+ /**
+ * @param MethodReflection $methodReflection
+ * @param MethodCall $methodCall
+ * @param Scope $scope
+ * @return Type
+ */
+ public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
+ {
+ $first = $methodCall->getArgs()[2] ?? false;
+ if ($first) {
+ return new StringType();
+ }
+
+ return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
+ }
+}
diff --git a/tests/phpstan/extension.neon b/tests/phpstan/extension.neon
new file mode 100644
index 000000000..ef44d0b41
--- /dev/null
+++ b/tests/phpstan/extension.neon
@@ -0,0 +1,5 @@
+services:
+ -
+ class: PHPStan\Toolbox\UniformResourceLocatorExtension
+ tags:
+ - phpstan.broker.dynamicMethodReturnTypeExtension
diff --git a/tests/phpstan/phpstan.neon b/tests/phpstan/phpstan.neon
index 12dc402a2..ef7a598de 100644
--- a/tests/phpstan/phpstan.neon
+++ b/tests/phpstan/phpstan.neon
@@ -2,6 +2,7 @@
includes:
#- '../../vendor/phpstan/phpstan-strict-rules/rules.neon'
- '../../vendor/phpstan/phpstan-deprecation-rules/rules.neon'
+ - 'extension.neon'
parameters:
fileExtensions:
- php
@@ -10,15 +11,27 @@ parameters:
- phpstan-bootstrap.php
excludePaths:
- */system/src/Grav/Common/Errors/Resources/layout.html.php
- - */system/src/Twig/DeferredExtension/DeferredNodeVisitor.php
+ - */system/src/Twig/DeferredExtension/DeferredNodeVisitorCompat.php # Twig 1
+ - */system/src/Twig/DeferredExtension/DeferredNodeVisitor.php # Twig 2+3
+ # Ignore vendor dev dependencies and tests
+ - */vendor/*/*/tests
+ - */vendor/behat
+ - */vendor/codeception
+ - */vendor/phpstan
+ - */vendor/phpunit
+ - */vendor/phpspec
+ - */vendor/phpdocumentor
+ - */vendor/sebastian
+ - */vendor/theseer
+ - */vendor/webmozart
inferPrivatePropertyTypeFromConstructor: true
reportUnmatchedIgnoredErrors: false
treatPhpDocTypesAsCertain: false
- # These checks are new in phpstan 0.12, ignore them for now.
+ # These checks are new in phpstan 1, ignore them for now.
checkMissingIterableValueType: false
- checkGenericClassInNonGenericObjectType: false
+ #checkGenericClassInNonGenericObjectType: false
universalObjectCratesClasses:
- Grav\Common\Config\Config
@@ -33,42 +46,23 @@ parameters:
dynamicConstantNames:
- GRAV_CLI
ignoreErrors:
- # New in phpstan 0.12, ignore them for now.
+ # New in phpstan 1, ignore them for now.
- '#Unsafe usage of new static\(\)#'
- - '#Cannot instantiate interface Grav\\Framework\\#'
- # TODO: phpstan bug #3875 (fixed, test if can be removed)
- -
- message: '#Unreachable statement - code above always terminates#'
- path: '*/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php'
-
- # FIXME: Bugs that need to be fixed
- # FIXME: PHP 7.3 bug workaround
- -
- message: '#If condition is always false.#'
- path: '*/system/src/Grav/Framework/Session/Session.php'
# TODO: Errors that needs some more thinking (bad design?)
- '#Access to an undefined property RocketTheme\\Toolbox\\Event\\Event::#'
- '#Instantiation of deprecated class RocketTheme\\Toolbox\\Event\\Event#'
- '#extends deprecated class RocketTheme\\Toolbox\\Event\\Event#'
- - '#implements deprecated interface RocketTheme\\Toolbox\\Event\\EventSubscriberInterface#'
- '#Access to an undefined property Grav\\Common\\Data\\Blueprint::#'
- - '#Access to an undefined property Grav\\Common\\Media\\Interfaces\\MediaObjectInterface::#'
-
message: '#Cannot call method path\(\) on string#'
path: '*/system/src/Grav/Common/Page/Media.php'
- - '"FlexCollectionInterface::filterBy\(\) invoked with 2 parameters"'
# TODO: system.twig.umask_fix will not work with Twig 2 anymore
-
message: '#Call to deprecated method writeCacheFile\(\) of class Twig\\Environment#'
path: '*/system/src/Grav/Common/Twig/WriteCacheFileTrait.php'
- # 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'
-
# PSR-16 Exception interfaces do not extend \Throwable
- '#PHPDoc tag \@throws with type Psr\\SimpleCache\\(CacheException|InvalidArgumentException) is not subtype of Throwable#'
@@ -85,17 +79,12 @@ parameters:
-
message: '#unknown class Grav\\Plugin\\Admin#'
path: '*/system/src/Grav/Common/Flex/Pages/PageObject.php'
- -
- message: '#unknown class Grav\\Common\\Grav\\Plugin\\Form\\Forms#'
- path: '*/system/src/Grav/Common/Session.php'
-
message: '#unknown class Grav\\Plugin\\Admin\\Admin#'
path: '*/system/src/Grav/Common/Flex/Types/Pages/PageObject.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'
+ message: '#unknown class Grav\\Plugin\\Form\\Forms#'
+ path: '*/system/src/Grav/Common/Processors/PagesProcessor.php'
# Clockwork does not define functions for __call() call
-
@@ -141,9 +130,6 @@ parameters:
-
message: '#Call to deprecated method getLegacyFiles\(\)#'
path: '*/system/src/Grav/Common/Session.php'
- -
- message: '#Call to deprecated method getType\(\) of class#'
- path: '*/system/src/Grav/Framework/Object/Base/ObjectTrait.php'
-
message: '#Call to deprecated method \w+\(\) of class Grav\\Framework\\Flex\\FlexObject#'
path: '*/system/src/Grav/Framework/Flex/FlexObject.php'
diff --git a/tests/phpstan/plugins-bootstrap.php b/tests/phpstan/plugins-bootstrap.php
index c28f2ab8a..1c1828033 100644
--- a/tests/phpstan/plugins-bootstrap.php
+++ b/tests/phpstan/plugins-bootstrap.php
@@ -10,10 +10,6 @@ use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
$autoload = require __DIR__ . '/../../vendor/autoload.php';
-if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) {
- exit(sprintf("You are running PHP %s, but Grav needs at least PHP %s to run.\n", $ver, $req));
-}
-
if (!ini_get('date.timezone')) {
date_default_timezone_set('UTC');
}
diff --git a/tests/phpstan/plugins.neon b/tests/phpstan/plugins.neon
index ae257f80e..82570cca5 100644
--- a/tests/phpstan/plugins.neon
+++ b/tests/phpstan/plugins.neon
@@ -1,6 +1,7 @@
includes:
#- '../../vendor/phpstan/phpstan-strict-rules/rules.neon'
- '../../vendor/phpstan/phpstan-deprecation-rules/rules.neon'
+ - 'extension.neon'
parameters:
fileExtensions:
- php
@@ -9,12 +10,23 @@ parameters:
- %currentWorkingDirectory%/user/plugins/*/tests/*
- %currentWorkingDirectory%/user/plugins/gantry5/src/platforms
- %currentWorkingDirectory%/user/plugins/gantry5/src/classes/Gantry/Framework/Services/ErrorServiceProvider.php
+ # Ignore vendor dev dependencies and tests
+ - */vendor/*/*/tests
+ - */vendor/behat
+ - */vendor/codeception
+ - */vendor/phpstan
+ - */vendor/phpunit
+ - */vendor/phpspec
+ - */vendor/phpdocumentor
+ - */vendor/sebastian
+ - */vendor/theseer
+ - */vendor/webmozart
bootstrapFiles:
- plugins-bootstrap.php
inferPrivatePropertyTypeFromConstructor: true
reportUnmatchedIgnoredErrors: false
- # These checks are new in phpstan 0.12, ignore them for now.
+ # These checks are new in phpstan 1, ignore them for now.
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
@@ -26,6 +38,7 @@ parameters:
- Grav\Common\GPM\Common\Package
- Grav\Common\GPM\Local\Package
- Grav\Common\GPM\Remote\Package
+ - Grav\Common\Page\Header
- Grav\Common\Session
- Gantry\Component\Config\Config
dynamicConstantNames:
@@ -37,7 +50,7 @@ parameters:
- GANTRY5_PLATFORM
- GANTRY5_ROOT
ignoreErrors:
- # New in phpstan 0.12, ignore them for now.
+ # New in phpstan 1, ignore them for now.
- '#Unsafe usage of new static\(\)#'
- '#Cannot instantiate interface Grav\\Framework\\#'
diff --git a/tmp/.gitkeep b/tmp/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/tmp/.gitkeep
+++ b/tmp/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/user/accounts/.gitkeep b/user/accounts/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/user/accounts/.gitkeep
+++ b/user/accounts/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/user/data/.gitkeep b/user/data/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/user/data/.gitkeep
+++ b/user/data/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/user/plugins/.gitkeep b/user/plugins/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/user/plugins/.gitkeep
+++ b/user/plugins/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/user/themes/.gitkeep b/user/themes/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/user/themes/.gitkeep
+++ b/user/themes/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/webserver-configs/htaccess.txt b/webserver-configs/htaccess.txt
index 83063ae2e..098c58244 100644
--- a/webserver-configs/htaccess.txt
+++ b/webserver-configs/htaccess.txt
@@ -59,9 +59,9 @@ RewriteRule .* index.php [L]
# Block all direct access for these folders
RewriteRule ^(\.git|cache|bin|logs|backup|webserver-configs|tests)/(.*) error [F]
# Block access to specific file types for these system folders
-RewriteRule ^(system|vendor)/(.*)\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
+RewriteRule ^(system|vendor)/(.*)\.(txt|xml|md|html|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
# Block access to specific file types for these user folders
-RewriteRule ^(user)/(.*)\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
+RewriteRule ^(user)/(.*)\.(txt|md|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
# Block all direct access to .md files:
RewriteRule \.md$ error [F]
# Block all direct access to files and folders beginning with a dot
diff --git a/webserver-configs/lighttpd.conf b/webserver-configs/lighttpd.conf
index 512362fd1..f14c5a8b9 100644
--- a/webserver-configs/lighttpd.conf
+++ b/webserver-configs/lighttpd.conf
@@ -33,7 +33,7 @@ $HTTP["url"] =~ "^/grav_path/(LICENSE\.txt|composer\.json|composer\.lock|nginx\.
$HTTP["url"] =~ "^/grav_path/(\.git|cache|bin|logs|backup|tests)/(.*)" {
url.access-deny = ("")
}
-$HTTP["url"] =~ "^/grav_path/(system|user|vendor)/(.*)\.(txt|md|html|yaml|yml|php|twig|sh|bat)$" {
+$HTTP["url"] =~ "^/grav_path/(system|user|vendor)/(.*)\.(txt|md|html|json|yaml|yml|php|twig|sh|bat)$" {
url.access-deny = ("")
}
$HTTP["url"] =~ "^/grav_path/(\.(.*))" {
diff --git a/webserver-configs/nginx.conf b/webserver-configs/nginx.conf
index bbca7d32d..fc7d06b49 100644
--- a/webserver-configs/nginx.conf
+++ b/webserver-configs/nginx.conf
@@ -20,9 +20,9 @@ server {
# deny all direct access for these folders
location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
# deny running scripts inside core system folders
- location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
+ location ~* /(system|vendor)/.*\.(txt|xml|md|html|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
# deny running scripts inside user folder
- location ~* /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
+ location ~* /user/.*\.(txt|md|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
# deny access to specific files in the root folder
location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }
## End - Security
diff --git a/webserver-configs/web.config b/webserver-configs/web.config
index 892ce9282..1c351a3b3 100644
--- a/webserver-configs/web.config
+++ b/webserver-configs/web.config
@@ -18,7 +18,7 @@
-
+
@@ -26,11 +26,11 @@
-
+
-
+