diff --git a/system/src/Grav/Common/Assets/Pipeline.php b/system/src/Grav/Common/Assets/Pipeline.php index b009585c8..0470aeecc 100644 --- a/system/src/Grav/Common/Assets/Pipeline.php +++ b/system/src/Grav/Common/Assets/Pipeline.php @@ -60,7 +60,7 @@ class Pipeline extends PropertyObject * The closure will receive as the only parameter a string with the path/URL of the asset and * it should return the content of the asset file as a string. * - * @var \Closure + * @var \Closure|null */ protected $fetch_command; diff --git a/system/src/Grav/Common/Data/Blueprint.php b/system/src/Grav/Common/Data/Blueprint.php index 481a1b3fa..f819010b8 100644 --- a/system/src/Grav/Common/Data/Blueprint.php +++ b/system/src/Grav/Common/Data/Blueprint.php @@ -20,12 +20,13 @@ class Blueprint extends BlueprintForm /** @var string */ protected $context = 'blueprints://'; + /** @var string|null */ protected $scope; - /** @var BlueprintSchema */ + /** @var BlueprintSchema|null */ protected $blueprintSchema; - /** @var object */ + /** @var object|null */ protected $object; /** @var array|null */ @@ -40,11 +41,17 @@ class Blueprint extends BlueprintForm } } + /** + * @param string $scope + */ public function setScope($scope) { $this->scope = $scope; } + /** + * @param object $object + */ public function setObject($object) { $this->object = $object; @@ -232,6 +239,10 @@ class Blueprint extends BlueprintForm return $this->blueprintSchema; } + /** + * @param string $name + * @param callable $callable + */ public function addDynamicHandler(string $name, callable $callable): void { $this->handlers[$name] = $callable; @@ -259,7 +270,7 @@ class Blueprint extends BlueprintForm /** * @param string $filename - * @return string + * @return array */ protected function loadFile($filename) { @@ -420,6 +431,11 @@ class Blueprint extends BlueprintForm } } + /** + * @param array $field + * @param string $property + * @param mixed $value + */ protected function addPropertyRecursive(array &$field, $property, $value) { if (\is_array($value) && isset($field[$property]) && \is_array($field[$property])) { diff --git a/system/src/Grav/Common/Data/Data.php b/system/src/Grav/Common/Data/Data.php index 3823fda04..e8f6b1929 100644 --- a/system/src/Grav/Common/Data/Data.php +++ b/system/src/Grav/Common/Data/Data.php @@ -13,7 +13,6 @@ use RocketTheme\Toolbox\ArrayTraits\Countable; use RocketTheme\Toolbox\ArrayTraits\Export; use RocketTheme\Toolbox\ArrayTraits\ExportInterface; use RocketTheme\Toolbox\ArrayTraits\NestedArrayAccessWithGetters; -use RocketTheme\Toolbox\File\File; use RocketTheme\Toolbox\File\FileInterface; class Data implements DataInterface, \ArrayAccess, \Countable, \JsonSerializable, ExportInterface @@ -26,10 +25,10 @@ class Data implements DataInterface, \ArrayAccess, \Countable, \JsonSerializable /** @var array */ protected $items; - /** @var Blueprint */ + /** @var Blueprint|null */ protected $blueprints; - /** @var File */ + /** @var FileInterface|null */ protected $storage; /** @@ -281,7 +280,7 @@ class Data implements DataInterface, \ArrayAccess, \Countable, \JsonSerializable * Set or get the data storage. * * @param FileInterface|null $storage Optionally enter a new storage. - * @return FileInterface + * @return FileInterface|null */ public function file(FileInterface $storage = null) { diff --git a/system/src/Grav/Common/Debugger.php b/system/src/Grav/Common/Debugger.php index bc6271b73..de8b65635 100644 --- a/system/src/Grav/Common/Debugger.php +++ b/system/src/Grav/Common/Debugger.php @@ -26,7 +26,6 @@ use DebugBar\DataCollector\RequestDataCollector; use DebugBar\DataCollector\TimeDataCollector; use DebugBar\DebugBar; use DebugBar\JavascriptRenderer; -use DebugBar\StandardDebugBar; use Grav\Common\Config\Config; use Grav\Common\Processors\ProcessorInterface; use Grav\Common\Twig\TwigClockworkDataSource; @@ -45,19 +44,19 @@ class Debugger /** @var static */ protected static $instance; - /** @var Grav $grav */ + /** @var Grav|null */ protected $grav; - /** @var Config $config */ + /** @var Config|null */ protected $config; - /** @var JavascriptRenderer $renderer */ + /** @var JavascriptRenderer|null */ protected $renderer; - /** @var StandardDebugBar $debugbar */ + /** @var DebugBar|null */ protected $debugbar; - /** @var Clockwork */ + /** @var Clockwork|null */ protected $clockwork; /** @var bool */ @@ -68,18 +67,22 @@ class Debugger /** @var array */ protected $timers = []; - /** @var array $deprecations */ + /** @var array */ protected $deprecations = []; /** @var callable|null */ protected $errorHandler; + /** @var float */ protected $requestTime; + + /** @var float */ protected $currentTime; /** @var int */ protected $profiling = 0; + /** @var bool */ protected $censored = false; /** @@ -447,7 +450,7 @@ class Debugger * * @param string $name * - * @return DataCollectorInterface + * @return DataCollectorInterface|null * @throws \DebugBar\DebugBarException */ public function getCollector($name) diff --git a/system/src/Grav/Common/File/CompiledFile.php b/system/src/Grav/Common/File/CompiledFile.php index 45ffb8fde..591e804da 100644 --- a/system/src/Grav/Common/File/CompiledFile.php +++ b/system/src/Grav/Common/File/CompiledFile.php @@ -17,7 +17,7 @@ trait CompiledFile * Get/set parsed file contents. * * @param mixed $var - * @return string + * @return string|array */ public function content($var = null) { diff --git a/system/src/Grav/Common/File/CompiledJsonFile.php b/system/src/Grav/Common/File/CompiledJsonFile.php index d73e817b2..8d34c5c9d 100644 --- a/system/src/Grav/Common/File/CompiledJsonFile.php +++ b/system/src/Grav/Common/File/CompiledJsonFile.php @@ -20,7 +20,7 @@ class CompiledJsonFile extends JsonFile * * @param string $var * @param bool $assoc - * @return array mixed + * @return array */ protected function decode($var, $assoc = true) { diff --git a/system/src/Grav/Common/GPM/GPM.php b/system/src/Grav/Common/GPM/GPM.php index d6a97b52b..ae571198d 100644 --- a/system/src/Grav/Common/GPM/GPM.php +++ b/system/src/Grav/Common/GPM/GPM.php @@ -128,7 +128,7 @@ class GPM extends Iterator /** * Return the instance of a specific Plugin * @param string $slug The slug of the Plugin - * @return Local\Package The instance of the Plugin + * @return Local\Package|null The instance of the Plugin */ public function getInstalledPlugin($slug) { @@ -162,7 +162,7 @@ class GPM extends Iterator /** * Return the instance of a specific Theme * @param string $slug The slug of the Theme - * @return Local\Package The instance of the Theme + * @return Local\Package|null The instance of the Theme */ public function getInstalledTheme($slug) { diff --git a/system/src/Grav/Common/GPM/Licenses.php b/system/src/Grav/Common/GPM/Licenses.php index 4b9bc8143..171743a46 100644 --- a/system/src/Grav/Common/GPM/Licenses.php +++ b/system/src/Grav/Common/GPM/Licenses.php @@ -41,6 +41,7 @@ class Licenses public static function set($slug, $license) { $licenses = self::getLicenseFile(); + /** @var array $data */ $data = (array)$licenses->content(); $slug = strtolower($slug); @@ -74,6 +75,7 @@ class Licenses public static function get($slug = null) { $licenses = self::getLicenseFile(); + /** @var array $data */ $data = (array)$licenses->content(); $licenses->free(); $slug = strtolower($slug); diff --git a/system/src/Grav/Common/Helpers/Truncator.php b/system/src/Grav/Common/Helpers/Truncator.php index 6447343b5..db3dbe2a6 100644 --- a/system/src/Grav/Common/Helpers/Truncator.php +++ b/system/src/Grav/Common/Helpers/Truncator.php @@ -162,6 +162,7 @@ class Truncator */ private static function removeProceedingNodes($domNode, $topNode) { + /** @var DOMNode|null $nextNode */ $nextNode = $domNode->nextSibling; if ($nextNode !== null) { diff --git a/system/src/Grav/Common/Inflector.php b/system/src/Grav/Common/Inflector.php index f70d1f931..5643a1f57 100644 --- a/system/src/Grav/Common/Inflector.php +++ b/system/src/Grav/Common/Inflector.php @@ -42,7 +42,7 @@ class Inflector * @param string $word English noun to pluralize * @param int $count The count * - * @return string Plural noun + * @return string|false Plural noun */ public static function pluralize($word, $count = 2) { diff --git a/system/src/Grav/Common/Iterator.php b/system/src/Grav/Common/Iterator.php index 6664481b9..4e1aa20e9 100644 --- a/system/src/Grav/Common/Iterator.php +++ b/system/src/Grav/Common/Iterator.php @@ -133,7 +133,7 @@ class Iterator implements \ArrayAccess, \Iterator, \Countable, \Serializable /** * @param mixed $needle Searched value. * - * @return string|bool Key if found, otherwise false. + * @return string|int|false Key if found, otherwise false. */ public function indexOf($needle) { diff --git a/system/src/Grav/Common/Language/Language.php b/system/src/Grav/Common/Language/Language.php index f4a08c448..450929576 100644 --- a/system/src/Grav/Common/Language/Language.php +++ b/system/src/Grav/Common/Language/Language.php @@ -149,7 +149,7 @@ class Language * * @param string $lang * - * @return bool + * @return string|bool */ public function setDefault($lang) { diff --git a/system/src/Grav/Common/Page/Markdown/Excerpts.php b/system/src/Grav/Common/Page/Markdown/Excerpts.php index 9ce1898b2..7585ac639 100644 --- a/system/src/Grav/Common/Page/Markdown/Excerpts.php +++ b/system/src/Grav/Common/Page/Markdown/Excerpts.php @@ -12,6 +12,7 @@ namespace Grav\Common\Page\Markdown; use Grav\Common\Grav; use Grav\Common\Page\Interfaces\PageInterface; use Grav\Common\Page\Medium\Link; +use Grav\Common\Page\Pages; use Grav\Common\Uri; use Grav\Common\Page\Medium\Medium; use Grav\Common\Utils; @@ -20,7 +21,7 @@ use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator; class Excerpts { - /** @var PageInterface */ + /** @var PageInterface|null */ protected $page; /** @var array */ protected $config; diff --git a/system/src/Grav/Common/Page/Medium/AbstractMedia.php b/system/src/Grav/Common/Page/Medium/AbstractMedia.php index f67cd650e..c107e4d0f 100644 --- a/system/src/Grav/Common/Page/Medium/AbstractMedia.php +++ b/system/src/Grav/Common/Page/Medium/AbstractMedia.php @@ -28,6 +28,7 @@ abstract class AbstractMedia implements ExportInterface, MediaCollectionInterfac use Export; protected $items = []; + /** @var string */ protected $path; protected $images = []; protected $videos = []; @@ -150,7 +151,7 @@ abstract class AbstractMedia implements ExportInterface, MediaCollectionInterfac /** * @param string $name - * @param MediaObjectInterface $file + * @param MediaObjectInterface|null $file */ public function add($name, $file) { diff --git a/system/src/Grav/Common/Page/Medium/ImageMedium.php b/system/src/Grav/Common/Page/Medium/ImageMedium.php index f04502521..4684c63b8 100644 --- a/system/src/Grav/Common/Page/Medium/ImageMedium.php +++ b/system/src/Grav/Common/Page/Medium/ImageMedium.php @@ -22,7 +22,7 @@ class ImageMedium extends Medium protected $thumbnailTypes = ['page', 'media', 'default']; /** - * @var ImageFile + * @var ImageFile|null */ protected $image; @@ -643,7 +643,7 @@ class ImageMedium extends Medium /** * Return the image higher quality version * - * @return ImageMedium the alternative version with higher quality + * @return Medium|ImageMedium the alternative version with higher quality */ public function higherQualityAlternative() { diff --git a/system/src/Grav/Common/Page/Medium/Medium.php b/system/src/Grav/Common/Page/Medium/Medium.php index 951b307f3..498bcdc43 100644 --- a/system/src/Grav/Common/Page/Medium/Medium.php +++ b/system/src/Grav/Common/Page/Medium/Medium.php @@ -479,7 +479,7 @@ class Medium extends Data implements RenderableInterface, MediaObjectInterface * * @param string $mode * - * @return $this|null + * @return self|null */ public function display($mode = 'source') { @@ -648,7 +648,7 @@ class Medium extends Data implements RenderableInterface, MediaObjectInterface /** * Get the thumbnail Medium object * - * @return ThumbnailImageMedium + * @return ThumbnailImageMedium|null */ protected function getThumbnail() { diff --git a/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php b/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php index 1d9ceb6ef..4b4714069 100644 --- a/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php +++ b/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php @@ -15,7 +15,7 @@ use Grav\Common\Page\Markdown\Excerpts; trait ParsedownHtmlTrait { /** - * @var \Grav\Common\Markdown\Parsedown + * @var \Grav\Common\Markdown\Parsedown|null */ protected $parsedown; diff --git a/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php b/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php index 252116835..71ab56835 100644 --- a/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php +++ b/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php @@ -12,7 +12,7 @@ namespace Grav\Common\Page\Medium; class ThumbnailImageMedium extends ImageMedium { /** - * @var Medium + * @var Medium|null */ public $parent = null; @@ -67,7 +67,7 @@ class ThumbnailImageMedium extends ImageMedium * * @param string $mode * - * @return $this + * @return array|Link|Medium */ public function display($mode = 'source') { @@ -79,7 +79,7 @@ class ThumbnailImageMedium extends ImageMedium * * @param string $type * - * @return $this + * @return array|Link|Medium */ public function thumbnail($type = 'auto') { @@ -119,7 +119,7 @@ class ThumbnailImageMedium extends ImageMedium * @param string $method * @param array $arguments * @param bool $testLinked - * @return Medium|Link|array + * @return array|Link|Medium */ protected function bubble($method, array $arguments = [], $testLinked = true) { diff --git a/system/src/Grav/Common/Page/Medium/VideoMedium.php b/system/src/Grav/Common/Page/Medium/VideoMedium.php index dff4bd34e..730558f82 100644 --- a/system/src/Grav/Common/Page/Medium/VideoMedium.php +++ b/system/src/Grav/Common/Page/Medium/VideoMedium.php @@ -98,7 +98,7 @@ class VideoMedium extends Medium /** * Allows ability to set the preload option * - * @param null $status + * @param string|null $status * @return $this */ public function preload($status = null) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 4bb2461a9..2da55856a 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -19,6 +19,7 @@ use Grav\Common\Language\Language; use Grav\Common\Markdown\Parsedown; use Grav\Common\Markdown\ParsedownExtra; use Grav\Common\Media\Interfaces\MediaCollectionInterface; +use Grav\Common\Page\Interfaces\PageCollectionInterface; use Grav\Common\Page\Interfaces\PageInterface; use Grav\Common\Media\Traits\MediaTrait; use Grav\Common\Page\Markdown\Excerpts; @@ -64,7 +65,7 @@ class Page implements PageInterface protected $redirect; protected $external_url; protected $items; - /** @var \stdClass */ + /** @var object|null */ protected $header; protected $frontmatter; protected $language; @@ -1216,8 +1217,8 @@ class Page implements PageInterface /** * Gets and sets the associated media as found in the page folder. * - * @param Media $var Representation of associated media. - * @return Media Representation of associated media. + * @param MediaCollectionInterface|Media $var Representation of associated media. + * @return MediaCollectionInterface|Media Representation of associated media. */ public function media($var = null) { @@ -1376,8 +1377,8 @@ class Page implements PageInterface * Gets and sets the cache-control property. If not set it will return the default value (null) * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control for more details on valid options * - * @param null $var - * @return null + * @param string|null $var + * @return string|null */ public function cacheControl($var = null) { @@ -1829,7 +1830,7 @@ class Page implements PageInterface /** * Gets and Sets the page raw route * - * @param null $var + * @param string|null $var * * @return null|string */ @@ -1875,7 +1876,7 @@ class Page implements PageInterface * Gets the canonical route for this page if its set. If provided it will use * that value, else if it's `true` it will use the default route. * - * @param null $var + * @param string|null $var * * @return bool|string */ @@ -2309,7 +2310,7 @@ class Page implements PageInterface /** * Returns children of this page. * - * @return Collection + * @return PageCollectionInterface|Collection */ public function children() { @@ -2433,7 +2434,7 @@ class Page implements PageInterface $routes = Grav::instance()['pages']->routes(); if (isset($routes[$uri_path])) { - /** @var PageInterface $child_page */ + /** @var PageInterface|null $child_page */ $child_page = $pages->find($uri->route())->parent(); if ($child_page) { while (!$child_page->root()) { @@ -2561,7 +2562,7 @@ class Page implements PageInterface * @param string|array $params * @param bool $pagination * - * @return Collection + * @return PageCollectionInterface|Collection * @throws \InvalidArgumentException */ public function collection($params = 'content', $pagination = true) @@ -2590,7 +2591,7 @@ class Page implements PageInterface /** * @param string|array $value * @param bool $only_published - * @return Collection + * @return PageCollectionInterface|Collection */ public function evaluate($value, $only_published = true) { diff --git a/system/src/Grav/Common/Scheduler/IntervalTrait.php b/system/src/Grav/Common/Scheduler/IntervalTrait.php index 821833780..ef309bf3c 100644 --- a/system/src/Grav/Common/Scheduler/IntervalTrait.php +++ b/system/src/Grav/Common/Scheduler/IntervalTrait.php @@ -374,7 +374,7 @@ trait IntervalTrait /** * Validate sequence of cron expression. * - * @param int|string $value + * @param int|string|null $value * @param int $min * @param int $max * @return mixed diff --git a/system/src/Grav/Common/Scheduler/Job.php b/system/src/Grav/Common/Scheduler/Job.php index 6fcd4a2ea..70b1990e5 100644 --- a/system/src/Grav/Common/Scheduler/Job.php +++ b/system/src/Grav/Common/Scheduler/Job.php @@ -37,6 +37,7 @@ class Job private $after; private $whenOverlapping; private $outputMode; + /** @var Process|null $process */ private $process; private $successful = false; private $backlink; @@ -73,7 +74,7 @@ class Job /** * Get the command * - * @return string + * @return \Closure|string */ public function getCommand() { @@ -322,7 +323,6 @@ class Job */ public function finalize() { - /** @var Process $process */ $process = $this->process; if ($process) { diff --git a/system/src/Grav/Common/Scheduler/Scheduler.php b/system/src/Grav/Common/Scheduler/Scheduler.php index e2ee7deef..5b214face 100644 --- a/system/src/Grav/Common/Scheduler/Scheduler.php +++ b/system/src/Grav/Common/Scheduler/Scheduler.php @@ -126,7 +126,7 @@ class Scheduler /** * Get a specific Job based on id * - * @param $jobid + * @param string $jobid * @return Job|null */ public function getJob($jobid) diff --git a/system/src/Grav/Common/Security.php b/system/src/Grav/Common/Security.php index 494be2e13..0aef82cce 100644 --- a/system/src/Grav/Common/Security.php +++ b/system/src/Grav/Common/Security.php @@ -116,7 +116,7 @@ class Security * return false positives because of it tags all potentially dangerous HTML tags and attributes without looking into * their content. * - * @param string $string The string to run XSS detection logic on + * @param string|null $string The string to run XSS detection logic on * @return bool|string Type of XSS vector if the given `$string` may contain XSS, false otherwise. * * Copies the code from: https://github.com/symphonycms/xssfilter/blob/master/extension.driver.php#L138 diff --git a/system/src/Grav/Common/Session.php b/system/src/Grav/Common/Session.php index f913810b4..b388e4ea3 100644 --- a/system/src/Grav/Common/Session.php +++ b/system/src/Grav/Common/Session.php @@ -118,12 +118,12 @@ class Session extends \Grav\Framework\Session\Session /** @var Uri $uri */ $uri = $grav['uri']; - /** @var Grav\Plugin\Form\Forms $form */ + /** @var Grav\Plugin\Form\Forms|null $form */ $form = $grav['forms']->getActiveForm(); $sessionField = base64_encode($uri->url); - /** @var FormFlash $flash */ + /** @var FormFlash|null $flash */ $flash = $form ? $form->getFlash() : null; $object = $flash && method_exists($flash, 'getLegacyFiles') ? [$sessionField => $flash->getLegacyFiles()] : null; } diff --git a/system/src/Grav/Common/Twig/TwigExtension.php b/system/src/Grav/Common/Twig/TwigExtension.php index 1d6a6c38e..e78790ab3 100644 --- a/system/src/Grav/Common/Twig/TwigExtension.php +++ b/system/src/Grav/Common/Twig/TwigExtension.php @@ -251,7 +251,7 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface /** * Returns array in a random order. * - * @param array $original + * @param array|\Traversable $original * @param int $offset Can be used to return only slice of the array. * * @return array @@ -421,7 +421,7 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface /** * Return ksorted collection. * - * @param array $array + * @param array|null $array * * @return array */ @@ -979,9 +979,9 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface /** * Wrapper for array_intersect() method * - * @param array $array1 - * @param array $array2 - * @return array + * @param array|Collection $array1 + * @param array|Collection $array2 + * @return array|Collection */ public function arrayIntersectFunc($array1, $array2) { diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php index 1ff32a918..b6a1893ae 100644 --- a/system/src/Grav/Common/Uri.php +++ b/system/src/Grav/Common/Uri.php @@ -22,10 +22,10 @@ class Uri { const HOSTNAME_REGEX = '/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/'; - /** @var \Grav\Framework\Uri\Uri */ + /** @var \Grav\Framework\Uri\Uri|null */ protected static $currentUri; - /** @var \Grav\Framework\Route\Route */ + /** @var \Grav\Framework\Route\Route|null */ protected static $currentRoute; public $url; @@ -953,7 +953,7 @@ class Uri * @param PageInterface $page the current page to use as reference * @param string $markdown_url the URL as it was written in the markdown * @param string $type the type of URL, image | link - * @param null $relative if null, will use system default, if true will use relative links internally + * @param bool|null $relative if null, will use system default, if true will use relative links internally * * @return string the more friendly formatted url */ @@ -1109,7 +1109,7 @@ class Uri /** * Filters the user info string. * - * @param string $info The raw user or password. + * @param string|null $info The raw user or password. * @return string The percent-encoded user or password string. */ public static function filterUserInfo($info) @@ -1125,7 +1125,7 @@ class Uri * will NOT double-encode characters that are already * percent-encoded. * - * @param string $path The raw uri path. + * @param string|null $path The raw uri path. * @return string The RFC 3986 percent-encoded uri path. * @link http://www.faqs.org/rfcs/rfc3986.html */ @@ -1137,7 +1137,7 @@ class Uri /** * Filters the query string or fragment of a URI. * - * @param string $query The raw uri query string. + * @param string|null $query The raw uri query string. * @return string The percent-encoded query string. */ public static function filterQuery($query) diff --git a/system/src/Grav/Common/User/DataUser/User.php b/system/src/Grav/Common/User/DataUser/User.php index 64bf0936f..fe247fa4d 100644 --- a/system/src/Grav/Common/User/DataUser/User.php +++ b/system/src/Grav/Common/User/DataUser/User.php @@ -103,7 +103,7 @@ class User extends Data implements UserInterface */ public function save() { - /** @var CompiledYamlFile $file */ + /** @var CompiledYamlFile|null $file */ $file = $this->file(); if (!$file || !$file->filename()) { user_error(__CLASS__ . ': calling \$user = new ' . __CLASS__ . "() is deprecated since Grav 1.6, use \$grav['accounts']->load(\$username) or \$grav['accounts']->load('') instead", E_USER_DEPRECATED); diff --git a/system/src/Grav/Common/User/FlexUser/Group.php b/system/src/Grav/Common/User/FlexUser/Group.php index 31a5cc655..a2a780170 100644 --- a/system/src/Grav/Common/User/FlexUser/Group.php +++ b/system/src/Grav/Common/User/FlexUser/Group.php @@ -97,7 +97,7 @@ class Group extends FlexObject /** * @param mixed $value - * @return Access + * @return array */ protected function offsetPrepare_access($value): array { @@ -105,7 +105,7 @@ class Group extends FlexObject } /** - * @param Access|null $value + * @param array|null $value * @return array|null */ protected function offsetSerialize_access(?array $value): ?array diff --git a/system/src/Grav/Common/User/FlexUser/GroupIndex.php b/system/src/Grav/Common/User/FlexUser/GroupIndex.php index 0eb302989..a292030df 100644 --- a/system/src/Grav/Common/User/FlexUser/GroupIndex.php +++ b/system/src/Grav/Common/User/FlexUser/GroupIndex.php @@ -11,6 +11,12 @@ namespace Grav\Common\User\FlexUser; use Grav\Framework\Flex\FlexIndex; +/** + * Class GroupIndex + * @package Grav\Common\User\FlexUser + * + * @method bool|null authorize(string $action, string $scope = null) + */ class GroupIndex extends FlexIndex { } diff --git a/system/src/Grav/Common/User/FlexUser/User.php b/system/src/Grav/Common/User/FlexUser/User.php index 4f17ae9ba..daf47b818 100644 --- a/system/src/Grav/Common/User/FlexUser/User.php +++ b/system/src/Grav/Common/User/FlexUser/User.php @@ -15,8 +15,10 @@ use Grav\Common\Page\Media; use Grav\Common\Page\Medium\ImageMedium; use Grav\Common\Page\Medium\Medium; use Grav\Common\Page\Medium\MediumFactory; +use Grav\Common\Page\Medium\StaticImageMedium; use Grav\Common\User\Access; use Grav\Common\User\Authentication; +use Grav\Common\User\Interfaces\UserCollectionInterface; use Grav\Common\User\Interfaces\UserInterface; use Grav\Common\User\Traits\UserTrait; use Grav\Common\Utils; @@ -465,7 +467,7 @@ class User extends FlexObject implements UserInterface, MediaManipulationInterfa * Set or get the data storage. * * @param FileInterface|null $storage Optionally enter a new storage. - * @return FileInterface + * @return FileInterface|null */ public function file(FileInterface $storage = null) { @@ -552,7 +554,7 @@ class User extends FlexObject implements UserInterface, MediaManipulationInterfa /** * Return media object for the User's avatar. * - * @return ImageMedium|null + * @return ImageMedium|StaticImageMedium|null * @deprecated 1.6 Use ->getAvatarImage() method instead. */ public function getAvatarMedia() @@ -644,7 +646,7 @@ class User extends FlexObject implements UserInterface, MediaManipulationInterfa /** * @param mixed $value - * @return Access + * @return array */ protected function offsetPrepare_access($value): array { @@ -652,7 +654,7 @@ class User extends FlexObject implements UserInterface, MediaManipulationInterfa } /** - * @param Access|null $value + * @param array|null $value * @return array|null */ protected function offsetSerialize_access(?array $value): ?array @@ -786,7 +788,7 @@ class User extends FlexObject implements UserInterface, MediaManipulationInterfa protected function saveUpdatedMedia(): void { // Upload/delete original sized images. - /** @var FormFlashFile $file */ + /** @var FormFlashFile|null $file */ foreach ($this->_uploads_original ?? [] as $name => $file) { $name = 'original/' . $name; if ($file) { @@ -798,7 +800,7 @@ class User extends FlexObject implements UserInterface, MediaManipulationInterfa /** * @var string $filename - * @var UploadedFileInterface $file + * @var UploadedFileInterface|null $file */ foreach ($this->getUpdatedMedia() as $filename => $file) { if ($file) { @@ -830,9 +832,9 @@ class User extends FlexObject implements UserInterface, MediaManipulationInterfa continue; } - /** @var Medium $thumbFile */ + /** @var Medium|null $thumbFile */ $thumbFile = $resizedMedia[$filename]; - /** @var Medium $imageFile */ + /** @var Medium|null $imageFile */ $imageFile = $originalMedia[$filename] ?? $thumbFile; if ($thumbFile) { $list[$filename] = [ @@ -890,14 +892,14 @@ class User extends FlexObject implements UserInterface, MediaManipulationInterfa } /** - * @return GroupCollection + * @return GroupCollection|GroupIndex */ protected function getUserGroups() { $grav = Grav::instance(); $flex = $grav['flex_objects'] ?? null; - /** @var GroupCollection $groups */ + /** @var GroupCollection|null $groups */ $groups = $flex ? $flex->getDirectory('grav-user-groups') : null; if ($groups) { diff --git a/system/src/Grav/Common/User/Traits/UserTrait.php b/system/src/Grav/Common/User/Traits/UserTrait.php index 69d2e7528..049ed8dfe 100644 --- a/system/src/Grav/Common/User/Traits/UserTrait.php +++ b/system/src/Grav/Common/User/Traits/UserTrait.php @@ -116,7 +116,7 @@ trait UserTrait * * Note: if there's no local avatar image for the user, you should call getAvatarUrl() to get the external avatar URL. * - * @return Medium|null + * @return ImageMedium|StaticImageMedium|null */ public function getAvatarImage(): ?Medium { diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index 36864b943..0df0391aa 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -1298,7 +1298,7 @@ abstract class Utils * Get a portion of an array (passed by reference) with dot-notation key * * @param array $array - * @param string|int $key + * @param string|int|null $key * @param null $default * @return mixed */ @@ -1327,10 +1327,10 @@ abstract class Utils * Set portion of array (passed by reference) for a dot-notation key * and set the value * - * @param array $array - * @param string|int $key - * @param mixed $value - * @param bool $merge + * @param array $array + * @param string|int|null $key + * @param mixed $value + * @param bool $merge * * @return mixed */ diff --git a/system/src/Grav/Console/Cli/SchedulerCommand.php b/system/src/Grav/Console/Cli/SchedulerCommand.php index a0068ed6b..64058c120 100644 --- a/system/src/Grav/Console/Cli/SchedulerCommand.php +++ b/system/src/Grav/Console/Cli/SchedulerCommand.php @@ -159,7 +159,6 @@ class SchedulerCommand extends ConsoleCommand } elseif ($jobid = $this->input->getOption('run')) { $io->title('Force Run Job: ' . $jobid); - /** @var Job $job */ $job = $scheduler->getJob($jobid); if ($job) { diff --git a/system/src/Grav/Console/Gpm/InstallCommand.php b/system/src/Grav/Console/Gpm/InstallCommand.php index 20a962f2a..a1ac8ba6c 100644 --- a/system/src/Grav/Console/Gpm/InstallCommand.php +++ b/system/src/Grav/Console/Gpm/InstallCommand.php @@ -320,7 +320,7 @@ class InstallCommand extends ConsoleCommand } /** - * @param Package $package + * @param Package|null $package * @param bool $is_update True if the package is an update */ private function processPackage($package, $is_update = false) @@ -447,7 +447,7 @@ class InstallCommand extends ConsoleCommand } else { $repo_dir = $matches[2]; } - + $paths = (array) $paths; foreach ($paths as $repo) { $path = rtrim($repo, '/') . '/' . $repo_dir; diff --git a/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php b/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php index f601fd0a2..689d2ac39 100644 --- a/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php +++ b/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php @@ -106,7 +106,7 @@ class FlexPageCollection extends FlexCollection * * @param string $path * - * @return PageInterface|null The next item. + * @return PageInterface|false The next item. */ public function nextSibling($path) { @@ -119,7 +119,7 @@ class FlexPageCollection extends FlexCollection * @param string $path * @param int $direction either -1 or +1 * - * @return PageInterface|null The sibling item. + * @return PageInterface|false The sibling item. */ public function adjacentSibling($path, $direction = 1) { diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php index 9a9e717b3..45b70fc98 100644 --- a/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php +++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php @@ -1098,9 +1098,27 @@ trait PageLegacyTrait * @return CacheInterface */ abstract public function getCache(string $namespace = null); + + /** + * @param PageInterface|null $var + * @return PageInterface|FlexObjectInterface|null + */ abstract public function parent(PageInterface $var = null); + abstract public function getFlexDirectory(): FlexDirectory; + abstract protected function exists(): bool; + + /** + * @return string|null + */ abstract protected function getStorageFolder(); + + /** + * @param string $property + * @param mixed $var + * @param callable $filter + * @return mixed|null + */ abstract protected function loadHeaderProperty(string $property, $var, callable $filter); } diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php index 48b2daca5..3363c56c2 100644 --- a/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php +++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php @@ -15,6 +15,7 @@ use Grav\Common\Page\Interfaces\PageCollectionInterface; use Grav\Common\Page\Interfaces\PageInterface; use Grav\Common\Page\Pages; use Grav\Common\Uri; +use Grav\Framework\Flex\Interfaces\FlexObjectInterface; use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator; /** @@ -377,7 +378,7 @@ trait PageRoutableTrait * Gets and Sets the parent object for this page * * @param PageInterface|null $var the parent page object - * @return PageInterface|null the parent page object if it exists. + * @return PageInterface|FlexObjectInterface|null the parent page object if it exists. */ public function parent(PageInterface $var = null) { diff --git a/tests/phpstan/phpstan.neon b/tests/phpstan/phpstan.neon index dca9776e7..413a3030f 100644 --- a/tests/phpstan/phpstan.neon +++ b/tests/phpstan/phpstan.neon @@ -115,3 +115,9 @@ parameters: - message: '#deprecated class#' path: 'system/src/Grav/Framework/Uri/Uri.php' + - + message: '#Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch#' + path: 'system/src/Grav/Common/Grav.php' + - '#Call to deprecated method stopPropagation\(\) of class Symfony\\Component\\EventDispatcher\\Event#' + - '#Parameter \#2 \$listener of method Symfony\\Component\\EventDispatcher\\EventDispatcher::addListener\(\)#' + - '#Parameter \#2 \$listener of method Symfony\\Component\\EventDispatcher\\EventDispatcher::removeListener\(\)#'