Added missing docblocks, fixed some typehints

This commit is contained in:
Matias Griese 2019-12-04 10:25:24 +02:00
parent b314ea13aa
commit 620fd7ed88
53 changed files with 646 additions and 110 deletions

View File

@ -25,7 +25,7 @@ abstract class BaseAsset extends PropertyObject
/** @const Regex to match CSS import content */
protected const CSS_IMPORT_REGEX = '{@import(.*?);}';
/** @var string */
/** @var string|false */
protected $asset;
/** @var string */
protected $asset_type;
@ -55,8 +55,16 @@ abstract class BaseAsset extends PropertyObject
/** @var bool */
private $css_minify = false;
/**
* @return string
*/
abstract function render();
/**
* BaseAsset constructor.
* @param array $elements
* @param string|null $key
*/
public function __construct(array $elements = [], $key = null)
{
$base_config = [
@ -73,6 +81,11 @@ abstract class BaseAsset extends PropertyObject
parent::__construct($elements, $key);
}
/**
* @param string|false $asset
* @param array $options
* @return $this|false
*/
public function init($asset, $options)
{
$config = Grav::instance()['config'];
@ -130,19 +143,30 @@ abstract class BaseAsset extends PropertyObject
return $this;
}
/**
* @return string|false
*/
public function getAsset()
{
return $this->asset;
}
/**
* @return bool
*/
public function getRemote()
{
return $this->remote;
}
/**
* @param string $position
* @return $this
*/
public function setPosition($position)
{
$this->position = $position;
return $this;
}

View File

@ -13,6 +13,11 @@ use Grav\Common\Utils;
class Css extends BaseAsset
{
/**
* Css constructor.
* @param array $elements
* @param string|null $key
*/
public function __construct(array $elements = [], $key = null)
{
$base_options = [
@ -28,6 +33,9 @@ class Css extends BaseAsset
parent::__construct($merged_attributes, $key);
}
/**
* @return string
*/
public function render()
{
if (isset($this->attributes['loading']) && $this->attributes['loading'] === 'inline') {

View File

@ -13,6 +13,11 @@ use Grav\Common\Utils;
class InlineCss extends BaseAsset
{
/**
* InlineCss constructor.
* @param array $elements
* @param string|null $key
*/
public function __construct(array $elements = [], $key = null)
{
$base_options = [
@ -25,6 +30,9 @@ class InlineCss extends BaseAsset
parent::__construct($merged_attributes, $key);
}
/**
* @return string
*/
public function render()
{
return '<style' . $this->renderAttributes(). ">\n" . trim($this->asset) . "\n</style>\n";

View File

@ -13,6 +13,11 @@ use Grav\Common\Utils;
class InlineJs extends BaseAsset
{
/**
* InlineJs constructor.
* @param array $elements
* @param string|null $key
*/
public function __construct(array $elements = [], $key = null)
{
$base_options = [
@ -25,6 +30,9 @@ class InlineJs extends BaseAsset
parent::__construct($merged_attributes, $key);
}
/**
* @return string
*/
public function render()
{
return '<script' . $this->renderAttributes(). ">\n" . trim($this->asset) . "\n</script>\n";

View File

@ -13,6 +13,11 @@ use Grav\Common\Utils;
class Js extends BaseAsset
{
/**
* Js constructor.
* @param array $elements
* @param string|null $key
*/
public function __construct(array $elements = [], $key = null)
{
$base_options = [
@ -24,6 +29,9 @@ class Js extends BaseAsset
parent::__construct($merged_attributes, $key);
}
/**
* @return string
*/
public function render()
{
if (isset($this->attributes['loading']) && $this->attributes['loading'] === 'inline') {

View File

@ -64,6 +64,11 @@ class Pipeline extends PropertyObject
/** @var string */
protected $asset;
/**
* Pipeline constructor.
* @param array $elements
* @param string|null $key
*/
public function __construct(array $elements = [], ?string $key = null)
{
parent::__construct($elements, $key);
@ -88,7 +93,6 @@ class Pipeline extends PropertyObject
* @param array $assets
* @param string $group
* @param array $attributes
*
* @return bool|string URL or generated content if available, else false
*/
public function renderCss($assets, $group, $attributes = [])
@ -152,7 +156,6 @@ class Pipeline extends PropertyObject
* @param array $assets
* @param string $group
* @param array $attributes
*
* @return bool|string URL or generated content if available, else false
*/
public function renderJs($assets, $group, $attributes = [])
@ -217,7 +220,6 @@ class Pipeline extends PropertyObject
* @param string $file the css source file
* @param string $dir , $local relative path to the css file
* @param bool $local is this a local or remote asset
*
* @return mixed
*/
protected function cssRewrite($file, $dir, $local)
@ -250,8 +252,10 @@ class Pipeline extends PropertyObject
return $file;
}
/**
* @param string $type
* @return bool
*/
private function shouldMinify($type = 'css')
{
$check = $type . '_minify';

View File

@ -55,7 +55,6 @@ trait AssetUtilsTrait
*
* @param array $assets
* @param bool $css
*
* @return string
*/
protected function gatherLinks(array $assets, $css = true)
@ -120,7 +119,6 @@ trait AssetUtilsTrait
* Moves @import statements to the top of the file per the CSS specification
*
* @param string $file the file containing the combined CSS files
*
* @return string the modified file with any @imports at the top of the file
*/
protected function moveImports($file)

View File

@ -13,7 +13,6 @@ use Grav\Common\Assets;
trait LegacyAssetsTrait
{
/**
* @param array $args
* @param string $type
@ -71,6 +70,11 @@ trait LegacyAssetsTrait
return $arguments;
}
/**
* @param array $args
* @param array $defaults
* @return array
*/
protected function createArgumentsFromLegacy(array $args, array $defaults)
{
// Remove arguments with old default values.
@ -93,8 +97,7 @@ trait LegacyAssetsTrait
* @param int $priority
* @param bool $pipeline
* @param string $group name of the group
*
* @return \Grav\Common\Assets
* @return Assets
* @deprecated Please use dynamic method with ['loading' => 'async'].
*/
public function addAsyncJs($asset, $priority = 10, $pipeline = true, $group = 'head')
@ -111,8 +114,7 @@ trait LegacyAssetsTrait
* @param int $priority
* @param bool $pipeline
* @param string $group name of the group
*
* @return \Grav\Common\Assets
* @return Assets
* @deprecated Please use dynamic method with ['loading' => 'defer'].
*/
public function addDeferJs($asset, $priority = 10, $pipeline = true, $group = 'head')

View File

@ -17,7 +17,6 @@ trait TestingAssetsTrait
* Determines if an asset exists as a collection, CSS or JS reference
*
* @param string $asset
*
* @return bool
*/
public function exists($asset)
@ -39,7 +38,6 @@ trait TestingAssetsTrait
* Set the array of collections explicitly
*
* @param array $collections
*
* @return $this
*/
public function setCollection($collections)
@ -54,7 +52,7 @@ trait TestingAssetsTrait
* If a $key is provided, it will try to return only that asset
* else it will return null
*
* @param null|string $key the asset key
* @param string|null $key the asset key
* @return array
*/
public function getCss($key = null)
@ -73,7 +71,7 @@ trait TestingAssetsTrait
* If a $key is provided, it will try to return only that asset
* else it will return null
*
* @param null|string $key the asset key
* @param string|null $key the asset key
* @return array
*/
public function getJs($key = null)
@ -91,7 +89,6 @@ trait TestingAssetsTrait
* Set the whole array of CSS assets
*
* @param array $css
*
* @return $this
*/
public function setCss($css)
@ -105,7 +102,6 @@ trait TestingAssetsTrait
* Set the whole array of JS assets
*
* @param array $js
*
* @return $this
*/
public function setJs($js)
@ -119,7 +115,6 @@ trait TestingAssetsTrait
* Removes an item from the CSS array if set
*
* @param string $key The asset key
*
* @return $this
*/
public function removeCss($key)
@ -136,7 +131,6 @@ trait TestingAssetsTrait
* Removes an item from the JS array if set
*
* @param string $key The asset key
*
* @return $this
*/
public function removeJs($key)
@ -153,7 +147,6 @@ trait TestingAssetsTrait
* Sets the state of CSS Pipeline
*
* @param bool $value
*
* @return $this
*/
public function setCssPipeline($value)
@ -167,7 +160,6 @@ trait TestingAssetsTrait
* Sets the state of JS Pipeline
*
* @param bool $value
*
* @return $this
*/
public function setJsPipeline($value)
@ -246,7 +238,6 @@ trait TestingAssetsTrait
*
* @param string $directory Relative to the Grav root path, or a stream identifier
* @param string $pattern (regex)
*
* @return $this
*/
public function addDir($directory, $pattern = self::DEFAULT_REGEX)
@ -296,7 +287,6 @@ trait TestingAssetsTrait
* Add all JavaScript assets within $directory
*
* @param string $directory Relative to the Grav root path, or a stream identifier
*
* @return $this
*/
public function addDirJs($directory)
@ -308,7 +298,6 @@ trait TestingAssetsTrait
* Add all CSS assets within $directory
*
* @param string $directory Relative to the Grav root path, or a stream identifier
*
* @return $this
*/
public function addDirCss($directory)
@ -322,7 +311,6 @@ trait TestingAssetsTrait
* @param string $directory
* @param string $pattern (regex)
* @param string $ltrim Will be trimmed from the left of the file path
*
* @return array
*/
protected function rglob($directory, $pattern, $ltrim = null)

View File

@ -49,6 +49,9 @@ class Backups
}
}
/**
* @param Event $event
*/
public function onSchedulerInitialized(Event $event)
{
/** @var Scheduler $scheduler */
@ -69,6 +72,11 @@ class Backups
}
}
/**
* @param string $backup
* @param string $base_url
* @return string
*/
public function getBackupDownloadUrl($backup, $base_url)
{
$param_sep = $param_sep = Grav::instance()['config']->get('system.param_sep', ':');
@ -81,21 +89,33 @@ class Backups
return $url;
}
/**
* @return array
*/
public static function getBackupProfiles()
{
return Grav::instance()['config']->get('backups.profiles');
}
/**
* @return array
*/
public static function getPurgeConfig()
{
return Grav::instance()['config']->get('backups.purge');
}
/**
* @return array
*/
public function getBackupNames()
{
return array_column(static::getBackupProfiles(), 'name');
}
/**
* @return float|int
*/
public static function getTotalBackupsSize()
{
$backups = static::getAvailableBackups();
@ -104,6 +124,10 @@ class Backups
return $size ?? 0;
}
/**
* @param bool $force
* @return array|null
*/
public static function getAvailableBackups($force = false)
{
if ($force || null === static::$backups) {
@ -140,10 +164,9 @@ class Backups
/**
* Backup
*
* @param int $id
* @param int $id
* @param callable|null $status
*
* @return null|string
* @return string|null
*/
public static function backup($id = 0, callable $status = null)
{
@ -217,6 +240,9 @@ class Backups
return $destination;
}
/**
* @throws \Exception
*/
public static function purge()
{
$purge_config = static::getPurgeConfig();
@ -255,6 +281,10 @@ class Backups
}
}
/**
* @param string $exclude
* @return array
*/
protected static function convertExclude($exclude)
{
$lines = preg_split("/[\s,]+/", $exclude);

View File

@ -23,7 +23,7 @@ abstract class CompiledBase
public $checksum;
/** @var int Timestamp of compiled configuration */
public $timestamp;
public $timestamp = 0;
/** @var string Cache folder to be used. */
protected $cacheFolder;
@ -52,7 +52,6 @@ abstract class CompiledBase
$this->path = $path ? rtrim($path, '\\/') . '/' : '';
$this->cacheFolder = $cacheFolder;
$this->files = $files;
$this->timestamp = 0;
}
/**
@ -122,6 +121,9 @@ abstract class CompiledBase
return $this->checksum;
}
/**
* @return string
*/
protected function createFilename()
{
return "{$this->cacheFolder}/{$this->name()->name}.php";
@ -241,6 +243,9 @@ abstract class CompiledBase
$this->modified();
}
/**
* @return array
*/
protected function getState()
{
return $this->object->toArray();

View File

@ -19,6 +19,12 @@ use Grav\Common\Grav;
*/
class CompiledBlueprints extends CompiledBase
{
/**
* CompiledBlueprints constructor.
* @param string $cacheFolder
* @param array $files
* @param string $path
*/
public function __construct($cacheFolder, array $files, $path)
{
parent::__construct($cacheFolder, $files, $path);
@ -45,7 +51,7 @@ class CompiledBlueprints extends CompiledBase
/**
* Create configuration object.
*
* @param array $data
* @param array $data
*/
protected function createObject(array $data = [])
{
@ -112,6 +118,9 @@ class CompiledBlueprints extends CompiledBase
return true;
}
/**
* @return array
*/
protected function getState()
{
return $this->object->getState();

View File

@ -17,8 +17,14 @@ class CompiledConfig extends CompiledBase
protected $callable;
/** @var bool */
protected $withDefaults;
protected $withDefaults = false;
/**
* CompiledConfig constructor.
* @param string $cacheFolder
* @param array $files
* @param string $path
*/
public function __construct($cacheFolder, array $files, $path)
{
parent::__construct($cacheFolder, $files, $path);

View File

@ -13,6 +13,12 @@ use Grav\Common\File\CompiledYamlFile;
class CompiledLanguages extends CompiledBase
{
/**
* CompiledLanguages constructor.
* @param string $cacheFolder
* @param array $files
* @param string $path
*/
public function __construct($cacheFolder, array $files, $path)
{
parent::__construct($cacheFolder, $files, $path);

View File

@ -29,6 +29,9 @@ class Config extends Data
/** @var bool */
protected $modified = false;
/**
* @return string
*/
public function key()
{
if (null === $this->key) {
@ -38,6 +41,10 @@ class Config extends Data
return $this->key;
}
/**
* @param string|null $checksum
* @return string|null
*/
public function checksum($checksum = null)
{
if ($checksum !== null) {
@ -47,6 +54,10 @@ class Config extends Data
return $this->checksum;
}
/**
* @param null $modified
* @return bool
*/
public function modified($modified = null)
{
if ($modified !== null) {
@ -56,6 +67,10 @@ class Config extends Data
return $this->modified;
}
/**
* @param null $timestamp
* @return int
*/
public function timestamp($timestamp = null)
{
if ($timestamp !== null) {
@ -65,6 +80,9 @@ class Config extends Data
return $this->timestamp;
}
/**
* @return $this
*/
public function reload()
{
$grav = Grav::instance();

View File

@ -17,13 +17,16 @@ class Languages extends Data
/** @var string|null */
protected $checksum;
/** @var string|null */
protected $modified;
/** @var string|null */
protected $timestamp;
/** @var bool */
protected $modified = false;
/** @var int */
protected $timestamp = 0;
/**
* @param string|null $checksum
* @return string
*/
public function checksum($checksum = null)
{
if ($checksum !== null) {
@ -33,6 +36,10 @@ class Languages extends Data
return $this->checksum;
}
/**
* @param bool|null $modified
* @return bool
*/
public function modified($modified = null)
{
if ($modified !== null) {
@ -42,6 +49,10 @@ class Languages extends Data
return $this->modified;
}
/**
* @param int|null $timestamp
* @return int
*/
public function timestamp($timestamp = null)
{
if ($timestamp !== null) {
@ -59,17 +70,28 @@ class Languages extends Data
}
}
/**
* @param array $data
*/
public function mergeRecursive(array $data)
{
$this->items = Utils::arrayMergeRecursiveUnique($this->items, $data);
}
/**
* @param string $lang
* @return array
*/
public function flattenByLang($lang)
{
$language = $this->items[$lang];
return Utils::arrayFlattenDotNotation($language);
}
/**
* @param array $array
* @return array
*/
public function unflatten($array)
{
return Utils::arrayUnflattenDotNotation($array);

View File

@ -153,6 +153,12 @@ class Validation
return true;
}
/**
* @param mixed $value
* @param array $params
* @param array $field
* @return string
*/
protected static function filterText($value, array $params, array $field)
{
if (!\is_string($value) && !is_numeric($value)) {
@ -166,26 +172,54 @@ class Validation
return (string) $value;
}
/**
* @param mixed $value
* @param array $params
* @param array $field
* @return bool
*/
protected static function filterCheckbox($value, array $params, array $field)
{
return (bool) $value;
}
/**
* @param mixed $value
* @param array $params
* @param array $field
* @return array|array[]|false|string[]
*/
protected static function filterCommaList($value, array $params, array $field)
{
return \is_array($value) ? $value : preg_split('/\s*,\s*/', $value, -1, PREG_SPLIT_NO_EMPTY);
}
/**
* @param mixed $value
* @param array $params
* @param array $field
* @return bool
*/
public static function typeCommaList($value, array $params, array $field)
{
return \is_array($value) ? true : self::typeText($value, $params, $field);
}
/**
* @param mixed $value
* @param array $params
* @return string
*/
protected static function filterLower($value, array $params)
{
return strtolower($value);
}
/**
* @param mixed $value
* @param array $params
* @return string
*/
protected static function filterUpper($value, array $params)
{
return strtoupper($value);
@ -251,6 +285,12 @@ class Validation
return self::typeArray((array) $value, $params, $field);
}
/**
* @param mixed $value
* @param array $params
* @param array $field
* @return array|null
*/
protected static function filterCheckboxes($value, array $params, array $field)
{
return self::filterArray($value, $params, $field);
@ -315,6 +355,12 @@ class Validation
return self::typeArray((array)$value, $params, $field);
}
/**
* @param mixed $value
* @param array $params
* @param array $field
* @return array
*/
protected static function filterFile($value, array $params, array $field)
{
return (array)$value;
@ -360,11 +406,23 @@ class Validation
return !(isset($params['step']) && fmod($value - $min, $params['step']) === 0);
}
/**
* @param mixed $value
* @param array $params
* @param array $field
* @return float|int
*/
protected static function filterNumber($value, array $params, array $field)
{
return (string)(int)$value !== (string)(float)$value ? (float) $value : (int) $value;
}
/**
* @param mixed $value
* @param array $params
* @param array $field
* @return string
*/
protected static function filterDateTime($value, array $params, array $field)
{
$format = Grav::instance()['config']->get('system.pages.dateformat.default');
@ -375,7 +433,6 @@ class Validation
return $value;
}
/**
* HTML5 input: range
*
@ -389,6 +446,12 @@ class Validation
return self::typeNumber($value, $params, $field);
}
/**
* @param mixed $value
* @param array $params
* @param array $field
* @return float|int
*/
protected static function filterRange($value, array $params, array $field)
{
return self::filterNumber($value, $params, $field);
@ -595,6 +658,12 @@ class Validation
return !($options && array_diff($value, $options));
}
/**
* @param mixed $value
* @param array $params
* @param array $field
* @return array|null
*/
protected static function filterArray($value, $params, $field)
{
$values = (array) $value;
@ -643,6 +712,12 @@ class Validation
return $values;
}
/**
* @param mixed $value
* @param array $params
* @param array $field
* @return bool
*/
public static function typeList($value, array $params, array $field)
{
if (!\is_array($value)) {
@ -662,11 +737,22 @@ class Validation
return true;
}
/**
* @param mixed $value
* @param array $params
* @param array $field
* @return array
*/
protected static function filterList($value, array $params, array $field)
{
return (array) $value;
}
/**
* @param mixed $value
* @param array $params
* @return array
*/
public static function filterYaml($value, $params)
{
if (!\is_string($value)) {
@ -689,6 +775,12 @@ class Validation
return true;
}
/**
* @param mixed $value
* @param array $params
* @param array $field
* @return mixed
*/
public static function filterIgnore($value, array $params, array $field)
{
return $value;
@ -707,6 +799,12 @@ class Validation
return true;
}
/**
* @param mixed $value
* @param array $params
* @param array $field
* @return null
*/
public static function filterUnset($value, array $params, array $field)
{
return null;
@ -714,6 +812,11 @@ class Validation
// HTML5 attributes (min, max and range are handled inside the types)
/**
* @param mixed $value
* @param bool $params
* @return bool
*/
public static function validateRequired($value, $params)
{
if (is_scalar($value)) {
@ -723,74 +826,143 @@ class Validation
return (bool) $params !== true || !empty($value);
}
/**
* @param mixed $value
* @param string $params
* @return bool
*/
public static function validatePattern($value, $params)
{
return (bool) preg_match("`^{$params}$`u", $value);
}
// Internal types
/**
* @param mixed $value
* @param mixed $params
* @return bool
*/
public static function validateAlpha($value, $params)
{
return ctype_alpha($value);
}
/**
* @param mixed $value
* @param mixed $params
* @return bool
*/
public static function validateAlnum($value, $params)
{
return ctype_alnum($value);
}
/**
* @param mixed $value
* @param mixed $params
* @return bool
*/
public static function typeBool($value, $params)
{
return \is_bool($value) || $value == 1 || $value == 0;
}
/**
* @param mixed $value
* @param mixed $params
* @return bool
*/
public static function validateBool($value, $params)
{
return \is_bool($value) || $value == 1 || $value == 0;
}
/**
* @param mixed $value
* @param mixed $params
* @return bool
*/
protected static function filterBool($value, $params)
{
return (bool) $value;
}
/**
* @param mixed $value
* @param mixed $params
* @return bool
*/
public static function validateDigit($value, $params)
{
return ctype_digit($value);
}
/**
* @param mixed $value
* @param mixed $params
* @return bool
*/
public static function validateFloat($value, $params)
{
return \is_float(filter_var($value, FILTER_VALIDATE_FLOAT));
}
/**
* @param mixed $value
* @param mixed $params
* @return float
*/
protected static function filterFloat($value, $params)
{
return (float) $value;
}
/**
* @param mixed $value
* @param mixed $params
* @return bool
*/
public static function validateHex($value, $params)
{
return ctype_xdigit($value);
}
/**
* @param mixed $value
* @param mixed $params
* @return bool
*/
public static function validateInt($value, $params)
{
return is_numeric($value) && (int)$value == $value;
}
/**
* @param mixed $value
* @param mixed $params
* @return int
*/
protected static function filterInt($value, $params)
{
return (int)$value;
}
/**
* @param mixed $value
* @param mixed $params
* @return bool
*/
public static function validateArray($value, $params)
{
return \is_array($value) || ($value instanceof \ArrayAccess && $value instanceof \Traversable && $value instanceof \Countable);
}
/**
* @param mixed $value
* @param mixed $params
* @return array
*/
public static function filterItem_List($value, $params)
{
return array_values(array_filter($value, function ($v) {
@ -798,6 +970,11 @@ class Validation
}));
}
/**
* @param mixed $value
* @param mixed $params
* @return bool
*/
public static function validateJson($value, $params)
{
return (bool) (@json_decode($value));

View File

@ -16,6 +16,10 @@ class ValidationException extends \RuntimeException
/** @var array */
protected $messages = [];
/**
* @param array $messages
* @return $this
*/
public function setMessages(array $messages = [])
{
$this->messages = $messages;
@ -33,6 +37,9 @@ class ValidationException extends \RuntimeException
return $this;
}
/**
* @return array
*/
public function getMessages()
{
return $this->messages;

View File

@ -14,7 +14,7 @@ use Whoops\Handler\Handler;
class BareHandler extends Handler
{
/**
* @return int|null
* @return int
*/
public function handle()
{

View File

@ -27,7 +27,7 @@ class SimplePageHandler extends Handler
}
/**
* @return int|null
* @return int
*/
public function handle()
{
@ -61,7 +61,6 @@ class SimplePageHandler extends Handler
/**
* @param string $resource
*
* @return string
* @throws \RuntimeException
*/
@ -91,6 +90,9 @@ class SimplePageHandler extends Handler
);
}
/**
* @param string $path
*/
public function addResourcePath($path)
{
if (!is_dir($path)) {
@ -102,6 +104,9 @@ class SimplePageHandler extends Handler
array_unshift($this->searchPaths, $path);
}
/**
* @return array
*/
public function getResourcePaths()
{
return $this->searchPaths;

View File

@ -16,7 +16,6 @@ class SystemFacade extends \Whoops\Util\SystemFacade
/**
* @param callable $function
*
* @return void
*/
public function registerShutdownFunction(callable $function)

View File

@ -84,6 +84,8 @@ trait CompiledFile
/**
* Serialize file.
*
* @return array
*/
public function __sleep()
{

View File

@ -22,6 +22,10 @@ abstract class Archiver
/** @var string */
protected $archive_file;
/**
* @param string $compression
* @return ZipArchiver
*/
public static function create($compression)
{
if ($compression === 'zip') {
@ -31,12 +35,20 @@ abstract class Archiver
return new ZipArchiver();
}
/**
* @param string $archive_file
* @return $this
*/
public function setArchive($archive_file)
{
$this->archive_file = $archive_file;
return $this;
}
/**
* @param array $options
* @return $this
*/
public function setOptions($options)
{
// Set infinite PHP execution time if possible.
@ -48,12 +60,31 @@ abstract class Archiver
return $this;
}
/**
* @param string $folder
* @param callable|null $status
* @return $this
*/
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);
/**
* @param array $folders
* @param callable|null $status
* @return $this
*/
abstract public function addEmptyFolders($folders, callable $status = null);
/**
* @param string $rootPath
* @return \RecursiveIteratorIterator
*/
protected function getArchiveFiles($rootPath)
{
$exclude_paths = $this->options['exclude_paths'];

View File

@ -51,7 +51,6 @@ abstract class Folder
*
* @param string $path
* @param string $extensions which files to search for specifically
*
* @return int
*/
public static function lastModifiedFile($path, $extensions = 'md|yaml')
@ -115,9 +114,8 @@ abstract class Folder
/**
* Get relative path between target and base path. If path isn't relative, return full path.
*
* @param string $path
* @param mixed|string $base
*
* @param string $path
* @param string $base
* @return string
*/
public static function getRelativePath($path, $base = GRAV_ROOT)

View File

@ -60,6 +60,9 @@ class RecursiveDirectoryFilterIterator extends \RecursiveFilterIterator
return false;
}
/**
* @return RecursiveDirectoryFilterIterator|\RecursiveFilterIterator
*/
public function getChildren()
{
/** @var RecursiveDirectoryFilterIterator $iterator */

View File

@ -11,7 +11,11 @@ namespace Grav\Common\Filesystem;
class ZipArchiver extends Archiver
{
/**
* @param string $destination
* @param callable|null $status
* @return $this
*/
public function extract($destination, callable $status = null)
{
$zip = new \ZipArchive();
@ -31,6 +35,11 @@ class ZipArchiver extends Archiver
throw new \RuntimeException('ZipArchiver: Failed to open ' . $this->archive_file);
}
/**
* @param string $source
* @param callable|null $status
* @return $this
*/
public function compress($source, callable $status = null)
{
if (!extension_loaded('zip')) {
@ -81,6 +90,11 @@ class ZipArchiver extends Archiver
return $this;
}
/**
* @param array $folders
* @param callable|null $status
* @return $this
*/
public function addEmptyFolders($folders, callable $status = null)
{
if (!extension_loaded('zip')) {

View File

@ -13,11 +13,17 @@ use Grav\Common\Iterator;
abstract class AbstractCollection extends Iterator
{
/**
* @return string
*/
public function toJson()
{
return json_encode($this->toArray());
}
/**
* @return array
*/
public function toArray()
{
$items = [];

View File

@ -16,6 +16,9 @@ abstract class AbstractPackageCollection extends Iterator
/** @var string */
protected $type;
/**
* @return string
*/
public function toJson()
{
$items = [];
@ -27,6 +30,9 @@ abstract class AbstractPackageCollection extends Iterator
return json_encode($items);
}
/**
* @return array
*/
public function toArray()
{
$items = [];

View File

@ -16,6 +16,11 @@ class CachedCollection extends Iterator
/** @var array */
protected static $cache = [];
/**
* CachedCollection constructor.
*
* @param array $items
*/
public function __construct($items)
{
parent::__construct();

View File

@ -19,6 +19,11 @@ class Package
/** @var Data */
protected $data;
/**
* Package constructor.
* @param Data $package
* @param string|null $type
*/
public function __construct(Data $package, $type = null)
{
$this->data = $package;
@ -36,26 +41,44 @@ class Package
return $this->data;
}
/**
* @param string $key
* @return mixed
*/
public function __get($key)
{
return $this->data->get($key);
}
/**
* @param string $key
* @param mixed $value
*/
public function __set($key, $value)
{
$this->data->set($key, $value);
}
/**
* @param string $key
* @return bool
*/
public function __isset($key)
{
return isset($this->data->{$key});
}
/**
* @return string
*/
public function __toString()
{
return $this->toJson();
}
/**
* @return string
*/
public function toJson()
{
return $this->data->toJson();

View File

@ -39,8 +39,9 @@ class GPM extends Iterator
/**
* Creates a new GPM instance with Local and Remote packages available
*
* @param bool $refresh Applies to Remote Packages only and forces a refetch of data
* @param callable $callback Either a function or callback in array notation
* @param callable|null $callback Either a function or callback in array notation
*/
public function __construct($refresh = false, $callback = null)
{
@ -87,6 +88,7 @@ class GPM extends Iterator
/**
* Returns the amount of locally installed packages
*
* @return int Amount of installed packages
*/
public function countInstalled()
@ -117,6 +119,7 @@ class GPM extends Iterator
/**
* Return the instance of a specific Plugin
*
* @param string $slug The slug of the Plugin
* @return Local\Package|null The instance of the Plugin
*/
@ -136,6 +139,7 @@ class GPM extends Iterator
/**
* Checks if a Plugin is installed
*
* @param string $slug The slug of the Plugin
* @return bool True if the Plugin has been installed. False otherwise
*/
@ -144,6 +148,10 @@ class GPM extends Iterator
return isset($this->installed['plugins'][$slug]);
}
/**
* @param string $slug
* @return bool
*/
public function isPluginInstalledAsSymlink($slug)
{
return $this->installed['plugins'][$slug]->symlink;
@ -151,6 +159,7 @@ class GPM extends Iterator
/**
* Return the instance of a specific Theme
*
* @param string $slug The slug of the Theme
* @return Local\Package|null The instance of the Theme
*/
@ -161,6 +170,7 @@ class GPM extends Iterator
/**
* Returns the Locally installed themes
*
* @return Iterator The installed themes
*/
public function getInstalledThemes()
@ -170,6 +180,7 @@ class GPM extends Iterator
/**
* Checks if a Theme is installed
*
* @param string $slug The slug of the Theme
* @return bool True if the Theme has been installed. False otherwise
*/
@ -180,6 +191,7 @@ class GPM extends Iterator
/**
* Returns the amount of updates available
*
* @return int Amount of available updates
*/
public function countUpdates()
@ -195,6 +207,7 @@ class GPM extends Iterator
/**
* Returns an array of Plugins and Themes that can be updated.
* Plugins and Themes are extended with the `available` property that relies to the remote version
*
* @param array $list_type_update specifies what type of package to update
* @return array Array of updatable Plugins and Themes.
* Format: ['total' => int, 'plugins' => array, 'themes' => array]
@ -218,6 +231,7 @@ class GPM extends Iterator
/**
* Returns an array of Plugins that can be updated.
* The Plugins are extended with the `available` property that relies to the remote version
*
* @return array Array of updatable Plugins
*/
public function getUpdatablePlugins()
@ -255,7 +269,6 @@ class GPM extends Iterator
* Get the latest release of a package from the GPM
*
* @param string $package_name
*
* @return string|null
*/
public function getLatestVersionOfPackage($package_name)
@ -276,6 +289,7 @@ class GPM extends Iterator
/**
* Check if a Plugin or Theme is updatable
*
* @param string $slug The slug of the package
* @return bool True if updatable. False otherwise or if not found
*/
@ -286,6 +300,7 @@ class GPM extends Iterator
/**
* Checks if a Plugin is updatable
*
* @param string $plugin The slug of the Plugin
* @return bool True if the Plugin is updatable. False otherwise
*/
@ -297,6 +312,7 @@ class GPM extends Iterator
/**
* Returns an array of Themes that can be updated.
* The Themes are extended with the `available` property that relies to the remote version
*
* @return array Array of updatable Themes
*/
public function getUpdatableThemes()
@ -332,6 +348,7 @@ class GPM extends Iterator
/**
* Checks if a Theme is Updatable
*
* @param string $theme The slug of the Theme
* @return bool True if the Theme is updatable. False otherwise
*/
@ -344,7 +361,6 @@ class GPM extends Iterator
* Get the release type of a package (stable / testing)
*
* @param string $package_name
*
* @return string|null
*/
public function getReleaseType($package_name)
@ -367,7 +383,6 @@ class GPM extends Iterator
* Returns true if the package latest release is stable
*
* @param string $package_name
*
* @return bool
*/
public function isStableRelease($package_name)
@ -379,7 +394,6 @@ class GPM extends Iterator
* Returns true if the package latest release is testing
*
* @param string $package_name
*
* @return bool
*/
public function isTestingRelease($package_name)
@ -392,6 +406,7 @@ class GPM extends Iterator
/**
* Returns a Plugin from the repository
*
* @param string $slug The slug of the Plugin
* @return mixed Package if found, NULL if not
*/
@ -402,6 +417,7 @@ class GPM extends Iterator
/**
* Returns the list of Plugins available in the repository
*
* @return Iterator The Plugins remotely available
*/
public function getRepositoryPlugins()
@ -411,6 +427,7 @@ class GPM extends Iterator
/**
* Returns a Theme from the repository
*
* @param string $slug The slug of the Theme
* @return mixed Package if found, NULL if not
*/
@ -421,6 +438,7 @@ class GPM extends Iterator
/**
* Returns the list of Themes available in the repository
*
* @return Iterator The Themes remotely available
*/
public function getRepositoryThemes()
@ -430,6 +448,7 @@ class GPM extends Iterator
/**
* Returns the list of Plugins and Themes available in the repository
*
* @return Remote\Packages Available Plugins and Themes
* Format: ['plugins' => array, 'themes' => array]
*/
@ -440,6 +459,7 @@ class GPM extends Iterator
/**
* Searches for a Package in the repository
*
* @param string $search Can be either the slug or the name
* @param bool $ignore_exception True if should not fire an exception (for use in Twig)
* @return Remote\Package|bool Package if found, FALSE if not
@ -645,6 +665,7 @@ class GPM extends Iterator
/**
* Searches for a list of Packages in the repository
*
* @param array $searches An array of either slugs or names
* @return array Array of found Packages
* Format: ['total' => int, 'not_found' => array, <found-slugs>]
@ -701,7 +722,6 @@ class GPM extends Iterator
* Return the list of packages that have the passed one as dependency
*
* @param string $slug The slug name of the package
*
* @return array
*/
public function getPackagesThatDependOnPackage($slug)
@ -757,7 +777,6 @@ class GPM extends Iterator
* @param string $slug
* @param string $version_with_operator
* @param array $ignore_packages_list
*
* @return bool
* @throws \RuntimeException
*/
@ -804,7 +823,6 @@ class GPM extends Iterator
* Check the passed packages list can be updated
*
* @param array $packages_names_list
*
* @throws \Exception
*/
public function checkPackagesCanBeInstalled($packages_names_list)
@ -827,7 +845,6 @@ class GPM extends Iterator
* `update` means the package is already installed and must be updated as a dependency needs a higher version.
*
* @param array $packages
*
* @return mixed
* @throws \Exception
*/
@ -956,6 +973,9 @@ class GPM extends Iterator
return $dependencies;
}
/**
* @param array $dependencies_slugs
*/
public function checkNoOtherPackageNeedsTheseDependenciesInALowerVersion($dependencies_slugs)
{
foreach ($dependencies_slugs as $dependency_slug) {
@ -967,6 +987,11 @@ class GPM extends Iterator
}
}
/**
* @param string $firstVersion
* @param string $secondVersion
* @return bool
*/
private function firstVersionIsLower($firstVersion, $secondVersion)
{
return version_compare($firstVersion, $secondVersion) === -1;
@ -976,9 +1001,7 @@ class GPM extends Iterator
* Calculates and merges the dependencies of a package
*
* @param string $packageName The package information
*
* @param array $dependencies The dependencies array
*
* @return array
* @throws \Exception
*/
@ -1072,7 +1095,6 @@ class GPM extends Iterator
* Calculates and merges the dependencies of the passed packages
*
* @param array $packages
*
* @return mixed
* @throws \Exception
*/
@ -1097,7 +1119,6 @@ class GPM extends Iterator
* $versionInformation == '' => returns null
*
* @param string $version
*
* @return null|string
*/
public function calculateVersionNumberFromDependencyVersion($version)
@ -1124,7 +1145,6 @@ class GPM extends Iterator
* Example: returns true for $version: '~2.0'
*
* @param string $version
*
* @return bool
*/
public function versionFormatIsNextSignificantRelease($version): bool
@ -1138,7 +1158,6 @@ class GPM extends Iterator
* Example: returns true for $version: '>=2.0'
*
* @param string $version
*
* @return bool
*/
public function versionFormatIsEqualOrHigher($version): bool
@ -1156,7 +1175,6 @@ class GPM extends Iterator
*
* @param string $version1 the version string (e.g. '2.0.0' or '1.0')
* @param string $version2 the version string (e.g. '2.0.0' or '1.0')
*
* @return bool
*/
public function checkNextSignificantReleasesAreCompatible($version1, $version2): bool

View File

@ -193,7 +193,6 @@ class Installer
*
* @param string $installer_file_folder The folder path that contains install.php
* @param bool $is_install True if install, false if removal
*
* @return null|string
*/
private static function loadInstaller($installer_file_folder, $is_install)
@ -244,7 +243,6 @@ class Installer
/**
* @param string $source_path
* @param string $install_path
*
* @return bool
*/
public static function moveInstall($source_path, $install_path)
@ -261,7 +259,6 @@ class Installer
/**
* @param string $source_path
* @param string $install_path
*
* @return bool
*/
public static function copyInstall($source_path, $install_path)
@ -280,7 +277,6 @@ class Installer
* @param string $install_path
* @param array $ignores
* @param bool $keep_source
*
* @return bool
*/
public static function sophisticatedInstall($source_path, $install_path, $ignores = [], $keep_source = false)
@ -319,7 +315,6 @@ class Installer
*
* @param string $path The slug of the package(s)
* @param array $options Options to use for uninstalling
*
* @return bool True if everything went fine, False otherwise.
*/
public static function uninstall($path, $options = [])
@ -361,7 +356,6 @@ class Installer
*
* @param string $destination The directory to run validations at
* @param array $exclude An array of constants to exclude from the validation
*
* @return bool True if validation passed. False otherwise
*/
public static function isValidDestination($destination, $exclude = [])
@ -390,7 +384,6 @@ class Installer
* Validates if the given path is a Grav Instance
*
* @param string $target The local path to the Grav Instance
*
* @return bool True if is a Grav Instance. False otherwise
*/
public static function isGravInstance($target)
@ -411,6 +404,7 @@ class Installer
/**
* Returns the last message added by the installer
*
* @return string The message
*/
public static function getMessage()
@ -420,6 +414,7 @@ class Installer
/**
* Returns the last error occurred in a string message format
*
* @return string The message of the last error
*/
public static function lastErrorMsg()
@ -510,6 +505,7 @@ class Installer
/**
* Returns the last error code of the occurred error
*
* @return int|string The code of the last error
*/
public static function lastErrorCode()
@ -522,7 +518,6 @@ class Installer
*
* @param int|string $error the Error code
*/
public static function setError($error)
{
self::$error = $error;

View File

@ -30,7 +30,6 @@ class Licenses
*
* @param string $slug
* @param string $license
*
* @return bool
*/
public static function set($slug, $license)
@ -64,7 +63,6 @@ class Licenses
* Returns the license for a Premium package
*
* @param string $slug
*
* @return array|string
*/
public static function get($slug = null)
@ -86,8 +84,7 @@ class Licenses
/**
* Validates the License format
*
* @param string $license
*
* @param string|null $license
* @return bool
*/
public static function validate($license = null)

View File

@ -13,6 +13,11 @@ use Grav\Common\GPM\Common\AbstractPackageCollection as BaseCollection;
abstract class AbstractPackageCollection extends BaseCollection
{
/**
* AbstractPackageCollection constructor.
*
* @param array $items
*/
public function __construct($items)
{
parent::__construct();

View File

@ -17,6 +17,11 @@ class Package extends BasePackage
/** @var array */
protected $settings;
/**
* Package constructor.
* @param Data $package
* @param string|null $package_type
*/
public function __construct(Data $package, $package_type = null)
{
$data = new Data($package->blueprints()->toArray());

View File

@ -31,9 +31,9 @@ class AbstractPackageCollection extends BaseCollection
/**
* AbstractPackageCollection constructor.
*
* @param null $repository
* @param string|null $repository
* @param bool $refresh
* @param null $callback
* @param callable|null $callback
*/
public function __construct($repository = null, $refresh = false, $callback = null)
{
@ -60,6 +60,11 @@ class AbstractPackageCollection extends BaseCollection
}
}
/**
* @param bool $refresh
* @param callable|null $callback
* @return string
*/
public function fetch($refresh = false, $callback = null)
{
if (!$this->raw || $refresh) {

View File

@ -67,7 +67,6 @@ class GravCore extends AbstractPackageCollection
* Returns the changelog list for each version of Grav
*
* @param string $diff the version number to start the diff from
*
* @return array changelog list for each version
*/
public function getChangelog($diff = null)

View File

@ -14,12 +14,20 @@ use Grav\Common\GPM\Common\Package as BasePackage;
class Package extends BasePackage implements \JsonSerializable
{
/**
* Package constructor.
* @param array $package
* @param string|null $package_type
*/
public function __construct($package, $package_type = null)
{
$data = new Data($package);
parent::__construct($data, $package_type);
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->data;

View File

@ -13,6 +13,11 @@ use Grav\Common\GPM\Common\CachedCollection;
class Packages extends CachedCollection
{
/**
* Packages constructor.
* @param bool $refresh
* @param callable|null $callback
*/
public function __construct($refresh = false, $callback = null)
{
$items = [

View File

@ -19,7 +19,7 @@ class Plugins extends AbstractPackageCollection
/**
* Local Plugins Constructor
* @param bool $refresh
* @param callable $callback Either a function or callback in array notation
* @param callable|null $callback Either a function or callback in array notation
*/
public function __construct($refresh = false, $callback = null)
{

View File

@ -19,7 +19,7 @@ class Themes extends AbstractPackageCollection
/**
* Local Themes Constructor
* @param bool $refresh
* @param callable $callback Either a function or callback in array notation
* @param callable|null $callback Either a function or callback in array notation
*/
public function __construct($refresh = false, $callback = null)
{

View File

@ -61,7 +61,6 @@ class Response
* Sets the preferred method to use for making HTTP calls.
*
* @param string $method Default is `auto`
*
* @return Response
*/
public static function setMethod($method = 'auto')
@ -80,8 +79,7 @@ class Response
*
* @param string $uri URL to call
* @param array $options An array of parameters for both `curl` and `fopen`
* @param callable $callback Either a function or callback in array notation
*
* @param callable|null $callback Either a function or callback in array notation
* @return string The response of the request
*/
public static function get($uri = '', $options = [], $callback = null)
@ -350,7 +348,6 @@ class Response
* @param resource $ch
* @param array $options
* @param bool $callback
*
* @return bool|mixed
*/
private static function curlExecFollow($ch, $options, $callback)

View File

@ -80,7 +80,6 @@ class Upgrader
* Returns the changelog list for each version of Grav
*
* @param string $diff the version number to start the diff from
*
* @return array return the changelog list for each version
*/
public function getChangelog($diff = null)

View File

@ -30,6 +30,7 @@ class Truncator
{
/**
* Safely truncates HTML by a given number of words.
*
* @param string $html Input HTML.
* @param int $limit Limit to how many words we preserve.
* @param string $ellipsis String to use as ellipsis (if any).
@ -85,6 +86,7 @@ class Truncator
/**
* Safely truncates HTML by a given number of letters.
*
* @param string $html Input HTML.
* @param int $limit Limit to how many letters we preserve.
* @param string $ellipsis String to use as ellipsis (if any).
@ -130,6 +132,7 @@ class Truncator
/**
* Builds a DOMDocument object from a string containing HTML.
*
* @param string $html HTML to load
* @return DOMDocument Returns a DOMDocument object.
*/
@ -155,6 +158,7 @@ class Truncator
/**
* Removes all nodes after the current node.
*
* @param DOMNode|DOMElement $domNode
* @param DOMNode|DOMElement $topNode
* @return void
@ -204,6 +208,7 @@ class Truncator
/**
* Inserts an ellipsis
*
* @param DOMNode|DOMElement $domNode Element to insert after.
* @param string $ellipsis Text used to suffix our document.
* @return void
@ -230,7 +235,12 @@ class Truncator
}
/**
*
* @param string $text
* @param int $length
* @param string $ending
* @param bool $exact
* @param bool $considerHtml
* @return string
*/
public function truncate(
$text,

View File

@ -16,6 +16,10 @@ use Symfony\Component\Yaml\Yaml;
class YamlLinter
{
/**
* @param string|null $folder
* @return array
*/
public static function lint(string $folder = null)
{
if (null !== $folder) {
@ -27,16 +31,25 @@ class YamlLinter
return array_merge(static::lintConfig(), static::lintPages(), static::lintBlueprints());
}
/**
* @return array
*/
public static function lintPages()
{
return static::recurseFolder('page://');
}
/**
* @return array
*/
public static function lintConfig()
{
return static::recurseFolder('config://');
}
/**
* @return array
*/
public static function lintBlueprints()
{
/** @var UniformResourceLocator $locator */
@ -49,6 +62,11 @@ class YamlLinter
return static::recurseFolder('blueprints://');
}
/**
* @param string $path
* @param string $extensions
* @return array
*/
public static function recurseFolder($path, $extensions = '(md|yaml)')
{
$lint_errors = [];
@ -76,6 +94,10 @@ class YamlLinter
return $lint_errors;
}
/**
* @param string $path
* @return string
*/
protected static function extractYaml($path)
{
$extension = pathinfo($path, PATHINFO_EXTENSION);

View File

@ -43,7 +43,7 @@ class Language
/**
* Constructor
*
* @param \Grav\Common\Grav $grav
* @param Grav $grav
*/
public function __construct(Grav $grav)
{
@ -152,7 +152,6 @@ class Language
* Sets default language manually
*
* @param string $lang
*
* @return string|bool
*/
public function setDefault($lang)
@ -181,7 +180,6 @@ class Language
* Sets active language manually
*
* @param string $lang
*
* @return string|bool
*/
public function setActive($lang)
@ -204,7 +202,6 @@ class Language
* Sets the active language based on the first part of the URL
*
* @param string $uri
*
* @return string
*/
public function setActiveFromUri($uri)
@ -297,7 +294,7 @@ class Language
* Get full list of used language page extensions: [''=>'.md', 'en'=>'.en.md', ...]
*
* @param string|null $fileExtension
* @return mixed
* @return array
*/
public function getPageExtensions($fileExtension = null)
{
@ -441,7 +438,6 @@ class Language
* Ensures the language is valid and supported
*
* @param string $lang
*
* @return bool
*/
public function validate($lang)
@ -457,7 +453,6 @@ class Language
* @param array|null $languages
* @param bool $array_support
* @param bool $html_out
*
* @return string
*/
public function translate($args, array $languages = null, $array_support = false, $html_out = false)
@ -503,7 +498,6 @@ class Language
* @param string $index
* @param array|null $languages
* @param bool $html_out
*
* @return string
*/
public function translateArray($key, $index, $languages = null, $html_out = false)
@ -536,7 +530,6 @@ class Language
* @param string $lang lang code
* @param string $key key to lookup with
* @param bool $array_support
*
* @return string
*/
public function getTranslation($lang, $key, $array_support = false)
@ -598,6 +591,9 @@ class Language
return LanguageCodes::get($code, $type);
}
/**
* @return array
*/
public function __debugInfo()
{
$vars = get_object_vars($this);

View File

@ -151,11 +151,19 @@ class LanguageCodes
'zu' => [ 'name' => 'Zulu', 'nativeName' => 'isiZulu' ]
];
/**
* @param string $code
* @return string|false
*/
public static function getName($code)
{
return static::get($code, 'name');
}
/**
* @param string $code
* @return string|false
*/
public static function getNativeName($code)
{
if (isset(static::$codes[$code])) {
@ -169,6 +177,10 @@ class LanguageCodes
return $code;
}
/**
* @param string $code
* @return string
*/
public static function getOrientation($code)
{
if (isset(static::$codes[$code])) {
@ -179,11 +191,19 @@ class LanguageCodes
return 'ltr';
}
/**
* @param string $code
* @return bool
*/
public static function isRtl($code)
{
return static::getOrientation($code) === 'rtl';
}
/**
* @param array $keys
* @return array
*/
public static function getNames(array $keys)
{
$results = [];
@ -195,6 +215,11 @@ class LanguageCodes
return $results;
}
/**
* @param string $code
* @param string $type
* @return string|false
*/
public static function get($code, $type)
{
if (isset(static::$codes[$code][$type])) {
@ -204,6 +229,10 @@ class LanguageCodes
return false;
}
/**
* @param bool $native
* @return array
*/
public static function getList($native = true)
{
$list = [];

View File

@ -131,7 +131,6 @@ trait ParsedownGravTrait
* Overrides the default behavior to allow for plugin-provided blocks to be continuable
*
* @param string $Type
*
* @return bool
*/
protected function isBlockContinuable($Type)
@ -146,7 +145,6 @@ trait ParsedownGravTrait
* Overrides the default behavior to allow for plugin-provided blocks to be completable
*
* @param string $Type
*
* @return bool
*/
protected function isBlockCompletable($Type)
@ -162,7 +160,6 @@ trait ParsedownGravTrait
* Make the element function publicly accessible, Medium uses this to render from Twig
*
* @param array $Element
*
* @return string markup
*/
public function elementToHtml(array $Element)
@ -174,7 +171,6 @@ trait ParsedownGravTrait
* Setter for special chars
*
* @param array $special_chars
*
* @return $this
*/
public function setSpecialChars($special_chars)
@ -199,6 +195,10 @@ trait ParsedownGravTrait
return null;
}
/**
* @param array $excerpt
* @return array|null
*/
protected function inlineSpecialCharacter($excerpt)
{
if ($excerpt['text'][0] === '&' && !preg_match('/^&#?\w+;/', $excerpt['text'])) {
@ -218,6 +218,10 @@ trait ParsedownGravTrait
return null;
}
/**
* @param array $excerpt
* @return array
*/
protected function inlineImage($excerpt)
{
if (preg_match($this->twig_link_regex, $excerpt['text'], $matches)) {
@ -240,6 +244,10 @@ trait ParsedownGravTrait
return $excerpt;
}
/**
* @param array $excerpt
* @return array
*/
protected function inlineLink($excerpt)
{
$type = $excerpt['type'] ?? 'link';
@ -266,13 +274,17 @@ trait ParsedownGravTrait
/**
* For extending this class via plugins
*
* @param string $method
* @param array $args
* @return mixed|null
*/
public function __call($method, $args)
{
if (isset($this->{$method}) === true) {
$func = $this->{$method};
return \call_user_func_array($func, $args);
return \call_user_func_array($func, $args);
}
return null;

View File

@ -18,7 +18,7 @@ use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
trait MediaTrait
{
/** @var MediaCollectionInterface */
/** @var MediaCollectionInterface|null */
protected $media;
/** @var bool */
protected $_loadMedia = true;

View File

@ -26,6 +26,11 @@ class Excerpts
/** @var array */
protected $config;
/**
* Excerpts constructor.
* @param PageInterface|null $page
* @param array|null $config
*/
public function __construct(PageInterface $page = null, array $config = null)
{
$this->page = $page ?? Grav::instance()['page'] ?? null;
@ -43,16 +48,25 @@ class Excerpts
$this->config = $config;
}
/**
* @return PageInterface|null
*/
public function getPage(): ?PageInterface
{
return $this->page;
}
/**
* @return array
*/
public function getConfig(): array
{
return $this->config;
}
/**
* @param object $markdown
*/
public function fireInitializedEvent($markdown): void
{
$grav = Grav::instance();

View File

@ -52,6 +52,9 @@ abstract class AbstractMedia implements ExportInterface, MediaCollectionInterfac
return $this->path;
}
/**
* @param string|null $path
*/
public function setPath(?string $path)
{
$this->path = $path;

View File

@ -57,7 +57,7 @@ class AudioMedium extends Medium
public function preload($preload)
{
$validPreloadAttrs = ['auto', 'metadata', 'none'];
if (\in_array($preload, $validPreloadAttrs, true)) {
$this->attributes['preload'] = $preload;
}
@ -131,7 +131,6 @@ class AudioMedium extends Medium
return $this;
}
/**
* Reset medium.
*

View File

@ -25,8 +25,7 @@ class GlobalMedia extends AbstractMedia
}
/**
* @param mixed $offset
*
* @param string $offset
* @return bool
*/
public function offsetExists($offset)
@ -35,8 +34,7 @@ class GlobalMedia extends AbstractMedia
}
/**
* @param mixed $offset
*
* @param string $offset
* @return mixed
*/
public function offsetGet($offset)