Fixed phpstan level 1 issues

This commit is contained in:
Matias Griese 2019-03-13 10:16:47 +02:00
parent 8564524984
commit 39b1940f94
10 changed files with 18 additions and 11 deletions

View File

@ -88,7 +88,7 @@
},
"scripts": {
"post-create-project-cmd": "bin/grav install",
"phpstan": "vendor/bin/phpstan analyse -l 0 -c ./tests/phpstan/phpstan.neon system/src --memory-limit=256M",
"phpstan": "vendor/bin/phpstan analyse -l 1 -c ./tests/phpstan/phpstan.neon system/src --memory-limit=256M",
"test": "vendor/bin/codecept run unit",
"test-windows": "vendor\\bin\\codecept run unit"
},

View File

@ -23,11 +23,11 @@ class Package extends BasePackage
$this->settings = $package->toArray();
$html_description = \Parsedown::instance()->line($this->description);
$this->data->set('slug', $package->slug);
$html_description = \Parsedown::instance()->line($this->__get('description'));
$this->data->set('slug', $package->__get('slug'));
$this->data->set('description_html', $html_description);
$this->data->set('description_plain', strip_tags($html_description));
$this->data->set('symlink', is_link(USER_DIR . $package_type . DS . $this->slug));
$this->data->set('symlink', is_link(USER_DIR . $package_type . DS . $this->__get('slug')));
}
/**

View File

@ -13,6 +13,7 @@ use Grav\Common\Getters;
use Grav\Common\Grav;
use Grav\Common\Media\Interfaces\MediaCollectionInterface;
use Grav\Common\Media\Interfaces\MediaObjectInterface;
use Grav\Common\Page\Page;
use Grav\Common\Utils;
abstract class AbstractMedia extends Getters implements MediaCollectionInterface
@ -166,7 +167,8 @@ abstract class AbstractMedia extends Getters implements MediaCollectionInterface
protected function orderMedia($media)
{
if (null === $this->media_order) {
$page = Grav::instance()['pages']->get($this->path);
/** @var Page $page */
$page = Grav::instance()['pages']->get($this->__get('path'));
if ($page && isset($page->header()->media_order)) {
$this->media_order = array_map('trim', explode(',', $page->header()->media_order));

View File

@ -408,7 +408,7 @@ class ImageMedium extends Medium
}
if ($width && $height) {
$this->cropResize($width, $height);
$this->__call('cropResize', [$width, $height]);
}
return parent::lightbox($width, $height, $reset);
@ -418,7 +418,7 @@ class ImageMedium extends Medium
* Sets or gets the quality of the image
*
* @param int $quality 0-100 quality
* @return Medium
* @return int|$this
*/
public function quality($quality = null)
{

View File

@ -413,6 +413,8 @@ class Medium extends Data implements RenderableInterface, MediaObjectInterface
case 'source':
$element = $this->sourceParsedownElement($attributes, false);
break;
default:
$element = [];
}
if ($reset) {

View File

@ -268,6 +268,7 @@ class Twig
$local_twig = clone $this->twig;
$output = '';
try {
// Process Modular Twig
if ($item->modularTwig()) {

View File

@ -89,14 +89,14 @@ class Group extends Data
$blueprints = new Blueprints();
$blueprint = $blueprints->get('user/group');
$config->set("groups.{$this->groupname}", []);
$config->set("groups.{$this->get('groupname')}", []);
$fields = $blueprint->fields();
foreach ($fields as $field) {
if ($field['type'] === 'text') {
$value = $field['name'];
if (isset($this->items['data'][$value])) {
$config->set("groups.{$this->groupname}.{$value}", $this->items['data'][$value]);
$config->set("groups.{$this->get('groupname')}.{$value}", $this->items['data'][$value]);
}
}
if ($field['type'] === 'array' || $field['type'] === 'permissions') {
@ -105,7 +105,7 @@ class Group extends Data
if ($arrayValues) {
foreach ($arrayValues as $arrayIndex => $arrayValue) {
$config->set("groups.{$this->groupname}.{$value}.{$arrayIndex}", $arrayValue);
$config->set("groups.{$this->get('groupname')}.{$value}.{$arrayIndex}", $arrayValue);
}
}
}

View File

@ -221,6 +221,7 @@ class Flex implements \Countable
foreach ($keys as $key) {
$flexKey = $guessed[$key] ?? $key;
if (\is_array($flexKey)) {
$result = null;
foreach ($flexKey as $tryKey) {
if ($result = $list[$tryKey] ?? null) {
// Use the first matching object (conflicting objects will be ignored for now).

View File

@ -328,7 +328,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
$debugger->addException($e);
}
if (null === $result) {
if (!isset($result)) {
$collection = $this->loadCollection();
$result = $collection->{$name}(...$arguments);

View File

@ -4,3 +4,4 @@
*/
define('GRAV_USER_INSTANCE', 'FLEX');
define('GRAV_REQUEST_TIME', microtime(true));