Revert multiple changes as many of those break Grav functionality [#2699]

This commit is contained in:
Matias Griese
2019-10-22 15:20:35 +03:00
parent 9c123f7d3d
commit 913efdbd6a
83 changed files with 135 additions and 198 deletions

View File

@@ -5,8 +5,6 @@
*
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*
* @phan-file-suppress PhanUndeclaredProperty,PhanUndeclaredConstant,PhanUndeclaredMethod
*/
namespace Grav\Common\Assets\Traits;

View File

@@ -96,7 +96,6 @@ trait LegacyAssetsTrait
*
* @return \Grav\Common\Assets
* @deprecated Please use dynamic method with ['loading' => 'async'].
* @suppress PhanUndeclaredMethod
*/
public function addAsyncJs($asset, $priority = 10, $pipeline = true, $group = 'head')
{
@@ -115,7 +114,6 @@ trait LegacyAssetsTrait
*
* @return \Grav\Common\Assets
* @deprecated Please use dynamic method with ['loading' => 'defer'].
* @suppress PhanUndeclaredMethod
*/
public function addDeferJs($asset, $priority = 10, $pipeline = true, $group = 'head')
{

View File

@@ -5,8 +5,6 @@
*
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*
* @phan-file-suppress PhanUndeclaredProperty,PhanUndeclaredConstant,PhanUndeclaredMethod
*/
namespace Grav\Common\Assets\Traits;

View File

@@ -50,7 +50,6 @@ class ConfigFileFinder
* @param string $pattern Pattern to match the file. Pattern will also be removed from the key.
* @param int $levels Maximum number of recursive directories.
* @return array
* @suppress PhanTypeMismatchReturn - false positive on the += array trick
*/
public function getFiles(array $paths, $pattern = '|\.yaml$|', $levels = -1)
{

View File

@@ -150,7 +150,6 @@ class Setup extends Data
/**
* @param Container|array $container
* @suppress PhanUndeclaredConstant
*/
public function __construct($container)
{

View File

@@ -28,7 +28,7 @@ class Blueprint extends BlueprintForm
/** @var object */
protected $object;
/** @var ?array */
/** @var array|null */
protected $defaults;
protected $handlers = [];

View File

@@ -197,13 +197,13 @@ class Data implements DataInterface, \ArrayAccess, \Countable, \JsonSerializable
}
/**
* @param mixed ...$args
* @return $this
*/
public function filter(...$args)
public function filter()
{
$missingValuesAsNull = $args[0] ?? false;
$keepEmptyValues = $args[1] ?? false;
$args = func_get_args();
$missingValuesAsNull = (bool)(array_shift($args) ?: false);
$keepEmptyValues = (bool)(array_shift($args) ?: false);
$this->items = $this->blueprints()->filter($this->items, $missingValuesAsNull, $keepEmptyValues);
@@ -280,7 +280,7 @@ class Data implements DataInterface, \ArrayAccess, \Countable, \JsonSerializable
/**
* Set or get the data storage.
*
* @param ?FileInterface $storage Optionally enter a new storage.
* @param FileInterface|null $storage Optionally enter a new storage.
* @return FileInterface
*/
public function file(FileInterface $storage = null)

View File

@@ -63,7 +63,7 @@ interface DataInterface
/**
* Set or get the data storage.
*
* @param ?FileInterface $storage Optionally enter a new storage.
* @param FileInterface|null $storage Optionally enter a new storage.
* @return FileInterface
*/
public function file(FileInterface $storage = null);

View File

@@ -73,7 +73,7 @@ class Debugger
/** @var array $deprecations */
protected $deprecations = [];
/** @var ?callable */
/** @var callable|null */
protected $errorHandler;
protected $requestTime;
@@ -403,7 +403,6 @@ class Debugger
$this->renderer = $this->debugbar->getJavascriptRenderer();
$this->renderer->setIncludeVendors(false);
// @phan-suppress-next-line PhanTypeMismatchArgument maximebf/debugbar has an incorrect phpdoc type for $type
list($css_files, $js_files) = $this->renderer->getAssets(null, JavascriptRenderer::RELATIVE_URL);
foreach ((array)$css_files as $css) {
@@ -431,7 +430,7 @@ class Debugger
/**
* Adds a data collector
*
* @param string $collector
* @param DataCollectorInterface $collector
*
* @return $this
* @throws \DebugBar\DebugBarException
@@ -504,7 +503,7 @@ class Debugger
/**
* Returns collected debugger data.
*
* @return ?array
* @return array|null
*/
public function getData()
{
@@ -782,7 +781,6 @@ class Debugger
* @param string $errfile
* @param int $errline
* @return bool
* @suppress PhanAccessMethodInternal,PhanTypeArraySuspicious,PhanTypeArraySuspiciousNull
*/
public function deprecatedErrorHandler($errno, $errstr, $errfile, $errline)
{

View File

@@ -5,8 +5,6 @@
*
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*
* @phan-file-suppress PhanUndeclaredProperty,PhanUndeclaredMethod,PhanTraitParentReference,PhanUndeclaredStaticProperty
*/
namespace Grav\Common\File;

View File

@@ -110,7 +110,7 @@ class GPM extends Iterator
* Return the instance of a specific Package
*
* @param string $slug The slug of the Package
* @return ?Local\Package The instance of the Package
* @return Local\Package|null The instance of the Package
*/
public function getInstalledPackage($slug)
{

View File

@@ -24,7 +24,7 @@ class GravCore extends AbstractPackageCollection
/**
* @param bool $refresh
* @param ?callable $callback
* @param callable|null $callback
* @throws \InvalidArgumentException
*/
public function __construct($refresh = false, $callback = null)

View File

@@ -251,7 +251,7 @@ class Response
/**
* Automatically picks the preferred method
*
* @return ?string The response of the request
* @return string|null The response of the request
*/
private static function getAuto()
{
@@ -270,8 +270,6 @@ class Response
* Starts a HTTP request via fopen
*
* @return string The response of the request
*
* @suppress PhanTypeInvalidDimOffset,PhanTypeMismatchArgumentInternal
*/
private static function getFopen()
{

View File

@@ -47,15 +47,13 @@ class Grav extends Container
public $output;
/**
* @var ?static The singleton instance
* @var static|null The singleton instance
*/
protected static $instance;
/**
* @var array Contains all Services and ServicesProviders that are mapped
* to the dependency injection container.
*
* @suppress PhanPluginMixedKeyNoKey
*/
protected static $diMap = [
'Grav\Common\Service\AccountsServiceProvider',
@@ -123,7 +121,7 @@ class Grav extends Container
*/
public static function instance(array $values = [])
{
if (empty(self::$instance)) {
if (null === self::$instance) {
self::$instance = static::load($values);
} elseif ($values) {
$instance = self::$instance;
@@ -156,6 +154,10 @@ class Grav extends Container
Setup::$environment = $environment;
}
// Initialize setup and streams.
$this['setup'];
$this['streams'];
return $this;
}
@@ -399,7 +401,7 @@ class Grav extends Container
* Fires an event with optional parameters.
*
* @param string $eventName
* @param ?Event $event
* @param Event|null $event
*
* @return Event
*/

View File

@@ -450,7 +450,7 @@ class Language
*
* @param string|array $args The first argument is the lookup key value
* Other arguments can be passed and replaced in the translation with sprintf syntax
* @param ?array $languages
* @param array|null $languages
* @param bool $array_support
* @param bool $html_out
*

View File

@@ -5,8 +5,6 @@
*
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*
* @phan-file-suppress PhanUndeclaredProperty,PhanTraitParentReference
*/
namespace Grav\Common\Markdown;

View File

@@ -15,8 +15,6 @@ use Grav\Common\Utils;
/**
* Implements PageContentInterface.
*
* @phan-file-suppress PhanUndeclaredMethod
*/
trait PageContentTrait
{

View File

@@ -20,8 +20,6 @@ use Grav\Common\Utils;
/**
* Implements PageLegacyInterface.
*
* @phan-file-suppress PhanUndeclaredMethod
*/
trait PageLegacyTrait
{
@@ -107,7 +105,7 @@ trait PageLegacyTrait
/**
* Helper method to return an ancestor page.
*
* @param ?string $lookup Name of the parent folder
* @param string|null $lookup Name of the parent folder
*
* @return PageInterface|null page you were looking for if it exists
*/

View File

@@ -19,8 +19,6 @@ use Grav\Common\Utils;
/**
* Implements PageRoutableInterface.
*
* @phan-file-suppress PhanUndeclaredMethod
*/
trait PageRoutableTrait
{
@@ -51,7 +49,7 @@ trait PageRoutableTrait
/**
* Gets and Sets the parent object for this page
*
* @param ?PageInterface $var the parent page object
* @param PageInterface|null $var the parent page object
*
* @return PageInterface|null the parent page object if it exists.
*/

View File

@@ -19,7 +19,6 @@ use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
/**
* Implements PageTranslateInterface
* @phan-file-suppress PhanUndeclaredMethod
*/
trait PageTranslateTrait
{

View File

@@ -75,11 +75,10 @@ interface PageContentInterface
*
* @param string $name Variable name.
* @param mixed|null $default
* @param mixed|null $separator
*
* @return mixed
*/
public function value($name, $default = null, $separator = null);
public function value($name, $default = null);
/**
* Gets and sets the associated media as found in the page folder.
@@ -248,5 +247,5 @@ interface PageContentInterface
*
* @return bool
*/
public function exists():bool;
public function exists();
}

View File

@@ -119,7 +119,7 @@ interface PageRoutableInterface
* Gets and sets the path to the folder where the .md for this Page object resides.
* This is equivalent to the filePath but without the filename.
*
* @param ?string $var the path
* @param string|null $var the path
*
* @return string|null the path
*/
@@ -137,7 +137,7 @@ interface PageRoutableInterface
/**
* Gets and Sets the parent object for this page
*
* @param ?PageInterface $var the parent page object
* @param PageInterface|null $var the parent page object
*
* @return PageInterface|null the parent page object if it exists.
*/

View File

@@ -25,10 +25,9 @@ class Excerpts
/** @var array */
protected $config;
/** @suppress PhanPossiblyNullTypeMismatchProperty - hopefully Grav::instance()['page'] can't be null here */
public function __construct(PageInterface $page = null, array $config = null)
{
$this->page = $page ?? Grav::instance()['page'];
$this->page = $page ?? Grav::instance()['page'] ?? null;
// Add defaults to the configuration.
if (null === $config || !isset($config['markdown'], $config['images'])) {

View File

@@ -25,7 +25,7 @@ class Media extends AbstractMedia
/**
* @param string $path
* @param ?array $media_order
* @param array|null $media_order
* @param bool $load
*/
public function __construct($path, array $media_order = null, $load = true)

View File

@@ -17,11 +17,11 @@ class GlobalMedia extends AbstractMedia
/**
* Return media path.
*
* @return string
* @return string|null
*/
public function getPath()
{
return '';
return null;
}
/**

View File

@@ -76,7 +76,7 @@ class ImageMedium extends Medium
* Construct.
*
* @param array $items
* @param ?Blueprint $blueprint
* @param Blueprint|null $blueprint
*/
public function __construct($items = [], Blueprint $blueprint = null)
{
@@ -625,18 +625,18 @@ class ImageMedium extends Medium
/**
* Filter image by using user defined filter parameters.
*
* @param mixed ...$args Filter to be used - varags to be compatible with parent
* @param string $filter Filter to be used.
* @return $this
*/
public function filter(...$args)
public function filter($filter = 'image.filters.default')
{
$filter = $args[0] ?? 'image.filters.default';
$filters = (array) $this->get($filter, []);
foreach ($filters as $params) {
$params = (array) $params;
$method = array_shift($params);
$this->__call($method, $params);
}
return $this;
}

View File

@@ -34,10 +34,10 @@ class Link implements RenderableInterface
/**
* Get an element (is array) that can be rendered by the Parsedown engine
*
* @param ?string $title
* @param ?string $alt
* @param ?string $class
* @param ?string $id
* @param string|null $title
* @param string|null $alt
* @param string|null $class
* @param string|null $id
* @param bool $reset
* @return array
*/

View File

@@ -32,7 +32,7 @@ class Medium extends Data implements RenderableInterface, MediaObjectInterface
protected $mode = 'source';
/**
* @var ?Medium
* @var Medium|null
*/
protected $_thumbnail = null;
@@ -74,7 +74,7 @@ class Medium extends Data implements RenderableInterface, MediaObjectInterface
* Construct.
*
* @param array $items
* @param ?Blueprint $blueprint
* @param Blueprint|null $blueprint
*/
public function __construct($items = [], Blueprint $blueprint = null)
{
@@ -281,7 +281,7 @@ class Medium extends Data implements RenderableInterface, MediaObjectInterface
/**
* Get/set querystring for the file's url
*
* @param ?string $querystring
* @param string|null $querystring
* @param bool $withQuestionmark
* @return string
*/
@@ -345,10 +345,10 @@ class Medium extends Data implements RenderableInterface, MediaObjectInterface
/**
* Get an element (is array) that can be rendered by the Parsedown engine
*
* @param ?string $title
* @param ?string $alt
* @param ?string $class
* @param ?string $id
* @param string|null $title
* @param string|null $alt
* @param string|null $class
* @param string|null $id
* @param bool $reset
* @return array
*/
@@ -479,7 +479,7 @@ class Medium extends Data implements RenderableInterface, MediaObjectInterface
*
* @param string $mode
*
* @return ?$this
* @return $this|null
*/
public function display($mode = 'source')
{

View File

@@ -20,7 +20,7 @@ class MediumFactory
*
* @param string $file
* @param array $params
* @return ?Medium
* @return Medium|null
*/
public static function fromFile($file, array $params = [])
{
@@ -73,7 +73,7 @@ class MediumFactory
*
* @param FormFlashFile $uploadedFile
* @param array $params
* @return ?Medium
* @return Medium|null
*/
public static function fromUploadedFile(FormFlashFile $uploadedFile, array $params = [])
{
@@ -82,7 +82,7 @@ class MediumFactory
$ext = $parts['extension'];
$basename = $parts['filename'];
$file = $uploadedFile->getTmpFile();
$path = empty($file) ? '' : dirname($file);
$path = $file ? dirname($file) : '';
$config = Grav::instance()['config'];
@@ -104,7 +104,7 @@ class MediumFactory
'basename' => $basename,
'extension' => $ext,
'path' => $path,
'modified' => empty($file) ? 0 : filemtime($file),
'modified' => $file ? filemtime($file) : 0,
'thumbnails' => []
];
@@ -149,7 +149,7 @@ class MediumFactory
/**
* Create a new ImageMedium by scaling another ImageMedium object.
*
* @param Medium $medium
* @param ImageMedium|Medium $medium
* @param int $from
* @param int $to
* @return Medium|array

View File

@@ -22,13 +22,12 @@ trait ParsedownHtmlTrait
/**
* Return HTML markup from the medium.
*
* @param ?string $title
* @param ?string $alt
* @param ?string $class
* @param ?string $id
* @param string|null $title
* @param string|null $alt
* @param string|null $class
* @param string|null $id
* @param bool $reset
* @return string
* @suppress PhanUndeclaredMethod
*/
public function html($title = null, $alt = null, $class = null, $id = null, $reset = true)
{

View File

@@ -14,10 +14,10 @@ interface RenderableInterface
/**
* Return HTML markup from the medium.
*
* @param ?string $title
* @param ?string $alt
* @param ?string $class
* @param ?string $id
* @param string|null $title
* @param string|null $alt
* @param string|null $class
* @param string|null $id
* @param bool $reset
* @return string
*/
@@ -26,10 +26,10 @@ interface RenderableInterface
/**
* Return Parsedown Element from the medium.
*
* @param ?string $title
* @param ?string $alt
* @param ?string $class
* @param ?string $id
* @param string|null $title
* @param string|null $alt
* @param string|null $class
* @param string|null $id
* @param bool $reset
* @return array
*/

View File

@@ -17,7 +17,6 @@ trait StaticResizeTrait
* @param int $width
* @param int $height
* @return $this
* @suppress PhanUndeclaredProperty
*/
public function resize($width = null, $height = null)
{

View File

@@ -35,11 +35,11 @@ class ThumbnailImageMedium extends ImageMedium
/**
* Get an element (is array) that can be rendered by the Parsedown engine
*
* @param ?string $title
* @param ?string $alt
* @param ?string $class
* @param ?string $id
* @param bool $reset
* @param string|null $title
* @param string|null $alt
* @param string|null $class
* @param string|null $id
* @param bool $reset
* @return array
*/
public function parsedownElement($title = null, $alt = null, $class = null, $id = null, $reset = true)
@@ -50,10 +50,10 @@ class ThumbnailImageMedium extends ImageMedium
/**
* Return HTML markup from the medium.
*
* @param ?string $title
* @param ?string $alt
* @param ?string $class
* @param ?string $id
* @param string|null $title
* @param string|null $alt
* @param string|null $class
* @param string|null $id
* @param bool $reset
* @return string
*/

View File

@@ -2259,7 +2259,7 @@ class Page implements PageInterface
/**
* Gets and Sets the parent object for this page
*
* @param ?PageInterface $var the parent page object
* @param PageInterface|null $var the parent page object
*
* @return PageInterface|null the parent page object if it exists.
*/

View File

@@ -921,7 +921,6 @@ class Pages
* @param string $type
*
* @return Blueprint
* @suppress PhanTypeMismatchArgument
*/
public function blueprints($type)
{
@@ -946,7 +945,7 @@ class Pages
/**
* Get all pages
*
* @param ?PageInterface $current
* @param PageInterface|null $current
*
* @return Collection
*/
@@ -1015,7 +1014,7 @@ class Pages
/**
* Get list of route/title of all pages.
*
* @param ?PageInterface $current
* @param PageInterface|null $current
* @param int $level
* @param bool $rawRoutes
*
@@ -1813,7 +1812,7 @@ class Pages
// do this header query work only once
if (strpos($order_by, 'header.') === 0) {
$query = explode('|', str_replace('header.', '', $order_by), 2);
$header_query = array_shift($query);
$header_query = array_shift($query) ?? '';
$header_default = array_shift($query);
}
@@ -1857,7 +1856,7 @@ class Pages
if (!$child_header instanceof Header) {
$child_header = new Header((array)$child_header);
}
$header_value = $child_header->get((string)$header_query);
$header_value = $child_header->get($header_query);
if (is_array($header_value)) {
$list[$key] = implode(',', $header_value);
} elseif ($header_value) {

View File

@@ -66,7 +66,7 @@ class Plugin implements EventSubscriberInterface, \ArrayAccess
*
* @param string $name
* @param Grav $grav
* @param ?Config $config
* @param Config|null $config
*/
public function __construct($name, Grav $grav, Config $config = null)
{

View File

@@ -11,7 +11,6 @@ namespace Grav\Common\Scheduler;
use Cron\CronExpression;
/** @phan-file-suppress PhanUndeclaredProperty,PhanTypeMismatchArgument */
trait IntervalTrait
{
/**

View File

@@ -145,7 +145,7 @@ class Job
* the job is due. Defaults to job creation time.
* It also default the execution time if not previously defined.
*
* @param ?\DateTime $date
* @param \DateTime|null $date
* @return bool
*/
public function isDue(\DateTime $date = null)
@@ -217,7 +217,7 @@ class Job
* The job id is used as a filename for the lock file.
*
* @param string $tempDir The directory path for the lock files
* @param ?callable $whenOverlapping A callback to ignore job overlapping
* @param callable|null $whenOverlapping A callback to ignore job overlapping
* @return self
*/
public function onlyOne($tempDir = null, callable $whenOverlapping = null)

View File

@@ -40,7 +40,6 @@ class TwigTokenParserRender extends AbstractTokenParser
/**
* @param Token $token
* @return array
* @suppress PhanAccessMethodInternal - parseExpression() is marked as Twig-internal
*/
protected function parseArguments(Token $token)
{

View File

@@ -52,7 +52,6 @@ class TwigTokenParserScript extends AbstractTokenParser
/**
* @param Token $token
* @return array
* @suppress PhanAccessMethodInternal - parseExpression() is marked as Twig-internal
*/
protected function parseArguments(Token $token)
{

View File

@@ -51,7 +51,6 @@ class TwigTokenParserStyle extends AbstractTokenParser
/**
* @param Token $token
* @return array
* @suppress PhanAccessMethodInternal - parseExpression() is marked as Twig-internal
*/
protected function parseArguments(Token $token)
{

View File

@@ -32,7 +32,6 @@ class TwigTokenParserSwitch extends AbstractTokenParser
{
/**
* {@inheritdoc}
* @suppress PhanAccessMethodInternal - parseExpression() is marked as Twig-internal
*/
public function parse(Token $token)
{

View File

@@ -29,7 +29,6 @@ class TwigTokenParserThrow extends AbstractTokenParser
* @param Token $token A Twig Token instance
*
* @return Node A Twig Node instance
* @suppress PhanAccessMethodInternal - parseExpression() is marked as Twig-internal
*/
public function parse(Token $token)
{

View File

@@ -44,7 +44,7 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
/** @var Grav */
protected $grav;
/** @var ?Debugger */
/** @var Debugger|null */
protected $debugger;
/** @var Config */
@@ -667,24 +667,24 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
/**
* @param string $value
* @param string $chars
* @param string|null $chars
*
* @return string
*/
public function rtrimFilter($value, $chars = '')
public function rtrimFilter($value, $chars = null)
{
return rtrim($value, $chars);
return null !== $chars ? rtrim($value, $chars) : rtrim($value);
}
/**
* @param string $value
* @param string $chars
* @param string|null $chars
*
* @return string
*/
public function ltrimFilter($value, $chars = '')
public function ltrimFilter($value, $chars = null)
{
return ltrim($value, $chars);
return null !== $chars ? ltrim($value, $chars) : ltrim($value);
}
/**
@@ -966,12 +966,12 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
*
* @param array $array1
* @param array $array2
* @return array|Collection
* @return array
*/
public function arrayIntersectFunc($array1, $array2)
{
if ($array1 instanceof Collection && $array2 instanceof Collection) {
return $array1->intersect($array2);
return $array1->intersect($array2)->toArray();
}
return array_intersect($array1, $array2);
@@ -1405,8 +1405,6 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
* @param string|null $typeTest
* @param string|null $className
* @return bool
*
* @suppress PhanPluginUnreachableCode
*/
public function ofTypeFunc($var, $typeTest = null, $className = null)
{

View File

@@ -406,7 +406,7 @@ class User extends FlexObject implements UserInterface, MediaManipulationInterfa
/**
* Set or get the data storage.
*
* @param ?FileInterface $storage Optionally enter a new storage.
* @param FileInterface|null $storage Optionally enter a new storage.
* @return FileInterface
*/
public function file(FileInterface $storage = null)

View File

@@ -16,7 +16,6 @@ use Grav\Common\Page\Medium\StaticImageMedium;
use Grav\Common\User\Authentication;
use Grav\Common\Utils;
/** @phan-file-suppress PhanUndeclaredMethod */
trait UserTrait
{
/**

View File

@@ -43,6 +43,7 @@ trait ConsoleTrait
{
// Initialize cache with CLI compatibility
Grav::instance()['config']->set('system.cache.cli_compatibility', true);
Grav::instance()['cache'];
$this->argv = $_SERVER['argv'][0];
$this->input = $input;

View File

@@ -12,7 +12,6 @@ namespace Grav\Console\Gpm;
use Grav\Common\Cache;
use Grav\Common\Filesystem\Folder;
use Grav\Common\GPM\Installer;
use Grav\Common\GPM\Remote\Package;
use Grav\Common\GPM\Response;
use Grav\Common\GPM\Upgrader;
use Grav\Common\Grav;

View File

@@ -33,8 +33,8 @@ trait ControllerResponseTrait
/**
* @param string $content
* @param ?int $code
* @param ?array $headers
* @param int|null $code
* @param array|null $headers
* @return Response
*/
protected function createHtmlResponse(string $content, int $code = null, array $headers = null): ResponseInterface
@@ -50,8 +50,8 @@ trait ControllerResponseTrait
/**
* @param array $content
* @param ?int $code
* @param ?array $headers
* @param int|null $code
* @param array|null $headers
* @return Response
*/
protected function createJsonResponse(array $content, int $code = null, array $headers = null): ResponseInterface
@@ -70,7 +70,7 @@ trait ControllerResponseTrait
/**
* @param string $url
* @param ?int $code
* @param int|null $code
* @return Response
*/
protected function createRedirectResponse(string $url, int $code = null): ResponseInterface

View File

@@ -66,7 +66,7 @@ interface FilesystemInterface
* @see http://php.net/manual/en/function.pathinfo.php
*
* @param string $path A filename or path, does not need to exist as a file.
* @param ?int $options A PATHINFO_* constant.
* @param int|null $options A PATHINFO_* constant.
*
* @return array|string
* @api

View File

@@ -434,7 +434,7 @@ class FlexDirectory implements FlexAuthorizeInterface
/**
* @param array $entries
* @param ?string $keyField
* @param string|null $keyField
* @return FlexCollectionInterface
*/
public function createCollection(array $entries, string $keyField = null): FlexCollectionInterface
@@ -447,7 +447,7 @@ class FlexDirectory implements FlexAuthorizeInterface
/**
* @param array $entries
* @param ?string $keyField
* @param string|null $keyField
* @return FlexIndexInterface
*/
public function createIndex(array $entries, string $keyField = null): FlexIndexInterface
@@ -497,7 +497,7 @@ class FlexDirectory implements FlexAuthorizeInterface
/**
* @param array $entries
* @param ?string $keyField
* @param string|null $keyField
* @return FlexCollectionInterface
*/
public function loadCollection(array $entries, string $keyField = null): FlexCollectionInterface

View File

@@ -487,7 +487,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
/**
* @param array $entries
* @param ?string $keyField
* @param string|null $keyField
* @return static
*/
protected function createFrom(array $entries, string $keyField = null)

View File

@@ -420,7 +420,6 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
/**
* {@inheritdoc}
* @see FlexObjectInterface::render()
* @suppress PhanAccessMethodInternal - the render() call is marked internal in Twig
*/
public function render(string $layout = null, array $context = [])
{

View File

@@ -31,7 +31,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
*
* @param FlexObjectInterface[] $entries Associated array of Flex Objects to be included in the collection.
* @param FlexDirectory $directory Flex Directory where all the objects belong into.
* @param ?string $keyField Key field used to index the collection.
* @param string|null $keyField Key field used to index the collection.
*
* @return static Returns a new Flex Collection.
*/
@@ -43,7 +43,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
* @used-by FlexDirectory::createCollection() Official method to create Flex Collection.
*
* @param FlexObjectInterface[] $entries Associated array of Flex Objects to be included in the collection.
* @param ?FlexDirectory $directory Flex Directory where all the objects belong into.
* @param FlexDirectory|null $directory Flex Directory where all the objects belong into.
*
* @throws \InvalidArgumentException
*/

View File

@@ -57,7 +57,7 @@ interface FlexIndexInterface extends FlexCollectionInterface
public function withKeyField(string $keyField = null);
/**
* @param ?string $indexKey
* @param string|null $indexKey
* @return array
*/
public function getIndexMap(string $indexKey = null);

View File

@@ -186,7 +186,7 @@ interface FlexObjectInterface extends FlexCommonInterface, NestedObjectInterface
* @see FlexObjectInterface::getForm()
*
* @param string $name Property name.
* @param ?string $separator Optional nested property separator.
* @param string|null $separator Optional nested property separator.
*
* @return mixed|null Returns default value of the field, null if there is no default value.
*/
@@ -208,7 +208,7 @@ interface FlexObjectInterface extends FlexCommonInterface, NestedObjectInterface
*
* @param string $name Property name.
* @param mixed $default Default value.
* @param ?string $separator Optional nested property separator.
* @param string|null $separator Optional nested property separator.
*
* @return mixed Returns value of the field.
*/

View File

@@ -77,7 +77,7 @@ interface FlexStorageInterface
* If you pass object or array as value, that value will be used to save I/O.
*
* @param array $rows Array of `[key => row, ...]` pairs.
* @param ?array $fetched Optional reference to store only fetched items.
* @param array|null $fetched Optional reference to store only fetched items.
*
* @return array Returns rows. Note that non-existing rows will have `null` as their value.
*/

View File

@@ -24,8 +24,6 @@ use RocketTheme\Toolbox\Event\Event;
/**
* Implements PageContentInterface.
*
* @phan-file-suppress PhanUndeclaredMethod,PhanUndeclaredConstant,PhanUndeclaredProperty,PhanTypeMismatchArgument
*/
trait PageContentTrait
{

View File

@@ -27,8 +27,6 @@ use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
/**
* Implements PageLegacyInterface
*
* @phan-file-suppress PhanUndeclaredMethod,PhanUndeclaredProperty,PhanParamSignatureMismatch
*/
trait PageLegacyTrait
{

View File

@@ -19,8 +19,6 @@ use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
/**
* Implements PageRoutableInterface
*
* @phan-file-suppress PhanUndeclaredMethod
*/
trait PageRoutableTrait
{
@@ -265,7 +263,7 @@ trait PageRoutableTrait
* Gets and sets the path to the folder where the .md for this Page object resides.
* This is equivalent to the filePath but without the filename.
*
* @param ?string $var the path
* @param string|null $var the path
* @return string|null the path
*/
public function path($var = null): ?string
@@ -336,7 +334,7 @@ trait PageRoutableTrait
/**
* Gets and Sets the parent object for this page
*
* @param ?PageInterface $var the parent page object
* @param PageInterface|null $var the parent page object
* @return PageInterface|null the parent page object if it exists.
*/
public function parent(PageInterface $var = null)

View File

@@ -16,8 +16,6 @@ use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
/**
* Implements PageTranslateInterface
*
* @phan-file-suppress PhanUndeclaredMethod
*/
trait PageTranslateTrait
{

View File

@@ -18,7 +18,6 @@ use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
/**
* Implements basic ACL
* @phan-file-suppress PhanPossiblyUndeclaredMethod,PhanPluginPrintfVariableFormatString
*/
trait FlexAuthorizeTrait
{

View File

@@ -27,8 +27,6 @@ use RuntimeException;
/**
* Implements Grav Page content and header manipulation methods.
*
* @phan-file-suppress PhanUndeclaredMethod,PhanUnanalyzableInheritance
*/
trait FlexMediaTrait
{
@@ -63,7 +61,6 @@ trait FlexMediaTrait
/**
* @return MediaCollectionInterface
* @suppress PhanTypeMismatchArgumentNullable - assuming MediumFactory::fromUploadedFile($upload) will not return null here
*/
public function getMedia()
{
@@ -92,7 +89,9 @@ trait FlexMediaTrait
return $this->media;
}
/** @suppress PhanPluginPrintfVariableFormatString */
/**
* @param UploadedFileInterface $uploadedFile
*/
public function checkUploadedMediaFile(UploadedFileInterface $uploadedFile)
{
$grav = Grav::instance();
@@ -175,7 +174,7 @@ trait FlexMediaTrait
try {
// Upload it
$filepath = sprintf('%s/%s', $path, $filename ?? '');
$filepath = sprintf('%s/%s', $path, $filename);
Folder::create(\dirname($filepath));
if ($uploadedFile instanceof FormFlashFile) {
$metadata = $uploadedFile->getMetaData();

View File

@@ -496,10 +496,10 @@ class FormFlash implements FormFlashInterface
}
/**
* @param ?string $field
* @param string|null $field
* @param string $name
* @param array $data
* @param ?array $crop
* @param array|null $crop
*/
protected function addFileInternal(?string $field, string $name, array $data, array $crop = null): void
{

View File

@@ -139,7 +139,7 @@ interface FormFlashInterface extends \JsonSerializable
*
* @param string $filename
* @param string $field
* @param ?array $crop
* @param array|null $crop
* @return bool
*/
public function addFile(string $filename, string $field, array $crop = null): bool;
@@ -148,7 +148,7 @@ interface FormFlashInterface extends \JsonSerializable
* Remove any file from form flash.
*
* @param string $name
* @param ?string $field
* @param string|null $field
* @return bool
*/
public function removeFile(string $name, string $field = null): bool;

View File

@@ -131,14 +131,14 @@ interface FormInterface extends RenderInterface, \Serializable
/**
* @param ServerRequestInterface $request
* @return FormInterface
* @return $this
*/
public function handleRequest(ServerRequestInterface $request): FormInterface;
/**
* @param array $data
* @param ?UploadedFileInterface[] $files
* @return FormInterface
* @param UploadedFileInterface[]|null $files
* @return $this
*/
public function submit(array $data, array $files = null): FormInterface;

View File

@@ -32,7 +32,6 @@ use Twig\TemplateWrapper;
/**
* Trait FormTrait
* @package Grav\Framework\Form
* @phan-file-suppress PhanTypeMismatchReturn
*/
trait FormTrait
{
@@ -175,7 +174,7 @@ trait FormTrait
/**
* @param ServerRequestInterface $request
* @return FormInterface
* @return FormInterface|$this
*/
public function handleRequest(ServerRequestInterface $request): FormInterface
{
@@ -207,7 +206,7 @@ trait FormTrait
/**
* @param ServerRequestInterface $request
* @return FormInterface
* @return FormInterface|$this
*/
public function setRequest(ServerRequestInterface $request): FormInterface
{
@@ -265,8 +264,8 @@ trait FormTrait
/**
* @param array $data
* @param ?UploadedFileInterface[] $files
* @return FormInterface
* @param UploadedFileInterface[]|null $files
* @return FormInterface|$this
*/
public function submit(array $data, array $files = null): FormInterface
{
@@ -409,7 +408,6 @@ trait FormTrait
/**
* {@inheritdoc}
* @see FormInterface::render()
* @suppress PhanAccessMethodInternal - Twig render() is marked as internal
*/
public function render(string $layout = null, array $context = [])
{
@@ -640,7 +638,6 @@ trait FormTrait
* Validate uploaded file.
*
* @param UploadedFileInterface $file
* @suppress PhanPluginPrintfVariableFormatString
*/
protected function validateUpload(UploadedFileInterface $file): void
{

View File

@@ -14,6 +14,4 @@ namespace Grav\Framework\Media\Interfaces;
*/
interface MediaObjectInterface
{
/** @var string */
public $type;
}

View File

@@ -31,10 +31,9 @@ trait NestedPropertyTrait
/**
* @param string $property Object property to be fetched.
* @param ?mixed $default Default value if property has not been set.
* @param ?string $separator Separator, defaults to '.'
* @param mixed|null $default Default value if property has not been set.
* @param string|null $separator Separator, defaults to '.'
* @return mixed Property value.
* @suppress PhanUndeclaredMethod
*/
public function getNestedProperty($property, $default = null, $separator = null)
{

View File

@@ -14,7 +14,6 @@ use Grav\Framework\Object\Interfaces\ObjectInterface;
/**
* ObjectCollection Trait
* @package Grav\Framework\Object
* @phan-file-suppress PhanUndeclaredMethod
*/
trait ObjectCollectionTrait
{
@@ -322,10 +321,9 @@ trait ObjectCollectionTrait
* Group items in the collection by a field and return them as associated array.
*
* @param string $property
* @param ?string $separator
* @return array
*/
public function group($property, $separator = null)
public function group($property)
{
$list = [];

View File

@@ -13,7 +13,6 @@ namespace Grav\Framework\Object\Base;
* Object trait.
*
* @package Grav\Framework\Object
* @phan-file-suppress PhanUndeclaredMethod
*/
trait ObjectTrait
{

View File

@@ -94,7 +94,7 @@ class ObjectExpressionVisitor extends ClosureExpressionVisitor
*
* @param string $name
* @param int $orientation
* @param ?\Closure $next
* @param \Closure|null $next
*
* @return \Closure
*/

View File

@@ -50,7 +50,7 @@ trait ArrayPropertyTrait
* @param bool $doCreate Set true to create variable.
* @return mixed Property value.
*/
public function &doGetProperty($property, $default = null, $doCreate = false)
protected function &doGetProperty($property, $default = null, $doCreate = false)
{
if (!array_key_exists($property, $this->_elements)) {
if ($doCreate) {

View File

@@ -31,7 +31,7 @@ trait ObjectPropertyTrait
/**
* @param array $elements
* @param ?string $key
* @param string|null $key
* @throws \InvalidArgumentException
*/
public function __construct(array $elements = [], $key = null)

View File

@@ -220,7 +220,7 @@ class AbstractPagination implements PaginationInterface
}
/**
* @param ?int $start
* @param int|null $start
* @return $this
*/
protected function setStart(int $start = null)

View File

@@ -50,7 +50,7 @@ class Response implements ResponseInterface
* response to the client.
*
* @param mixed $data The data
* @param ?int $status The HTTP status code.
* @param int|null $status The HTTP status code.
* @param int $options Json encoding options
* @param int $depth Json encoding max depth
* @return static

View File

@@ -16,7 +16,6 @@ use Psr\Http\Message\StreamInterface;
/**
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
* @phan-file-suppress PhanTypeInvalidTraitReturn,PhanParamSignatureMismatch
*/
trait MessageDecoratorTrait
{

View File

@@ -16,7 +16,6 @@ use Psr\Http\Message\UriInterface;
/**
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
* @phan-file-suppress PhanTypeInvalidTraitReturn,PhanParamSignatureMismatch
*/
trait RequestDecoratorTrait
{

View File

@@ -7,8 +7,6 @@ declare(strict_types=1);
*
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*
* @phan-file-suppress PhanUnanalyzableInheritance
*/
namespace Grav\Framework\Psr7\Traits;

View File

@@ -7,8 +7,6 @@ declare(strict_types=1);
*
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*
* @phan-file-suppress PhanTypeMismatchReturn
*/
namespace Grav\Framework\Psr7\Traits;

View File

@@ -31,7 +31,6 @@ trait RequestHandlerTrait
/**
* {@inheritdoc}
* @throws InvalidArgumentException
* @suppress PhanTypeMismatchArgument - $this in a trait can't be statically determined
*/
public function handle(ServerRequestInterface $request): ResponseInterface
{

View File

@@ -41,7 +41,7 @@ class PagesTest extends \Codeception\TestCase\Test
$this->pages->base('/test');
$this->assertSame('/test', $this->pages->base());
$this->pages->base('');
$this->assertNull($this->pages->base());
$this->assertSame($this->pages->base(), '');
}
public function testLastModified()
@@ -126,7 +126,6 @@ class PagesTest extends \Codeception\TestCase\Test
$this->assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
}
/** @suppress PhanAccessMethodInternal - sortCollection() is internal */
public function testSortCollection()
{
/** @var UniformResourceLocator $locator */

View File

@@ -62,7 +62,7 @@ class TwigExtensionTest extends \Codeception\TestCase\Test
$threeYears = time() - (60*60*24*365*3);
$measures = ['minutes','hours','days','months','years'];
$this->assertSame('No date provided', $this->twig_ext->nicetimeFunc(''));
$this->assertSame('No date provided', $this->twig_ext->nicetimeFunc(null));
for ($i=0; $i<count($measures); $i++) {
$time = 'three' . ucfirst($measures[$i]);