Upgrade to 3.9.5

This commit is contained in:
Bastian Allgeier
2023-06-07 14:12:49 +02:00
parent 38c8ba7e59
commit f76fbaa53e
49 changed files with 625 additions and 633 deletions

View File

@@ -364,8 +364,8 @@ class App
* by name. All relevant dependencies are
* automatically injected
*
* @param string $name
* @return \Kirby\Cms\Collection|null
* @return \Kirby\Toolkit\Collection|null
* @todo 5.0 Add return type declaration
*/
public function collection(string $name)
{
@@ -379,10 +379,8 @@ class App
/**
* Returns all user-defined collections
*
* @return \Kirby\Cms\Collections
*/
public function collections()
public function collections(): Collections
{
return $this->collections ??= new Collections();
}

View File

@@ -66,7 +66,7 @@ trait AppUsers
} finally {
// ensure that the impersonation is *always* reset
// to the original value, even if an error occurred
$auth->impersonate($userBefore !== null ? $userBefore->id() : null);
$auth->impersonate($userBefore?->id());
}
}

View File

@@ -209,9 +209,9 @@ class Collection extends BaseCollection
* or ids and then search accordingly.
*
* @param string|object $needle
* @return int
* @return int|false
*/
public function indexOf($needle): int
public function indexOf($needle): int|false
{
if (is_string($needle) === true) {
return array_search($needle, $this->keys());

View File

@@ -28,25 +28,20 @@ class Collections
* has been called, to avoid further
* processing on sequential calls to
* the same collection.
*
* @var array
*/
protected $cache = [];
protected array $cache = [];
/**
* Store of all collections
*
* @var array
*/
protected $collections = [];
protected array $collections = [];
/**
* Magic caller to enable something like
* `$collections->myCollection()`
*
* @param string $name
* @param array $arguments
* @return \Kirby\Cms\Collection|null
* @return \Kirby\Toolkit\Collection|null
* @todo 5.0 Add return type declaration
*/
public function __call(string $name, array $arguments = [])
{
@@ -56,9 +51,9 @@ class Collections
/**
* Loads a collection by name if registered
*
* @param string $name
* @param array $data
* @return \Kirby\Cms\Collection|null
* @return \Kirby\Toolkit\Collection|null
* @todo 4.0 Add deprecation warning when anything else than a Collection is returned
* @todo 5.0 Add return type declaration
*/
public function get(string $name, array $data = [])
{

View File

@@ -95,7 +95,7 @@ trait HasFiles
// find by global UUID
if (Uuid::is($filename, 'file') === true) {
return Uuid::for($filename, $this->files())->model();
return Uuid::for($filename, $this->$in())->model();
}
if (strpos($filename, '/') !== false) {

View File

@@ -19,9 +19,9 @@ trait HasSiblings
*
* @param \Kirby\Cms\Collection|null $collection
*
* @return int
* @return int|false
*/
public function indexOf($collection = null): int
public function indexOf($collection = null): int|false
{
$collection ??= $this->siblingsCollection();
return $collection->indexOf($this);
@@ -29,10 +29,13 @@ trait HasSiblings
/**
* Returns the next item in the collection if available
* @todo `static` return type hint is not 100% accurate because of
* quirks in the `Form` classes; would break if enforced
* (https://github.com/getkirby/kirby/pull/5175)
*
* @param \Kirby\Cms\Collection|null $collection
*
* @return \Kirby\Cms\Model|null
* @return static|null
*/
public function next($collection = null)
{
@@ -55,10 +58,13 @@ trait HasSiblings
/**
* Returns the previous item in the collection if available
* @todo `static` return type hint is not 100% accurate because of
* quirks in the `Form` classes; would break if enforced
* (https://github.com/getkirby/kirby/pull/5175)
*
* @param \Kirby\Cms\Collection|null $collection
*
* @return \Kirby\Cms\Model|null
* @return static|null
*/
public function prev($collection = null)
{

View File

@@ -270,9 +270,9 @@ class Pages extends Collection
$query = $startAt;
foreach ($path as $key) {
$collection = $item ? $item->children() : $this;
$query = ltrim($query . '/' . $key, '/');
$item = $collection->get($query) ?? null;
$collection = $item?->children() ?? $this;
$query = ltrim($query . '/' . $key, '/');
$item = $collection->get($query) ?? null;
if ($item === null && $multiLang === true && !App::instance()->language()->isDefault()) {
if (count($path) > 1 || $collection->parent()) {