Merge branch '1.7' of github.com:getgrav/grav into feature/1.7-media

 Conflicts:
	system/src/Grav/Common/Page/Medium/ImageMedium.php
This commit is contained in:
Matias Griese
2020-05-12 20:34:26 +03:00
42 changed files with 600 additions and 75 deletions

View File

@@ -19,51 +19,51 @@
"ext-curl": "*",
"ext-zip": "*",
"ext-dom": "*",
"symfony/polyfill-iconv": "^1.9",
"symfony/polyfill-php72": "^1.9",
"symfony/polyfill-php73": "^1.9",
"symfony/polyfill-iconv": "^1.15",
"symfony/polyfill-php72": "^1.15",
"symfony/polyfill-php73": "^1.15",
"psr/simple-cache": "^1.0",
"psr/http-message": "^1.0",
"psr/http-server-middleware": "^1.0",
"kodus/psr7-server": "*",
"nyholm/psr7": "^1.0",
"twig/twig": "~1.0",
"nyholm/psr7": "^1.2",
"twig/twig": "~1.42",
"erusev/parsedown": "^1.7",
"erusev/parsedown-extra": "~0.8",
"symfony/contracts": "~1.0",
"symfony/yaml": "~4.4.0",
"symfony/console": "~4.4.0",
"symfony/event-dispatcher": "~4.4.0",
"symfony/var-dumper": "~4.4.0",
"symfony/process": "~4.4.0",
"doctrine/cache": "^1.8",
"doctrine/collections": "^1.5",
"guzzlehttp/psr7": "^1.4",
"filp/whoops": "~2.2",
"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.6",
"filp/whoops": "~2.7",
"matthiasmullie/minify": "^1.3",
"monolog/monolog": "~1.0",
"monolog/monolog": "~1.25",
"gregwar/image": "~2.0",
"donatj/phpuseragentparser": "~0.10",
"donatj/phpuseragentparser": "~1.0",
"pimple/pimple": "~3.2",
"rockettheme/toolbox": "~1.5",
"maximebf/debugbar": "~1.0",
"league/climate": "^3.4",
"maximebf/debugbar": "~1.16",
"league/climate": "^3.5",
"antoligy/dom-string-iterators": "^1.0",
"miljar/php-exif": "^0.6.4",
"composer/ca-bundle": "^1.0",
"miljar/php-exif": "^0.6",
"composer/ca-bundle": "^1.2",
"dragonmantank/cron-expression": "^1.2",
"phive/twig-extensions-deferred": "^1.0",
"willdurand/negotiation": "2.x-dev",
"itsgoingd/clockwork": "^4.1",
"enshrined/svg-sanitize": "~0.1",
"enshrined/svg-sanitize": "~0.13",
"symfony/http-client": "^4.4"
},
"require-dev": {
"codeception/codeception": "^2.4",
"codeception/codeception": "^2.5",
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-deprecation-rules": "^0.11",
"phpunit/php-code-coverage": "~6.0",
"fzaninotto/faker": "^1.8",
"phpunit/php-code-coverage": "~6.1",
"fzaninotto/faker": "^1.9",
"victorjonsson/markdowndocs": "dev-master"
},
"suggest": {

29
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "f1b19bd30c2a650efac9eca78af1630a",
"content-hash": "db60f72565a888f6d2d0aee966bbb66f",
"packages": [
{
"name": "antoligy/dom-string-iterators",
@@ -260,23 +260,23 @@
},
{
"name": "donatj/phpuseragentparser",
"version": "v0.16.0",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/donatj/PhpUserAgent.git",
"reference": "b3551112ed84524aef6542a8778a3f812c8098ce"
"reference": "1431382850017ac017d194f2a6f6cacb35212888"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/donatj/PhpUserAgent/zipball/b3551112ed84524aef6542a8778a3f812c8098ce",
"reference": "b3551112ed84524aef6542a8778a3f812c8098ce",
"url": "https://api.github.com/repos/donatj/PhpUserAgent/zipball/1431382850017ac017d194f2a6f6cacb35212888",
"reference": "1431382850017ac017d194f2a6f6cacb35212888",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"camspiers/json-pretty": "0.1.*",
"camspiers/json-pretty": "~1.0",
"donatj/drop": "*",
"phpunit/phpunit": "~4.8"
},
@@ -284,7 +284,10 @@
"autoload": {
"files": [
"src/UserAgentParser.php"
]
],
"psr-4": {
"donatj\\UserAgent\\": "src/UserAgent"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -307,7 +310,7 @@
"user agent",
"useragent"
],
"time": "2020-04-07T15:47:30+00:00"
"time": "2020-04-24T18:07:07+00:00"
},
{
"name": "dragonmantank/cron-expression",
@@ -1003,16 +1006,16 @@
},
{
"name": "maximebf/debugbar",
"version": "v1.16.2",
"version": "v1.16.3",
"source": {
"type": "git",
"url": "https://github.com/maximebf/php-debugbar.git",
"reference": "40f375504a4dd8e59f779c3f3cac524777ddcde5"
"reference": "1a1605b8e9bacb34cc0c6278206d699772e1d372"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/40f375504a4dd8e59f779c3f3cac524777ddcde5",
"reference": "40f375504a4dd8e59f779c3f3cac524777ddcde5",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/1a1605b8e9bacb34cc0c6278206d699772e1d372",
"reference": "1a1605b8e9bacb34cc0c6278206d699772e1d372",
"shasum": ""
},
"require": {
@@ -1060,7 +1063,7 @@
"debug",
"debugbar"
],
"time": "2020-04-16T09:05:52+00:00"
"time": "2020-05-06T07:06:27+00:00"
},
{
"name": "miljar/php-exif",

View File

@@ -9,6 +9,8 @@
namespace Grav\Common;
use function donatj\UserAgent\parse_user_agent;
/**
* Internally uses the PhpUserAgent package https://github.com/donatj/PhpUserAgent
*/

View File

@@ -393,6 +393,17 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
return array_keys($list);
}
/**
* Mimicks Pages class.
*
* @return $this
* @deprecated 1.7 Not needed anymore in Flex Pages (does nothing).
*/
public function all()
{
return $this;
}
/**
* Returns the items between a set of date ranges of either the page date field (default) or
* an arbitrary datetime page field where end date is optional

View File

@@ -759,6 +759,17 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
return $collection;
}
/**
* Mimicks Pages class.
*
* @return $this
* @deprecated 1.7 Not needed anymore in Flex Pages (does nothing).
*/
public function all()
{
return $this;
}
/**
* Creates new collection with only visible pages
*

View File

@@ -72,7 +72,7 @@ abstract class AbstractLazyCollection extends BaseAbstractLazyCollection impleme
}
/**
* {@inheritDoc}
* @return array
*/
public function jsonSerialize()
{

View File

@@ -104,10 +104,7 @@ class ContentBlock implements ContentBlockInterface
public function toArray()
{
$blocks = [];
/**
* @var string $id
* @var ContentBlockInterface $block
*/
/** @var ContentBlockInterface $block */
foreach ($this->blocks as $block) {
$blocks[$block->getId()] = $block->toArray();
}
@@ -167,6 +164,7 @@ class ContentBlock implements ContentBlockInterface
/**
* @param array $serialized
* @return void
* @throws \RuntimeException
*/
public function build(array $serialized)
@@ -266,6 +264,7 @@ class ContentBlock implements ContentBlockInterface
/**
* @param string $serialized
* @return void
*/
public function unserialize($serialized)
{
@@ -283,6 +282,7 @@ class ContentBlock implements ContentBlockInterface
/**
* @param array $serialized
* @return void
* @throws \RuntimeException
*/
protected function checkVersion(array $serialized)

View File

@@ -59,6 +59,7 @@ interface ContentBlockInterface extends \Serializable
/**
* @param array $serialized
* @return void
*/
public function build(array $serialized);

View File

@@ -103,6 +103,7 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
/**
* @param array $serialized
* @return void
* @throws \RuntimeException
*/
public function build(array $serialized)
@@ -362,6 +363,7 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
/**
* @param array $items
* @return void
*/
protected function sortAssetsInLocation(array &$items)
{
@@ -381,6 +383,7 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
/**
* @param array $array
* @return void
*/
protected function sortAssets(array &$array)
{

View File

@@ -42,6 +42,7 @@ abstract class AbstractFormatter implements FileFormatterInterface
/**
* @param string $serialized
* @return void
*/
public function unserialize($serialized): void
{

View File

@@ -42,7 +42,9 @@ class CsvFormatter extends AbstractFormatter
}
/**
* {@inheritdoc}
* @param array $data
* @param string|null $delimiter
* @return string
* @see FileFormatterInterface::encode()
*/
public function encode($data, $delimiter = null): string
@@ -65,7 +67,9 @@ class CsvFormatter extends AbstractFormatter
}
/**
* {@inheritdoc}
* @param string $data
* @param string|null $delimiter
* @return array
* @see FileFormatterInterface::decode()
*/
public function decode($data, $delimiter = null): array
@@ -111,7 +115,12 @@ class CsvFormatter extends AbstractFormatter
return $list;
}
protected function encodeLine(array $line, $delimiter = null): string
/**
* @param array $line
* @param string $delimiter
* @return string
*/
protected function encodeLine(array $line, string $delimiter): string
{
foreach ($line as $key => &$value) {
$value = $this->escape((string)$value);
@@ -121,6 +130,10 @@ class CsvFormatter extends AbstractFormatter
return implode($delimiter, $line). "\n";
}
/**
* @param string $value
* @return string
*/
protected function escape(string $value)
{
if (preg_match('/[,"\r\n]/u', $value)) {

View File

@@ -65,7 +65,10 @@ class YamlFormatter extends AbstractFormatter
}
/**
* {@inheritdoc}
* @param array $data
* @param int|null $inline
* @param int|null $indent
* @return string
* @see FileFormatterInterface::encode()
*/
public function encode($data, $inline = null, $indent = null): string

View File

@@ -29,7 +29,6 @@ class Filesystem implements FilesystemInterface
/**
* @param bool|null $normalize See $this->setNormalization()
*
* @return Filesystem
*/
public static function getInstance(bool $normalize = null): Filesystem
@@ -67,7 +66,6 @@ class Filesystem implements FilesystemInterface
* not normalized.
*
* @param bool|null $normalize
*
* @return Filesystem
*/
public function setNormalization(bool $normalize = null): self
@@ -78,7 +76,7 @@ class Filesystem implements FilesystemInterface
/**
* Force all paths to be normalized.
*
* @return static
* @return self
*/
public function unsafe(): self
{
@@ -88,7 +86,7 @@ class Filesystem implements FilesystemInterface
/**
* Force all paths not to be normalized (speeds up the calls if given paths are known to be normalized).
*
* @return static
* @return self
*/
public function safe(): self
{
@@ -165,7 +163,6 @@ class Filesystem implements FilesystemInterface
* @param string|null $scheme
* @param string $path
* @param int $levels
*
* @return array
*/
protected function dirnameInternal(?string $scheme, string $path, int $levels = 1): array
@@ -188,7 +185,6 @@ class Filesystem implements FilesystemInterface
* @param string|null $scheme
* @param string $path
* @param int|null $options
*
* @return array|string
*/
protected function pathinfoInternal(?string $scheme, string $path, int $options = null)
@@ -222,7 +218,6 @@ class Filesystem implements FilesystemInterface
* Gets a 2-tuple of scheme (may be null) and hierarchical part of a filename (e.g. file:///tmp -> array(file, tmp)).
*
* @param string $filename
*
* @return array
*/
protected function getSchemeAndHierarchy(string $filename): array
@@ -235,7 +230,6 @@ class Filesystem implements FilesystemInterface
/**
* @param string|null $scheme
* @param string $path
*
* @return string
*/
protected function toString(?string $scheme, string $path): string
@@ -249,7 +243,6 @@ class Filesystem implements FilesystemInterface
/**
* @param string $path
*
* @return string
* @throws \RuntimeException
*/

View File

@@ -297,6 +297,11 @@ class Flex implements FlexInterface
return \count($this->types);
}
/**
* @param string $flexKey
* @param string|null $type
* @return array
*/
protected function resolveKeyAndType(string $flexKey, string $type = null): array
{
$guess = false;
@@ -313,6 +318,10 @@ class Flex implements FlexInterface
return [$key, $type, $guess];
}
/**
* @param string|null $type
* @return string
*/
protected function resolveType(string $type = null): string
{
if (null !== $type && strpos($type, '.') !== false) {

View File

@@ -221,11 +221,11 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
*/
public function getCacheChecksum(): string
{
$list = [];
/**
* @var string $key
* @var FlexObjectInterface $object
*/
$list = [];
foreach ($this as $key => $object) {
$list[$key] = $object->getCacheChecksum();
}
@@ -497,6 +497,9 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
return $elements;
}
/**
* @return array
*/
public function __debugInfo()
{
return [
@@ -515,7 +518,6 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
*
* @param array $elements Elements.
* @param string|null $keyField
*
* @return static
* @throws \InvalidArgumentException
*/
@@ -612,6 +614,10 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
return $flex->getDirectory($type);
}
/**
* @param string|null $keyField
* @return void
*/
protected function setKeyField($keyField = null): void
{
$this->_keyField = $keyField ?? 'storage_key';

View File

@@ -89,6 +89,9 @@ class FlexDirectory implements FlexAuthorizeInterface
$this->objects = [];
}
/**
* @return bool
*/
public function isListed(): bool
{
$grav = Grav::instance();
@@ -668,6 +671,10 @@ class FlexDirectory implements FlexAuthorizeInterface
return $list;
}
/**
* @return void
* @throws InvalidArgumentException
*/
public function reloadIndex(): void
{
$cache = $this->getCache('index');
@@ -737,6 +744,7 @@ class FlexDirectory implements FlexAuthorizeInterface
* @param array $field
* @param string $property
* @param array $call
* @return void
*/
protected function dynamicDataField(array &$field, $property, array &$call)
{
@@ -774,6 +782,7 @@ class FlexDirectory implements FlexAuthorizeInterface
* @param array $field
* @param string $property
* @param array $call
* @return void
*/
protected function dynamicFlexField(array &$field, $property, array &$call)
{

View File

@@ -420,6 +420,7 @@ class FlexForm implements FlexObjectFormInterface, \JsonSerializable
/**
* @param string $name
* @param mixed $value
* @return void
*/
public function __set($name, $value)
{
@@ -447,6 +448,7 @@ class FlexForm implements FlexObjectFormInterface, \JsonSerializable
/**
* @param string $name
* @return void
*/
public function __unset($name)
{
@@ -491,6 +493,7 @@ class FlexForm implements FlexObjectFormInterface, \JsonSerializable
/**
* @param array $data
* @param array $files
* @return void
* @throws \Exception
*/
protected function doSubmit(array $data, array $files)
@@ -517,6 +520,7 @@ class FlexForm implements FlexObjectFormInterface, \JsonSerializable
/**
* @param array $data
* @return void
*/
protected function doUnserialize(array $data): void
{
@@ -529,6 +533,7 @@ class FlexForm implements FlexObjectFormInterface, \JsonSerializable
* Filter validated data.
*
* @param \ArrayAccess|Data|null $data
* @return void
*/
protected function filterData($data = null): void
{

View File

@@ -30,6 +30,7 @@ class FlexFormFlash extends FormFlash
/**
* @param FlexObjectInterface $object
* @return void
*/
public function setObject(FlexObjectInterface $object): void
{
@@ -92,6 +93,7 @@ class FlexFormFlash extends FormFlash
/**
* @param array|null $data
* @param array $config
* @return void
*/
protected function init(?array $data, array $config): void
{

View File

@@ -287,6 +287,9 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
return $this;
}
/**
* @return CollectionInterface|FlexCollectionInterface
*/
public function getCollection()
{
return $this->loadCollection();
@@ -402,6 +405,11 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
return $this->__call('call', [$method, $arguments]);
}
/**
* @param string $name
* @param array $arguments
* @return mixed
*/
public function __call($name, $arguments)
{
/** @var Debugger $debugger */
@@ -481,6 +489,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
/**
* @param string $serialized
* @return void
*/
public function unserialize($serialized)
{
@@ -518,12 +527,16 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
/**
* @param string|null $keyField
* @return void
*/
protected function setKeyField(string $keyField = null)
{
$this->_keyField = $keyField ?? 'storage_key';
}
/**
* @return array
*/
protected function getIndexKeys()
{
if (null === $this->_indexKeys) {
@@ -544,6 +557,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
/**
* @param array $indexKeys
* @return void
*/
protected function setIndexKeys(array $indexKeys)
{
@@ -615,6 +629,10 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
return $object->getMetaData();
}
/**
* @param FlexObjectInterface $element
* @return string
*/
protected function getCurrentKey($element)
{
$keyField = $this->getKeyField();
@@ -736,6 +754,10 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
{
}
/**
* @param FlexStorageInterface $storage
* @return array
*/
protected static function loadIndex(FlexStorageInterface $storage)
{
$indexFile = static::getIndexFile($storage);
@@ -762,6 +784,10 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
return ['version' => static::VERSION, 'timestamp' => 0, 'count' => 0, 'index' => []];
}
/**
* @param FlexStorageInterface $storage
* @return array
*/
protected static function loadEntriesFromIndex(FlexStorageInterface $storage)
{
$data = static::loadIndex($storage);
@@ -792,6 +818,10 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
return CompiledYamlFile::instance($filename);
}
/**
* @param \Exception $e
* @return void
*/
protected static function onException(\Exception $e)
{
$grav = Grav::instance();
@@ -806,6 +836,13 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
$debugger->addMessage($e, 'error');
}
/**
* @param array $entries
* @param array $added
* @param array $updated
* @param array $removed
* @return void
*/
protected static function onChanges(array $entries, array $added, array $updated, array $removed)
{
$addedCount = \count($added);

View File

@@ -90,6 +90,13 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
];
}
/**
* @param array $elements
* @param array $storage
* @param FlexDirectory $directory
* @param bool $validate
* @return static
*/
public static function createFromStorage(array $elements, array $storage, FlexDirectory $directory, bool $validate = false)
{
$instance = new static($elements, $storage['key'], $directory, $validate);

View File

@@ -82,7 +82,6 @@ class FlexPageCollection extends FlexCollection
* Check to see if this item is the first in the collection.
*
* @param string $path
*
* @return bool True if item is first.
*/
public function isFirst($path): bool
@@ -97,7 +96,6 @@ class FlexPageCollection extends FlexCollection
* Check to see if this item is the last in the collection.
*
* @param string $path
*
* @return bool True if item is last.
*/
public function isLast($path): bool
@@ -112,7 +110,6 @@ class FlexPageCollection extends FlexCollection
* Gets the previous sibling based on current position.
*
* @param string $path
*
* @return PageInterface|false The previous item.
*/
public function prevSibling($path)
@@ -124,7 +121,6 @@ class FlexPageCollection extends FlexCollection
* Gets the next sibling based on current position.
*
* @param string $path
*
* @return PageInterface|false The next item.
*/
public function nextSibling($path)
@@ -137,7 +133,6 @@ class FlexPageCollection extends FlexCollection
*
* @param string $path
* @param int $direction either -1 or +1
*
* @return PageInterface|false The sibling item.
*/
public function adjacentSibling($path, $direction = 1)
@@ -159,7 +154,6 @@ class FlexPageCollection extends FlexCollection
* Returns the item in the current position.
*
* @param string $path the path the item
*
* @return int|null The index of the current page, null if not found.
*/
public function currentPosition($path): ?int
@@ -176,11 +170,11 @@ class FlexPageCollection extends FlexCollection
{
$directory = $this->getFlexDirectory();
/** @var FlexPageObject $last */
$collection = $directory->getIndex();
$keys = $collection->getStorageKeys();
// Assign next free order.
/** @var FlexPageObject|null $last */
$last = null;
$order = 0;
foreach ($keys as $folder => $key) {

View File

@@ -197,6 +197,7 @@ class FlexPageObject extends FlexObject implements PageInterface, MediaManipulat
/**
* Get master storage key.
*
* @return string
* @see FlexObjectInterface::getStorageKey()
*/
public function getMasterKey(): string
@@ -326,6 +327,7 @@ class FlexPageObject extends FlexObject implements PageInterface, MediaManipulat
/*
* @param string $property
* @param mixed $default
* @return void
*/
public function setProperty($property, $value)
{
@@ -341,6 +343,12 @@ class FlexPageObject extends FlexObject implements PageInterface, MediaManipulat
return $this;
}
/**
* @param string $property
* @param mixed $value
* @param string|null $separator
* @return $this
*/
public function setNestedProperty($property, $value, $separator = null)
{
if (strpos($property, 'header.') === 0) {
@@ -354,6 +362,11 @@ class FlexPageObject extends FlexObject implements PageInterface, MediaManipulat
return $this;
}
/**
* @param string $property
* @param string|null $separator
* @return $this
*/
public function unsetNestedProperty($property, $separator = null)
{
if (strpos($property, 'header.') === 0) {
@@ -370,6 +383,7 @@ class FlexPageObject extends FlexObject implements PageInterface, MediaManipulat
/**
* @param array $elements
* @param bool $extended
* @return void
*/
protected function filterElements(array &$elements, bool $extended = false): void
{

View File

@@ -112,6 +112,10 @@ abstract class AbstractFilesystemStorage implements FlexStorageInterface
];
}
/**
* @param string|array $formatter
* @return void
*/
protected function initDataFormatter($formatter): void
{
// Initialize formatter.
@@ -126,7 +130,7 @@ abstract class AbstractFilesystemStorage implements FlexStorageInterface
/**
* @param string $filename
* @return null|string
* @return string|null
*/
protected function detectDataFormatter(string $filename): ?string
{

View File

@@ -333,6 +333,7 @@ class FolderStorage extends AbstractFilesystemStorage
* Prepares the row for saving and returns the storage key for the record.
*
* @param array $row
* @return void
*/
protected function prepareRow(array &$row): void
{
@@ -560,6 +561,10 @@ class FolderStorage extends AbstractFilesystemStorage
return $meta;
}
/**
* @param string $path
* @return array
*/
protected function buildIndexFromFilesystem($path)
{
$flags = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS;
@@ -582,6 +587,10 @@ class FolderStorage extends AbstractFilesystemStorage
return $list;
}
/**
* @param string $path
* @return array
*/
protected function buildPrefixedIndexFromFilesystem($path)
{
$flags = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS;
@@ -619,6 +628,7 @@ class FolderStorage extends AbstractFilesystemStorage
/**
* @param array $options
* @return void
*/
protected function initOptions(array $options): void
{

View File

@@ -96,6 +96,7 @@ trait FlexMediaTrait
/**
* @param UploadedFileInterface $uploadedFile
* @return void
*/
public function checkUploadedMediaFile(UploadedFileInterface $uploadedFile)
{
@@ -133,6 +134,10 @@ trait FlexMediaTrait
$this->checkMediaFilename($filename);
}
/**
* @param string $filename
* @return void
*/
public function checkMediaFilename(string $filename)
{
// Check the file extension.
@@ -150,6 +155,11 @@ trait FlexMediaTrait
}
}
/**
* @param UploadedFileInterface $uploadedFile
* @param string|null $filename
* @return void
*/
public function uploadMediaFile(UploadedFileInterface $uploadedFile, string $filename = null): void
{
$this->checkUploadedMediaFile($uploadedFile);
@@ -209,6 +219,10 @@ trait FlexMediaTrait
$this->clearMediaCache();
}
/**
* @param string $filename
* @return void
*/
public function deleteMediaFile(string $filename): void
{
$grav = Grav::instance();
@@ -287,6 +301,7 @@ trait FlexMediaTrait
/**
* @param array $files
* @return void
*/
protected function setUpdatedMedia(array $files): void
{
@@ -311,6 +326,9 @@ trait FlexMediaTrait
return $this->_uploads ?? [];
}
/**
* @return void
*/
protected function saveUpdatedMedia(): void
{
/**
@@ -352,17 +370,29 @@ trait FlexMediaTrait
return $this->getCache('object');
}
/**
* @return MediaCollectionInterface
*/
protected function offsetLoad_media()
{
return $this->getMedia();
}
/**
* @return null
*/
protected function offsetSerialize_media()
{
return null;
}
/**
* @return FlexDirectory
*/
abstract public function getFlexDirectory(): FlexDirectory;
/**
* @return string
*/
abstract public function getStorageKey(): string;
}

View File

@@ -80,6 +80,10 @@ class FormFlash implements FormFlashInterface
$this->init($this->loadStoredForm(), $config);
}
/**
* @param array|null $data
* @param array $config
*/
protected function init(?array $data, array $config): void
{
if (null === $data) {
@@ -103,7 +107,7 @@ class FormFlash implements FormFlashInterface
/**
* Load raw flex flash data from the filesystem.
*
* @return array
* @return array|null
*/
protected function loadStoredForm(): ?array
{
@@ -138,6 +142,7 @@ class FormFlash implements FormFlashInterface
}
/**
* @return string
* @deprecated 1.6.11 Use '->getUniqueId()' method instead.
*/
public function getUniqieId(): string
@@ -483,6 +488,9 @@ class FormFlash implements FormFlashInterface
}
}
/**
* @return void
*/
protected function removeTmpDir(): void
{
// Make sure that index file cache gets always cleared.
@@ -500,6 +508,7 @@ class FormFlash implements FormFlashInterface
* @param string $name
* @param array $data
* @param array|null $crop
* @return void
*/
protected function addFileInternal(?string $field, string $name, array $data, array $crop = null): void
{

View File

@@ -63,6 +63,10 @@ class FormFlashFile implements UploadedFileInterface, \JsonSerializable
return Stream::create($resource);
}
/**
* @param string $targetPath
* @return void
*/
public function moveTo($targetPath)
{
$this->validateActive();
@@ -87,31 +91,49 @@ class FormFlashFile implements UploadedFileInterface, \JsonSerializable
}
}
/**
* @return int
*/
public function getSize()
{
return $this->upload['size'];
}
/**
* @return int
*/
public function getError()
{
return $this->upload['error'] ?? \UPLOAD_ERR_OK;
}
/**
* @return string
*/
public function getClientFilename()
{
return $this->upload['name'] ?? 'unknown';
}
/**
* @return string
*/
public function getClientMediaType()
{
return $this->upload['type'] ?? 'application/octet-stream';
}
/**
* @return bool
*/
public function isMoved(): bool
{
return $this->moved;
}
/**
* @return array
*/
public function getMetaData(): array
{
if (isset($this->upload['crop'])) {
@@ -121,16 +143,25 @@ class FormFlashFile implements UploadedFileInterface, \JsonSerializable
return [];
}
/**
* @return string
*/
public function getDestination()
{
return $this->upload['path'] ?? '';
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->upload;
}
/**
* @return string|null
*/
public function getTmpFile(): ?string
{
$tmpName = $this->upload['tmp_name'] ?? null;
@@ -144,6 +175,9 @@ class FormFlashFile implements UploadedFileInterface, \JsonSerializable
return file_exists($tmpFile) ? $tmpFile : null;
}
/**
* @return array
*/
public function __debugInfo()
{
return [
@@ -154,6 +188,7 @@ class FormFlashFile implements UploadedFileInterface, \JsonSerializable
}
/**
* @return void
* @throws \RuntimeException if is moved or not ok
*/
private function validateActive(): void

View File

@@ -86,6 +86,7 @@ interface FormFlashInterface extends \JsonSerializable
* Set raw form data.
*
* @param array|null $data
* @return void
*/
public function setData(?array $data): void;
@@ -105,6 +106,8 @@ interface FormFlashInterface extends \JsonSerializable
/**
* Delete this form flash.
*
* @return $this
*/
public function delete();
@@ -155,6 +158,8 @@ interface FormFlashInterface extends \JsonSerializable
/**
* Clear form flash from all uploaded files.
*
* @return void
*/
public function clearFiles();

View File

@@ -164,6 +164,8 @@ interface FormInterface extends RenderInterface, \Serializable
/**
* Reset form.
*
* @return void
*/
public function reset(): void;

View File

@@ -63,61 +63,99 @@ trait FormTrait
/** @var Blueprint */
private $blueprint;
/**
* @return string
*/
public function getId(): string
{
return $this->id;
}
/**
* @param string $id
*/
public function setId(string $id): void
{
$this->id = $id;
}
/**
* @return string
*/
public function getUniqueId(): string
{
return $this->uniqueid;
}
/**
* @param string $uniqueId
* @return void
*/
public function setUniqueId(string $uniqueId): void
{
$this->uniqueid = $uniqueId;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @return string
*/
public function getFormName(): string
{
return $this->name;
}
/**
* @return string
*/
public function getNonceName(): string
{
return 'form-nonce';
}
/**
* @return string
*/
public function getNonceAction(): string
{
return 'form';
}
/**
* @return string
*/
public function getNonce(): string
{
return Utils::getNonce($this->getNonceAction());
}
/**
* @return string
*/
public function getAction(): string
{
return '';
}
/**
* @return string
*/
public function getTask(): string
{
return $this->getBlueprint()->get('form/task') ?? '';
}
/**
* @param string|null $name
* @return mixed
*/
public function getData(string $name = null)
{
return null !== $name ? $this->data[$name] : $this->data;
@@ -131,11 +169,19 @@ trait FormTrait
return $this->files ?? [];
}
/**
* @param string $name
* @return mixed|null
*/
public function getValue(string $name)
{
return $this->data[$name] ?? null;
}
/**
* @param string $name
* @return mixed|null
*/
public function getDefaultValue(string $name)
{
$path = explode('.', $name) ?: [];
@@ -310,6 +356,9 @@ trait FormTrait
return $this;
}
/**
* @return void
*/
public function reset(): void
{
// Make sure that the flash object gets deleted.
@@ -348,6 +397,9 @@ trait FormTrait
return $this->getBlueprint()->get('form/tasks') ?? [];
}
/**
* @return Blueprint
*/
abstract public function getBlueprint(): Blueprint;
/**
@@ -364,6 +416,7 @@ trait FormTrait
* Implements \Serializable::unserialize().
*
* @param string $serialized
* @return void
*/
public function unserialize($serialized): void
{
@@ -476,16 +529,26 @@ trait FormTrait
return $this->sessionid;
}
/**
* @param string $sessionId
* @return void
*/
protected function setSessionId(string $sessionId): void
{
$this->sessionid = $sessionId;
}
/**
* @return void
*/
protected function unsetFlash(): void
{
$this->flash = null;
}
/**
* @return string|null
*/
protected function getFlashFolder(): ?string
{
$grav = Grav::instance();
@@ -519,6 +582,9 @@ trait FormTrait
return strpos($path, '!!') === false ? rtrim($path, '/') : null;
}
/**
* @return string
*/
protected function getFlashLookupFolder(): string
{
if (null === $this->flashFolder) {
@@ -528,6 +594,10 @@ trait FormTrait
return $this->flashFolder;
}
/**
* @param string $folder
* @return void
*/
protected function setFlashLookupFolder(string $folder): void
{
$this->flashFolder = $folder;
@@ -537,6 +607,7 @@ trait FormTrait
* Set a single error.
*
* @param string $error
* @return void
*/
protected function setError(string $error): void
{
@@ -548,6 +619,7 @@ trait FormTrait
* Set all errors.
*
* @param array $errors
* @return void
*/
protected function setErrors(array $errors): void
{
@@ -625,6 +697,7 @@ trait FormTrait
* Validate data and throw validation exceptions if validation fails.
*
* @param \ArrayAccess|Data|null $data
* @return void
* @throws ValidationException
* @throws \Exception
*/
@@ -639,6 +712,7 @@ trait FormTrait
* Filter validated data.
*
* @param \ArrayAccess|Data|null $data
* @return void
*/
protected function filterData($data = null): void
{
@@ -651,6 +725,7 @@ trait FormTrait
* Validate all uploaded files.
*
* @param array $files
* @return void
*/
protected function validateUploads(array $files): void
{
@@ -670,6 +745,7 @@ trait FormTrait
* Validate uploaded file.
*
* @param UploadedFileInterface $file
* @return void
*/
protected function validateUpload(UploadedFileInterface $file): void
{
@@ -755,6 +831,7 @@ trait FormTrait
/**
* @param array $data
* @return void
*/
protected function doUnserialize(array $data): void
{

View File

@@ -19,7 +19,6 @@ class ObjectExpressionVisitor extends ClosureExpressionVisitor
*
* @param object $object
* @param string $field
*
* @return mixed
*/
public static function getObjectFieldValue($object, $field)
@@ -59,31 +58,55 @@ class ObjectExpressionVisitor extends ClosureExpressionVisitor
return $value;
}
/**
* @param string $str
* @return string
*/
public static function filterLower($str)
{
return mb_strtolower($str);
}
/**
* @param string $str
* @return string
*/
public static function filterUpper($str)
{
return mb_strtoupper($str);
}
/**
* @param string $str
* @return int
*/
public static function filterLength($str)
{
return mb_strlen($str);
}
/**
* @param string $str
* @return string
*/
public static function filterLtrim($str)
{
return ltrim($str);
}
/**
* @param string $str
* @return string
*/
public static function filterRtrim($str)
{
return rtrim($str);
}
/**
* @param string $str
* @return string
*/
public static function filterTrim($str)
{
return trim($str);

View File

@@ -99,11 +99,18 @@ class ObjectCollection extends ArrayCollection implements NestedObjectCollection
return $this->createFrom($filtered);
}
/**
* @return array
*/
protected function getElements()
{
return $this->toArray();
}
/**
* @param array $elements
* @return array
*/
protected function setElements(array $elements)
{
return $elements;

View File

@@ -157,6 +157,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
/**
* @param string $property Object property to be unset.
* @param string $separator Separator, defaults to '.'
* @return ObjectCollectionInterface
*/
public function unsetNestedProperty($property, $separator = null)
@@ -197,7 +198,9 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
}
/**
* {@inheritDoc}
* @param string $method
* @param array $arguments
* @return array|mixed
*/
public function call($method, array $arguments = [])
{
@@ -237,6 +240,11 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
return $collection->matching($criteria);
}
/**
* @param string $name
* @param array $arguments
* @return mixed
*/
abstract public function __call($name, $arguments);
/**

View File

@@ -57,31 +57,50 @@ class AbstractPagination implements PaginationInterface
/** @var array */
private $items;
/**
* @return bool
*/
public function isEnabled(): bool
{
return $this->count() > 1;
}
/**
* @return array
*/
public function getOptions(): array
{
return $this->options;
}
/**
* @return Route|null
*/
public function getRoute(): ?Route
{
return $this->route;
}
/**
* @return int
*/
public function getTotalPages(): int
{
return $this->pages;
}
/**
* @return int
*/
public function getPageNumber(): int
{
return $this->page ?? 1;
}
/**
* @param int $count
* @return int|null
*/
public function getPrevNumber(int $count = 1): ?int
{
$page = $this->page - $count;
@@ -89,6 +108,10 @@ class AbstractPagination implements PaginationInterface
return $page >= 1 ? $page : null;
}
/**
* @param int $count
* @return int|null
*/
public function getNextNumber(int $count = 1): ?int
{
$page = $this->page + $count;
@@ -96,6 +119,11 @@ class AbstractPagination implements PaginationInterface
return $page <= $this->pages ? $page : null;
}
/**
* @param int $page
* @param string|null $label
* @return PaginationPage|null
*/
public function getPage(int $page, string $label = null): ?PaginationPage
{
if ($page < 1 || $page > $this->pages) {
@@ -124,41 +152,73 @@ class AbstractPagination implements PaginationInterface
);
}
/**
* @param string|null $label
* @param int $count
* @return PaginationPage|null
*/
public function getFirstPage(string $label = null, int $count = 0): ?PaginationPage
{
return $this->getPage(1 + $count, $label ?? $this->getOptions()['label_first'] ?? null);
}
/**
* @param string|null $label
* @param int $count
* @return PaginationPage|null
*/
public function getPrevPage(string $label = null, int $count = 1): ?PaginationPage
{
return $this->getPage($this->page - $count, $label ?? $this->getOptions()['label_prev'] ?? null);
}
/**
* @param string|null $label
* @param int $count
* @return PaginationPage|null
*/
public function getNextPage(string $label = null, int $count = 1): ?PaginationPage
{
return $this->getPage($this->page + $count, $label ?? $this->getOptions()['label_next'] ?? null);
}
/**
* @param string|null $label
* @param int $count
* @return PaginationPage|null
*/
public function getLastPage(string $label = null, int $count = 0): ?PaginationPage
{
return $this->getPage($this->pages - $count, $label ?? $this->getOptions()['label_last'] ?? null);
}
/**
* @return int
*/
public function getStart(): int
{
return $this->start ?? 0;
}
/**
* @return int
*/
public function getLimit(): int
{
return $this->limit;
}
/**
* @return int
*/
public function getTotal(): int
{
return $this->total;
}
/**
* @return int
*/
public function count(): int
{
$this->loadItems();
@@ -166,6 +226,9 @@ class AbstractPagination implements PaginationInterface
return \count($this->items);
}
/**
* @return \ArrayIterator
*/
public function getIterator()
{
$this->loadItems();
@@ -173,6 +236,9 @@ class AbstractPagination implements PaginationInterface
return new \ArrayIterator($this->items);
}
/**
* @return array
*/
public function getPages(): array
{
$this->loadItems();
@@ -180,6 +246,9 @@ class AbstractPagination implements PaginationInterface
return $this->items;
}
/**
* @return void
*/
protected function loadItems()
{
$this->calculateRange();
@@ -197,6 +266,10 @@ class AbstractPagination implements PaginationInterface
}
}
/**
* @param Route $route
* @return $this
*/
protected function setRoute(Route $route)
{
$this->route = $route;
@@ -204,6 +277,10 @@ class AbstractPagination implements PaginationInterface
return $this;
}
/**
* @param array|null $options
* @return $this
*/
protected function setOptions(array $options = null)
{
$this->options = $options ? array_merge($this->defaultOptions, $options) : $this->defaultOptions;
@@ -211,6 +288,10 @@ class AbstractPagination implements PaginationInterface
return $this;
}
/**
* @param int|null $page
* @return $this
*/
protected function setPage(int $page = null)
{
$this->page = (int)max($page, 1);
@@ -256,6 +337,14 @@ class AbstractPagination implements PaginationInterface
return $this;
}
/**
* @param Route $route
* @param int $total
* @param int|null $pos
* @param int|null $limit
* @param array|null $options
* @return void
*/
protected function initialize(Route $route, int $total, int $pos = null, int $limit = null, array $options = null)
{
$this->setRoute($route);
@@ -270,6 +359,9 @@ class AbstractPagination implements PaginationInterface
$this->calculateLimits();
}
/**
* @return void
*/
protected function calculateLimits()
{
$limit = $this->limit;
@@ -300,6 +392,9 @@ class AbstractPagination implements PaginationInterface
$this->pages = (int)ceil($total / $limit);
}
/**
* @return void
*/
protected function calculateRange()
{
$options = $this->getOptions();

View File

@@ -13,31 +13,85 @@ use Grav\Framework\Pagination\PaginationPage;
interface PaginationInterface extends \Countable, \IteratorAggregate
{
/**
* @return int
*/
public function getTotalPages(): int;
/**
* @return int
*/
public function getPageNumber(): int;
/**
* @param int $count
* @return int|null
*/
public function getPrevNumber(int $count = 1): ?int;
/**
* @param int $count
* @return int|null
*/
public function getNextNumber(int $count = 1): ?int;
/**
* @return int
*/
public function getStart(): int;
/**
* @return int
*/
public function getLimit(): int;
/**
* @return int
*/
public function getTotal(): int;
/**
* @return int
*/
public function count(): int;
/**
* @return array
*/
public function getOptions(): array;
/**
* @param int $page
* @param string|null $label
* @return PaginationPage|null
*/
public function getPage(int $page, string $label = null): ?PaginationPage;
/**
* @param string|null $label
* @param int $count
* @return PaginationPage|null
*/
public function getFirstPage(string $label = null, int $count = 0): ?PaginationPage;
/**
* @param string|null $label
* @param int $count
* @return PaginationPage|null
*/
public function getPrevPage(string $label = null, int $count = 1): ?PaginationPage;
/**
* @param string|null $label
* @param int $count
* @return PaginationPage|null
*/
public function getNextPage(string $label = null, int $count = 1): ?PaginationPage;
/**
* @param string|null $label
* @param int $count
* @return PaginationPage|null
*/
public function getLastPage(string $label = null, int $count = 0): ?PaginationPage;
}

View File

@@ -11,15 +11,33 @@ namespace Grav\Framework\Pagination\Interfaces;
interface PaginationPageInterface
{
/**
* @return bool
*/
public function isActive(): bool;
/**
* @return bool
*/
public function isEnabled(): bool;
/**
* @return array
*/
public function getOptions(): array;
/**
* @return int|null
*/
public function getNumber(): ?int;
/**
* @return string
*/
public function getLabel(): string;
/**
* @return string|null
*/
public function getUrl(): ?string;
}

View File

@@ -353,6 +353,7 @@ abstract class AbstractUri implements UriInterface
/**
* @param array $parts
* @return void
* @throws \InvalidArgumentException
*/
protected function initParts(array $parts)
@@ -371,6 +372,7 @@ abstract class AbstractUri implements UriInterface
}
/**
* @return void
* @throws \InvalidArgumentException
*/
private function validate()
@@ -391,6 +393,9 @@ abstract class AbstractUri implements UriInterface
}
}
/**
* @return bool
*/
protected function isDefaultPort()
{
$scheme = $this->scheme;
@@ -400,6 +405,9 @@ abstract class AbstractUri implements UriInterface
|| (isset(static::$defaultPorts[$scheme]) && $port === static::$defaultPorts[$scheme]);
}
/**
* @return void
*/
private function unsetDefaultPort()
{
if ($this->isDefaultPort()) {

View File

@@ -18,6 +18,11 @@ class Stream implements StreamInterface
{
use StreamDecoratorTrait;
/**
* Stream constructor.
*
* @param string $body
*/
public function __construct($body = '')
{
$this->stream = \Nyholm\Psr7\Stream::create($body);

View File

@@ -210,7 +210,7 @@ class Route
* Allow the ability to set the route to something else
*
* @param string $route
* @return $this
* @return Route
*/
public function withRoute($route)
{
@@ -224,7 +224,7 @@ class Route
* Allow the ability to set the root to something else
*
* @param string $root
* @return $this
* @return Route
*/
public function withRoot($root)
{
@@ -358,7 +358,7 @@ class Route
* @param string $type
* @param string $param
* @param mixed $value
* @return static
* @return Route
*/
protected function withParam($type, $param, $value)
{
@@ -381,6 +381,9 @@ class Route
return $new;
}
/**
* @return Route
*/
protected function copy()
{
return clone $this;
@@ -419,6 +422,7 @@ class Route
/**
* @param array $parts
* @return void
*/
protected function initParts(array $parts)
{

View File

@@ -39,6 +39,11 @@ class Session implements SessionInterface
return self::$instance;
}
/**
* Session constructor.
*
* @param array $options
*/
public function __construct(array $options = [])
{
// Session is a singleton.
@@ -421,6 +426,7 @@ class Session implements SessionInterface
/**
* @param string $key
* @param mixed $value
* @return void
*/
protected function setOption($key, $value)
{

View File

@@ -34,7 +34,6 @@ interface SessionInterface extends \IteratorAggregate
* Set session ID
*
* @param string $id Session ID
*
* @return $this
*/
public function setId($id);
@@ -50,7 +49,6 @@ interface SessionInterface extends \IteratorAggregate
* Set session name
*
* @param string $name
*
* @return $this
*/
public function setName($name);
@@ -59,7 +57,7 @@ interface SessionInterface extends \IteratorAggregate
* Sets session.* ini variables.
*
* @param array $options
*
* @return void
* @see http://php.net/session.configuration
*/
public function setOptions(array $options);
@@ -136,6 +134,7 @@ interface SessionInterface extends \IteratorAggregate
*
* @param string $name
* @param mixed $value
* @return void
*/
public function __set($name, $value);
@@ -143,6 +142,7 @@ interface SessionInterface extends \IteratorAggregate
* Removes session variable.
*
* @param string $name
* @return void
*/
public function __unset($name);
}

View File

@@ -27,6 +27,7 @@ class Uri extends AbstractUri
* You can use `UriFactory` functions to create new `Uri` objects.
*
* @param array $parts
* @return void
* @throws \InvalidArgumentException
*/
public function __construct(array $parts = [])