mirror of
https://github.com/getgrav/grav.git
synced 2026-07-01 01:59:39 +02:00
Improve Framework code
This commit is contained in:
@@ -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']);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,7 +41,7 @@ abstract class AbstractPaginationPage implements PaginationPageInterface
|
||||
*/
|
||||
public function getOptions(): array
|
||||
{
|
||||
return $this->options ?? [];
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -258,7 +258,7 @@ class Response implements ResponseInterface
|
||||
}
|
||||
|
||||
$output .= self::EOL;
|
||||
$output .= (string) $response->getBody();
|
||||
$output .= $response->getBody();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user