I’d like to switch one of my playground projects from Kirby 3 to 4 but get this error:
Whoops\Exception\ErrorException thrown with message "Declaration of CdnFile::thumb($options = null) must be compatible with Kirby\Cms\File::thumb(array|string|null $options = null): Kirby\Cms\FileVersion|Kirby\Cms\File|Kirby\Filesystem\Asset"
I am using a custom File class CdnFile according to this Cookbook:
...
public function thumb($options = null)
{
return $this;
}
...
public function thumb(array|string|null $options = null): Kirby\Cms\FileVersion|Kirby\Cms\File|Kirby\Filesystem\Asset) {}
Kirby 4 adds a lot of type hints where there were none in Kirby 3, so you will likely get some of these errors. If you extends a method in a child class (page model, file model etc.), then you need to make sure that the signatures of the methods match (number and type of arguments, return types).