Add a .phan config file and stubs for Phan static analysis

I fixed some small inconsistencies here and there. There are still
a little over 200 to go. This time against the 1.7 branch.

To try it, checkout this PR and run:
composer require phan/phan
It doesn't have to be in the Grav tree. You can install it anywhere.
Then from the top-level Grav dir:
/vendor/bin/phan -p

You can see the ones that are left to address here:
https://gist.github.com/69eac9b37ced1cadc08ed4be0ee84f40

Also, and the main reason I added it, was to get some nice
dependency graphs from Phan to help me understand the Grav code. Some
examples:
http://pdep.lerdorf.com/?mode=class&node=\Grav\Common\File\CompiledFile&d=3
http://pdep.lerdorf.com/?mode=class&node=\Grav\Common\Filesystem\Folder&d=1
http://pdep.lerdorf.com/?mode=class&node=\Doctrine\Common\Cache\Cache&d=2
http://pdep.lerdorf.com/?mode=class&node=\RocketTheme\Toolbox\ArrayTraits\Export&d=1

Move the slider to change the number of dependency levels shown.
This commit is contained in:
Rasmus Lerdorf
2019-10-16 10:38:08 -07:00
parent d568ddfa5c
commit 32a9acc62e
101 changed files with 7188 additions and 154 deletions

44
.phan/config.php Normal file
View File

