Upgrade to 4.0.0
This commit is contained in:
@@ -26,10 +26,8 @@ class Files extends Collection
|
||||
|
||||
/**
|
||||
* All registered files methods
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $methods = [];
|
||||
public static array $methods = [];
|
||||
|
||||
/**
|
||||
* Adds a single file or
|
||||
@@ -40,7 +38,7 @@ class Files extends Collection
|
||||
* @return $this
|
||||
* @throws \Kirby\Exception\InvalidArgumentException When no `File` or `Files` object or an ID of an existing file is passed
|
||||
*/
|
||||
public function add($object)
|
||||
public function add($object): static
|
||||
{
|
||||
// add a files collection
|
||||
if ($object instanceof self) {
|
||||
@@ -74,7 +72,7 @@ class Files extends Collection
|
||||
* @param int $offset Sorting offset
|
||||
* @return $this
|
||||
*/
|
||||
public function changeSort(array $files, int $offset = 0)
|
||||
public function changeSort(array $files, int $offset = 0): static
|
||||
{
|
||||
foreach ($files as $filename) {
|
||||
if ($file = $this->get($filename)) {
|
||||
@@ -88,12 +86,8 @@ class Files extends Collection
|
||||
|
||||
/**
|
||||
* Creates a files collection from an array of props
|
||||
*
|
||||
* @param array $files
|
||||
* @param \Kirby\Cms\Model $parent
|
||||
* @return static
|
||||
*/
|
||||
public static function factory(array $files, Model $parent)
|
||||
public static function factory(array $files, Page|Site|User $parent): static
|
||||
{
|
||||
$collection = new static([], $parent);
|
||||
$kirby = $parent->kirby();
|
||||
@@ -114,11 +108,8 @@ class Files extends Collection
|
||||
/**
|
||||
* Finds a file by its filename
|
||||
* @internal Use `$files->find()` instead
|
||||
*
|
||||
* @param string $key
|
||||
* @return \Kirby\Cms\File|null
|
||||
*/
|
||||
public function findByKey(string $key)
|
||||
public function findByKey(string $key): File|null
|
||||
{
|
||||
if ($file = $this->findByUuid($key, 'file')) {
|
||||
return $file;
|
||||
@@ -136,7 +127,6 @@ class Files extends Collection
|
||||
* @param string|null|false $locale Locale for number formatting,
|
||||
* `null` for the current locale,
|
||||
* `false` to disable number formatting
|
||||
* @return string
|
||||
*/
|
||||
public function niceSize($locale = null): string
|
||||
{
|
||||
@@ -147,8 +137,6 @@ class Files extends Collection
|
||||
* Returns the raw size for all
|
||||
* files in the collection
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function size(): int
|
||||
{
|
||||
@@ -158,10 +146,8 @@ class Files extends Collection
|
||||
/**
|
||||
* Returns the collection sorted by
|
||||
* the sort number and the filename
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function sorted()
|
||||
public function sorted(): static
|
||||
{
|
||||
return $this->sort('sort', 'asc', 'filename', 'asc');
|
||||
}
|
||||
@@ -169,10 +155,9 @@ class Files extends Collection
|
||||
/**
|
||||
* Filter all files by the given template
|
||||
*
|
||||
* @param null|string|array $template
|
||||
* @return $this|static
|
||||
*/
|
||||
public function template($template)
|
||||
public function template(string|array|null $template): static
|
||||
{
|
||||
if (empty($template) === true) {
|
||||
return $this;
|
||||
|
||||
Reference in New Issue
Block a user