diff --git a/system/src/Grav/Framework/Form/Traits/FormTrait.php b/system/src/Grav/Framework/Form/Traits/FormTrait.php index 32df48037..3c368d97b 100644 --- a/system/src/Grav/Framework/Form/Traits/FormTrait.php +++ b/system/src/Grav/Framework/Form/Traits/FormTrait.php @@ -203,7 +203,7 @@ trait FormTrait */ public function getFiles(): array { - return $this->files ?? []; + return $this->files; } /** @@ -221,8 +221,8 @@ trait FormTrait */ public function getDefaultValue(string $name) { - $path = explode('.', $name) ?: []; - $offset = array_shift($path) ?? ''; + $path = explode('.', $name); + $offset = array_shift($path); $current = $this->getDefaultValues(); @@ -692,7 +692,7 @@ trait FormTrait throw new RuntimeException(sprintf('FlexForm: Bad HTTP method %s', $method)); } - $body = $request->getParsedBody(); + $body = (array)$request->getParsedBody(); $data = isset($body['data']) ? $this->decodeData($body['data']) : null; $flash = $this->getFlash(); @@ -799,9 +799,7 @@ trait FormTrait // Decode JSON encoded fields and merge them to data. if (isset($data['_json'])) { $data = array_replace_recursive($data, $this->jsonDecode($data['_json'])); - if (null === $data) { - throw new RuntimeException(__METHOD__ . '(): Unexpected error'); - } + unset($data['_json']); } diff --git a/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php b/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php index 7409f4c9e..40395cbb0 100644 --- a/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php +++ b/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php @@ -42,8 +42,8 @@ trait NestedPropertyTrait public function getNestedProperty($property, $default = null, $separator = null) { $separator = $separator ?: '.'; - $path = explode($separator, $property) ?: []; - $offset = array_shift($path) ?? ''; + $path = explode($separator, $property); + $offset = array_shift($path); if (!$this->hasProperty($offset)) { return $default; @@ -85,8 +85,8 @@ trait NestedPropertyTrait public function setNestedProperty($property, $value, $separator = null) { $separator = $separator ?: '.'; - $path = explode($separator, $property) ?: []; - $offset = array_shift($path) ?? ''; + $path = explode($separator, $property); + $offset = array_shift($path); if (!$path) { $this->setProperty($offset, $value); @@ -127,8 +127,8 @@ trait NestedPropertyTrait public function unsetNestedProperty($property, $separator = null) { $separator = $separator ?: '.'; - $path = explode($separator, $property) ?: []; - $offset = array_shift($path) ?? ''; + $path = explode($separator, $property); + $offset = array_shift($path); if (!$path) { $this->unsetProperty($offset); diff --git a/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php b/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php index fa3fed1d3..6f935fe97 100644 --- a/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php +++ b/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php @@ -97,7 +97,7 @@ trait ArrayPropertyTrait */ protected function getElements() { - return array_filter($this->_elements, function ($val) { + return array_filter($this->_elements, static function ($val) { return $val !== null; }); } diff --git a/system/src/Grav/Framework/Object/Property/LazyPropertyTrait.php b/system/src/Grav/Framework/Object/Property/LazyPropertyTrait.php index d5baddbee..99ad446ea 100644 --- a/system/src/Grav/Framework/Object/Property/LazyPropertyTrait.php +++ b/system/src/Grav/Framework/Object/Property/LazyPropertyTrait.php @@ -87,8 +87,7 @@ trait LazyPropertyTrait */ protected function doUnsetProperty($property) { - $this->hasObjectProperty($property) ? - $this->unsetObjectProperty($property) : $this->unsetArrayProperty($property); + $this->hasObjectProperty($property) ? $this->unsetObjectProperty($property) : $this->unsetArrayProperty($property); } /** diff --git a/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php b/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php index 95ff8af35..946139589 100644 --- a/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php +++ b/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php @@ -41,7 +41,7 @@ abstract class AbstractPaginationPage implements PaginationPageInterface */ public function getOptions(): array { - return $this->options ?? []; + return $this->options; } /** diff --git a/system/src/Grav/Framework/Psr7/Response.php b/system/src/Grav/Framework/Psr7/Response.php index a5c2c8a8a..6d8e68f68 100644 --- a/system/src/Grav/Framework/Psr7/Response.php +++ b/system/src/Grav/Framework/Psr7/Response.php @@ -258,7 +258,7 @@ class Response implements ResponseInterface } $output .= self::EOL; - $output .= (string) $response->getBody(); + $output .= $response->getBody(); return $output; } diff --git a/system/src/Grav/Framework/Psr7/Uri.php b/system/src/Grav/Framework/Psr7/Uri.php index c920b3373..bb88e937d 100644 --- a/system/src/Grav/Framework/Psr7/Uri.php +++ b/system/src/Grav/Framework/Psr7/Uri.php @@ -24,9 +24,6 @@ class Uri implements UriInterface { use UriDecorationTrait; - /** @var array Array of Uri query. */ - private $queryParams; - public function __construct(string $uri = '') { $this->uri = new \Nyholm\Psr7\Uri($uri); diff --git a/tests/phpstan/phpstan.neon b/tests/phpstan/phpstan.neon index 448f0019f..546e2f088 100644 --- a/tests/phpstan/phpstan.neon +++ b/tests/phpstan/phpstan.neon @@ -30,7 +30,7 @@ parameters: # These checks are new in phpstan 1, ignore them for now. checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false + #checkGenericClassInNonGenericObjectType: false universalObjectCratesClasses: - Grav\Common\Config\Config