diff --git a/composer.json b/composer.json index ac08100e2..1dcac5d06 100644 --- a/composer.json +++ b/composer.json @@ -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" }, diff --git a/system/src/Grav/Common/GPM/Local/Package.php b/system/src/Grav/Common/GPM/Local/Package.php index 27be6660f..ff797a78c 100644 --- a/system/src/Grav/Common/GPM/Local/Package.php +++ b/system/src/Grav/Common/GPM/Local/Package.php @@ -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'))); } /** diff --git a/system/src/Grav/Common/Page/Medium/AbstractMedia.php b/system/src/Grav/Common/Page/Medium/AbstractMedia.php index ada87f2c3..636df4c3d 100644 --- a/system/src/Grav/Common/Page/Medium/AbstractMedia.php +++ b/system/src/Grav/Common/Page/Medium/AbstractMedia.php @@ -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)); diff --git a/system/src/Grav/Common/Page/Medium/ImageMedium.php b/system/src/Grav/Common/Page/Medium/ImageMedium.php index bae243102..515232326 100644 --- a/system/src/Grav/Common/Page/Medium/ImageMedium.php +++ b/system/src/Grav/Common/Page/Medium/ImageMedium.php @@ -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) { diff --git a/system/src/Grav/Common/Page/Medium/Medium.php b/system/src/Grav/Common/Page/Medium/Medium.php index 9d07d39bd..3afe687ca 100644 --- a/system/src/Grav/Common/Page/Medium/Medium.php +++ b/system/src/Grav/Common/Page/Medium/Medium.php @@ -413,6 +413,8 @@ class Medium extends Data implements RenderableInterface, MediaObjectInterface case 'source': $element = $this->sourceParsedownElement($attributes, false); break; + default: + $element = []; } if ($reset) { diff --git a/system/src/Grav/Common/Twig/Twig.php b/system/src/Grav/Common/Twig/Twig.php index 4c7ea6351..ba682a76b 100644 --- a/system/src/Grav/Common/Twig/Twig.php +++ b/system/src/Grav/Common/Twig/Twig.php @@ -268,6 +268,7 @@ class Twig $local_twig = clone $this->twig; + $output = ''; try { // Process Modular Twig if ($item->modularTwig()) { diff --git a/system/src/Grav/Common/User/Group.php b/system/src/Grav/Common/User/Group.php index d1901496f..9815c0e5e 100644 --- a/system/src/Grav/Common/User/Group.php +++ b/system/src/Grav/Common/User/Group.php @@ -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); } } } diff --git a/system/src/Grav/Framework/Flex/Flex.php b/system/src/Grav/Framework/Flex/Flex.php index c8278e9af..49fd2b2f7 100644 --- a/system/src/Grav/Framework/Flex/Flex.php +++ b/system/src/Grav/Framework/Flex/Flex.php @@ -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). diff --git a/system/src/Grav/Framework/Flex/FlexIndex.php b/system/src/Grav/Framework/Flex/FlexIndex.php index c31930ad7..bd8762eed 100644 --- a/system/src/Grav/Framework/Flex/FlexIndex.php +++ b/system/src/Grav/Framework/Flex/FlexIndex.php @@ -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); diff --git a/tests/phpstan/phpstan-bootstrap.php b/tests/phpstan/phpstan-bootstrap.php index 656ca5fd2..b145fa1a0 100644 --- a/tests/phpstan/phpstan-bootstrap.php +++ b/tests/phpstan/phpstan-bootstrap.php @@ -4,3 +4,4 @@ */ define('GRAV_USER_INSTANCE', 'FLEX'); +define('GRAV_REQUEST_TIME', microtime(true));