mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Compare commits
88 Commits
develop
...
1.8.0-beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a15fe29f43 | ||
|
|
3126fa8388 | ||
|
|
b0c339c9eb | ||
|
|
f812ee8555 | ||
|
|
8c6388bb74 | ||
|
|
d7aaef986e | ||
|
|
ab9363c478 | ||
|
|
7f2da96c0b | ||
|
|
b16db4b9c0 | ||
|
|
42c0682dd8 | ||
|
|
1969ec1876 | ||
|
|
c30661736c | ||
|
|
3d2dfa2faf | ||
|
|
f06bbfc563 | ||
|
|
37e5526a4f | ||
|
|
85c4b8279e | ||
|
|
46736ce256 | ||
|
|
800b2e1ecb | ||
|
|
4f065b95a7 | ||
|
|
b59a3adc80 | ||
|
|
4ec9a3a489 | ||
|
|
173d08243a | ||
|
|
62c60b8ba1 | ||
|
|
59031a8711 | ||
|
|
5cd859865f | ||
|
|
16eafbbb04 | ||
|
|
3947bb03aa | ||
|
|
ee55d097f2 | ||
|
|
ae567469b7 | ||
|
|
f6decaab15 | ||
|
|
10d36a10bc | ||
|
|
574a430a10 | ||
|
|
302f02ca5d | ||
|
|
c334479e4c | ||
|
|
b96483c49a | ||
|
|
cccce836f6 | ||
|
|
bdcb77d429 | ||
|
|
e15cc86716 | ||
|
|
dcfbd73d43 | ||
|
|
1967910789 | ||
|
|
4f1f9a7755 | ||
|
|
e4f483998d | ||
|
|
7a393101ee | ||
|
|
10b15bedf2 | ||
|
|
8c14a9907e | ||
|
|
f490d9a7e1 | ||
|
|
81ca0c2e25 | ||
|
|
fbfac9f8f4 | ||
|
|
d6e72708bf | ||
|
|
2aff274c31 | ||
|
|
74c1dfa433 | ||
|
|
f51a9d9d87 | ||
|
|
e5498f58e6 | ||
|
|
8f58a4494c | ||
|
|
5bfd43256d | ||
|
|
69bc3f7f25 | ||
|
|
782ceada80 | ||
|
|
36392acbea | ||
|
|
4b564df38f | ||
|
|
9d179e5b2a | ||
|
|
6032bd07dc | ||
|
|
9a87a509b0 | ||
|
|
46f2a81b21 | ||
|
|
f5e21645f6 | ||
|
|
12c8cf9c40 | ||
|
|
93bb929b38 | ||
|
|
85eaf308d5 | ||
|
|
d9ede28b99 | ||
|
|
2e65b0eea4 | ||
|
|
7660a80ef7 | ||
|
|
6d0a436834 | ||
|
|
176fd8f1d8 | ||
|
|
2f85fe9c99 | ||
|
|
d93d297dc4 | ||
|
|
fcd9093f84 | ||
|
|
58b54a70bd | ||
|
|
9daa0a9041 | ||
|
|
965e03daf2 | ||
|
|
b6c3db082a | ||
|
|
26b68953c4 | ||
|
|
fba015c5d9 | ||
|
|
7223c177c4 | ||
|
|
a68bdd2b75 | ||
|
|
38e4624506 | ||
|
|
ad9287ee0f | ||
|
|
777ac119de | ||
|
|
076c64841e | ||
|
|
62cb40fef5 |
8
.github/workflows/build.yaml
vendored
8
.github/workflows/build.yaml
vendored
|
|
@ -11,7 +11,7 @@ jobs:
|
|||
permissions:
|
||||
contents: write # for release creation (svenstaro/upload-release-action)
|
||||
|
||||
if: "!github.event.release.prerelease"
|
||||
#if: "!github.event.release.prerelease"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
|
@ -23,7 +23,7 @@ jobs:
|
|||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.3
|
||||
php-version: 8.2
|
||||
extensions: opcache, gd
|
||||
tools: composer:v2
|
||||
coverage: none
|
||||
|
|
@ -38,10 +38,10 @@ jobs:
|
|||
- name: Retrieval of Builder Scripts
|
||||
run: |
|
||||
# Real Grav URL
|
||||
curl --silent -H "Authorization: token ${{ secrets.GLOBAL_TOKEN }}" -H "Accept: application/vnd.github.v3.raw" ${{ secrets.BUILD_SCRIPT_URL }} --output build-grav.sh
|
||||
curl --silent -H "Authorization: token ${{ secrets.GLOBAL_TOKEN }}" -H "Accept: application/vnd.github.v3.raw" ${{ secrets.BUILD_SCRIPT_URL_18 }} --output build-grav.sh
|
||||
|
||||
# Development Local URL
|
||||
# curl ${{ secrets.BUILD_SCRIPT_URL }} --output build-grav.sh
|
||||
# curl ${{ secrets.BUILD_SCRIPT_URL_18 }} --output build-grav.sh
|
||||
|
||||
- name: Grav Builder
|
||||
run: |
|
||||
|
|
|
|||
56
CHANGELOG.md
56
CHANGELOG.md
|
|
@ -1,3 +1,39 @@
|
|||
# v1.8.0-beta.3
|
||||
## 11/21/2024
|
||||
|
||||
1. [](#improved)
|
||||
* Updated composer libraries to latest versions for compatibility fixes
|
||||
|
||||
# v1.8.0-beta.2
|
||||
## 10/28/2024
|
||||
|
||||
1. [](#new)
|
||||
* Use `dev-master` branch of Clockwork to support Monolog2 / Monolog3
|
||||
* `AVIF` image support via updates to `getgrav/Image` library
|
||||
* Upgraded to **Doctrine Collection 2.2**
|
||||
1. [](#improved)
|
||||
* Updated composer libraries
|
||||
* Updated composer.php binary to `v2.8.1`
|
||||
* Fixes for PHP 8.4 - Implicitly nullable parameter declarations deprecated
|
||||
* Added back Missing `RocketTheme\Toolbox\Event\EventSubscriberInterface` for Gantry5
|
||||
1. [](#bugfix)
|
||||
* Various fixes to use `$log->debug()`, `$log->info()`, `$log->warning()` and `$log->error()` For Monolog2 support
|
||||
|
||||
# v1.8.0-beta.1
|
||||
## 10/23/2024
|
||||
|
||||
1. [](#new)
|
||||
* Set minimum requirements to **PHP 8.2**
|
||||
* Updated to **Twig 2.14**
|
||||
* Updated to **Symfony 6.4**
|
||||
* Updated to **Monolog 2.3**
|
||||
* Updated to **RocketTheme/Toolbox 2.0**
|
||||
* Updated to **Composer/Semver 3.2**
|
||||
* Use **Symfony Cache** instead of unmaintained **Doctrine Cache**
|
||||
* Removed unsupported **APC**, **WinCache**, **XCache** and **Memcache**, use apcu or memcached instead
|
||||
* Removed `system.umask_fix` setting for security reasons
|
||||
* Support phpstan level 6 in Framework classes
|
||||
|
||||
# v1.7.48
|
||||
## 10/28/2024
|
||||
|
||||
|
|
@ -12,18 +48,18 @@
|
|||
## 10/23/2024
|
||||
|
||||
1. [](#new)
|
||||
* New `Utils::toAscii()` method
|
||||
* Added support for Clockwork Debugger to allow web UI (requires new `clockwork-web` plugin)
|
||||
* New `Utils::toAscii()` method
|
||||
* Added support for Clockwork Debugger to allow web UI (requires new `clockwork-web` plugin)
|
||||
1. [](#improved)
|
||||
* Include modular sub-pages in last-modification date computation [#3562](https://github.com/getgrav/grav/pull/3562)
|
||||
* Updated vendor libs to latest versions
|
||||
* Updated JQuery to `3.7.1` [#3787](https://github.com/getgrav/grav/pull/3827)
|
||||
* Updated vendor libraries to latest versions
|
||||
* Support for Fediverse Creator meta tag [#3844](https://github.com/getgrav/grav/pull/3844)
|
||||
* Include modular sub-pages in last-modification date computation [#3562](https://github.com/getgrav/grav/pull/3562)
|
||||
* Updated vendor libs to latest versions
|
||||
* Updated JQuery to `3.7.1` [#3787](https://github.com/getgrav/grav/pull/3827)
|
||||
* Updated vendor libraries to latest versions
|
||||
* Support for Fediverse Creator meta tag [#3844](https://github.com/getgrav/grav/pull/3844)
|
||||
1. [](#bugfix)
|
||||
* Fixes deprecated for return type in Filesystem with PHP 8.3.6 [#3831](https://github.com/getgrav/grav/issues/3831)
|
||||
* Fix for `exif_imagtetype()` throwing an exception when file doesn't exist
|
||||
* Fix JSON output comments check with content type [#3859](https://github.com/getgrav/grav/pull/3859)
|
||||
* Fixes deprecated for return type in Filesystem with PHP 8.3.6 [#3831](https://github.com/getgrav/grav/issues/3831)
|
||||
* Fix for `exif_imagtetype()` throwing an exception when file doesn't exist
|
||||
* Fix JSON output comments check with content type [#3859](https://github.com/getgrav/grav/pull/3859)
|
||||
|
||||
# v1.7.46
|
||||
## 05/15/2024
|
||||
|
|
|
|||
|
|
@ -89,9 +89,10 @@ $ bin/gpm update
|
|||
|
||||
## Upgrading from older version
|
||||
|
||||
* [Upgrading to Grav 1.8](https://learn.getgrav.org/16/advanced/grav-development/grav-18-upgrade-guide)
|
||||
* [Upgrading to Grav 1.7](https://learn.getgrav.org/16/advanced/grav-development/grav-17-upgrade-guide)
|
||||
* [Upgrading to Grav 1.6](https://learn.getgrav.org/16/advanced/grav-development/grav-16-upgrade-guide)
|
||||
* [Upgrading from Grav <1.6](https://learn.getgrav.org/16/advanced/grav-development/grav-15-upgrade-guide)
|
||||
* [Upgrading from Grav before 1.6](https://learn.getgrav.org/16/advanced/grav-development/grav-15-upgrade-guide)
|
||||
|
||||
# Contributing
|
||||
We appreciate any contribution to Grav, whether it is related to bugs, grammar, or simply a suggestion or improvement! Please refer to the [Contributing guide](CONTRIBUTING.md) for more guidance on this topic.
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -2,7 +2,7 @@ actor: Tester
|
|||
bootstrap: _bootstrap.php
|
||||
paths:
|
||||
tests: tests
|
||||
log: tests/_output
|
||||
output: tests/_output
|
||||
data: tests/_data
|
||||
support: tests/_support
|
||||
envs: tests/_envs
|
||||
|
|
|
|||
102
composer.json
102
composer.json
|
|
@ -12,7 +12,7 @@
|
|||
"homepage": "https://getgrav.org",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^7.3.6 || ^8.0",
|
||||
"php": "^8.2",
|
||||
"ext-json": "*",
|
||||
"ext-openssl": "*",
|
||||
"ext-curl": "*",
|
||||
|
|
@ -20,61 +20,71 @@
|
|||
"ext-dom": "*",
|
||||
"ext-libxml": "*",
|
||||
"ext-gd": "*",
|
||||
"symfony/polyfill-mbstring": "~1.23",
|
||||
"symfony/polyfill-iconv": "^1.23",
|
||||
"symfony/polyfill-php74": "^1.23",
|
||||
"symfony/polyfill-php80": "^1.23",
|
||||
"symfony/polyfill-php81": "^1.23",
|
||||
"symfony/polyfill-mbstring": "^1.24",
|
||||
"symfony/polyfill-iconv": "^1.24",
|
||||
"symfony/polyfill-php80": "^1.24",
|
||||
"symfony/polyfill-php81": "^1.24",
|
||||
"psr/simple-cache": "^1.0",
|
||||
"psr/http-message": "^1.0",
|
||||
"psr/http-message": "^1.1",
|
||||
"psr/http-server-middleware": "^1.0",
|
||||
"psr/container": "~1.1.0",
|
||||
"nyholm/psr7-server": "^1.0",
|
||||
"nyholm/psr7": "^1.3",
|
||||
"twig/twig": "~v1.44",
|
||||
"psr/container": "^1.1",
|
||||
"psr/log": "^1.1",
|
||||
"symfony/cache": "^6.4",
|
||||
"symfony/yaml": "^6.4",
|
||||
"symfony/console": "^6.4",
|
||||
"symfony/event-dispatcher": "^6.4",
|
||||
"symfony/var-exporter": "^6.4",
|
||||
"symfony/var-dumper": "^6.4",
|
||||
"symfony/process": "^6.4",
|
||||
"symfony/http-client": "^6.4",
|
||||
"twig/twig": "^2.1",
|
||||
"monolog/monolog": "^2.0",
|
||||
"doctrine/cache": "^2.2",
|
||||
"doctrine/collections": "^2.2",
|
||||
"pimple/pimple": "~3.5.0",
|
||||
"nyholm/psr7-server": "^1.1",
|
||||
"nyholm/psr7": "^1.8",
|
||||
"erusev/parsedown": "^1.7",
|
||||
"erusev/parsedown-extra": "~0.8",
|
||||
"symfony/contracts": "~1.1",
|
||||
"symfony/yaml": "~4.4",
|
||||
"symfony/console": "~4.4",
|
||||
"symfony/event-dispatcher": "~4.4",
|
||||
"symfony/var-dumper": "~4.4",
|
||||
"symfony/process": "~4.4",
|
||||
"doctrine/cache": "^1.10",
|
||||
"doctrine/collections": "^1.6",
|
||||
"guzzlehttp/psr7": "^1.7",
|
||||
"filp/whoops": "~2.9",
|
||||
"matthiasmullie/minify": "^1.3",
|
||||
"monolog/monolog": "~1.25",
|
||||
"getgrav/image": "^3.0",
|
||||
"getgrav/cache": "^2.0",
|
||||
"donatj/phpuseragentparser": "~1.1",
|
||||
"pimple/pimple": "~3.5.0",
|
||||
"rockettheme/toolbox": "~1.5",
|
||||
"maximebf/debugbar": "~1.16",
|
||||
"league/climate": "^3.6",
|
||||
"miljar/php-exif": "^0.6",
|
||||
"composer/ca-bundle": "^1.2",
|
||||
"dragonmantank/cron-expression": "^1.2",
|
||||
"willdurand/negotiation": "^3.0",
|
||||
"itsgoingd/clockwork": "^5.0",
|
||||
"symfony/http-client": "^4.4",
|
||||
"composer/semver": "^1.4",
|
||||
"rockettheme/toolbox": "v2.x-dev",
|
||||
"composer/ca-bundle": "^1.5",
|
||||
"composer/semver": "^3.4",
|
||||
"dragonmantank/cron-expression": "^3.0",
|
||||
"willdurand/negotiation": "^3.1",
|
||||
"rhukster/dom-sanitizer": "^1.0",
|
||||
"matthiasmullie/minify": "^1.3",
|
||||
"donatj/phpuseragentparser": "~1.9",
|
||||
"guzzlehttp/psr7": "^2.7",
|
||||
"filp/whoops": "~2.16",
|
||||
"itsgoingd/clockwork": "^5.3",
|
||||
"maximebf/debugbar": "~1.23",
|
||||
"getgrav/image": "^4.0",
|
||||
"getgrav/cache": "^2.0",
|
||||
"antoligy/dom-string-iterators": "^1.0",
|
||||
"miljar/php-exif": "^0.6",
|
||||
"league/climate": "^3.8",
|
||||
"multiavatar/multiavatar-php": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"codeception/codeception": "^4.1",
|
||||
"phpstan/phpstan": "^1.8",
|
||||
"phpstan/phpstan-deprecation-rules": "^1.0",
|
||||
"codeception/codeception": "^5.1",
|
||||
"phpstan/phpstan": "^1.12",
|
||||
"phpstan/phpstan-deprecation-rules": "^1.2",
|
||||
"phpunit/php-code-coverage": "~9.2",
|
||||
"getgrav/markdowndocs": "^2.0",
|
||||
"codeception/module-asserts": "^1.3",
|
||||
"codeception/module-phpbrowser": "^1.0"
|
||||
"codeception/module-asserts": "*",
|
||||
"codeception/module-phpbrowser": "*",
|
||||
"rector/rector": "^1.2"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/rockettheme/toolbox"
|
||||
}
|
||||
],
|
||||
"replace": {
|
||||
"symfony/polyfill-php72": "*",
|
||||
"symfony/polyfill-php73": "*"
|
||||
"symfony/polyfill-php73": "*",
|
||||
"symfony/polyfill-php74": "*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring": "Recommended for better performance",
|
||||
|
|
@ -89,12 +99,14 @@
|
|||
"config": {
|
||||
"apcu-autoloader": true,
|
||||
"platform": {
|
||||
"php": "7.3.6"
|
||||
"php": "8.2"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Grav\\": "system/src/Grav",
|
||||
"Doctrine\\": "system/src/Doctrine",
|
||||
"RocketTheme\\": "system/src/RocketTheme",
|
||||
"Twig\\": "system/src/Twig"
|
||||
},
|
||||
"files": [
|
||||
|
|
@ -117,7 +129,7 @@
|
|||
"api-17": "vendor/bin/phpdoc-md generate system/src > user/pages/14.api/default.17.md",
|
||||
"post-create-project-cmd": "bin/grav install",
|
||||
"phpstan": "vendor/bin/phpstan analyse -l 2 -c ./tests/phpstan/phpstan.neon --memory-limit=720M system/src",
|
||||
"phpstan-framework": "vendor/bin/phpstan analyse -l 5 -c ./tests/phpstan/phpstan.neon --memory-limit=480M system/src/Grav/Framework system/src/Grav/Events system/src/Grav/Installer",
|
||||
"phpstan-framework": "vendor/bin/phpstan analyse -l 6 -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"
|
||||
|
|
|
|||
2510
composer.lock
generated
2510
composer.lock
generated
File diff suppressed because it is too large
Load Diff
|
|
@ -10,7 +10,7 @@
|
|||
namespace Grav;
|
||||
|
||||
\define('GRAV_REQUEST_TIME', microtime(true));
|
||||
\define('GRAV_PHP_MIN', '7.3.6');
|
||||
\define('GRAV_PHP_MIN', '8.2.0');
|
||||
|
||||
if (PHP_SAPI === 'cli-server') {
|
||||
$symfony_server = stripos(getenv('_'), 'symfony') !== false || stripos($_SERVER['SERVER_SOFTWARE'] ?? '', 'symfony') !== false || stripos($_ENV['SERVER_SOFTWARE'] ?? '', 'symfony') !== false;
|
||||
|
|
|
|||
|
|
@ -619,11 +619,9 @@ form:
|
|||
options:
|
||||
auto: Auto detect
|
||||
file: File
|
||||
apc: APC
|
||||
apcu: APCu
|
||||
memcache: Memcache
|
||||
memcached: Memcached
|
||||
wincache: WinCache
|
||||
redis: Redis
|
||||
|
||||
cache.prefix:
|
||||
|
|
@ -707,20 +705,6 @@ form:
|
|||
validate:
|
||||
type: bool
|
||||
|
||||
cache.memcache.server:
|
||||
type: text
|
||||
size: medium
|
||||
label: PLUGIN_ADMIN.MEMCACHE_SERVER
|
||||
help: PLUGIN_ADMIN.MEMCACHE_SERVER_HELP
|
||||
placeholder: "localhost"
|
||||
|
||||
cache.memcache.port:
|
||||
type: text
|
||||
size: small
|
||||
label: PLUGIN_ADMIN.MEMCACHE_PORT
|
||||
help: PLUGIN_ADMIN.MEMCACHE_PORT_HELP
|
||||
placeholder: "11211"
|
||||
|
||||
cache.memcached.server:
|
||||
type: text
|
||||
size: medium
|
||||
|
|
@ -884,17 +868,6 @@ form:
|
|||
validate:
|
||||
type: bool
|
||||
|
||||
twig.umask_fix:
|
||||
type: toggle
|
||||
label: PLUGIN_ADMIN.TWIG_UMASK_FIX
|
||||
help: PLUGIN_ADMIN.TWIG_UMASK_FIX_HELP
|
||||
highlight: 0
|
||||
options:
|
||||
1: PLUGIN_ADMIN.YES
|
||||
0: PLUGIN_ADMIN.NO
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
assets:
|
||||
type: tab
|
||||
title: PLUGIN_ADMIN.ASSETS
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -93,13 +93,13 @@ cache:
|
|||
enabled: true # Set to true to enable caching
|
||||
check:
|
||||
method: file # Method to check for updates in pages: file|folder|hash|none
|
||||
driver: auto # One of: auto|file|apcu|memcache|wincache
|
||||
driver: auto # One of: auto|file|apcu|memcached|redis
|
||||
prefix: 'g' # Cache prefix string (prevents cache conflicts)
|
||||
purge_at: '0 4 * * *' # How often to purge old file cache (using new scheduler)
|
||||
clear_at: '0 3 * * *' # How often to clear cache (using new scheduler)
|
||||
clear_job_type: 'standard' # Type to clear when processing the scheduled clear job `standard`|`all`
|
||||
clear_images_by_default: false # By default grav does not include processed images in cache clear, this can be enabled
|
||||
cli_compatibility: false # Ensures only non-volatile drivers are used (file, redis, memcache, etc.)
|
||||
cli_compatibility: false # Ensures only non-volatile drivers are used (file, redis, memcached, etc.)
|
||||
lifetime: 604800 # Lifetime of cached data in seconds (0 = infinite)
|
||||
gzip: false # GZip compress the page output
|
||||
allow_webserver_gzip: false # If true, `content-encoding: identity` but connection isn't closed before `onShutDown()` event
|
||||
|
|
@ -117,7 +117,6 @@ twig:
|
|||
undefined_filters: true # Allow undefined filters
|
||||
safe_functions: [] # List of PHP functions which are allowed to be used as Twig functions
|
||||
safe_filters: [] # List of PHP functions which are allowed to be used as Twig filters
|
||||
umask_fix: false # By default Twig creates cached files as 755, fix switches this to 775
|
||||
|
||||
assets: # Configuration for Assets Manager (JS, CSS)
|
||||
css_pipeline: false # The CSS pipeline is the unification of multiple CSS resources into one file
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@
|
|||
|
||||
// Some standard defines
|
||||
define('GRAV', true);
|
||||
define('GRAV_VERSION', '1.7.48');
|
||||
define('GRAV_VERSION', '1.8.0-beta.3');
|
||||
define('GRAV_SCHEMA', '1.7.0_2020-11-20_1');
|
||||
define('GRAV_TESTING', false);
|
||||
define('GRAV_TESTING', true);
|
||||
|
||||
// PHP minimum requirement
|
||||
if (!defined('GRAV_PHP_MIN')) {
|
||||
define('GRAV_PHP_MIN', '7.3.6');
|
||||
define('GRAV_PHP_MIN', '8.2.0');
|
||||
}
|
||||
|
||||
// Directory separator
|
||||
|
|
|
|||
93
system/src/Doctrine/Common/Cache/FilesystemCache.php
Normal file
93
system/src/Doctrine/Common/Cache/FilesystemCache.php
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
|
||||
/**
|
||||
* Filesystem cache driver (backwards compatibility).
|
||||
*/
|
||||
class FilesystemCache extends CacheProvider
|
||||
{
|
||||
public const EXTENSION = '.doctrinecache.data';
|
||||
|
||||
/** @var FilesystemAdapter */
|
||||
private $pool;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($directory, $extension = self::EXTENSION, $umask = 0002)
|
||||
{
|
||||
user_error(__CLASS__ . ' is deprecated since Grav 1.8, use Symfony cache instead', E_USER_DEPRECATED);
|
||||
|
||||
$this->pool = new FilesystemAdapter('', 0, $directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
$item = $this->pool->getItem(rawurlencode($id));
|
||||
|
||||
return $item->isHit() ? $item->get() : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return $this->pool->hasItem(rawurlencode($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
$item = $this->pool->getItem(rawurlencode($id));
|
||||
|
||||
if (0 < $lifeTime) {
|
||||
$item->expiresAfter($lifeTime);
|
||||
}
|
||||
|
||||
return $this->pool->save($item->set($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return $this->pool->deleteItem(rawurlencode($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return $this->pool->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -194,7 +194,7 @@ class Backups
|
|||
* @param callable|null $status
|
||||
* @return string|null
|
||||
*/
|
||||
public static function backup($id = 0, callable $status = null)
|
||||
public static function backup($id = 0, ?callable $status = null)
|
||||
{
|
||||
$grav = Grav::instance();
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@
|
|||
namespace Grav\Common;
|
||||
|
||||
use DirectoryIterator;
|
||||
use \Doctrine\Common\Cache as DoctrineCache;
|
||||
use Doctrine\Common\Cache\CacheProvider;
|
||||
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
|
||||
use Exception;
|
||||
use Grav\Common\Config\Config;
|
||||
use Grav\Common\Filesystem\Folder;
|
||||
|
|
@ -18,6 +19,12 @@ use Grav\Common\Scheduler\Scheduler;
|
|||
use LogicException;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use RocketTheme\Toolbox\Event\Event;
|
||||
use Symfony\Component\Cache\Adapter\AdapterInterface;
|
||||
use Symfony\Component\Cache\Adapter\ApcuAdapter;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Cache\Adapter\MemcachedAdapter;
|
||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||
use Symfony\Component\Cache\Psr16Cache;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use function dirname;
|
||||
use function extension_loaded;
|
||||
|
|
@ -27,12 +34,11 @@ use function is_array;
|
|||
|
||||
/**
|
||||
* The GravCache object is used throughout Grav to store and retrieve cached data.
|
||||
* It uses DoctrineCache library and supports a variety of caching mechanisms. Those include:
|
||||
* It uses Symfony library (adding backward compatibility to Doctrine Cache) and supports a variety of caching mechanisms. Those include:
|
||||
*
|
||||
* APCu
|
||||
* RedisCache
|
||||
* MemCache
|
||||
* MemCacheD
|
||||
* MemCached
|
||||
* FileSystem
|
||||
*/
|
||||
class Cache extends Getters
|
||||
|
|
@ -49,7 +55,10 @@ class Cache extends Getters
|
|||
/** @var Config $config */
|
||||
protected $config;
|
||||
|
||||
/** @var DoctrineCache\CacheProvider */
|
||||
/** @var AdapterInterface */
|
||||
protected $adapter;
|
||||
|
||||
/** @var CacheProvider */
|
||||
protected $driver;
|
||||
|
||||
/** @var CacheInterface */
|
||||
|
|
@ -70,6 +79,7 @@ class Cache extends Getters
|
|||
protected static $standard_remove = [
|
||||
'cache://twig/',
|
||||
'cache://doctrine/',
|
||||
'cache://grav/',
|
||||
'cache://compiled/',
|
||||
'cache://clockwork/',
|
||||
'cache://validated-',
|
||||
|
|
@ -80,6 +90,7 @@ class Cache extends Getters
|
|||
protected static $standard_remove_no_images = [
|
||||
'cache://twig/',
|
||||
'cache://doctrine/',
|
||||
'cache://grav/',
|
||||
'cache://compiled/',
|
||||
'cache://clockwork/',
|
||||
'cache://validated-',
|
||||
|
|
@ -142,10 +153,10 @@ class Cache extends Getters
|
|||
|
||||
// Cache key allows us to invalidate all cache on configuration changes.
|
||||
$this->key = ($prefix ?: 'g') . '-' . $uniqueness;
|
||||
$this->cache_dir = $grav['locator']->findResource('cache://doctrine/' . $uniqueness, true, true);
|
||||
$this->cache_dir = $grav['locator']->findResource('cache://grav/' . $uniqueness, true, true);
|
||||
$this->driver_setting = $this->config->get('system.cache.driver');
|
||||
$this->driver = $this->getCacheDriver();
|
||||
$this->driver->setNamespace($this->key);
|
||||
$this->adapter = $this->getCacheAdapter();
|
||||
$this->driver = $this->getCacheDriver($this->adapter);
|
||||
|
||||
/** @var EventDispatcher $dispatcher */
|
||||
$dispatcher = Grav::instance()['events'];
|
||||
|
|
@ -158,12 +169,7 @@ class Cache extends Getters
|
|||
public function getSimpleCache()
|
||||
{
|
||||
if (null === $this->simpleCache) {
|
||||
$cache = new \Grav\Framework\Cache\Adapter\DoctrineCache($this->driver, '', $this->getLifetime());
|
||||
|
||||
// Disable cache key validation.
|
||||
$cache->setValidation(false);
|
||||
|
||||
$this->simpleCache = $cache;
|
||||
$this->simpleCache = new Psr16Cache($this->adapter);
|
||||
}
|
||||
|
||||
return $this->simpleCache;
|
||||
|
|
@ -229,53 +235,42 @@ class Cache extends Getters
|
|||
* If there is no config option for $driver in the config, or it's set to 'auto', it will
|
||||
* pick the best option based on which cache extensions are installed.
|
||||
*
|
||||
* @return DoctrineCache\CacheProvider The cache driver to use
|
||||
* @param string|null $namespace
|
||||
* @param int|null $defaultLifetime
|
||||
* @return AdapterInterface The cache driver to use
|
||||
* @throws \RedisException
|
||||
* @throws \Symfony\Component\Cache\Exception\CacheException
|
||||
*/
|
||||
public function getCacheDriver()
|
||||
public function getCacheAdapter(?string $namespace = null, ?int $defaultLifetime = null): AdapterInterface
|
||||
{
|
||||
$setting = $this->driver_setting;
|
||||
$setting = $this->driver_setting ?? 'auto';
|
||||
$driver_name = 'file';
|
||||
|
||||
if (in_array($setting, ['apc', 'xcache', 'wincache', 'memcache'], true)) {
|
||||
throw new LogicException(sprintf('Cache driver for %s has been removed, use auto, file, apcu or memcached instead!', $setting));
|
||||
}
|
||||
|
||||
// CLI compatibility requires a non-volatile cache driver
|
||||
if ($this->config->get('system.cache.cli_compatibility') && (
|
||||
$setting === 'auto' || $this->isVolatileDriver($setting))) {
|
||||
if ($this->config->get('system.cache.cli_compatibility') && ($setting === 'auto' || $this->isVolatileDriver($setting))) {
|
||||
$setting = $driver_name;
|
||||
}
|
||||
|
||||
if (!$setting || $setting === 'auto') {
|
||||
if ($setting === 'auto' || $this->isVolatileDriver($setting)) {
|
||||
if (extension_loaded('apcu')) {
|
||||
$driver_name = 'apcu';
|
||||
} elseif (extension_loaded('wincache')) {
|
||||
$driver_name = 'wincache';
|
||||
}
|
||||
} else {
|
||||
$driver_name = $setting;
|
||||
}
|
||||
|
||||
$this->driver_name = $driver_name;
|
||||
$namespace = $namespace ?? $this->key;
|
||||
$defaultLifetime = $defaultLifetime ?? 0;
|
||||
|
||||
switch ($driver_name) {
|
||||
case 'apc':
|
||||
case 'apcu':
|
||||
$driver = new DoctrineCache\ApcuCache();
|
||||
break;
|
||||
|
||||
case 'wincache':
|
||||
$driver = new DoctrineCache\WinCacheCache();
|
||||
break;
|
||||
|
||||
case 'memcache':
|
||||
if (extension_loaded('memcache')) {
|
||||
$memcache = new \Memcache();
|
||||
$memcache->connect(
|
||||
$this->config->get('system.cache.memcache.server', 'localhost'),
|
||||
$this->config->get('system.cache.memcache.port', 11211)
|
||||
);
|
||||
$driver = new DoctrineCache\MemcacheCache();
|
||||
$driver->setMemcache($memcache);
|
||||
} else {
|
||||
throw new LogicException('Memcache PHP extension has not been installed');
|
||||
}
|
||||
$adapter = new ApcuAdapter($namespace, $defaultLifetime);
|
||||
break;
|
||||
|
||||
case 'memcached':
|
||||
|
|
@ -285,8 +280,7 @@ class Cache extends Getters
|
|||
$this->config->get('system.cache.memcached.server', 'localhost'),
|
||||
$this->config->get('system.cache.memcached.port', 11211)
|
||||
);
|
||||
$driver = new DoctrineCache\MemcachedCache();
|
||||
$driver->setMemcached($memcached);
|
||||
$adapter = new MemcachedAdapter($memcached, $namespace, $defaultLifetime);
|
||||
} else {
|
||||
throw new LogicException('Memcached PHP extension has not been installed');
|
||||
}
|
||||
|
|
@ -318,19 +312,39 @@ class Cache extends Getters
|
|||
throw new \RedisException('Could not select alternate Redis database ID');
|
||||
}
|
||||
|
||||
$driver = new DoctrineCache\RedisCache();
|
||||
$driver->setRedis($redis);
|
||||
$adapter = new RedisAdapter($redis, $namespace, $defaultLifetime);
|
||||
} else {
|
||||
throw new LogicException('Redis PHP extension has not been installed');
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$driver = new DoctrineCache\FilesystemCache($this->cache_dir);
|
||||
$adapter = new FilesystemAdapter($namespace, $defaultLifetime, $this->cache_dir);
|
||||
break;
|
||||
}
|
||||
|
||||
return $driver;
|
||||
return $adapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically picks the cache mechanism to use. If you pick one manually it will use that
|
||||
* If there is no config option for $driver in the config, or it's set to 'auto', it will
|
||||
* pick the best option based on which cache extensions are installed.
|
||||
*
|
||||
* @return CacheProvider The cache driver to use
|
||||
*/
|
||||
public function getCacheDriver(?AdapterInterface $adapter = null)
|
||||
{
|
||||
if (null === $adapter) {
|
||||
$adapter = $this->getCacheAdapter();
|
||||
}
|
||||
|
||||
$cache = DoctrineProvider::wrap($adapter);
|
||||
if (!$cache instanceof CacheProvider) {
|
||||
throw new \RuntimeException('Internal error');
|
||||
}
|
||||
|
||||
return $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -618,7 +632,7 @@ class Cache extends Getters
|
|||
*/
|
||||
public function isVolatileDriver($setting)
|
||||
{
|
||||
return in_array($setting, ['apc', 'apcu', 'xcache', 'wincache'], true);
|
||||
return $setting === 'apcu';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ class Data implements DataInterface, ArrayAccess, \Countable, JsonSerializable,
|
|||
* @param FileInterface|null $storage Optionally enter a new storage.
|
||||
* @return FileInterface|null
|
||||
*/
|
||||
public function file(FileInterface $storage = null)
|
||||
public function file(?FileInterface $storage = null)
|
||||
{
|
||||
if ($storage) {
|
||||
$this->storage = $storage;
|
||||
|
|
|
|||
|
|
@ -80,5 +80,5 @@ interface DataInterface
|
|||
* @param FileInterface|null $storage Optionally enter a new storage.
|
||||
* @return FileInterface
|
||||
*/
|
||||
public function file(FileInterface $storage = null);
|
||||
public function file(?FileInterface $storage = null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ class Validation
|
|||
* @param UserInterface|null $user
|
||||
* @return bool
|
||||
*/
|
||||
public static function authorize($action, UserInterface $user = null)
|
||||
public static function authorize($action, ?UserInterface $user = null)
|
||||
{
|
||||
if (!$user) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -544,7 +544,7 @@ class Debugger
|
|||
* @param string|null $message
|
||||
* @return mixed
|
||||
*/
|
||||
public function profile(callable $callable, string $message = null)
|
||||
public function profile(callable $callable, ?string $message = null)
|
||||
{
|
||||
$this->startProfiling();
|
||||
$response = $callable();
|
||||
|
|
@ -585,7 +585,7 @@ class Debugger
|
|||
* @param string|null $message
|
||||
* @return array|null
|
||||
*/
|
||||
public function stopProfiling(string $message = null): ?array
|
||||
public function stopProfiling(?string $message = null): ?array
|
||||
{
|
||||
$timings = null;
|
||||
if ($this->enabled && extension_loaded('tideways_xhprof')) {
|
||||
|
|
@ -776,7 +776,7 @@ class Debugger
|
|||
* @param float|null $time
|
||||
* @return $this
|
||||
*/
|
||||
public function addEvent(string $name, $event, EventDispatcherInterface $dispatcher, float $time = null)
|
||||
public function addEvent(string $name, $event, EventDispatcherInterface $dispatcher, ?float $time = null)
|
||||
{
|
||||
if ($this->enabled && $this->clockwork) {
|
||||
$time = $time ?? microtime(true);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class Errors
|
|||
$logger = $grav['log'];
|
||||
$whoops->pushHandler(function ($exception, $inspector, $run) use ($logger) {
|
||||
try {
|
||||
$logger->addCritical($exception->getMessage() . ' - Trace: ' . $exception->getTraceAsString());
|
||||
$logger->critical($exception->getMessage() . ' - Trace: ' . $exception->getTraceAsString());
|
||||
} catch (Exception $e) {
|
||||
echo $e;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,21 +75,21 @@ abstract class Archiver
|
|||
* @param callable|null $status
|
||||
* @return $this
|
||||
*/
|
||||
abstract public function compress($folder, callable $status = null);
|
||||
abstract public function compress($folder, ?callable $status = null);
|
||||
|
||||
/**
|
||||
* @param string $destination
|
||||
* @param callable|null $status
|
||||
* @return $this
|
||||
*/
|
||||
abstract public function extract($destination, callable $status = null);
|
||||
abstract public function extract($destination, ?callable $status = null);
|
||||
|
||||
/**
|
||||
* @param array $folders
|
||||
* @param callable|null $status
|
||||
* @return $this
|
||||
*/
|
||||
abstract public function addEmptyFolders($folders, callable $status = null);
|
||||
abstract public function addEmptyFolders($folders, ?callable $status = null);
|
||||
|
||||
/**
|
||||
* @param string $rootPath
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class ZipArchiver extends Archiver
|
|||
* @param callable|null $status
|
||||
* @return $this
|
||||
*/
|
||||
public function extract($destination, callable $status = null)
|
||||
public function extract($destination, ?callable $status = null)
|
||||
{
|
||||
$zip = new ZipArchive();
|
||||
$archive = $zip->open($this->archive_file);
|
||||
|
|
@ -51,7 +51,7 @@ class ZipArchiver extends Archiver
|
|||
* @param callable|null $status
|
||||
* @return $this
|
||||
*/
|
||||
public function compress($source, callable $status = null)
|
||||
public function compress($source, ?callable $status = null)
|
||||
{
|
||||
if (!extension_loaded('zip')) {
|
||||
throw new InvalidArgumentException('ZipArchiver: Zip PHP module not installed...');
|
||||
|
|
@ -105,7 +105,7 @@ class ZipArchiver extends Archiver
|
|||
* @param callable|null $status
|
||||
* @return $this
|
||||
*/
|
||||
public function addEmptyFolders($folders, callable $status = null)
|
||||
public function addEmptyFolders($folders, ?callable $status = null)
|
||||
{
|
||||
if (!extension_loaded('zip')) {
|
||||
throw new InvalidArgumentException('ZipArchiver: Zip PHP module not installed...');
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ abstract class FlexObject extends \Grav\Framework\Flex\FlexObject implements Med
|
|||
* {@inheritdoc}
|
||||
* @see FlexObjectInterface::getFormValue()
|
||||
*/
|
||||
public function getFormValue(string $name, $default = null, string $separator = null)
|
||||
public function getFormValue(string $name, $default = null, ?string $separator = null)
|
||||
{
|
||||
$value = $this->getNestedProperty($name, null, $separator);
|
||||
|
||||
|
|
|
|||
|
|
@ -766,7 +766,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* @return static
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function withTranslation(bool $bool = true, string $languageCode = null, bool $fallback = null)
|
||||
public function withTranslation(bool $bool = true, ?string $languageCode = null, ?bool $fallback = null)
|
||||
{
|
||||
$list = array_keys(array_filter($this->call('hasTranslation', [$languageCode, $fallback])));
|
||||
|
||||
|
|
@ -778,7 +778,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* @param bool|null $fallback
|
||||
* @return PageIndex
|
||||
*/
|
||||
public function withTranslated(string $languageCode = null, bool $fallback = null)
|
||||
public function withTranslated(?string $languageCode = null, ?bool $fallback = null)
|
||||
{
|
||||
return $this->getIndex()->withTranslated($languageCode, $fallback);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
public const ORDER_LIST_REGEX = '/(\/\d+)\.[^\/]+/u';
|
||||
public const PAGE_ROUTE_REGEX = '/\/\d+\./u';
|
||||
|
||||
/** @var PageObject|array */
|
||||
/** @var T|array */
|
||||
protected $_root;
|
||||
/** @var array|null */
|
||||
protected $_params;
|
||||
|
|
@ -66,7 +66,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* @param array $entries
|
||||
* @param FlexDirectory|null $directory
|
||||
*/
|
||||
public function __construct(array $entries = [], FlexDirectory $directory = null)
|
||||
public function __construct(array $entries = [], ?FlexDirectory $directory = null)
|
||||
{
|
||||
// Remove root if it's taken.
|
||||
if (isset($entries[''])) {
|
||||
|
|
@ -181,7 +181,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* @return static
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function withTranslated(string $languageCode = null, bool $fallback = null)
|
||||
public function withTranslated(?string $languageCode = null, ?bool $fallback = null)
|
||||
{
|
||||
if (null === $languageCode) {
|
||||
return $this;
|
||||
|
|
@ -413,7 +413,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* @return static
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
protected function createFrom(array $entries, string $keyField = null)
|
||||
protected function createFrom(array $entries, ?string $keyField = null)
|
||||
{
|
||||
/** @var static $index */
|
||||
$index = parent::createFrom($entries, $keyField);
|
||||
|
|
@ -428,7 +428,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* @param bool|null $fallback
|
||||
* @return array
|
||||
*/
|
||||
protected function translateEntries(array $entries, string $lang, bool $fallback = null): array
|
||||
protected function translateEntries(array $entries, string $lang, ?bool $fallback = null): array
|
||||
{
|
||||
$languages = $this->getFallbackLanguages($lang, $fallback);
|
||||
foreach ($entries as $key => &$entry) {
|
||||
|
|
@ -493,7 +493,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* @param bool|null $fallback
|
||||
* @return array
|
||||
*/
|
||||
protected function getFallbackLanguages(string $languageCode = null, bool $fallback = null): array
|
||||
protected function getFallbackLanguages(?string $languageCode = null, ?bool $fallback = null): array
|
||||
{
|
||||
$fallback = $fallback ?? true;
|
||||
if (!$fallback && null !== $languageCode) {
|
||||
|
|
@ -781,7 +781,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* @param int|null $timestamp
|
||||
* @return string|null
|
||||
*/
|
||||
private function jsDate(int $timestamp = null): ?string
|
||||
private function jsDate(?int $timestamp = null): ?string
|
||||
{
|
||||
if (!$timestamp) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class PageObject extends FlexPageObject
|
|||
/**
|
||||
* @inheritdoc PageInterface
|
||||
*/
|
||||
public function getFormValue(string $name, $default = null, string $separator = null)
|
||||
public function getFormValue(string $name, $default = null, ?string $separator = null)
|
||||
{
|
||||
$test = new stdClass();
|
||||
|
||||
|
|
@ -261,7 +261,7 @@ class PageObject extends FlexPageObject
|
|||
/**
|
||||
* @param UserInterface|null $user
|
||||
*/
|
||||
public function check(UserInterface $user = null): void
|
||||
public function check(?UserInterface $user = null): void
|
||||
{
|
||||
parent::check($user);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ trait PageRoutableTrait
|
|||
* @return PageInterface|null the parent page object if it exists.
|
||||
*/
|
||||
|
||||
public function parent(PageInterface $var = null)
|
||||
public function parent(?PageInterface $var = null)
|
||||
{
|
||||
if (Utils::isAdminPlugin()) {
|
||||
return parent::parent();
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class UserGroupCollection extends FlexCollection
|
|||
* @param string|null $scope
|
||||
* @return bool|null
|
||||
*/
|
||||
public function authorize(string $action, string $scope = null): ?bool
|
||||
public function authorize(string $action, ?string $scope = null): ?bool
|
||||
{
|
||||
$authorized = null;
|
||||
/** @var UserGroupObject $object */
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class UserGroupObject extends FlexObject implements UserGroupInterface
|
|||
* @param string|null $scope
|
||||
* @return bool|null
|
||||
*/
|
||||
public function authorize(string $action, string $scope = null): ?bool
|
||||
public function authorize(string $action, ?string $scope = null): ?bool
|
||||
{
|
||||
if ($scope === 'test') {
|
||||
$scope = null;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class UserFileStorage extends FileStorage
|
|||
* {@inheritdoc}
|
||||
* @see FlexStorageInterface::getMediaPath()
|
||||
*/
|
||||
public function getMediaPath(string $key = null): ?string
|
||||
public function getMediaPath(?string $key = null): ?string
|
||||
{
|
||||
// There is no media support for file storage (fallback to common location).
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ class UserIndex extends FlexIndex implements UserCollectionInterface
|
|||
|
||||
/** @var Logger $logger */
|
||||
$logger = $grav['log'];
|
||||
$logger->addDebug($message);
|
||||
$logger->debug($message);
|
||||
|
||||
/** @var Debugger $debugger */
|
||||
$debugger = $grav['debugger'];
|
||||
|
|
|
|||
|
|
@ -92,9 +92,9 @@ class UserObject extends FlexObject implements UserInterface, Countable
|
|||
protected $_uploads_original;
|
||||
/** @var FileInterface|null */
|
||||
protected $_storage;
|
||||
/** @var UserGroupIndex */
|
||||
/** @var UserGroupIndex|null */
|
||||
protected $_groups;
|
||||
/** @var Access */
|
||||
/** @var Access|null */
|
||||
protected $_access;
|
||||
/** @var array|null */
|
||||
protected $access;
|
||||
|
|
@ -270,7 +270,7 @@ class UserObject extends FlexObject implements UserInterface, Countable
|
|||
* @param string|null $scope
|
||||
* @return bool|null
|
||||
*/
|
||||
public function authorize(string $action, string $scope = null): ?bool
|
||||
public function authorize(string $action, ?string $scope = null): ?bool
|
||||
{
|
||||
if ($scope === 'test') {
|
||||
// Special scope to test user permissions.
|
||||
|
|
@ -557,7 +557,7 @@ class UserObject extends FlexObject implements UserInterface, Countable
|
|||
* @param FileInterface|null $storage Optionally enter a new storage.
|
||||
* @return FileInterface|null
|
||||
*/
|
||||
public function file(FileInterface $storage = null)
|
||||
public function file(?FileInterface $storage = null)
|
||||
{
|
||||
if (null !== $storage) {
|
||||
$this->_storage = $storage;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Grav\Common\GPM\Remote;
|
|||
use Grav\Common\Grav;
|
||||
use Grav\Common\HTTP\Response;
|
||||
use Grav\Common\GPM\Common\AbstractPackageCollection as BaseCollection;
|
||||
use \Doctrine\Common\Cache\FilesystemCache;
|
||||
use Doctrine\Common\Cache\FilesystemCache;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ class Grav extends Container
|
|||
* @param string|null $environment
|
||||
* @return $this
|
||||
*/
|
||||
public function setup(string $environment = null)
|
||||
public function setup(?string $environment = null)
|
||||
{
|
||||
if (isset($this->initialized['setup'])) {
|
||||
return $this;
|
||||
|
|
@ -522,7 +522,7 @@ class Grav extends Container
|
|||
* @param ResponseInterface|null $response
|
||||
* @return void
|
||||
*/
|
||||
public function header(ResponseInterface $response = null): void
|
||||
public function header(?ResponseInterface $response = null): void
|
||||
{
|
||||
if (null === $response) {
|
||||
/** @var PageInterface $page */
|
||||
|
|
@ -585,7 +585,7 @@ class Grav extends Container
|
|||
* @param Event|null $event
|
||||
* @return Event
|
||||
*/
|
||||
public function fireEvent($eventName, Event $event = null)
|
||||
public function fireEvent($eventName, ?Event $event = null)
|
||||
{
|
||||
/** @var EventDispatcherInterface $events */
|
||||
$events = $this['events'];
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class Client
|
|||
'User-Agent' => 'Grav CMS'
|
||||
];
|
||||
|
||||
public static function getClient(array $overrides = [], int $connections = 6, callable $callback = null): HttpClientInterface
|
||||
public static function getClient(array $overrides = [], int $connections = 6, ?callable $callback = null): HttpClientInterface
|
||||
{
|
||||
$config = Grav::instance()['config'];
|
||||
$options = static::getOptions();
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class Response
|
|||
* @return string
|
||||
* @throws TransportExceptionInterface|RedirectionExceptionInterface|ServerExceptionInterface|TransportExceptionInterface|ClientExceptionInterface
|
||||
*/
|
||||
public static function get(string $uri = '', array $overrides = [], callable $callback = null): string
|
||||
public static function get(string $uri = '', array $overrides = [], ?callable $callback = null): string
|
||||
{
|
||||
$response = static::request('GET', $uri, $overrides, $callback);
|
||||
return $response->getContent();
|
||||
|
|
@ -58,7 +58,7 @@ class Response
|
|||
* @return ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
*/
|
||||
public static function request(string $method, string $uri, array $overrides = [], callable $callback = null): ResponseInterface
|
||||
public static function request(string $method, string $uri, array $overrides = [], ?callable $callback = null): ResponseInterface
|
||||
{
|
||||
if (empty($method)) {
|
||||
throw new TransportException('missing method (GET, PUT, etc.)');
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class Excerpts
|
|||
* @param PageInterface|null $page Page, defaults to the current page object
|
||||
* @return string Returns final HTML string
|
||||
*/
|
||||
public static function processImageHtml($html, PageInterface $page = null)
|
||||
public static function processImageHtml($html, ?PageInterface $page = null)
|
||||
{
|
||||
$excerpt = static::getExcerptFromHtml($html, 'img');
|
||||
if (null === $excerpt) {
|
||||
|
|
@ -61,7 +61,7 @@ class Excerpts
|
|||
* @param PageInterface|null $page Page, defaults to the current page object
|
||||
* @return string Returns final HTML string
|
||||
*/
|
||||
public static function processLinkHtml($html, PageInterface $page = null)
|
||||
public static function processLinkHtml($html, ?PageInterface $page = null)
|
||||
{
|
||||
$excerpt = static::getExcerptFromHtml($html, 'a');
|
||||
if (null === $excerpt) {
|
||||
|
|
@ -158,7 +158,7 @@ class Excerpts
|
|||
* @param string $type
|
||||
* @return mixed
|
||||
*/
|
||||
public static function processLinkExcerpt($excerpt, PageInterface $page = null, $type = 'link')
|
||||
public static function processLinkExcerpt($excerpt, ?PageInterface $page = null, $type = 'link')
|
||||
{
|
||||
$excerpts = new ExcerptsObject($page);
|
||||
|
||||
|
|
@ -172,7 +172,7 @@ class Excerpts
|
|||
* @param PageInterface|null $page Page, defaults to the current page object
|
||||
* @return array
|
||||
*/
|
||||
public static function processImageExcerpt(array $excerpt, PageInterface $page = null)
|
||||
public static function processImageExcerpt(array $excerpt, ?PageInterface $page = null)
|
||||
{
|
||||
$excerpts = new ExcerptsObject($page);
|
||||
|
||||
|
|
@ -187,7 +187,7 @@ class Excerpts
|
|||
* @param PageInterface|null $page Page, defaults to the current page object
|
||||
* @return Medium|Link
|
||||
*/
|
||||
public static function processMediaActions($medium, $url, PageInterface $page = null)
|
||||
public static function processMediaActions($medium, $url, ?PageInterface $page = null)
|
||||
{
|
||||
$excerpts = new ExcerptsObject($page);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class YamlLinter
|
|||
* @param string|null $folder
|
||||
* @return array
|
||||
*/
|
||||
public static function lint(string $folder = null)
|
||||
public static function lint(?string $folder = null)
|
||||
{
|
||||
if (null !== $folder) {
|
||||
$folder = $folder ?: GRAV_ROOT;
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ class Iterator implements \ArrayAccess, \Iterator, \Countable, \Serializable
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function filter(callable $callback = null)
|
||||
public function filter(?callable $callback = null)
|
||||
{
|
||||
foreach ($this->items as $key => $value) {
|
||||
if ((!$callback && !(bool)$value) || ($callback && !$callback($value, $key))) {
|
||||
|
|
@ -250,7 +250,7 @@ class Iterator implements \ArrayAccess, \Iterator, \Countable, \Serializable
|
|||
* @return $this|array
|
||||
*
|
||||
*/
|
||||
public function sort(callable $callback = null, $desc = false)
|
||||
public function sort(?callable $callback = null, $desc = false)
|
||||
{
|
||||
if (!$callback || !is_callable($callback)) {
|
||||
return $this;
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ class Language
|
|||
* @param bool $assoc Return values in ['en' => '.en.md', ...] format.
|
||||
* @return array Key is the language code, value is the file extension to be used.
|
||||
*/
|
||||
public function getFallbackPageExtensions(string $fileExtension = null, string $languageCode = null, bool $assoc = false)
|
||||
public function getFallbackPageExtensions(?string $fileExtension = null, ?string $languageCode = null, bool $assoc = false)
|
||||
{
|
||||
$fileExtension = $fileExtension ?: CONTENT_EXT;
|
||||
$key = $fileExtension . '-' . ($languageCode ?? 'default') . '-' . (int)$assoc;
|
||||
|
|
@ -411,7 +411,7 @@ class Language
|
|||
* @param bool $includeDefault If true, list contains '', which can be used for default
|
||||
* @return array
|
||||
*/
|
||||
public function getFallbackLanguages(string $languageCode = null, bool $includeDefault = false)
|
||||
public function getFallbackLanguages(?string $languageCode = null, bool $includeDefault = false)
|
||||
{
|
||||
// Handle default.
|
||||
if ($languageCode === '' || !$this->enabled()) {
|
||||
|
|
@ -489,7 +489,7 @@ class Language
|
|||
* @param bool $html_out
|
||||
* @return string|string[]
|
||||
*/
|
||||
public function translate($args, array $languages = null, $array_support = false, $html_out = false)
|
||||
public function translate($args, ?array $languages = null, $array_support = false, $html_out = false)
|
||||
{
|
||||
if (is_array($args)) {
|
||||
$lookup = array_shift($args);
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ interface MediaCollectionInterface extends \Grav\Framework\Media\Interfaces\Medi
|
|||
* @param Blueprint|null $blueprint
|
||||
* @return Medium|null
|
||||
*/
|
||||
public function createFromArray(array $items = [], Blueprint $blueprint = null);
|
||||
public function createFromArray(array $items = [], ?Blueprint $blueprint = null);
|
||||
|
||||
/**
|
||||
* @param MediaObjectInterface $mediaObject
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ interface MediaUploadInterface
|
|||
* @return string
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function checkUploadedFile(UploadedFileInterface $uploadedFile, string $filename = null, array $settings = null): string;
|
||||
public function checkUploadedFile(UploadedFileInterface $uploadedFile, ?string $filename = null, ?array $settings = null): string;
|
||||
|
||||
/**
|
||||
* Copy uploaded file to the media collection.
|
||||
|
|
@ -51,7 +51,7 @@ interface MediaUploadInterface
|
|||
* @return void
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function copyUploadedFile(UploadedFileInterface $uploadedFile, string $filename, array $settings = null): void;
|
||||
public function copyUploadedFile(UploadedFileInterface $uploadedFile, string $filename, ?array $settings = null): void;
|
||||
|
||||
/**
|
||||
* Delete real file from the media collection.
|
||||
|
|
@ -60,7 +60,7 @@ interface MediaUploadInterface
|
|||
* @param array|null $settings
|
||||
* @return void
|
||||
*/
|
||||
public function deleteFile(string $filename, array $settings = null): void;
|
||||
public function deleteFile(string $filename, ?array $settings = null): void;
|
||||
|
||||
/**
|
||||
* Rename file inside the media collection.
|
||||
|
|
@ -69,5 +69,5 @@ interface MediaUploadInterface
|
|||
* @param string $to
|
||||
* @param array|null $settings
|
||||
*/
|
||||
public function renameFile(string $from, string $to, array $settings = null): void;
|
||||
public function renameFile(string $from, string $to, ?array $settings = null): void;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ trait MediaUploadTrait
|
|||
* @return string
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function checkUploadedFile(UploadedFileInterface $uploadedFile, string $filename = null, array $settings = null): string
|
||||
public function checkUploadedFile(UploadedFileInterface $uploadedFile, ?string $filename = null, ?array $settings = null): string
|
||||
{
|
||||
// Check if there is an upload error.
|
||||
switch ($uploadedFile->getError()) {
|
||||
|
|
@ -115,7 +115,7 @@ trait MediaUploadTrait
|
|||
* @return string
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function checkFileMetadata(array $metadata, string $filename = null, array $settings = null): string
|
||||
public function checkFileMetadata(array $metadata, ?string $filename = null, ?array $settings = null): string
|
||||
{
|
||||
// Add the defaults to the settings.
|
||||
$settings = $this->getUploadSettings($settings);
|
||||
|
|
@ -252,7 +252,7 @@ trait MediaUploadTrait
|
|||
* @return void
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function copyUploadedFile(UploadedFileInterface $uploadedFile, string $filename, array $settings = null): void
|
||||
public function copyUploadedFile(UploadedFileInterface $uploadedFile, string $filename, ?array $settings = null): void
|
||||
{
|
||||
// Add the defaults to the settings.
|
||||
$settings = $this->getUploadSettings($settings);
|
||||
|
|
@ -329,7 +329,7 @@ trait MediaUploadTrait
|
|||
* @return void
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function deleteFile(string $filename, array $settings = null): void
|
||||
public function deleteFile(string $filename, ?array $settings = null): void
|
||||
{
|
||||
// Add the defaults to the settings.
|
||||
$settings = $this->getUploadSettings($settings);
|
||||
|
|
@ -371,7 +371,7 @@ trait MediaUploadTrait
|
|||
* @param string $to
|
||||
* @param array|null $settings
|
||||
*/
|
||||
public function renameFile(string $from, string $to, array $settings = null): void
|
||||
public function renameFile(string $from, string $to, ?array $settings = null): void
|
||||
{
|
||||
// Add the defaults to the settings.
|
||||
$settings = $this->getUploadSettings($settings);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class Collection extends Iterator implements PageCollectionInterface
|
|||
* @param array $params
|
||||
* @param Pages|null $pages
|
||||
*/
|
||||
public function __construct($items = [], array $params = [], Pages $pages = null)
|
||||
public function __construct($items = [], array $params = [], ?Pages $pages = null)
|
||||
{
|
||||
parent::__construct($items);
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
* Add a single page to a collection
|
||||
*
|
||||
* @param PageInterface $page
|
||||
* @return $this
|
||||
* @return $this|PageCollectionInterface<TKey,T>
|
||||
*/
|
||||
public function addPage(PageInterface $page);
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
*
|
||||
* Create a copy of this collection
|
||||
*
|
||||
* @return static
|
||||
* @return static<TKey,T>
|
||||
*/
|
||||
public function copy();
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ interface PageRoutableInterface
|
|||
* @param PageInterface|null $var the parent page object
|
||||
* @return PageInterface|null the parent page object if it exists.
|
||||
*/
|
||||
public function parent(PageInterface $var = null);
|
||||
public function parent(?PageInterface $var = null);
|
||||
|
||||
/**
|
||||
* Gets the top parent object for this page. Can return page itself.
|
||||
|
|
|
|||
|
|
@ -52,5 +52,5 @@ interface PagesSourceInterface // extends \Iterator
|
|||
* @param array|null $options
|
||||
* @return array
|
||||
*/
|
||||
public function getChildren(string $route, array $options = null): array;
|
||||
public function getChildren(string $route, ?array $options = null): array;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class Excerpts
|
|||
* @param PageInterface|null $page
|
||||
* @param array|null $config
|
||||
*/
|
||||
public function __construct(PageInterface $page = null, array $config = null)
|
||||
public function __construct(?PageInterface $page = null, ?array $config = null)
|
||||
{
|
||||
$this->page = $page ?? Grav::instance()['page'] ?? null;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class Media extends AbstractMedia
|
|||
* @param array|null $media_order
|
||||
* @param bool $load
|
||||
*/
|
||||
public function __construct($path, array $media_order = null, $load = true)
|
||||
public function __construct($path, ?array $media_order = null, $load = true)
|
||||
{
|
||||
$this->setPath($path);
|
||||
$this->media_order = $media_order;
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ abstract class AbstractMedia implements ExportInterface, MediaCollectionInterfac
|
|||
* @param Blueprint|null $blueprint
|
||||
* @return Medium|null
|
||||
*/
|
||||
public function createFromArray(array $items = [], Blueprint $blueprint = null)
|
||||
public function createFromArray(array $items = [], ?Blueprint $blueprint = null)
|
||||
{
|
||||
return MediumFactory::fromArray($items, $blueprint);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
|
|||
* @param array $items
|
||||
* @param Blueprint|null $blueprint
|
||||
*/
|
||||
public function __construct($items = [], Blueprint $blueprint = null)
|
||||
public function __construct($items = [], ?Blueprint $blueprint = null)
|
||||
{
|
||||
parent::__construct($items, $blueprint);
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class Medium extends Data implements RenderableInterface, MediaFileInterface
|
|||
* @param array $items
|
||||
* @param Blueprint|null $blueprint
|
||||
*/
|
||||
public function __construct($items = [], Blueprint $blueprint = null)
|
||||
public function __construct($items = [], ?Blueprint $blueprint = null)
|
||||
{
|
||||
parent::__construct($items, $blueprint);
|
||||
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ class MediumFactory
|
|||
* @param Blueprint|null $blueprint
|
||||
* @return Medium
|
||||
*/
|
||||
public static function fromArray(array $items = [], Blueprint $blueprint = null)
|
||||
public static function fromArray(array $items = [], ?Blueprint $blueprint = null)
|
||||
{
|
||||
$type = $items['type'] ?? null;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class VectorImageMedium extends StaticImageMedium
|
|||
* @param array $items
|
||||
* @param Blueprint|null $blueprint
|
||||
*/
|
||||
public function __construct($items = [], Blueprint $blueprint = null)
|
||||
public function __construct($items = [], ?Blueprint $blueprint = null)
|
||||
{
|
||||
parent::__construct($items, $blueprint);
|
||||
|
||||
|
|
|
|||
|
|
@ -2395,7 +2395,7 @@ class Page implements PageInterface
|
|||
* @param PageInterface|null $var the parent page object
|
||||
* @return PageInterface|null the parent page object if it exists.
|
||||
*/
|
||||
public function parent(PageInterface $var = null)
|
||||
public function parent(?PageInterface $var = null)
|
||||
{
|
||||
if ($var) {
|
||||
$this->parent = $var->path();
|
||||
|
|
|
|||
|
|
@ -645,7 +645,7 @@ class Pages
|
|||
* @param PageInterface|null $self
|
||||
* @return Collection
|
||||
*/
|
||||
protected function evaluate($value, PageInterface $self = null)
|
||||
protected function evaluate($value, ?PageInterface $self = null)
|
||||
{
|
||||
// Parse command.
|
||||
if (is_string($value)) {
|
||||
|
|
@ -757,6 +757,10 @@ class Pages
|
|||
break;
|
||||
}
|
||||
|
||||
if (!$collection instanceof Collection) {
|
||||
$collection = new Collection($collection->toArray());
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
|
|
@ -1156,7 +1160,7 @@ class Pages
|
|||
* @param PageInterface|null $current
|
||||
* @return Collection
|
||||
*/
|
||||
public function all(PageInterface $current = null)
|
||||
public function all(?PageInterface $current = null)
|
||||
{
|
||||
$all = new Collection();
|
||||
|
||||
|
|
@ -1230,7 +1234,7 @@ class Pages
|
|||
* @param bool $limitLevels
|
||||
* @return array
|
||||
*/
|
||||
public function getList(PageInterface $current = null, $level = 0, $rawRoutes = false, $showAll = true, $showFullpath = false, $showSlug = false, $showModular = false, $limitLevels = false)
|
||||
public function getList(?PageInterface $current = null, $level = 0, $rawRoutes = false, $showAll = true, $showFullpath = false, $showSlug = false, $showModular = false, $limitLevels = false)
|
||||
{
|
||||
if (!$current) {
|
||||
if ($level) {
|
||||
|
|
@ -1818,7 +1822,7 @@ class Pages
|
|||
* @throws RuntimeException
|
||||
* @internal
|
||||
*/
|
||||
protected function recurse(string $directory, PageInterface $parent = null)
|
||||
protected function recurse(string $directory, ?PageInterface $parent = null)
|
||||
{
|
||||
$directory = rtrim($directory, DS);
|
||||
$page = new Page;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class Plugin implements EventSubscriberInterface, ArrayAccess
|
|||
* @param Grav $grav
|
||||
* @param Config|null $config
|
||||
*/
|
||||
public function __construct($name, Grav $grav, Config $config = null)
|
||||
public function __construct($name, Grav $grav, ?Config $config = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->grav = $grav;
|
||||
|
|
@ -414,7 +414,7 @@ class Plugin implements EventSubscriberInterface, ArrayAccess
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function inheritedConfigOption(string $plugin, string $var, PageInterface $page = null, $default = null)
|
||||
public static function inheritedConfigOption(string $plugin, string $var, ?PageInterface $page = null, $default = null)
|
||||
{
|
||||
if (Utils::isAdminPlugin()) {
|
||||
$page = Grav::instance()['admin']->page() ?? null;
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ class Plugins extends Iterator
|
|||
|
||||
// Log a warning if plugin cannot be found.
|
||||
if (null === $class) {
|
||||
$grav['log']->addWarning(
|
||||
$grav['log']->warning(
|
||||
sprintf("Plugin '%s' enabled but not found! Try clearing cache with `bin/grav clearcache`", $name)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ class InitializeProcessor extends ProcessorBase
|
|||
$this->stopTimer('_init_uri');
|
||||
}
|
||||
|
||||
protected function handleRedirectRequest(RequestInterface $request, int $code = null): ?ResponseInterface
|
||||
protected function handleRedirectRequest(RequestInterface $request, ?int $code = null): ?ResponseInterface
|
||||
{
|
||||
if (!in_array($request->getMethod(), ['GET', 'HEAD'])) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ class Job
|
|||
* @param DateTime|null $date
|
||||
* @return bool
|
||||
*/
|
||||
public function isDue(DateTime $date = null)
|
||||
public function isDue(?DateTime $date = null)
|
||||
{
|
||||
// The execution time is being defaulted if not defined
|
||||
if (!$this->executionTime) {
|
||||
|
|
@ -259,7 +259,7 @@ class Job
|
|||
* @param callable|null $whenOverlapping A callback to ignore job overlapping
|
||||
* @return self
|
||||
*/
|
||||
public function onlyOne($tempDir = null, callable $whenOverlapping = null)
|
||||
public function onlyOne($tempDir = null, ?callable $whenOverlapping = null)
|
||||
{
|
||||
if ($tempDir === null || !is_dir($tempDir)) {
|
||||
$tempDir = $this->tempDir;
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ class Scheduler
|
|||
* @param DateTime|null $runTime Optional, run at specific moment
|
||||
* @param bool $force force run even if not due
|
||||
*/
|
||||
public function run(DateTime $runTime = null, $force = false)
|
||||
public function run(?DateTime $runTime = null, $force = false)
|
||||
{
|
||||
$this->loadSavedJobs();
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class Security
|
|||
* @param array|null $options
|
||||
* @return string|null
|
||||
*/
|
||||
public static function detectXssFromSvgFile(string $filepath, array $options = null): ?string
|
||||
public static function detectXssFromSvgFile(string $filepath, ?array $options = null): ?string
|
||||
{
|
||||
if (file_exists($filepath) && Grav::instance()['config']->get('security.sanitize_svg')) {
|
||||
$content = file_get_contents($filepath);
|
||||
|
|
@ -95,7 +95,7 @@ class Security
|
|||
* @param callable|null $status
|
||||
* @return array
|
||||
*/
|
||||
public static function detectXssFromPages(Pages $pages, $route = true, callable $status = null)
|
||||
public static function detectXssFromPages(Pages $pages, $route = true, ?callable $status = null)
|
||||
{
|
||||
$routes = $pages->getList(null, 0, true);
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ class Security
|
|||
* @param string $prefix Prefix for returned values.
|
||||
* @return array Returns flatten list of potentially dangerous input values, such as 'data.content'.
|
||||
*/
|
||||
public static function detectXssFromArray(array $array, string $prefix = '', array $options = null)
|
||||
public static function detectXssFromArray(array $array, string $prefix = '', ?array $options = null)
|
||||
{
|
||||
if (null === $options) {
|
||||
$options = static::getXssDefaults();
|
||||
|
|
@ -176,7 +176,7 @@ class Security
|
|||
*
|
||||
* Copies the code from: https://github.com/symphonycms/xssfilter/blob/master/extension.driver.php#L138
|
||||
*/
|
||||
public static function detectXss($string, array $options = null): ?string
|
||||
public static function detectXss($string, ?array $options = null): ?string
|
||||
{
|
||||
// Skip any null or non string values
|
||||
if (null === $string || !is_string($string) || empty($string)) {
|
||||
|
|
|
|||
|
|
@ -932,7 +932,7 @@ class GravExtension extends AbstractExtension implements GlobalsInterface
|
|||
* @param bool $html_out
|
||||
* @return string
|
||||
*/
|
||||
public function translateLanguage($args, array $languages = null, $array_support = false, $html_out = false)
|
||||
public function translateLanguage($args, ?array $languages = null, $array_support = false, $html_out = false)
|
||||
{
|
||||
/** @var Language $language */
|
||||
$language = $this->grav['language'];
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class TwigNodeSwitch extends Node
|
|||
* @param int $lineno
|
||||
* @param string|null $tag
|
||||
*/
|
||||
public function __construct(Node $value, Node $cases, Node $default = null, $lineno = 0, $tag = null)
|
||||
public function __construct(Node $value, Node $cases, ?Node $default = null, $lineno = 0, $tag = null)
|
||||
{
|
||||
$nodes = ['value' => $value, 'cases' => $cases, 'default' => $default];
|
||||
$nodes = array_filter($nodes);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class TwigNodeTryCatch extends Node
|
|||
* @param int $lineno
|
||||
* @param string|null $tag
|
||||
*/
|
||||
public function __construct(Node $try, Node $catch = null, $lineno = 0, $tag = null)
|
||||
public function __construct(Node $try, ?Node $catch = null, $lineno = 0, $tag = null)
|
||||
{
|
||||
$nodes = ['try' => $try, 'catch' => $catch];
|
||||
$nodes = array_filter($nodes);
|
||||
|
|
|
|||
|
|
@ -43,6 +43,17 @@ use function function_exists;
|
|||
use function in_array;
|
||||
use function is_array;
|
||||
|
||||
// Twig3 compatibility
|
||||
if (!class_exists('Twig_SimpleFunction')) {
|
||||
class_alias('\Twig\TwigFunction', 'Twig_SimpleFunction');
|
||||
}
|
||||
if (!class_exists('Twig_SimpleFilter')) {
|
||||
class_alias('\Twig\TwigFilter', 'Twig_SimpleFilter');
|
||||
}
|
||||
if (!class_exists('Twig_Extension')) {
|
||||
class_alias('\Twig\Extension\AbstractExtension', 'Twig_Extension');
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Twig
|
||||
* @package Grav\Common\Twig
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ use Twig\TemplateWrapper;
|
|||
*/
|
||||
class TwigEnvironment extends Environment
|
||||
{
|
||||
use WriteCacheFileTrait;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*
|
||||
* TODO: Needed for Twig 1 compatibility.
|
||||
*/
|
||||
public function resolveTemplate($names)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,5 +22,5 @@ interface AuthorizeInterface
|
|||
* @param string|null $scope
|
||||
* @return bool|null
|
||||
*/
|
||||
public function authorize(string $action, string $scope = null): ?bool;
|
||||
public function authorize(string $action, ?string $scope = null): ?bool;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ trait UserTrait
|
|||
* @param string|null $scope
|
||||
* @return bool|null
|
||||
*/
|
||||
public function authorize(string $action, string $scope = null): ?bool
|
||||
public function authorize(string $action, ?string $scope = null): ?bool
|
||||
{
|
||||
// User needs to be enabled.
|
||||
if ($this->get('state', 'enabled') !== 'enabled') {
|
||||
|
|
|
|||
|
|
@ -1005,7 +1005,7 @@ abstract class Utils
|
|||
* @param int|null $flags
|
||||
* @return array|string
|
||||
*/
|
||||
public static function pathinfo($path, int $flags = null)
|
||||
public static function pathinfo($path, ?int $flags = null)
|
||||
{
|
||||
$path = str_replace(['%2F', '%5C'], ['/', '\\'], rawurlencode($path));
|
||||
|
||||
|
|
@ -1618,7 +1618,7 @@ abstract class Utils
|
|||
* @return string
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public static function getPagePathFromToken($path, PageInterface $page = null)
|
||||
public static function getPagePathFromToken($path, ?PageInterface $page = null)
|
||||
{
|
||||
return static::getPathFromToken($path, $page);
|
||||
}
|
||||
|
|
@ -1947,7 +1947,7 @@ abstract class Utils
|
|||
* @param array|null $defaults
|
||||
* @return array
|
||||
*/
|
||||
public static function getSupportPageTypes(array $defaults = null)
|
||||
public static function getSupportPageTypes(?array $defaults = null)
|
||||
{
|
||||
$types = Grav::instance()['config']->get('system.pages.types', $defaults);
|
||||
if (!is_array($types)) {
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class PluginApplication extends Application
|
|||
* @return int
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function run(InputInterface $input = null, OutputInterface $output = null): int
|
||||
public function run(?InputInterface $input = null, ?OutputInterface $output = null): int
|
||||
{
|
||||
if (null === $input) {
|
||||
$argv = $_SERVER['argv'] ?? [];
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ class InstallCommand extends GravCommand
|
|||
* @param string|null $type
|
||||
* @return int
|
||||
*/
|
||||
private function symlink(string $name = null, string $type = null): int
|
||||
private function symlink(?string $name = null, ?string $type = null): int
|
||||
{
|
||||
$io = $this->getIO();
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ trait ConsoleTrait
|
|||
* @return $this
|
||||
* @throws InvalidArgumentException If option mode is invalid or incompatible
|
||||
*/
|
||||
public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null)
|
||||
public function addOption(string $name, array|string|null $shortcut = null, ?int $mode = null, string $description = '', mixed $default = null): static
|
||||
{
|
||||
if ($name !== 'env' && $name !== 'lang') {
|
||||
parent::addOption($name, $shortcut, $mode, $description, $default);
|
||||
|
|
@ -140,7 +140,7 @@ trait ConsoleTrait
|
|||
* @param string|null $code
|
||||
* @return $this
|
||||
*/
|
||||
final protected function setLanguage(string $code = null)
|
||||
final protected function setLanguage(?string $code = null)
|
||||
{
|
||||
$this->initializeGrav();
|
||||
|
||||
|
|
|
|||
|
|
@ -573,7 +573,7 @@ class InstallCommand extends GpmCommand
|
|||
* @param string|null $license
|
||||
* @return string|null
|
||||
*/
|
||||
private function downloadPackage(Package $package, string $license = null)
|
||||
private function downloadPackage(Package $package, ?string $license = null)
|
||||
{
|
||||
$io = $this->getIO();
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class Access implements JsonSerializable, IteratorAggregate, Countable
|
|||
* @param array|null $rules
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($acl = null, array $rules = null, string $name = '')
|
||||
public function __construct($acl = null, ?array $rules = null, string $name = '')
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->rules = $rules ?? [];
|
||||
|
|
@ -70,7 +70,7 @@ class Access implements JsonSerializable, IteratorAggregate, Countable
|
|||
* @param string|null $name
|
||||
* @return void
|
||||
*/
|
||||
public function inherit(Access $parent, string $name = null)
|
||||
public function inherit(Access $parent, ?string $name = null)
|
||||
{
|
||||
// Remove cached null actions from acl.
|
||||
$acl = $this->getAllActions();
|
||||
|
|
@ -88,7 +88,7 @@ class Access implements JsonSerializable, IteratorAggregate, Countable
|
|||
* @param string|null $scope
|
||||
* @return bool|null
|
||||
*/
|
||||
public function authorize(string $action, string $scope = null): ?bool
|
||||
public function authorize(string $action, ?string $scope = null): ?bool
|
||||
{
|
||||
if (null !== $scope) {
|
||||
$action = $scope !== 'test' ? "{$scope}.{$action}" : $action;
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ class Permissions implements ArrayAccess, Countable, IteratorAggregate
|
|||
* @param array|null $access
|
||||
* @return Access
|
||||
*/
|
||||
public function getAccess(array $access = null): Access
|
||||
public function getAccess(?array $access = null): Access
|
||||
{
|
||||
return new Access($access ?? []);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -551,14 +551,14 @@ abstract class AbstractIndexCollection implements CollectionInterface
|
|||
* @return array
|
||||
* @phpstan-return array<TKey,T>
|
||||
*/
|
||||
abstract protected function loadElements(array $entries = null): array;
|
||||
abstract protected function loadElements(?array $entries = null): array;
|
||||
|
||||
/**
|
||||
* @param array|null $entries
|
||||
* @return CollectionInterface
|
||||
* @phpstan-return C
|
||||
*/
|
||||
abstract protected function loadCollection(array $entries = null): CollectionInterface;
|
||||
abstract protected function loadCollection(?array $entries = null): CollectionInterface;
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class FileCollection extends AbstractFileCollection
|
|||
* @param callable|null $filterFunction
|
||||
* @return $this
|
||||
*/
|
||||
public function setFilter(callable $filterFunction = null)
|
||||
public function setFilter(?callable $filterFunction = null)
|
||||
{
|
||||
$this->filterFunction = $filterFunction;
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ class FileCollection extends AbstractFileCollection
|
|||
* @param callable|null $objectFunction
|
||||
* @return $this
|
||||
*/
|
||||
public function setObjectBuilder(callable $objectFunction = null)
|
||||
public function setObjectBuilder(?callable $objectFunction = null)
|
||||
{
|
||||
$this->createObjectFunction = $objectFunction ?: [$this, 'createObject'];
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ interface RelationshipInterface extends Countable, IteratorAggregate, JsonSerial
|
|||
* @return bool
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function has(string $id, string $type = null): bool;
|
||||
public function has(string $id, ?string $type = null): bool;
|
||||
|
||||
/**
|
||||
* @param T $identifier
|
||||
|
|
@ -72,7 +72,7 @@ interface RelationshipInterface extends Countable, IteratorAggregate, JsonSerial
|
|||
* @param T|null $identifier
|
||||
* @return bool
|
||||
*/
|
||||
public function removeIdentifier(IdentifierInterface $identifier = null): bool;
|
||||
public function removeIdentifier(?IdentifierInterface $identifier = null): bool;
|
||||
|
||||
/**
|
||||
* @return iterable<T>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ interface ToManyRelationshipInterface extends RelationshipInterface
|
|||
* @return T|null
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function getIdentifier(string $id, string $type = null): ?IdentifierInterface;
|
||||
public function getIdentifier(string $id, ?string $type = null): ?IdentifierInterface;
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
|
|
@ -33,7 +33,7 @@ interface ToManyRelationshipInterface extends RelationshipInterface
|
|||
* @return T|null
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function getObject(string $id, string $type = null): ?object;
|
||||
public function getObject(string $id, ?string $type = null): ?object;
|
||||
|
||||
/**
|
||||
* @param iterable<T> $identifiers
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ interface ToOneRelationshipInterface extends RelationshipInterface
|
|||
* @return T|null
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function getIdentifier(string $id = null, string $type = null): ?IdentifierInterface;
|
||||
public function getIdentifier(?string $id = null, ?string $type = null): ?IdentifierInterface;
|
||||
|
||||
/**
|
||||
* @param string|null $id
|
||||
|
|
@ -27,11 +27,11 @@ interface ToOneRelationshipInterface extends RelationshipInterface
|
|||
* @return T|null
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function getObject(string $id = null, string $type = null): ?object;
|
||||
public function getObject(?string $id = null, ?string $type = null): ?object;
|
||||
|
||||
/**
|
||||
* @param T|null $identifier
|
||||
* @return bool
|
||||
*/
|
||||
public function replaceIdentifier(IdentifierInterface $identifier = null): bool;
|
||||
public function replaceIdentifier(?IdentifierInterface $identifier = null): bool;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ trait ControllerResponseTrait
|
|||
* @param array|null $headers
|
||||
* @return Response
|
||||
*/
|
||||
protected function createHtmlResponse(string $content, int $code = null, array $headers = null): ResponseInterface
|
||||
protected function createHtmlResponse(string $content, ?int $code = null, ?array $headers = null): ResponseInterface
|
||||
{
|
||||
$code = $code ?? 200;
|
||||
if ($code < 100 || $code > 599) {
|
||||
|
|
@ -66,7 +66,7 @@ trait ControllerResponseTrait
|
|||
* @param array|null $headers
|
||||
* @return Response
|
||||
*/
|
||||
protected function createJsonResponse(array $content, int $code = null, array $headers = null): ResponseInterface
|
||||
protected function createJsonResponse(array $content, ?int $code = null, ?array $headers = null): ResponseInterface
|
||||
{
|
||||
$code = $code ?? $content['code'] ?? 200;
|
||||
if (null === $code || $code < 100 || $code > 599) {
|
||||
|
|
@ -87,7 +87,7 @@ trait ControllerResponseTrait
|
|||
* @param array|null $options
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
protected function createDownloadResponse(string $filename, $resource, array $headers = null, array $options = null): ResponseInterface
|
||||
protected function createDownloadResponse(string $filename, $resource, ?array $headers = null, ?array $options = null): ResponseInterface
|
||||
{
|
||||
// Required for IE, otherwise Content-Disposition may be ignored
|
||||
if (ini_get('zlib.output_compression')) {
|
||||
|
|
@ -134,7 +134,7 @@ trait ControllerResponseTrait
|
|||
* @param int|null $code
|
||||
* @return Response
|
||||
*/
|
||||
protected function createRedirectResponse(string $url, int $code = null): ResponseInterface
|
||||
protected function createRedirectResponse(string $url, ?int $code = null): ResponseInterface
|
||||
{
|
||||
if (null === $code || $code < 301 || $code > 307) {
|
||||
$code = (int)$this->getConfig()->get('system.pages.redirect_default_code', 302);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class AbstractFile implements FileInterface
|
|||
* @param string $filepath
|
||||
* @param Filesystem|null $filesystem
|
||||
*/
|
||||
public function __construct(string $filepath, Filesystem $filesystem = null)
|
||||
public function __construct(string $filepath, ?Filesystem $filesystem = null)
|
||||
{
|
||||
$this->filesystem = $filesystem ?? Filesystem::getInstance();
|
||||
$this->setFilepath($filepath);
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ abstract class AbstractFormatter implements FileFormatterInterface
|
|||
* @param string|null $name Configuration option (optional)
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getConfig(string $name = null)
|
||||
protected function getConfig(?string $name = null)
|
||||
{
|
||||
if (null !== $name) {
|
||||
return $this->config[$name] ?? null;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class MarkdownFormatter extends AbstractFormatter
|
|||
/** @var FileFormatterInterface */
|
||||
private $headerFormatter;
|
||||
|
||||
public function __construct(array $config = [], FileFormatterInterface $headerFormatter = null)
|
||||
public function __construct(array $config = [], ?FileFormatterInterface $headerFormatter = null)
|
||||
{
|
||||
$config += [
|
||||
'file_extension' => '.md',
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Filesystem implements FilesystemInterface
|
|||
* @param bool|null $normalize See $this->setNormalization()
|
||||
* @return Filesystem
|
||||
*/
|
||||
public static function getInstance(bool $normalize = null): Filesystem
|
||||
public static function getInstance(?bool $normalize = null): Filesystem
|
||||
{
|
||||
if ($normalize === true) {
|
||||
$instance = &static::$safe;
|
||||
|
|
@ -63,7 +63,7 @@ class Filesystem implements FilesystemInterface
|
|||
* @param bool|null $normalize
|
||||
* @internal
|
||||
*/
|
||||
protected function __construct(bool $normalize = null)
|
||||
protected function __construct(?bool $normalize = null)
|
||||
{
|
||||
$this->normalize = $normalize;
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ class Filesystem implements FilesystemInterface
|
|||
* @param bool|null $normalize
|
||||
* @return Filesystem
|
||||
*/
|
||||
public function setNormalization(bool $normalize = null): self
|
||||
public function setNormalization(?bool $normalize = null): self
|
||||
{
|
||||
return static::getInstance($normalize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class Flex implements FlexInterface
|
|||
* @param bool $keepMissing
|
||||
* @return array<FlexDirectory|null>
|
||||
*/
|
||||
public function getDirectories(array $types = null, bool $keepMissing = false): array
|
||||
public function getDirectories(?array $types = null, bool $keepMissing = false): array
|
||||
{
|
||||
if ($types === null) {
|
||||
return $this->types;
|
||||
|
|
@ -125,7 +125,7 @@ class Flex implements FlexInterface
|
|||
* @return FlexCollectionInterface|null
|
||||
* @phpstan-return FlexCollectionInterface<FlexObjectInterface>|null
|
||||
*/
|
||||
public function getCollection(string $type, array $keys = null, string $keyField = null): ?FlexCollectionInterface
|
||||
public function getCollection(string $type, ?array $keys = null, ?string $keyField = null): ?FlexCollectionInterface
|
||||
{
|
||||
$directory = $type ? $this->getDirectory($type) : null;
|
||||
|
||||
|
|
@ -271,7 +271,7 @@ class Flex implements FlexInterface
|
|||
* @param string|null $keyField
|
||||
* @return FlexObjectInterface|null
|
||||
*/
|
||||
public function getObject(string $key, string $type = null, string $keyField = null): ?FlexObjectInterface
|
||||
public function getObject(string $key, ?string $type = null, ?string $keyField = null): ?FlexObjectInterface
|
||||
{
|
||||
if (null === $type && null === $keyField) {
|
||||
// Special handling for quick Flex key lookups.
|
||||
|
|
@ -303,7 +303,7 @@ class Flex implements FlexInterface
|
|||
* @param string|null $type
|
||||
* @return array
|
||||
*/
|
||||
protected function resolveKeyAndType(string $flexKey, string $type = null): array
|
||||
protected function resolveKeyAndType(string $flexKey, ?string $type = null): array
|
||||
{
|
||||
$guess = false;
|
||||
if (strpos($flexKey, ':') !== false) {
|
||||
|
|
@ -323,7 +323,7 @@ class Flex implements FlexInterface
|
|||
* @param string|null $type
|
||||
* @return string
|
||||
*/
|
||||
protected function resolveType(string $type = null): string
|
||||
protected function resolveType(?string $type = null): string
|
||||
{
|
||||
if (null !== $type && strpos($type, '.') !== false) {
|
||||
return preg_replace('|\.obj$|', '', $type) ?? $type;
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
|||
* {@inheritdoc}
|
||||
* @see FlexCollectionInterface::createFromArray()
|
||||
*/
|
||||
public static function createFromArray(array $entries, FlexDirectory $directory, string $keyField = null)
|
||||
public static function createFromArray(array $entries, FlexDirectory $directory, ?string $keyField = null)
|
||||
{
|
||||
$instance = new static($entries, $directory);
|
||||
$instance->setKeyField($keyField);
|
||||
|
|
@ -96,7 +96,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
|||
* {@inheritdoc}
|
||||
* @see FlexCollectionInterface::__construct()
|
||||
*/
|
||||
public function __construct(array $entries = [], FlexDirectory $directory = null)
|
||||
public function __construct(array $entries = [], ?FlexDirectory $directory = null)
|
||||
{
|
||||
// @phpstan-ignore-next-line
|
||||
if (get_class($this) === __CLASS__) {
|
||||
|
|
@ -145,7 +145,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
|||
* {@inheritdoc}
|
||||
* @see FlexCollectionInterface::search()
|
||||
*/
|
||||
public function search(string $search, $properties = null, array $options = null)
|
||||
public function search(string $search, $properties = null, ?array $options = null)
|
||||
{
|
||||
$directory = $this->getFlexDirectory();
|
||||
$properties = $directory->getSearchProperties($properties);
|
||||
|
|
@ -298,7 +298,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
|||
* @param string|null $separator Separator, defaults to '.'
|
||||
* @return array
|
||||
*/
|
||||
public function getDistinctValues(string $property, string $separator = null): array
|
||||
public function getDistinctValues(string $property, ?string $separator = null): array
|
||||
{
|
||||
$list = [];
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
|||
* {@inheritdoc}
|
||||
* @see FlexCollectionInterface::withKeyField()
|
||||
*/
|
||||
public function withKeyField(string $keyField = null)
|
||||
public function withKeyField(?string $keyField = null)
|
||||
{
|
||||
$keyField = $keyField ?: 'key';
|
||||
if ($keyField === $this->getKeyField()) {
|
||||
|
|
@ -366,7 +366,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
|||
* {@inheritdoc}
|
||||
* @see FlexCollectionInterface::render()
|
||||
*/
|
||||
public function render(string $layout = null, array $context = [])
|
||||
public function render(?string $layout = null, array $context = [])
|
||||
{
|
||||
if (!$layout) {
|
||||
$config = $this->getTemplateConfig();
|
||||
|
|
@ -485,7 +485,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
|||
* @param string|null $namespace
|
||||
* @return CacheInterface
|
||||
*/
|
||||
public function getCache(string $namespace = null)
|
||||
public function getCache(?string $namespace = null)
|
||||
{
|
||||
return $this->_flexDirectory->getCache($namespace);
|
||||
}
|
||||
|
|
@ -505,7 +505,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
|||
* @return static
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function isAuthorized(string $action, string $scope = null, UserInterface $user = null)
|
||||
public function isAuthorized(string $action, ?string $scope = null, ?UserInterface $user = null)
|
||||
{
|
||||
$list = $this->call('isAuthorized', [$action, $scope, $user]);
|
||||
$list = array_filter($list);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ use Psr\SimpleCache\InvalidArgumentException;
|
|||
use RocketTheme\Toolbox\File\YamlFile;
|
||||
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\Cache\Psr16Cache;
|
||||
use function call_user_func_array;
|
||||
use function count;
|
||||
use function is_array;
|
||||
|
|
@ -155,7 +156,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfig(string $name = null, $default = null)
|
||||
public function getConfig(?string $name = null, $default = null)
|
||||
{
|
||||
if (null === $this->config) {
|
||||
$config = $this->getBlueprintInternal()->get('config', []);
|
||||
|
|
@ -197,7 +198,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
* @param array|null $options
|
||||
* @return array
|
||||
*/
|
||||
public function getSearchOptions(array $options = null): array
|
||||
public function getSearchOptions(?array $options = null): array
|
||||
{
|
||||
if (empty($options['merge'])) {
|
||||
return $options ?? (array)$this->getConfig('data.search.options');
|
||||
|
|
@ -214,7 +215,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
* @return FlexFormInterface
|
||||
* @internal
|
||||
*/
|
||||
public function getDirectoryForm(string $name = null, array $options = [])
|
||||
public function getDirectoryForm(?string $name = null, array $options = [])
|
||||
{
|
||||
$name = $name ?: $this->getConfig('admin.views.configure.form', '') ?: $this->getConfig('admin.configure.form', '');
|
||||
|
||||
|
|
@ -311,7 +312,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
* @param string|null $name
|
||||
* @return string
|
||||
*/
|
||||
public function getDirectoryConfigUri(string $name = null): string
|
||||
public function getDirectoryConfigUri(?string $name = null): string
|
||||
{
|
||||
$name = $name ?: $this->getFlexType();
|
||||
$blueprint = $this->getBlueprint();
|
||||
|
|
@ -323,7 +324,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
* @param string|null $name
|
||||
* @return array
|
||||
*/
|
||||
protected function getDirectoryConfig(string $name = null): array
|
||||
protected function getDirectoryConfig(?string $name = null): array
|
||||
{
|
||||
$grav = Grav::instance();
|
||||
|
||||
|
|
@ -372,7 +373,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
* @return FlexCollectionInterface
|
||||
* @phpstan-return FlexCollectionInterface<FlexObjectInterface>
|
||||
*/
|
||||
public function getCollection(array $keys = null, string $keyField = null): FlexCollectionInterface
|
||||
public function getCollection(?array $keys = null, ?string $keyField = null): FlexCollectionInterface
|
||||
{
|
||||
// Get all selected entries.
|
||||
$index = $this->getIndex($keys, $keyField);
|
||||
|
|
@ -399,7 +400,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
* @return FlexIndexInterface
|
||||
* @phpstan-return FlexIndexInterface<FlexObjectInterface>
|
||||
*/
|
||||
public function getIndex(array $keys = null, string $keyField = null): FlexIndexInterface
|
||||
public function getIndex(?array $keys = null, ?string $keyField = null): FlexIndexInterface
|
||||
{
|
||||
$keyField = $keyField ?? '';
|
||||
$index = $this->indexes[$keyField] ?? $this->loadIndex($keyField);
|
||||
|
|
@ -422,7 +423,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
* @param string|null $keyField Field to be used as the key.
|
||||
* @return FlexObjectInterface|null
|
||||
*/
|
||||
public function getObject($key = null, string $keyField = null): ?FlexObjectInterface
|
||||
public function getObject($key = null, ?string $keyField = null): ?FlexObjectInterface
|
||||
{
|
||||
if (null === $key) {
|
||||
return $this->createObject([], '');
|
||||
|
|
@ -438,7 +439,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
* @param string|null $namespace
|
||||
* @return CacheInterface
|
||||
*/
|
||||
public function getCache(string $namespace = null)
|
||||
public function getCache(?string $namespace = null)
|
||||
{
|
||||
$namespace = $namespace ?: 'index';
|
||||
$cache = $this->cache[$namespace] ?? null;
|
||||
|
|
@ -452,6 +453,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
$config = $this->getConfig('object.cache.' . $namespace);
|
||||
if (empty($config['enabled'])) {
|
||||
$cache = new MemoryCache('flex-objects-' . $this->getFlexType());
|
||||
$cache->setValidation(false);
|
||||
} else {
|
||||
$lifetime = $config['lifetime'] ?? 60;
|
||||
|
||||
|
|
@ -459,7 +461,8 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
if (Utils::isAdminPlugin()) {
|
||||
$key = substr($key, 0, -1);
|
||||
}
|
||||
$cache = new DoctrineCache($gravCache->getCacheDriver(), 'flex-objects-' . $this->getFlexType() . $key, $lifetime);
|
||||
|
||||
$cache = new Psr16Cache($gravCache->getCacheAdapter('flex-objects-' . $this->getFlexType() . $key, $lifetime));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/** @var Debugger $debugger */
|
||||
|
|
@ -467,10 +470,9 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
$debugger->addException($e);
|
||||
|
||||
$cache = new MemoryCache('flex-objects-' . $this->getFlexType());
|
||||
$cache->setValidation(false);
|
||||
}
|
||||
|
||||
// Disable cache key validation.
|
||||
$cache->setValidation(false);
|
||||
$this->cache[$namespace] = $cache;
|
||||
}
|
||||
|
||||
|
|
@ -506,7 +508,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
* @param string|null $key
|
||||
* @return string|null
|
||||
*/
|
||||
public function getStorageFolder(string $key = null): ?string
|
||||
public function getStorageFolder(?string $key = null): ?string
|
||||
{
|
||||
return $this->getStorage()->getStoragePath($key);
|
||||
}
|
||||
|
|
@ -515,7 +517,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
* @param string|null $key
|
||||
* @return string|null
|
||||
*/
|
||||
public function getMediaFolder(string $key = null): ?string
|
||||
public function getMediaFolder(?string $key = null): ?string
|
||||
{
|
||||
return $this->getStorage()->getMediaPath($key);
|
||||
}
|
||||
|
|
@ -555,7 +557,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
* @return FlexCollectionInterface
|
||||
* @phpstan-return FlexCollectionInterface<FlexObjectInterface>
|
||||
*/
|
||||
public function createCollection(array $entries, string $keyField = null): FlexCollectionInterface
|
||||
public function createCollection(array $entries, ?string $keyField = null): FlexCollectionInterface
|
||||
{
|
||||
/** phpstan-var class-string $className */
|
||||
$className = $this->collectionClassName ?: $this->getCollectionClass();
|
||||
|
|
@ -572,7 +574,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
* @return FlexIndexInterface
|
||||
* @phpstan-return FlexIndexInterface<FlexObjectInterface>
|
||||
*/
|
||||
public function createIndex(array $entries, string $keyField = null): FlexIndexInterface
|
||||
public function createIndex(array $entries, ?string $keyField = null): FlexIndexInterface
|
||||
{
|
||||
/** @phpstan-var class-string $className */
|
||||
$className = $this->indexClassName ?: $this->getIndexClass();
|
||||
|
|
@ -626,7 +628,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
* @return FlexCollectionInterface
|
||||
* @phpstan-return FlexCollectionInterface<FlexObjectInterface>
|
||||
*/
|
||||
public function loadCollection(array $entries, string $keyField = null): FlexCollectionInterface
|
||||
public function loadCollection(array $entries, ?string $keyField = null): FlexCollectionInterface
|
||||
{
|
||||
return $this->createCollection($this->loadObjects($entries), $keyField);
|
||||
}
|
||||
|
|
@ -1120,7 +1122,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
* @return FlexObjectInterface
|
||||
* @deprecated 1.7 Use $object->update()->save() instead.
|
||||
*/
|
||||
public function update(array $data, string $key = null): FlexObjectInterface
|
||||
public function update(array $data, ?string $key = null): FlexObjectInterface
|
||||
{
|
||||
user_error(__CLASS__ . '::' . __FUNCTION__ . '() should not be used anymore: use $object->update()->save() instead.', E_USER_DEPRECATED);
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class FlexDirectoryForm implements FlexDirectoryFormInterface, JsonSerializable
|
|||
* @param FlexDirectory $directory
|
||||
* @param array|null $options
|
||||
*/
|
||||
public function __construct(string $name, FlexDirectory $directory, array $options = null)
|
||||
public function __construct(string $name, FlexDirectory $directory, ?array $options = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->setDirectory($directory);
|
||||
|
|
@ -350,7 +350,7 @@ class FlexDirectoryForm implements FlexDirectoryFormInterface, JsonSerializable
|
|||
* @param string|null $extension
|
||||
* @return string
|
||||
*/
|
||||
public function getMediaTaskRoute(array $params = [], string $extension = null): string
|
||||
public function getMediaTaskRoute(array $params = [], ?string $extension = null): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class FlexForm implements FlexObjectFormInterface, JsonSerializable
|
|||
* @param FlexObjectInterface $object
|
||||
* @param array|null $options
|
||||
*/
|
||||
public function __construct(string $name, FlexObjectInterface $object, array $options = null)
|
||||
public function __construct(string $name, FlexObjectInterface $object, ?array $options = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->setObject($object);
|
||||
|
|
@ -428,7 +428,7 @@ class FlexForm implements FlexObjectFormInterface, JsonSerializable
|
|||
* @param string|null $extension
|
||||
* @return string
|
||||
*/
|
||||
public function getMediaTaskRoute(array $params = [], string $extension = null): string
|
||||
public function getMediaTaskRoute(array $params = [], ?string $extension = null): string
|
||||
{
|
||||
$grav = Grav::instance();
|
||||
/** @var Flex $flex */
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
namespace Grav\Framework\Flex;
|
||||
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Grav\Common\Debugger;
|
||||
use Grav\Common\File\CompiledJsonFile;
|
||||
|
|
@ -65,7 +66,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
|
|||
* {@inheritdoc}
|
||||
* @see FlexCollectionInterface::createFromArray()
|
||||
*/
|
||||
public static function createFromArray(array $entries, FlexDirectory $directory, string $keyField = null)
|
||||
public static function createFromArray(array $entries, FlexDirectory $directory, ?string $keyField = null)
|
||||
{
|
||||
$instance = new static($entries, $directory);
|
||||
$instance->setKeyField($keyField);
|
||||
|
|
@ -105,7 +106,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
|
|||
* @param array $entries
|
||||
* @param FlexDirectory|null $directory
|
||||
*/
|
||||
public function __construct(array $entries = [], FlexDirectory $directory = null)
|
||||
public function __construct(array $entries = [], ?FlexDirectory $directory = null)
|
||||
{
|
||||
// @phpstan-ignore-next-line
|
||||
if (get_class($this) === __CLASS__) {
|
||||
|
|
@ -160,7 +161,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
|
|||
* {@inheritdoc}
|
||||
* @see FlexCollectionInterface::search()
|
||||
*/
|
||||
public function search(string $search, $properties = null, array $options = null)
|
||||
public function search(string $search, $properties = null, ?array $options = null)
|
||||
{
|
||||
$directory = $this->getFlexDirectory();
|
||||
$properties = $directory->getSearchProperties($properties);
|
||||
|
|
@ -282,7 +283,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
|
|||
* {@inheritdoc}
|
||||
* @see FlexIndexInterface::withKeyField()
|
||||
*/
|
||||
public function withKeyField(string $keyField = null)
|
||||
public function withKeyField(?string $keyField = null)
|
||||
{
|
||||
$keyField = $keyField ?: 'key';
|
||||
if ($keyField === $this->getKeyField()) {
|
||||
|
|
@ -328,7 +329,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
|
|||
* {@inheritdoc}
|
||||
* @see FlexCollectionInterface::render()
|
||||
*/
|
||||
public function render(string $layout = null, array $context = [])
|
||||
public function render(?string $layout = null, array $context = [])
|
||||
{
|
||||
return $this->__call('render', [$layout, $context]);
|
||||
}
|
||||
|
|
@ -337,7 +338,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
|
|||
* {@inheritdoc}
|
||||
* @see FlexIndexInterface::getFlexKeys()
|
||||
*/
|
||||
public function getIndexMap(string $indexKey = null)
|
||||
public function getIndexMap(?string $indexKey = null)
|
||||
{
|
||||
if (null === $indexKey) {
|
||||
return $this->getEntries();
|
||||
|
|
@ -373,7 +374,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
|
|||
* @param string|null $namespace
|
||||
* @return CacheInterface
|
||||
*/
|
||||
public function getCache(string $namespace = null)
|
||||
public function getCache(?string $namespace = null)
|
||||
{
|
||||
return $this->getFlexDirectory()->getCache($namespace);
|
||||
}
|
||||
|
|
@ -557,7 +558,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
|
|||
* @return static
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
protected function createFrom(array $entries, string $keyField = null)
|
||||
protected function createFrom(array $entries, ?string $keyField = null)
|
||||
{
|
||||
/** @phpstan-var static<T,C> $index */
|
||||
$index = new static($entries, $this->getFlexDirectory());
|
||||
|
|
@ -570,7 +571,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
|
|||
* @param string|null $keyField
|
||||
* @return void
|
||||
*/
|
||||
protected function setKeyField(string $keyField = null)
|
||||
protected function setKeyField(?string $keyField = null)
|
||||
{
|
||||
$this->_keyField = $keyField ?? 'storage_key';
|
||||
}
|
||||
|
|
@ -641,7 +642,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
|
|||
* @return ObjectInterface[]
|
||||
* @phpstan-return T[]
|
||||
*/
|
||||
protected function loadElements(array $entries = null): array
|
||||
protected function loadElements(?array $entries = null): array
|
||||
{
|
||||
/** @phpstan-var T[] $objects */
|
||||
$objects = $this->getFlexDirectory()->loadObjects($entries ?? $this->getEntries());
|
||||
|
|
@ -654,7 +655,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
|
|||
* @return CollectionInterface
|
||||
* @phpstan-return C
|
||||
*/
|
||||
protected function loadCollection(array $entries = null): CollectionInterface
|
||||
protected function loadCollection(?array $entries = null): CollectionInterface
|
||||
{
|
||||
/** @var C $collection */
|
||||
$collection = $this->getFlexDirectory()->loadCollection($entries ?? $this->getEntries(), $this->_keyField);
|
||||
|
|
@ -880,7 +881,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
|
|||
|
||||
/** @var Logger $logger */
|
||||
$logger = $grav['log'];
|
||||
$logger->addAlert($e->getMessage());
|
||||
$logger->alert($e->getMessage());
|
||||
|
||||
/** @var Debugger $debugger */
|
||||
$debugger = $grav['debugger'];
|
||||
|
|
@ -927,4 +928,15 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
|
|||
|
||||
return $type . $this->getFlexType();
|
||||
}
|
||||
|
||||
public function findFirst(Closure $p)
|
||||
{
|
||||
// TODO: Implement findFirst() method.
|
||||
}
|
||||
|
||||
public function reduce(Closure $func, mixed $initial = null)
|
||||
{
|
||||
// TODO: Implement reduce() method.
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
* {@inheritdoc}
|
||||
* @see FlexObjectInterface::search()
|
||||
*/
|
||||
public function search(string $search, $properties = null, array $options = null): float
|
||||
public function search(string $search, $properties = null, ?array $options = null): float
|
||||
{
|
||||
$directory = $this->getFlexDirectory();
|
||||
$properties = $directory->getSearchProperties($properties);
|
||||
|
|
@ -362,7 +362,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
* @param array|null $options
|
||||
* @return float
|
||||
*/
|
||||
public function searchProperty(string $property, string $search, array $options = null): float
|
||||
public function searchProperty(string $property, string $search, ?array $options = null): float
|
||||
{
|
||||
$options = $options ?? (array)$this->getFlexDirectory()->getConfig('data.search.options');
|
||||
$value = $this->getProperty($property);
|
||||
|
|
@ -376,7 +376,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
* @param array|null $options
|
||||
* @return float
|
||||
*/
|
||||
public function searchNestedProperty(string $property, string $search, array $options = null): float
|
||||
public function searchNestedProperty(string $property, string $search, ?array $options = null): float
|
||||
{
|
||||
$options = $options ?? (array)$this->getFlexDirectory()->getConfig('data.search.options');
|
||||
if ($property === 'key') {
|
||||
|
|
@ -395,7 +395,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
* @param array|null $options
|
||||
* @return float
|
||||
*/
|
||||
protected function searchValue(string $name, $value, string $search, array $options = null): float
|
||||
protected function searchValue(string $name, $value, string $search, ?array $options = null): float
|
||||
{
|
||||
$options = $options ?? [];
|
||||
|
||||
|
|
@ -515,7 +515,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
* @param string|null $namespace
|
||||
* @return CacheInterface
|
||||
*/
|
||||
public function getCache(string $namespace = null)
|
||||
public function getCache(?string $namespace = null)
|
||||
{
|
||||
return $this->_flexDirectory->getCache($namespace);
|
||||
}
|
||||
|
|
@ -546,7 +546,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
* {@inheritdoc}
|
||||
* @see FlexObjectInterface::render()
|
||||
*/
|
||||
public function render(string $layout = null, array $context = [])
|
||||
public function render(?string $layout = null, array $context = [])
|
||||
{
|
||||
if (!$layout) {
|
||||
$config = $this->getTemplateConfig();
|
||||
|
|
@ -714,7 +714,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
* {@inheritdoc}
|
||||
* @see FlexObjectInterface::create()
|
||||
*/
|
||||
public function create(string $key = null)
|
||||
public function create(?string $key = null)
|
||||
{
|
||||
if ($key) {
|
||||
$this->setStorageKey($key);
|
||||
|
|
@ -731,7 +731,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
* @param string|null $key
|
||||
* @return FlexObject|FlexObjectInterface
|
||||
*/
|
||||
public function createCopy(string $key = null)
|
||||
public function createCopy(?string $key = null)
|
||||
{
|
||||
$this->markAsCopy();
|
||||
|
||||
|
|
@ -741,7 +741,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
/**
|
||||
* @param UserInterface|null $user
|
||||
*/
|
||||
public function check(UserInterface $user = null): void
|
||||
public function check(?UserInterface $user = null): void
|
||||
{
|
||||
// If user has been provided, check if the user has permissions to save this object.
|
||||
if ($user && !$this->isAuthorized('save', null, $user)) {
|
||||
|
|
@ -865,7 +865,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
* {@inheritdoc}
|
||||
* @see FlexObjectInterface::getForm()
|
||||
*/
|
||||
public function getForm(string $name = '', array $options = null)
|
||||
public function getForm(string $name = '', ?array $options = null)
|
||||
{
|
||||
$hash = $name . '-' . md5(json_encode($options, JSON_THROW_ON_ERROR));
|
||||
if (!isset($this->_forms[$hash])) {
|
||||
|
|
@ -879,7 +879,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
* {@inheritdoc}
|
||||
* @see FlexObjectInterface::getDefaultValue()
|
||||
*/
|
||||
public function getDefaultValue(string $name, string $separator = null)
|
||||
public function getDefaultValue(string $name, ?string $separator = null)
|
||||
{
|
||||
$separator = $separator ?: '.';
|
||||
$path = explode($separator, $name);
|
||||
|
|
@ -920,7 +920,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
* {@inheritdoc}
|
||||
* @see FlexObjectInterface::getFormValue()
|
||||
*/
|
||||
public function getFormValue(string $name, $default = null, string $separator = null)
|
||||
public function getFormValue(string $name, $default = null, ?string $separator = null)
|
||||
{
|
||||
if ($name === 'storage_key') {
|
||||
return $this->getStorageKey();
|
||||
|
|
@ -1018,7 +1018,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
* @param FlexDirectory|null $directory
|
||||
* @return void
|
||||
*/
|
||||
protected function doUnserialize(array $serialized, FlexDirectory $directory = null): void
|
||||
protected function doUnserialize(array $serialized, ?FlexDirectory $directory = null): void
|
||||
{
|
||||
$type = $serialized['type'] ?? 'unknown';
|
||||
|
||||
|
|
@ -1106,7 +1106,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
* @param array|null $options Form optiosn
|
||||
* @return FlexFormInterface
|
||||
*/
|
||||
protected function createFormObject(string $name, array $options = null)
|
||||
protected function createFormObject(string $name, ?array $options = null)
|
||||
{
|
||||
return new FlexForm($name, $this, $options);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,5 +29,5 @@ interface FlexAuthorizeInterface
|
|||
* @param UserInterface|null $user
|
||||
* @return bool|null
|
||||
*/
|
||||
public function isAuthorized(string $action, string $scope = null, UserInterface $user = null): ?bool;
|
||||
public function isAuthorized(string $action, ?string $scope = null, ?UserInterface $user = null): ?bool;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
|||
* @param string|null $keyField Key field used to index the collection.
|
||||
* @return static Returns a new Flex Collection.
|
||||
*/
|
||||
public static function createFromArray(array $entries, FlexDirectory $directory, string $keyField = null);
|
||||
public static function createFromArray(array $entries, FlexDirectory $directory, ?string $keyField = null);
|
||||
|
||||
/**
|
||||
* Creates a new Flex Collection.
|
||||
|
|
@ -48,7 +48,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
|||
* @param FlexDirectory|null $directory Flex Directory where all the objects belong into.
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(array $entries = [], FlexDirectory $directory = null);
|
||||
public function __construct(array $entries = [], ?FlexDirectory $directory = null);
|
||||
|
||||
/**
|
||||
* Search a string from the collection.
|
||||
|
|
@ -60,7 +60,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
|||
* @phpstan-return static<T>
|
||||
* @api
|
||||
*/
|
||||
public function search(string $search, $properties = null, array $options = null);
|
||||
public function search(string $search, $properties = null, ?array $options = null);
|
||||
|
||||
/**
|
||||
* Sort the collection.
|
||||
|
|
@ -116,7 +116,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
|||
* @phpstan-return static<T>
|
||||
* @api
|
||||
*/
|
||||
public function withKeyField(string $keyField = null);
|
||||
public function withKeyField(?string $keyField = null);
|
||||
|
||||
/**
|
||||
* Get Flex Index from the Flex Collection.
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface
|
|||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfig(string $name = null, $default = null);
|
||||
public function getConfig(?string $name = null, $default = null);
|
||||
|
||||
/**
|
||||
* @param string|null $name
|
||||
|
|
@ -57,7 +57,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface
|
|||
* @return FlexFormInterface
|
||||
* @internal
|
||||
*/
|
||||
public function getDirectoryForm(string $name = null, array $options = []);
|
||||
public function getDirectoryForm(?string $name = null, array $options = []);
|
||||
|
||||
/**
|
||||
* @return Blueprint
|
||||
|
|
@ -78,7 +78,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface
|
|||
* @param string|null $name
|
||||
* @return string
|
||||
*/
|
||||
public function getDirectoryConfigUri(string $name = null): string;
|
||||
public function getDirectoryConfigUri(?string $name = null): string;
|
||||
|
||||
/**
|
||||
* Returns a new uninitialized instance of blueprint.
|
||||
|
|
@ -107,7 +107,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface
|
|||
* @return FlexCollectionInterface
|
||||
* @phpstan-return FlexCollectionInterface<FlexObjectInterface>
|
||||
*/
|
||||
public function getCollection(array $keys = null, string $keyField = null): FlexCollectionInterface;
|
||||
public function getCollection(?array $keys = null, ?string $keyField = null): FlexCollectionInterface;
|
||||
|
||||
/**
|
||||
* Get the full collection of all stored objects.
|
||||
|
|
@ -119,7 +119,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface
|
|||
* @return FlexIndexInterface
|
||||
* @phpstan-return FlexIndexInterface<FlexObjectInterface>
|
||||
*/
|
||||
public function getIndex(array $keys = null, string $keyField = null): FlexIndexInterface;
|
||||
public function getIndex(?array $keys = null, ?string $keyField = null): FlexIndexInterface;
|
||||
|
||||
/**
|
||||
* Returns an object if it exists. If no arguments are passed (or both of them are null), method creates a new empty object.
|
||||
|
|
@ -130,13 +130,13 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface
|
|||
* @param string|null $keyField Field to be used as the key.
|
||||
* @return FlexObjectInterface|null
|
||||
*/
|
||||
public function getObject($key = null, string $keyField = null): ?FlexObjectInterface;
|
||||
public function getObject($key = null, ?string $keyField = null): ?FlexObjectInterface;
|
||||
|
||||
/**
|
||||
* @param string|null $namespace
|
||||
* @return CacheInterface
|
||||
*/
|
||||
public function getCache(string $namespace = null);
|
||||
public function getCache(?string $namespace = null);
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
|
|
@ -147,13 +147,13 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface
|
|||
* @param string|null $key
|
||||
* @return string|null
|
||||
*/
|
||||
public function getStorageFolder(string $key = null): ?string;
|
||||
public function getStorageFolder(?string $key = null): ?string;
|
||||
|
||||
/**
|
||||
* @param string|null $key
|
||||
* @return string|null
|
||||
*/
|
||||
public function getMediaFolder(string $key = null): ?string;
|
||||
public function getMediaFolder(?string $key = null): ?string;
|
||||
|
||||
/**
|
||||
* @return FlexStorageInterface
|
||||
|
|
@ -174,7 +174,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface
|
|||
* @return FlexCollectionInterface
|
||||
* @phpstan-return FlexCollectionInterface<FlexObjectInterface>
|
||||
*/
|
||||
public function createCollection(array $entries, string $keyField = null): FlexCollectionInterface;
|
||||
public function createCollection(array $entries, ?string $keyField = null): FlexCollectionInterface;
|
||||
|
||||
/**
|
||||
* @param array $entries
|
||||
|
|
@ -182,7 +182,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface
|
|||
* @return FlexIndexInterface
|
||||
* @phpstan-return FlexIndexInterface<FlexObjectInterface>
|
||||
*/
|
||||
public function createIndex(array $entries, string $keyField = null): FlexIndexInterface;
|
||||
public function createIndex(array $entries, ?string $keyField = null): FlexIndexInterface;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
|
@ -205,7 +205,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface
|
|||
* @return FlexCollectionInterface
|
||||
* @phpstan-return FlexCollectionInterface<FlexObjectInterface>
|
||||
*/
|
||||
public function loadCollection(array $entries, string $keyField = null): FlexCollectionInterface;
|
||||
public function loadCollection(array $entries, ?string $keyField = null): FlexCollectionInterface;
|
||||
|
||||
/**
|
||||
* @param array $entries
|
||||
|
|
|
|||
|
|
@ -54,11 +54,11 @@ interface FlexIndexInterface extends FlexCollectionInterface
|
|||
* @phpstan-return static<T>
|
||||
* @api
|
||||
*/
|
||||
public function withKeyField(string $keyField = null);
|
||||
public function withKeyField(?string $keyField = null);
|
||||
|
||||
/**
|
||||
* @param string|null $indexKey
|
||||
* @return array
|
||||
*/
|
||||
public function getIndexMap(string $indexKey = null);
|
||||
public function getIndexMap(?string $indexKey = null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ interface FlexInterface extends Countable
|
|||
* @param bool $keepMissing
|
||||
* @return array<FlexDirectory|null>
|
||||
*/
|
||||
public function getDirectories(array $types = null, bool $keepMissing = false): array;
|
||||
public function getDirectories(?array $types = null, bool $keepMissing = false): array;
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
|
|
@ -61,7 +61,7 @@ interface FlexInterface extends Countable
|
|||
* @return FlexCollectionInterface|null
|
||||
* @phpstan-return FlexCollectionInterface<FlexObjectInterface>|null
|
||||
*/
|
||||
public function getCollection(string $type, array $keys = null, string $keyField = null): ?FlexCollectionInterface;
|
||||
public function getCollection(string $type, ?array $keys = null, ?string $keyField = null): ?FlexCollectionInterface;
|
||||
|
||||
/**
|
||||
* @param array $keys
|
||||
|
|
@ -91,7 +91,7 @@ interface FlexInterface extends Countable
|
|||
* @param string|null $keyField
|
||||
* @return FlexObjectInterface|null
|
||||
*/
|
||||
public function getObject(string $key, string $type = null, string $keyField = null): ?FlexObjectInterface;
|
||||
public function getObject(string $key, ?string $type = null, ?string $keyField = null): ?FlexObjectInterface;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ interface FlexObjectInterface extends FlexCommonInterface, NestedObjectInterface
|
|||
* @return float Returns a weight between 0 and 1.
|
||||
* @api
|
||||
*/
|
||||
public function search(string $search, $properties = null, array $options = null): float;
|
||||
public function search(string $search, $properties = null, ?array $options = null): float;
|
||||
|
||||
/**
|
||||
* Returns true if object has a key.
|
||||
|
|
@ -136,7 +136,7 @@ interface FlexObjectInterface extends FlexCommonInterface, NestedObjectInterface
|
|||
* @throws RuntimeException if object already exists.
|
||||
* @api
|
||||
*/
|
||||
public function create(string $key = null);
|
||||
public function create(?string $key = null);
|
||||
|
||||
/**
|
||||
* Save object into the storage.
|
||||
|
|
@ -175,7 +175,7 @@ interface FlexObjectInterface extends FlexCommonInterface, NestedObjectInterface
|
|||
* @return FlexFormInterface Returns a Form.
|
||||
* @api
|
||||
*/
|
||||
public function getForm(string $name = '', array $options = null);
|
||||
public function getForm(string $name = '', ?array $options = null);
|
||||
|
||||
/**
|
||||
* Returns default value suitable to be used in a form for the given property.
|
||||
|
|
@ -186,7 +186,7 @@ interface FlexObjectInterface extends FlexCommonInterface, NestedObjectInterface
|
|||
* @param string|null $separator Optional nested property separator.
|
||||
* @return mixed|null Returns default value of the field, null if there is no default value.
|
||||
*/
|
||||
public function getDefaultValue(string $name, string $separator = null);
|
||||
public function getDefaultValue(string $name, ?string $separator = null);
|
||||
|
||||
/**
|
||||
* Returns default values suitable to be used in a form for the given property.
|
||||
|
|
@ -207,5 +207,5 @@ interface FlexObjectInterface extends FlexCommonInterface, NestedObjectInterface
|
|||
* @param string|null $separator Optional nested property separator.
|
||||
* @return mixed Returns value of the field.
|
||||
*/
|
||||
public function getFormValue(string $name, $default = null, string $separator = null);
|
||||
public function getFormValue(string $name, $default = null, ?string $separator = null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ interface FlexStorageInterface
|
|||
* @param array|null $fetched Optional reference to store only fetched items.
|
||||
* @return array Returns rows. Note that non-existing rows will have `null` as their value.
|
||||
*/
|
||||
public function readRows(array $rows, array &$fetched = null): array;
|
||||
public function readRows(array $rows, ?array &$fetched = null): array;
|
||||
|
||||
/**
|
||||
* Update existing rows in the storage.
|
||||
|
|
@ -126,7 +126,7 @@ interface FlexStorageInterface
|
|||
* @param string|null $key Optional storage key.
|
||||
* @return string|null Path in the filesystem. Can be URI or null if storage is not filesystem based.
|
||||
*/
|
||||
public function getStoragePath(string $key = null): ?string;
|
||||
public function getStoragePath(?string $key = null): ?string;
|
||||
|
||||
/**
|
||||
* Get filesystem path for the collection or object media.
|
||||
|
|
@ -134,5 +134,5 @@ interface FlexStorageInterface
|
|||
* @param string|null $key Optional storage key.
|
||||
* @return string|null Path in the filesystem. Can be URI or null if media isn't supported.
|
||||
*/
|
||||
public function getMediaPath(string $key = null): ?string;
|
||||
public function getMediaPath(?string $key = null): ?string;
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user