@@ -0,0 +1,44 @@
<?php
return [
"target_php_version" => null,
'pretend_newer_core_functions_exist' => true,
'allow_missing_properties' => false,
'null_casts_as_any_type' => false,
'null_casts_as_array' => false,
'array_casts_as_null' => false,
'strict_method_checking' => true,
'quick_mode' => false,
'simplify_ast' => false,
'directory_list' => [
'.',
],
"exclude_analysis_directory_list" => [
'vendor/'
],
'exclude_file_list' => [
'system/src/Grav/Common/Errors/Resources/layout.html.php',
'tests/_support/AcceptanceTester.php',
'tests/_support/FunctionalTester.php',
'tests/_support/UnitTester.php',
],
'autoload_internal_extension_signatures' => [
'memcached' => '.phan/internal_stubs/memcached.phan_php',
'memcache' => '.phan/internal_stubs/memcache.phan_php',
'redis' => '.phan/internal_stubs/Redis.phan_php',
],
'plugins' => [
'AlwaysReturnPlugin',
'UnreachableCodePlugin',
'DuplicateArrayKeyPlugin',
'PregRegexCheckerPlugin',
'PrintfCheckerPlugin',
],
'suppress_issue_types' => [
'PhanUnreferencedUseNormal',
'PhanTypeObjectUnsetDeclaredProperty',
'PhanTraitParentReference',
'PhanTypeInvalidThrowsIsInterface',
'PhanRequiredTraitNotAdded',
'PhanDeprecatedFunction', // Uncomment this to see all the deprecated calls
]
];

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,460 @@
<?php
// Start of memcache v.3.0.8
class MemcachePool {
/**
* (PECL memcache &gt;= 0.2.0)<br/>
* Open memcached server connection
* @link https://php.net/manual/en/memcache.connect.php
* @param string $host <p>
* Point to the host where memcached is listening for connections. This parameter
* may also specify other transports like <em>unix:///path/to/memcached.sock</em>
* to use UNIX domain sockets, in this case <b>port</b> must also
* be set to <em>0</em>.
* </p>
* @param int $port [optional] <p>
* Point to the port where memcached is listening for connections. Set this
* parameter to <em>0</em> when using UNIX domain sockets.
* </p>
* <p>
* Please note: <b>port</b> defaults to
* {@link https://php.net/manual/ru/memcache.ini.php#ini.memcache.default-port memcache.default_port}
* if not specified. For this reason it is wise to specify the port
* explicitly in this method call.
* </p>
* @param int $timeout [optional] <p>Value in seconds which will be used for connecting to the daemon. Think twice before changing the default value of 1 second - you can lose all the advantages of caching if your connection is too slow.</p>
* @return bool <p>Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.</p>
*/
public function connect ($host, $port, $timeout = 1) {}
/**
* (PECL memcache &gt;= 2.0.0)<br/>
* Add a memcached server to connection pool
* @link https://php.net/manual/en/memcache.addserver.php
* @param string $host <p>
* Point to the host where memcached is listening for connections. This parameter
* may also specify other transports like unix:///path/to/memcached.sock
* to use UNIX domain sockets, in this case <i>port</i> must also
* be set to 0.
* </p>
* @param int $port [optional] <p>
* Point to the port where memcached is listening for connections.
* Set this
* parameter to 0 when using UNIX domain sockets.
* </p>
* <p>
* Please note: <i>port</i> defaults to
* memcache.default_port
* if not specified. For this reason it is wise to specify the port
* explicitly in this method call.
* </p>
* @param bool $persistent [optional] <p>
* Controls the use of a persistent connection. Default to <b>TRUE</b>.
* </p>
* @param int $weight [optional] <p>
* Number of buckets to create for this server which in turn control its
* probability of it being selected. The probability is relative to the
* total weight of all servers.
* </p>
* @param int $timeout [optional] <p>
* Value in seconds which will be used for connecting to the daemon. Think
* twice before changing the default value of 1 second - you can lose all
* the advantages of caching if your connection is too slow.
* </p>
* @param int $retry_interval [optional] <p>
* Controls how often a failed server will be retried, the default value
* is 15 seconds. Setting this parameter to -1 disables automatic retry.
* Neither this nor the <i>persistent</i> parameter has any
* effect when the extension is loaded dynamically via <b>dl</b>.
* </p>
* <p>
* Each failed connection struct has its own timeout and before it has expired
* the struct will be skipped when selecting backends to serve a request. Once
* expired the connection will be successfully reconnected or marked as failed
* for another <i>retry_interval</i> seconds. The typical
* effect is that each web server child will retry the connection about every
* <i>retry_interval</i> seconds when serving a page.
* </p>
* @param bool $status [optional] <p>
* Controls if the server should be flagged as online. Setting this parameter
* to <b>FALSE</b> and <i>retry_interval</i> to -1 allows a failed
* server to be kept in the pool so as not to affect the key distribution
* algorithm. Requests for this server will then failover or fail immediately
* depending on the <i>memcache.allow_failover</i> setting.
* Default to <b>TRUE</b>, meaning the server should be considered online.
* </p>
* @param callable $failure_callback [optional] <p>
* Allows the user to specify a callback function to run upon encountering an
* error. The callback is run before failover is attempted. The function takes
* two parameters, the hostname and port of the failed server.
* </p>
* @param int $timeoutms [optional] <p>
* </p>
* @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure.
*/
public function addServer ($host, $port = 11211, $persistent = true, $weight = null, $timeout = 1, $retry_interval = 15, $status = true, callable $failure_callback = null, $timeoutms = null) {}
/**
* (PECL memcache &gt;= 2.1.0)<br/>
* Changes server parameters and status at runtime
* @link https://secure.php.net/manual/en/memcache.setserverparams.php
* @param string $host <p>Point to the host where memcached is listening for connections.</p.
* @param int $port [optional] <p>
* Point to the port where memcached is listening for connections.
* </p>
* @param int $timeout [optional] <p>
* Value in seconds which will be used for connecting to the daemon. Think twice before changing the default value of 1 second - you can lose all the advantages of caching if your connection is too slow.
* </p>
* @param int $retry_interval [optional] <p>
* Controls how often a failed server will be retried, the default value
* is 15 seconds. Setting this parameter to -1 disables automatic retry.
* Neither this nor the <b>persistent</b> parameter has any
* effect when the extension is loaded dynamically via {@link https://secure.php.net/manual/en/function.dl.php dl()}.
* </p>
* @param bool $status [optional] <p>
* Controls if the server should be flagged as online. Setting this parameter
* to <b>FALSE</b> and <b>retry_interval</b> to -1 allows a failed
* server to be kept in the pool so as not to affect the key distribution
* algorithm. Requests for this server will then failover or fail immediately
* depending on the <b>memcache.allow_failover</b> setting.
* Default to <b>TRUE</b>, meaning the server should be considered online.
* </p>
* @param callable $failure_callback [optional] <p>
* Allows the user to specify a callback function to run upon encountering an error. The callback is run before failover is attempted.
* The function takes two parameters, the hostname and port of the failed server.
* </p>
* @return bool <p>Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.</p>
*/
public function setServerParams ($host, $port = 11211, $timeout = 1, $retry_interval = 15, $status = true, callable $failure_callback = null) {}
/**
*
*/
public function setFailureCallback () {}
/**
* (PECL memcache &gt;= 2.1.0)<br/>
* Returns server status
* @link https://php.net/manual/en/memcache.getserverstatus.php
* @param string $host Point to the host where memcached is listening for connections.
* @param int $port Point to the port where memcached is listening for connections.
* @return int Returns a the servers status. 0 if server is failed, non-zero otherwise
*/
public function getServerStatus ($host, $port = 11211) {}
/**
*
*/
public function findServer () {}
/**
* (PECL memcache &gt;= 0.2.0)<br/>
* Return version of the server
* @link https://php.net/manual/en/memcache.getversion.php
* @return string|false Returns a string of server version number or <b>FALSE</b> on failure.
*/
public function getVersion () {}
/**
* (PECL memcache &gt;= 2.0.0)<br/>
* Add an item to the server. If the key already exists, the value will not be added and <b>FALSE</b> will be returned.
* @link https://php.net/manual/en/memcache.add.php
* @param string $key The key that will be associated with the item.
* @param mixed $var The variable to store. Strings and integers are stored as is, other types are stored serialized.
* @param int $flag [optional] <p>
* Use <b>MEMCACHE_COMPRESSED</b> to store the item
* compressed (uses zlib).
* </p>
* @param int $expire [optional] <p>Expiration time of the item.
* If it's equal to zero, the item will never expire.
* You can also use Unix timestamp or a number of seconds starting from current time, but in the latter case the number of seconds may not exceed 2592000 (30 days).</p>
* @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure. Returns <b>FALSE</b> if such key already exist. For the rest Memcache::add() behaves similarly to Memcache::set().
*/
public function add ($key , $var, $flag = null, $expire = null) {}
/**
* (PECL memcache &gt;= 0.2.0)<br/>
* Stores an item var with key on the memcached server. Parameter expire is expiration time in seconds.
* If it's 0, the item never expires (but memcached server doesn't guarantee this item to be stored all the time,
* it could be deleted from the cache to make place for other items).
* You can use MEMCACHE_COMPRESSED constant as flag value if you want to use on-the-fly compression (uses zlib).
* @link https://php.net/manual/en/memcache.set.php
* @param string $key The key that will be associated with the item.
* @param mixed $var The variable to store. Strings and integers are stored as is, other types are stored serialized.
* @param int $flag [optional] Use MEMCACHE_COMPRESSED to store the item compressed (uses zlib).
* @param int $expire [optional] Expiration time of the item. If it's equal to zero, the item will never expire. You can also use Unix timestamp or a number of seconds starting from current time, but in the latter case the number of seconds may not exceed 2592000 (30 days).
* @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.
*/
public function set ($key, $var, $flag = null, $expire = null) {}
/**
* (PECL memcache &gt;= 0.2.0)<br/>
* Replace value of the existing item
* @link https://php.net/manual/en/memcache.replace.php
* @param string $key <p>The key that will be associated with the item.</p>
* @param mixed $var <p>The variable to store. Strings and integers are stored as is, other types are stored serialized.</p>
* @param int $flag [optional] <p>Use <b>MEMCACHE_COMPRESSED</b> to store the item compressed (uses zlib).</p>
* @param int $expire [optional] <p>Expiration time of the item. If it's equal to zero, the item will never expire. You can also use Unix timestamp or a number of seconds starting from current time, but in the latter case the number of seconds may not exceed 2592000 (30 days).</p>
* @return bool Returns TRUE on success or FALSE on failure.
*/
public function replace ($key, $var, $flag = null, $expire = null) {}
public function cas () {}
public function append () {}
/**
* @return string
*/
public function prepend () {}
/**
* (PECL memcache &gt;= 0.2.0)<br/>
* Retrieve item from the server
* @link https://php.net/manual/en/memcache.get.php
* @param string|array $key <p>
* The key or array of keys to fetch.
* </p>
* @param int|array $flags [optional] <p>
* If present, flags fetched along with the values will be written to this parameter. These
* flags are the same as the ones given to for example {@link https://php.net/manual/en/memcache.set.php Memcache::set()}.
* The lowest byte of the int is reserved for pecl/memcache internal usage (e.g. to indicate
* compression and serialization status).
* </p>
* @return string|array|false <p>
* Returns the string associated with the <b>key</b> or
* an array of found key-value pairs when <b>key</b> is an {@link https://php.net/manual/en/language.types.array.php array}.
* Returns <b>FALSE</b> on failure, <b>key</b> is not found or
* <b>key</b> is an empty {@link https://php.net/manual/en/language.types.array.php array}.
* </p>
*/
public function get ($key, &$flags = null) {}
/**
* (PECL memcache &gt;= 0.2.0)<br/>
* Delete item from the server
* https://secure.php.net/manual/ru/memcache.delete.php
* @param $key string The key associated with the item to delete.
* @param $timeout int [optional] This deprecated parameter is not supported, and defaults to 0 seconds. Do not use this parameter.
* @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.
*/
public function delete ($key, $timeout = 0 ) {}
/**
* (PECL memcache &gt;= 0.2.0)<br/>
* Get statistics of the server
* @link https://php.net/manual/ru/memcache.getstats.php
* @param string $type [optional] <p>
* The type of statistics to fetch.
* Valid values are {reset, malloc, maps, cachedump, slabs, items, sizes}.
* According to the memcached protocol spec these additional arguments "are subject to change for the convenience of memcache developers".</p>
* @param int $slabid [optional] <p>
* Used in conjunction with <b>type</b> set to
* cachedump to identify the slab to dump from. The cachedump
* command ties up the server and is strictly to be used for
* debugging purposes.
* </p>
* @param int $limit [optional] <p>
* Used in conjunction with <b>type</b> set to cachedump to limit the number of entries to dump.
* </p>
* @return array|false Returns an associative array of server statistics or <b>FALSE</b> on failure.
*/
public function getStats ($type = null, $slabid = null, $limit = 100) {}
/**
* (PECL memcache &gt;= 2.0.0)<br/>
* Get statistics from all servers in pool
* @link https://php.net/manual/en/memcache.getextendedstats.php
* @param string $type [optional] <p>The type of statistics to fetch. Valid values are {reset, malloc, maps, cachedump, slabs, items, sizes}. According to the memcached protocol spec these additional arguments "are subject to change for the convenience of memcache developers".</p>
* @param int $slabid [optional] <p>
* Used in conjunction with <b>type</b> set to
* cachedump to identify the slab to dump from. The cachedump
* command ties up the server and is strictly to be used for
* debugging purposes.
* </p>
* @param int $limit Used in conjunction with type set to cachedump to limit the number of entries to dump.
* @return array|false Returns a two-dimensional associative array of server statistics or <b>FALSE</b>
* Returns a two-dimensional associative array of server statistics or <b>FALSE</b>
* on failure.
*/
public function getExtendedStats ($type = null, $slabid = null, $limit = 100) {}
/**
* (PECL memcache &gt;= 2.0.0)<br/>
* Enable automatic compression of large values
* @link https://php.net/manual/en/memcache.setcompressthreshold.php
* @param int $thresold <p>Controls the minimum value length before attempting to compress automatically.</p>
* @param float $min_saving [optional] <p>Specifies the minimum amount of savings to actually store the value compressed. The supplied value must be between 0 and 1. Default value is 0.2 giving a minimum 20% compression savings.</p>
* @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.
*/
public function setCompressThreshold ($thresold, $min_saving = 0.2) {}
/**
* (PECL memcache &gt;= 0.2.0)<br/>
* Increment item's value
* @link https://php.net/manual/en/memcache.increment.php
* @param $key string Key of the item to increment.
* @param $value int [optional] increment the item by <b>value</b>
* @return int|false Returns new items value on success or <b>FALSE</b> on failure.
*/
public function increment ($key, $value = 1) {}
/**
* (PECL memcache &gt;= 0.2.0)<br/>
* Decrement item's value
* @link https://php.net/manual/en/memcache.decrement.php
* @param $key string Key of the item do decrement.
* @param $value int Decrement the item by <b>value</b>.
* @return int|false Returns item's new value on success or <b>FALSE</b> on failure.
*/
public function decrement ($key, $value = 1) {}
/**
* (PECL memcache &gt;= 0.4.0)<br/>
* Close memcached server connection
* @link https://php.net/manual/en/memcache.close.php
* @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.
*/
public function close () {}
/**
* (PECL memcache &gt;= 1.0.0)<br/>
* Flush all existing items at the server
* @link https://php.net/manual/en/memcache.flush.php
* @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.
*/
public function flush () {}
}
/**
* Represents a connection to a set of memcache servers.
* @link https://php.net/manual/en/class.memcache.php
*/
class Memcache extends MemcachePool {
/**
* (PECL memcache &gt;= 0.4.0)<br/>
* Open memcached server persistent connection
* @link https://php.net/manual/en/memcache.pconnect.php
* @param string $host <p>
* Point to the host where memcached is listening for connections. This parameter
* may also specify other transports like unix:///path/to/memcached.sock
* to use UNIX domain sockets, in this case <i>port</i> must also
* be set to 0.
* </p>
* @param int $port [optional] <p>
* Point to the port where memcached is listening for connections. Set this
* parameter to 0 when using UNIX domain sockets.
* </p>
* @param int $timeout [optional] <p>
* Value in seconds which will be used for connecting to the daemon. Think
* twice before changing the default value of 1 second - you can lose all
* the advantages of caching if your connection is too slow.
* </p>
* @return mixed a Memcache object or <b>FALSE</b> on failure.
*/
public function pconnect ($host, $port, $timeout = 1) {}
}
// string $host [, int $port [, int $timeout ]]
/**
* (PECL memcache >= 0.2.0)</br>
* Memcache::connect — Open memcached server connection
* @link https://php.net/manual/en/memcache.connect.php
* @param string $host <p>
* Point to the host where memcached is listening for connections.
* This parameter may also specify other transports like
* unix:///path/to/memcached.sock to use UNIX domain sockets,
* in this case port must also be set to 0.
* </p>
* @param int $port [optional] <p>
* Point to the port where memcached is listening for connections.
* Set this parameter to 0 when using UNIX domain sockets.
* Note: port defaults to memcache.default_port if not specified.
* For this reason it is wise to specify the port explicitly in this method call.
* </p>
* @param int $timeout [optional] <p>
* Value in seconds which will be used for connecting to the daemon.
* </p>
* @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.
*/
function memcache_connect ($host, $port, $timeout = 1) {}
/**
* (PECL memcache >= 0.4.0)
* Memcache::pconnect — Open memcached server persistent connection
*
* @link https://php.net/manual/en/memcache.pconnect.php#example-5242
* @param $host
* @param null $port
* @param int $timeout
* @return Memcache
*/
function memcache_pconnect ($host, $port=null, $timeout=1) {}
function memcache_add_server () {}
function memcache_set_server_params () {}
function memcache_set_failure_callback () {}
function memcache_get_server_status () {}
function memcache_get_version () {}
function memcache_add () {}
function memcache_set () {}
function memcache_replace () {}
function memcache_cas () {}
function memcache_append () {}
function memcache_prepend () {}
function memcache_get () {}
function memcache_delete () {}
/**
* (PECL memcache &gt;= 0.2.0)<br/>
* Turn debug output on/off
* @link https://php.net/manual/en/function.memcache-debug.php
* @param bool $on_off <p>
* Turns debug output on if equals to <b>TRUE</b>.
* Turns debug output off if equals to <b>FALSE</b>.
* </p>
* @return bool <b>TRUE</b> if PHP was built with --enable-debug option, otherwise
* returns <b>FALSE</b>.
*/
function memcache_debug ($on_off) {}
function memcache_get_stats () {}
function memcache_get_extended_stats () {}
function memcache_set_compress_threshold () {}
function memcache_increment () {}
function memcache_decrement () {}
function memcache_close () {}
function memcache_flush () {}
define ('MEMCACHE_COMPRESSED', 2);
define ('MEMCACHE_USER1', 65536);
define ('MEMCACHE_USER2', 131072);
define ('MEMCACHE_USER3', 262144);
define ('MEMCACHE_USER4', 524288);
define ('MEMCACHE_HAVE_SESSION', 1);
// End of memcache v.3.0.8
?>

