Fixed some phpstan issues

This commit is contained in:
Matias Griese 2020-05-05 19:35:09 +03:00
parent 5f0380f547
commit d25014779d
10 changed files with 28 additions and 10 deletions

View File

@ -487,7 +487,7 @@ abstract class Folder
/**
* Does a directory contain children
*
* @param $dir
* @param string $directory
* @return bool
*/
public static function hasChildren($directory) {

View File

@ -222,7 +222,6 @@ class PageObject extends FlexPageObject
/**
* @param array $variables
* @return array
*/
protected function onAfterSave(array $variables): void
{

View File

@ -281,6 +281,9 @@ class AbstractFile implements FileInterface
} else {
// Support for symlinks.
$realpath = is_link($filepath) ? realpath($filepath) : $filepath;
if ($realpath === false) {
throw new \RuntimeException('Failed to save file ' . $filepath);
}
// Create file with a temporary name and rename it to make the save action atomic.
$tmp = $this->tempname($realpath);

View File

@ -444,7 +444,7 @@ class FlexPageObject extends FlexObject implements PageInterface, MediaManipulat
}
/**
* @return UserCollectionInterface|FlexCollectionInterface|null
* @return UserCollectionInterface|null
* @internal
*/
protected function loadAccounts()

View File

@ -230,6 +230,6 @@ trait PageAuthorsTrait
}
abstract public function getNestedProperty($property, $default = null, $separator = null);
abstract protected function loadAccounts();
abstract protected function loadAccounts();
}

View File

@ -28,7 +28,7 @@ trait PageRoutableTrait
/** @var string */
private $_route;
/** @var string */
/** @var string|null */
private $_path;
/**

View File

@ -34,8 +34,8 @@ abstract class AbstractFilesystemStorage implements FlexStorageInterface
protected $dataFormatter;
/** @var string */
protected $keyField = 'storage_key';
/** @var string */
protected $keyLen = '32';
/** @var int */
protected $keyLen = 32;
/**
* @return bool

View File

@ -242,7 +242,7 @@ trait FlexMediaTrait
$locator->clearCache($targetFile);
}
$fileParts = $filesystem->pathinfo($basename);
$fileParts = (array)$filesystem->pathinfo($basename);
if (!file_exists($targetPath)) {
return;

View File

@ -266,7 +266,7 @@ class Session implements SessionInterface
return $this;
}
// TODO: session_create_id() segfaults in PHP 7.3 (PHP bug #73461)
// TODO: session_create_id() segfaults in PHP 7.3 (PHP bug #73461), remove phpstan rule when fixing this one.
$newId = 0; // session_create_id();
// Set destroyed timestamp for the old session as well as pointer to the new id.

View File

@ -25,6 +25,10 @@ parameters:
ignoreErrors:
# FIXME: Bugs that need to be fixed
# FIXME: PHP 7.3 bug workaround
-
message: '#If condition is always false.#'
path: 'system/src/Grav/Framework/Session/Session.php'
# TODO: Errors that needs some more thinking (bad design?)
- '#Access to an undefined property RocketTheme\\Toolbox\\Event\\Event::#'
@ -90,8 +94,11 @@ parameters:
message: '#unknown class (Memcache|Memcached|Redis|RedisException)#'
path: 'system/src/Grav/Common/Cache.php'
-
message: '#on an unknown class Collator#'
message: '#unknown class Collator#'
path: 'system/src/Grav/Common/Page/Pages.php'
-
message: '#unknown class Collator#'
path: 'system/src/Grav/Common/Flex/Types/Pages/PageCollection.php'
-
message: '#Ternary operator condition is always true#'
path: 'system/src/Grav/Framework/Cache/AbstractCache.php'
@ -121,6 +128,15 @@ parameters:
-
message: '#Call to deprecated method \w+\(\) of class Grav\\Framework\\Flex\\FlexObject#'
path: 'system/src/Grav/Framework/Flex/FlexObject.php'
-
message: '#Call to deprecated method \w+\(\) of class Grav\\Framework\\Flex\\FlexIndex#'
path: 'system/src/Grav/Framework/Flex/FlexIndex.php'
-
message: '#Call to deprecated method \w+\(\) of class Grav\\Framework\\Flex\\FlexCollection#'
path: 'system/src/Grav/Framework/Flex/FlexCollection.php'
-
message: '#Call to deprecated method (getAuthorizeScope|getActiveUser)\(\) of class Grav\\Framework\\Flex\\FlexObject#'
path: 'system/src/Grav/Framework/Flex/Pages/Traits/PageAuthorsTrait.php'
-
message: '#deprecated class#'
path: 'system/src/Grav/Framework/Uri/Uri.php'