File diff suppressed because it is too large Load Diff

View File

@@ -162,7 +162,7 @@ abstract class BaseAsset extends PropertyObject
* *
* @param string $asset the asset string reference * @param string $asset the asset string reference
* *
* @return string the final link url to the asset * @return string|false the final link url to the asset
*/ */
protected function buildLocalLink($asset) protected function buildLocalLink($asset)
{ {

View File

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

View File

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

View File

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

View File

@@ -159,7 +159,7 @@ class Backups
$date = date(static::BACKUP_DATE_FORMAT, time()); $date = date(static::BACKUP_DATE_FORMAT, time());
$filename = trim($name, '_') . '--' . $date . '.zip'; $filename = trim($name, '_') . '--' . $date . '.zip';
$destination = static::$backup_dir . DS . $filename; $destination = static::$backup_dir . DS . $filename;
$max_execution_time = ini_set('max_execution_time', 600); $max_execution_time = ini_set('max_execution_time', '600');
$backup_root = $backup->root; $backup_root = $backup->root;
if ($locator->isStream($backup_root)) { if ($locator->isStream($backup_root)) {

View File

@@ -108,7 +108,7 @@ class Browser
/** /**
* Get the current major version identifier * Get the current major version identifier
* *
* @return string the browser major version identifier * @return int the browser major version identifier
*/ */
public function getVersion() public function getVersion()
{ {

View File

@@ -26,7 +26,7 @@ class Composer
} }
// check for global composer install // check for global composer install
$path = trim(shell_exec('command -v composer')); $path = trim((string)shell_exec('command -v composer'));
// fall back to grav bundled composer // fall back to grav bundled composer
if (!$path || !preg_match('/(composer|composer\.phar)$/', $path)) { if (!$path || !preg_match('/(composer|composer\.phar)$/', $path)) {

View File

@@ -29,7 +29,7 @@ abstract class CompiledBase
public $checksum; public $checksum;
/** /**
* @var string Timestamp of compiled configuration * @var int Timestamp of compiled configuration
*/ */
public $timestamp; public $timestamp;
@@ -159,7 +159,7 @@ abstract class CompiledBase
* Load single configuration file and append it to the correct position. * Load single configuration file and append it to the correct position.
* *
* @param string $name Name of the position. * @param string $name Name of the position.
* @param string $filename File to be loaded. * @param string|string[] $filename File(s) to be loaded.
*/ */
abstract protected function loadFile($name, $filename); abstract protected function loadFile($name, $filename);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -45,7 +45,7 @@ class Package
public function __set($key, $value) public function __set($key, $value)
{ {
return $this->data->set($key, $value); $this->data->set($key, $value);
} }
public function __isset($key) public function __isset($key)

View File

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

View File

@@ -40,7 +40,7 @@ class Installer
protected static $target; protected static $target;
/** /**
* @var int Error Code * @var int|string Error code or string
*/ */
protected static $error = 0; protected static $error = 0;

View File

@@ -15,6 +15,7 @@ use \Doctrine\Common\Cache\FilesystemCache;
class GravCore extends AbstractPackageCollection class GravCore extends AbstractPackageCollection
{ {
protected $repository = 'https://getgrav.org/downloads/grav.json'; protected $repository = 'https://getgrav.org/downloads/grav.json';
/** @var array */
private $data; private $data;
private $version; private $version;
@@ -23,7 +24,7 @@ class GravCore extends AbstractPackageCollection
/** /**
* @param bool $refresh * @param bool $refresh
* @param null $callback * @param ?callable $callback
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function __construct($refresh = false, $callback = null) public function __construct($refresh = false, $callback = null)

View File

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

View File

@@ -109,7 +109,7 @@ class Upgrader
/** /**
* Get minimum PHP version from remote * Get minimum PHP version from remote
* *
* @return null * @return string
*/ */
public function minPHPVersion() public function minPHPVersion()
{ {

View File

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

View File

@@ -132,7 +132,7 @@ class Truncator
/** /**
* Builds a DOMDocument object from a string containing HTML. * Builds a DOMDocument object from a string containing HTML.
* @param string $html HTML to load * @param string $html HTML to load
* @returns DOMDocument Returns a DOMDocument object. * @return DOMDocument Returns a DOMDocument object.
*/ */
public static function htmlToDomDocument($html) public static function htmlToDomDocument($html)
{ {

View File

@@ -247,7 +247,6 @@ class Iterator implements \ArrayAccess, \Iterator, \Countable, \Serializable
* @param bool $desc * @param bool $desc
* *
* @return $this|array * @return $this|array
* @internal param bool $asc
* *
*/ */
public function sort(callable $callback = null, $desc = false) public function sort(callable $callback = null, $desc = false)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -25,9 +25,10 @@ class Excerpts
/** @var array */ /** @var array */
protected $config; protected $config;
/** @suppress PhanPossiblyNullTypeMismatchProperty - hopefully Grav::instance()['page'] can't be null here */
public function __construct(PageInterface $page = null, array $config = null) public function __construct(PageInterface $page = null, array $config = null)
{ {
$this->page = $page ?? Grav::instance()['page'] ?? null; $this->page = $page ?? Grav::instance()['page'];
// Add defaults to the configuration. // Add defaults to the configuration.
if (null === $config || !isset($config['markdown'], $config['images'])) { if (null === $config || !isset($config['markdown'], $config['images'])) {
@@ -108,7 +109,7 @@ class Excerpts
} }
} }
$url_parts['query'] = http_build_query($actions, null, '&', PHP_QUERY_RFC3986); $url_parts['query'] = http_build_query($actions, '', '&', PHP_QUERY_RFC3986);
} }
// If no query elements left, unset query. // If no query elements left, unset query.

View File

@@ -25,7 +25,7 @@ class Media extends AbstractMedia
/** /**
* @param string $path * @param string $path
* @param array $media_order * @param ?array $media_order
* @param bool $load * @param bool $load
*/ */
public function __construct($path, array $media_order = null, $load = true) public function __construct($path, array $media_order = null, $load = true)
@@ -118,7 +118,7 @@ class Media extends AbstractMedia
foreach ($types['alternative'] as $ratio => &$alt) { foreach ($types['alternative'] as $ratio => &$alt) {
$alt['file'] = MediumFactory::fromFile($alt['file']); $alt['file'] = MediumFactory::fromFile($alt['file']);
if (!$alt['file']) { if (empty($alt['file'])) {
unset($types['alternative'][$ratio]); unset($types['alternative'][$ratio]);
} else { } else {
$alt['file']->set('size', $alt['size']); $alt['file']->set('size', $alt['size']);
@@ -142,7 +142,7 @@ class Media extends AbstractMedia
} else { } else {
$medium = MediumFactory::fromFile($types['base']['file']); $medium = MediumFactory::fromFile($types['base']['file']);
$medium && $medium->set('size', $types['base']['size']); $medium && $medium->set('size', $types['base']['size']);
$file_path = $medium->path(); $file_path = $medium ? $medium->path() : null;
} }
if (empty($medium)) { if (empty($medium)) {

View File

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

View File

@@ -110,7 +110,7 @@ class ImageFile extends Image
* @param string $type * @param string $type
* @param int $quality * @param int $quality
* @param array $extras * @param array $extras
* @return null * @return string
*/ */
public function getHash($type = 'guess', $quality = 80, $extras = []) public function getHash($type = 'guess', $quality = 80, $extras = [])
{ {

View File

@@ -76,7 +76,7 @@ class ImageMedium extends Medium
* Construct. * Construct.
* *
* @param array $items * @param array $items
* @param Blueprint $blueprint * @param ?Blueprint $blueprint
*/ */
public function __construct($items = [], Blueprint $blueprint = null) public function __construct($items = [], Blueprint $blueprint = null)
{ {
@@ -625,16 +625,19 @@ class ImageMedium extends Medium
/** /**
* Filter image by using user defined filter parameters. * Filter image by using user defined filter parameters.
* *
* @param string $filter Filter to be used. * @param mixed ...$args Filter to be used - varags to be compatible with parent
* @return $this
*/ */
public function filter($filter = 'image.filters.default') public function filter(...$args)
{ {
$filter = $args[0] ?? 'image.filters.default';
$filters = (array) $this->get($filter, []); $filters = (array) $this->get($filter, []);
foreach ($filters as $params) { foreach ($filters as $params) {
$params = (array) $params; $params = (array) $params;
$method = array_shift($params); $method = array_shift($params);
$this->__call($method, $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 * Get an element (is array) that can be rendered by the Parsedown engine
* *
* @param string $title * @param ?string $title
* @param string $alt * @param ?string $alt
* @param string $class * @param ?string $class
* @param string $id * @param ?string $id
* @param bool $reset * @param bool $reset
* @return array * @return array
*/ */

View File

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

View File

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

View File

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

View File

@@ -14,23 +14,24 @@ interface RenderableInterface
/** /**
* Return HTML markup from the medium. * Return HTML markup from the medium.
* *
* @param string $title * @param ?string $title
* @param string $alt * @param ?string $alt
* @param string $class * @param ?string $class
* @param ?string $id
* @param bool $reset * @param bool $reset
* @return string * @return string
*/ */
public function html($title = null, $alt = null, $class = null, $reset = true); public function html($title = null, $alt = null, $class = null, $id = null, $reset = true);
/** /**
* Return Parsedown Element from the medium. * Return Parsedown Element from the medium.
* *
* @param string $title * @param ?string $title
* @param string $alt * @param ?string $alt
* @param string $class * @param ?string $class
* @param string $id * @param ?string $id
* @param bool $reset * @param bool $reset
* @return string * @return array
*/ */
public function parsedownElement($title = null, $alt = null, $class = null, $id = null, $reset = true); public function parsedownElement($title = null, $alt = null, $class = null, $id = null, $reset = true);
} }

View File

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

View File

@@ -35,10 +35,10 @@ class ThumbnailImageMedium extends ImageMedium
/** /**
* Get an element (is array) that can be rendered by the Parsedown engine * Get an element (is array) that can be rendered by the Parsedown engine
* *
* @param string $title * @param ?string $title
* @param string $alt * @param ?string $alt
* @param string $class * @param ?string $class
* @param string $id * @param ?string $id
* @param bool $reset * @param bool $reset
* @return array * @return array
*/ */
@@ -50,10 +50,10 @@ class ThumbnailImageMedium extends ImageMedium
/** /**
* Return HTML markup from the medium. * Return HTML markup from the medium.
* *
* @param string $title * @param ?string $title
* @param string $alt * @param ?string $alt
* @param string $class * @param ?string $class
* @param string $id * @param ?string $id
* @param bool $reset * @param bool $reset
* @return string * @return string
*/ */
@@ -119,7 +119,7 @@ class ThumbnailImageMedium extends ImageMedium
* @param string $method * @param string $method
* @param array $arguments * @param array $arguments
* @param bool $testLinked * @param bool $testLinked
* @return Medium * @return Medium|Link|array
*/ */
protected function bubble($method, array $arguments = [], $testLinked = true) protected function bubble($method, array $arguments = [], $testLinked = true)
{ {

View File

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

View File

@@ -921,6 +921,7 @@ class Pages
* @param string $type * @param string $type
* *
* @return Blueprint * @return Blueprint
* @suppress PhanTypeMismatchArgument
*/ */
public function blueprints($type) public function blueprints($type)
{ {
@@ -945,7 +946,7 @@ class Pages
/** /**
* Get all pages * Get all pages
* *
* @param PageInterface $current * @param ?PageInterface $current
* *
* @return Collection * @return Collection
*/ */
@@ -1014,7 +1015,7 @@ class Pages
/** /**
* Get list of route/title of all pages. * Get list of route/title of all pages.
* *
* @param PageInterface $current * @param ?PageInterface $current
* @param int $level * @param int $level
* @param bool $rawRoutes * @param bool $rawRoutes
* *
@@ -1856,7 +1857,7 @@ class Pages
if (!$child_header instanceof Header) { if (!$child_header instanceof Header) {
$child_header = new Header((array)$child_header); $child_header = new Header((array)$child_header);
} }
$header_value = $child_header->get($header_query); $header_value = $child_header->get((string)$header_query);
if (is_array($header_value)) { if (is_array($header_value)) {
$list[$key] = implode(',', $header_value); $list[$key] = implode(',', $header_value);
} elseif ($header_value) { } elseif ($header_value) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -29,6 +29,7 @@ class TwigTokenParserThrow extends AbstractTokenParser
* @param Token $token A Twig Token instance * @param Token $token A Twig Token instance
* *
* @return Node A Twig Node instance * @return Node A Twig Node instance
* @suppress PhanAccessMethodInternal - parseExpression() is marked as Twig-internal
*/ */
public function parse(Token $token) public function parse(Token $token)
{ {
@@ -39,7 +40,7 @@ class TwigTokenParserThrow extends AbstractTokenParser
$message = $this->parser->getExpressionParser()->parseExpression(); $message = $this->parser->getExpressionParser()->parseExpression();
$stream->expect(Token::BLOCK_END_TYPE); $stream->expect(Token::BLOCK_END_TYPE);
return new TwigNodeThrow($code, $message, $lineno, $this->getTag()); return new TwigNodeThrow((int)$code, $message, $lineno, $this->getTag());
} }
/** /**

View File

@@ -44,7 +44,7 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
/** @var Grav */ /** @var Grav */
protected $grav; protected $grav;
/** @var Debugger */ /** @var ?Debugger */
protected $debugger; protected $debugger;
/** @var Config */ /** @var Config */
@@ -453,7 +453,8 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
* @param string $haystack * @param string $haystack
* @param string $needle * @param string $needle
* *
* @return bool * @return string|bool
* @todo returning $haystack here doesn't make much sense
*/ */
public function containsFilter($haystack, $needle) public function containsFilter($haystack, $needle)
{ {
@@ -620,9 +621,8 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
} }
/** /**
* @param string $string
*
* @param array $context * @param array $context
* @param string $string
* @param bool $block Block or Line processing * @param bool $block Block or Line processing
* @return mixed|string * @return mixed|string
*/ */
@@ -667,22 +667,22 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
/** /**
* @param string $value * @param string $value
* @param null $chars * @param string $chars
* *
* @return string * @return string
*/ */
public function rtrimFilter($value, $chars = null) public function rtrimFilter($value, $chars = '')
{ {
return rtrim($value, $chars); return rtrim($value, $chars);
} }
/** /**
* @param string $value * @param string $value
* @param null $chars * @param string $chars
* *
* @return string * @return string
*/ */
public function ltrimFilter($value, $chars = null) public function ltrimFilter($value, $chars = '')
{ {
return ltrim($value, $chars); return ltrim($value, $chars);
} }
@@ -698,7 +698,6 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
return (string) $input; return (string) $input;
} }
/** /**
* Casts input to int. * Casts input to int.
* *
@@ -967,7 +966,7 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
* *
* @param array $array1 * @param array $array1
* @param array $array2 * @param array $array2
* @return array * @return array|Collection
*/ */
public function arrayIntersectFunc($array1, $array2) public function arrayIntersectFunc($array1, $array2)
{ {
@@ -1406,6 +1405,8 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
* @param string|null $typeTest * @param string|null $typeTest
* @param string|null $className * @param string|null $className
* @return bool * @return bool
*
* @suppress PhanPluginUnreachableCode
*/ */
public function ofTypeFunc($var, $typeTest = null, $className = null) public function ofTypeFunc($var, $typeTest = null, $className = null)
{ {

View File

@@ -213,7 +213,7 @@ class Uri
/** /**
* Return URI path. * Return URI path.
* *
* @param string $id * @param int $id
* *
* @return string|string[] * @return string|string[]
*/ */

View File

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

View File

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

View File

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

View File

@@ -175,7 +175,7 @@ class SelfupgradeCommand extends ConsoleCommand
} }
// clear cache after successful upgrade // clear cache after successful upgrade
$this->clearCache('all'); $this->clearCache(['all']);
} }
/** /**

View File

@@ -303,7 +303,7 @@ trait CacheTrait
} }
if (\strlen($key) > 64) { if (\strlen($key) > 64) {
throw new InvalidArgumentException( throw new InvalidArgumentException(
sprintf('Cache key length must be less than 65 characters, key had %s characters', \strlen($key)) sprintf('Cache key length must be less than 65 characters, key had %d characters', \strlen($key))
); );
} }
if (strpbrk($key, '{}()/\@:') !== false) { if (strpbrk($key, '{}()/\@:') !== false) {

View File

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

View File

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

View File

@@ -87,7 +87,7 @@ class Flex implements \Countable
} }
/** /**
* @param array|string[] $types * @param array|string[]|null $types
* @param bool $keepMissing * @param bool $keepMissing
* @return array<FlexDirectory|null> * @return array<FlexDirectory|null>
*/ */

View File

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

View File

@@ -420,6 +420,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
* @see FlexObjectInterface::render() * @see FlexObjectInterface::render()
* @suppress PhanAccessMethodInternal - the render() call is marked internal in Twig
*/ */
public function render(string $layout = null, array $context = []) 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 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 $directory Flex Directory where all the objects belong into.
* @param string $keyField Key field used to index the collection. * @param ?string $keyField Key field used to index the collection.
* *
* @return static Returns a new Flex 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. * @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 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 $directory Flex Directory where all the objects belong into.
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */

View File

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

View File

@@ -186,7 +186,7 @@ interface FlexObjectInterface extends FlexCommonInterface, NestedObjectInterface
* @see FlexObjectInterface::getForm() * @see FlexObjectInterface::getForm()
* *
* @param string $name Property name. * @param string $name Property name.
* @param string $separator Optional nested property separator. * @param ?string $separator Optional nested property separator.
* *
* @return mixed|null Returns default value of the field, null if there is no default value. * @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 string $name Property name.
* @param mixed $default Default value. * @param mixed $default Default value.
* @param string $separator Optional nested property separator. * @param ?string $separator Optional nested property separator.
* *
* @return mixed Returns value of the field. * @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. * 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 $rows Array of `[key => row, ...]` pairs.
* @param array $fetched Optional reference to store only fetched items. * @param ?array $fetched Optional reference to store only fetched items.
* *
* @return array Returns rows. Note that non-existing rows will have `null` as their value. * @return array Returns rows. Note that non-existing rows will have `null` as their value.
*/ */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -496,10 +496,10 @@ class FormFlash implements FormFlashInterface
} }
/** /**
* @param string $field * @param ?string $field
* @param string $name * @param string $name
* @param array $data * @param array $data
* @param array|null $crop * @param ?array $crop
*/ */
protected function addFileInternal(?string $field, string $name, array $data, array $crop = null): void 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 $filename
* @param string $field * @param string $field
* @param array $crop * @param ?array $crop
* @return bool * @return bool
*/ */
public function addFile(string $filename, string $field, array $crop = null): 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. * Remove any file from form flash.
* *
* @param string $name * @param string $name
* @param string $field * @param ?string $field
* @return bool * @return bool
*/ */
public function removeFile(string $name, string $field = null): bool; public function removeFile(string $name, string $field = null): bool;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

Some files were not shown because too many files have changed in this diff Show More