refactor: add modules folder to phpstan paths + fix errors

This commit is contained in:
Yassine Doghri 2024-04-28 16:39:01 +00:00
parent 7a6d9df6db
commit bb628f355f
166 changed files with 452 additions and 526 deletions

View File

@ -2,7 +2,6 @@
declare(strict_types=1);
use Config\View;
use ViewThemes\Theme;
/**
@ -37,7 +36,8 @@ if (! function_exists('view')) {
/** @var CodeIgniter\View\View $renderer */
$renderer = single_service('renderer', $path);
$saveData = config(View::class)->saveData;
$saveData = config('View')
->saveData;
if (array_key_exists('saveData', $options)) {
$saveData = (bool) $options['saveData'];

View File

@ -34,10 +34,10 @@ class Fediverse extends FediverseBaseConfig
try {
$appTheme = service('settings')
->get('App.theme');
$defaultBanner = config(Images::class)
->podcastBannerDefaultPaths[$appTheme] ?? config(Images::class)->podcastBannerDefaultPaths['default'];
$defaultBanner = config('Images')
->podcastBannerDefaultPaths[$appTheme] ?? config('Images')->podcastBannerDefaultPaths['default'];
} catch (Exception) {
$defaultBanner = config(Images::class)
$defaultBanner = config('Images')
->podcastBannerDefaultPaths['default'];
}

View File

@ -18,7 +18,7 @@ class ActorController extends FediverseActorController
use AnalyticsTrait;
/**
* @var string[]
* @var list<string>
*/
protected $helpers = ['svg', 'components', 'misc', 'seo'];

View File

@ -12,7 +12,6 @@ namespace App\Controllers;
use CodeIgniter\Controller;
use CodeIgniter\HTTP\Response;
use Config\Colors;
class ColorsController extends Controller
{
@ -29,7 +28,7 @@ class ColorsController extends Controller
if (
! ($colorsCssBody = cache($cacheName))
) {
$colorThemes = config(Colors::class)
$colorThemes = config('Colors')
->themes;
$colorsCssBody = '';

View File

@ -16,7 +16,6 @@ use App\Entities\Podcast;
use App\Libraries\CommentObject;
use App\Models\EpisodeCommentModel;
use App\Models\EpisodeModel;
use App\Models\LikeModel;
use App\Models\PodcastModel;
use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\HTTP\RedirectResponse;
@ -170,7 +169,7 @@ class EpisodeCommentController extends BaseController
return redirect()->back();
}
model(LikeModel::class)
model('LikeModel')
->toggleLike($interactAsActor, $this->comment);
return redirect()->back();
@ -182,7 +181,7 @@ class EpisodeCommentController extends BaseController
return redirect()->back();
}
model(LikeModel::class)
model('LikeModel')
->toggleLike($interactAsActor, $this->comment);
return redirect()->back();

View File

@ -16,13 +16,11 @@ use App\Libraries\NoteObject;
use App\Libraries\PodcastEpisode;
use App\Models\EpisodeModel;
use App\Models\PodcastModel;
use App\Models\PostModel;
use CodeIgniter\Database\BaseBuilder;
use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\HTTP\Response;
use CodeIgniter\HTTP\ResponseInterface;
use Config\Embed;
use Config\Images;
use Config\Services;
use Modules\Analytics\AnalyticsTrait;
use Modules\Fediverse\Objects\OrderedCollectionObject;
@ -351,15 +349,15 @@ class EpisodeController extends BaseController
'author_url' => $this->podcast->link,
'html' => '<iframe src="' .
$this->episode->embed_url .
'" width="100%" height="' . config(Embed::class)->height . '" frameborder="0" scrolling="no"></iframe>',
'width' => config(Embed::class)
'" width="100%" height="' . config('Embed')->height . '" frameborder="0" scrolling="no"></iframe>',
'width' => config('Embed')
->width,
'height' => config(Embed::class)
'height' => config('Embed')
->height,
'thumbnail_url' => $this->episode->cover->og_url,
'thumbnail_width' => config(Images::class)
'thumbnail_width' => config('Images')
->podcastCoverSizes['og']['width'],
'thumbnail_height' => config(Images::class)
'thumbnail_height' => config('Images')
->podcastCoverSizes['og']['height'],
]);
}
@ -376,8 +374,8 @@ class EpisodeController extends BaseController
$oembed->addChild('author_name', $this->podcast->title);
$oembed->addChild('author_url', $this->podcast->link);
$oembed->addChild('thumbnail', $this->episode->cover->og_url);
$oembed->addChild('thumbnail_width', (string) config(Images::class)->podcastCoverSizes['og']['width']);
$oembed->addChild('thumbnail_height', (string) config(Images::class)->podcastCoverSizes['og']['height']);
$oembed->addChild('thumbnail_width', (string) config('Images')->podcastCoverSizes['og']['width']);
$oembed->addChild('thumbnail_height', (string) config('Images')->podcastCoverSizes['og']['height']);
$oembed->addChild(
'html',
htmlspecialchars(
@ -388,8 +386,8 @@ class EpisodeController extends BaseController
)->height . '" frameborder="0" scrolling="no"></iframe>',
),
);
$oembed->addChild('width', (string) config(Embed::class)->width);
$oembed->addChild('height', (string) config(Embed::class)->height);
$oembed->addChild('width', (string) config('Embed')->width);
$oembed->addChild('height', (string) config('Embed')->height);
// @phpstan-ignore-next-line
return $this->response->setXML($oembed);
@ -409,7 +407,7 @@ class EpisodeController extends BaseController
/**
* get comments: aggregated replies from posts referring to the episode
*/
$episodeComments = model(PostModel::class)
$episodeComments = model('PostModel')
->whereIn('in_reply_to_id', fn (BaseBuilder $builder): BaseBuilder => $builder->select('id')
->from('fediverse_posts')
->where('episode_id', $this->episode->id))

View File

@ -14,7 +14,6 @@ use App\Models\PodcastModel;
use CodeIgniter\Database\Exceptions\DatabaseException;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\ResponseInterface;
use Config\Cache;
use Modules\Media\FileManagers\FileManagerInterface;
class HomeController extends BaseController
@ -54,7 +53,7 @@ class HomeController extends BaseController
}
// --- Can Castopod connect to the cache handler
if (config(Cache::class)->handler !== 'dummy' && cache()->getCacheInfo() === null) {
if (config('Cache')->handler !== 'dummy' && cache()->getCacheInfo() === null) {
$errors[] = 'Unable connect to the cache handler.';
}

View File

@ -278,11 +278,11 @@ class PodcastController extends BaseController
{
if ($this->podcast->type === 'serial') {
// podcast is serial
$episodes = model(EpisodeModel::class)
$episodes = model('EpisodeModel')
->where('`published_at` <= UTC_TIMESTAMP()', null, false)
->orderBy('season_number DESC, number ASC');
} else {
$episodes = model(EpisodeModel::class)
$episodes = model('EpisodeModel')
->where('`published_at` <= UTC_TIMESTAMP()', null, false)
->orderBy('published_at', 'DESC');
}

View File

@ -37,7 +37,7 @@ class PostController extends FediversePostController
protected $post;
/**
* @var string[]
* @var list<string>
*/
protected $helpers = ['auth', 'fediverse', 'svg', 'components', 'misc', 'seo', 'premium_podcasts'];

View File

@ -22,7 +22,6 @@ use CodeIgniter\Entity\Entity;
use CodeIgniter\Files\File;
use CodeIgniter\HTTP\Files\UploadedFile;
use CodeIgniter\I18n\Time;
use Config\Images;
use Exception;
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\Autolink\AutolinkExtension;
@ -201,7 +200,7 @@ class Episode extends Entity
} else {
$cover = new Image([
'file_key' => 'podcasts/' . $this->getPodcast()->handle . '/' . $this->attributes['slug'] . '.' . $file->getExtension(),
'sizes' => config(Images::class)
'sizes' => config('Images')
->podcastCoverSizes,
'uploaded_by' => $this->attributes['updated_by'],
'updated_by' => $this->attributes['updated_by'],

View File

@ -14,7 +14,6 @@ use App\Models\PersonModel;
use CodeIgniter\Entity\Entity;
use CodeIgniter\Files\File;
use CodeIgniter\HTTP\Files\UploadedFile;
use Config\Images;
use Modules\Media\Entities\Image;
use Modules\Media\Models\MediaModel;
use RuntimeException;
@ -72,7 +71,7 @@ class Person extends Entity
} else {
$avatar = new Image([
'file_key' => 'persons/' . $this->attributes['unique_name'] . '.' . $file->getExtension(),
'sizes' => config(Images::class)
'sizes' => config('Images')
->personAvatarSizes,
'uploaded_by' => $this->attributes['updated_by'],
'updated_by' => $this->attributes['updated_by'],

View File

@ -20,7 +20,6 @@ use CodeIgniter\Files\File;
use CodeIgniter\HTTP\Files\UploadedFile;
use CodeIgniter\I18n\Time;
use CodeIgniter\Shield\Entities\User;
use Config\Images;
use Exception;
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\Autolink\AutolinkExtension;
@ -255,7 +254,7 @@ class Podcast extends Entity
} else {
$cover = new Image([
'file_key' => 'podcasts/' . $this->attributes['handle'] . '/cover.' . $file->getExtension(),
'sizes' => config(Images::class)
'sizes' => config('Images')
->podcastCoverSizes,
'uploaded_by' => $this->attributes['updated_by'],
'updated_by' => $this->attributes['updated_by'],
@ -298,7 +297,7 @@ class Podcast extends Entity
} else {
$banner = new Image([
'file_key' => 'podcasts/' . $this->attributes['handle'] . '/banner.' . $file->getExtension(),
'sizes' => config(Images::class)
'sizes' => config('Images')
->podcastBannerSizes,
'uploaded_by' => $this->attributes['updated_by'],
'updated_by' => $this->attributes['updated_by'],

View File

@ -5,7 +5,6 @@ declare(strict_types=1);
use App\Entities\Person;
use App\Entities\Podcast;
use Cocur\Slugify\Slugify;
use Config\App;
use Config\Images;
use Modules\Media\Entities\Image;
@ -25,7 +24,7 @@ if (! function_exists('get_browser_language')) {
function get_browser_language(?string $httpAcceptLanguage = null): string
{
if ($httpAcceptLanguage === null) {
return config(App::class)->defaultLocale;
return config('App')->defaultLocale;
}
$langs = explode(',', $httpAcceptLanguage);
@ -192,7 +191,7 @@ if (! function_exists('format_bytes')) {
if (! function_exists('get_site_icon_url')) {
function get_site_icon_url(string $size): string
{
if (config(App::class)->siteIcon['ico'] === service('settings')->get('App.siteIcon')['ico']) {
if (config('App')->siteIcon['ico'] === service('settings')->get('App.siteIcon')['ico']) {
// return default site icon url
return base_url(service('settings')->get('App.siteIcon')[$size]);
}
@ -205,12 +204,12 @@ if (! function_exists('get_podcast_banner')) {
function get_podcast_banner_url(Podcast $podcast, string $size): string
{
if (! $podcast->banner instanceof Image) {
$defaultBanner = config(Images::class)
$defaultBanner = config('Images')
->podcastBannerDefaultPaths[service('settings')->get('App.theme')] ?? config(
Images::class
)->podcastBannerDefaultPaths['default'];
$sizes = config(Images::class)
$sizes = config('Images')
->podcastBannerSizes;
$sizeConfig = $sizes[$size];
@ -231,7 +230,7 @@ if (! function_exists('get_podcast_banner_mimetype')) {
function get_podcast_banner_mimetype(Podcast $podcast, string $size): string
{
if (! $podcast->banner instanceof Image) {
$sizes = config(Images::class)
$sizes = config('Images')
->podcastBannerSizes;
$sizeConfig = $sizes[$size];
@ -252,10 +251,10 @@ if (! function_exists('get_avatar_url')) {
function get_avatar_url(Person $person, string $size): string
{
if (! $person->avatar instanceof Image) {
$defaultAvatarPath = config(Images::class)
$defaultAvatarPath = config('Images')
->avatarDefaultPath;
$sizes = config(Images::class)
$sizes = config('Images')
->personAvatarSizes;
$sizeConfig = $sizes[$size];

View File

@ -9,7 +9,6 @@ declare(strict_types=1);
*/
use App\Models\PageModel;
use Config\App;
if (! function_exists('render_page_links')) {
/**
@ -42,8 +41,8 @@ if (! function_exists('render_page_links')) {
}
// if set in .env, add legal notice link at the end of page links
if (config(App::class)->legalNoticeURL !== null) {
$links .= anchor(config(App::class)->legalNoticeURL, lang('Common.legal_notice'), [
if (config('App')->legalNoticeURL !== null) {
$links .= anchor(config('App')->legalNoticeURL, lang('Common.legal_notice'), [
'class' => 'px-2 py-1 underline hover:no-underline focus:ring-accent',
'target' => '_blank',
'rel' => 'noopener noreferrer',

View File

@ -8,8 +8,6 @@ use App\Entities\EpisodeComment;
use App\Entities\Page;
use App\Entities\Podcast;
use App\Entities\Post;
use Config\Embed;
use Config\Images;
use Melbahja\Seo\MetaTags;
use Melbahja\Seo\Schema;
use Melbahja\Seo\Schema\Thing;
@ -57,8 +55,8 @@ if (! function_exists('get_podcast_metatags')) {
->description(esc($podcast->description))
->image((string) $podcast->cover->og_url)
->canonical((string) current_url())
->og('image:width', (string) config(Images::class)->podcastCoverSizes['og']['width'])
->og('image:height', (string) config(Images::class)->podcastCoverSizes['og']['height'])
->og('image:width', (string) config('Images')->podcastCoverSizes['og']['width'])
->og('image:height', (string) config('Images')->podcastCoverSizes['og']['height'])
->og('locale', $podcast->language_code)
->og('site_name', esc(service('settings')->get('App.siteName')))
->push('link', [
@ -107,8 +105,8 @@ if (! function_exists('get_episode_metatags')) {
->image((string) $episode->cover->og_url, 'player')
->canonical($episode->link)
->og('site_name', esc(service('settings')->get('App.siteName')))
->og('image:width', (string) config(Images::class)->podcastCoverSizes['og']['width'])
->og('image:height', (string) config(Images::class)->podcastCoverSizes['og']['height'])
->og('image:width', (string) config('Images')->podcastCoverSizes['og']['width'])
->og('image:height', (string) config('Images')->podcastCoverSizes['og']['height'])
->og('locale', $episode->podcast->language_code)
->og('audio', $episode->audio_opengraph_url)
->og('audio:type', $episode->audio->file_mimetype)
@ -117,8 +115,8 @@ if (! function_exists('get_episode_metatags')) {
->twitter('audio:partner', $episode->podcast->publisher ?? '')
->twitter('audio:artist_name', esc($episode->podcast->owner_name))
->twitter('player', $episode->getEmbedUrl('light'))
->twitter('player:width', (string) config(Embed::class)->width)
->twitter('player:height', (string) config(Embed::class)->height)
->twitter('player:width', (string) config('Embed')->width)
->twitter('player:height', (string) config('Embed')->height)
->push('link', [
'rel' => 'alternate',
'type' => 'application/activity+json',

View File

@ -81,7 +81,7 @@ class Router extends CodeIgniterRouter
);
if ($this->collection->shouldUseSupportedLocalesOnly()
&& ! in_array($matched['locale'], config(App::class)->supportedLocales, true)) {
&& ! in_array($matched['locale'], config('App')->supportedLocales, true)) {
// Throw exception to prevent the autorouter, if enabled,
// from trying to find a route
throw PageNotFoundException::forLocaleNotSupported($matched['locale']);

View File

@ -14,7 +14,6 @@ use App\Entities\Actor;
use App\Entities\Podcast;
use CodeIgniter\HTTP\URI;
use CodeIgniter\Model;
use Config\Fediverse;
use phpseclib\Crypt\RSA;
class PodcastModel extends Model
@ -349,7 +348,7 @@ class PodcastModel extends Model
// delete all cache for podcast actor
cache()
->deleteMatching(config(Fediverse::class) ->cachePrefix . "actor#{$podcast->actor_id}*");
->deleteMatching(config('Fediverse') ->cachePrefix . "actor#{$podcast->actor_id}*");
// delete model requests cache, includes feed / query / episode lists, etc.
cache()

View File

@ -21,7 +21,7 @@ class PostModel extends FediversePostModel
protected $returnType = Post::class;
/**
* @var string[]
* @var list<string>
*/
protected $allowedFields = [
'id',

View File

@ -9,7 +9,7 @@
"php": "^8.1",
"adaures/ipcat-php": "^v1.0.0",
"adaures/podcast-persons-taxonomy": "^v1.0.1",
"aws/aws-sdk-php": "^3.305.3",
"aws/aws-sdk-php": "^3.305.4",
"chrisjean/php-ico": "^1.0.4",
"cocur/slugify": "^v4.5.1",
"codeigniter4/framework": "v4.5.1",

61
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "063a673edd8a39e318bae89316709ef0",
"content-hash": "b0b783684ed8d36e636fac3632c78c27",
"packages": [
{
"name": "adaures/ipcat-php",
@ -188,16 +188,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.305.3",
"version": "3.305.4",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "b190e24bd6568713436e1f13f9022bf28f491fc1"
"reference": "fc26a2ebf720e0b75a353d7e8fe206796671e00b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/b190e24bd6568713436e1f13f9022bf28f491fc1",
"reference": "b190e24bd6568713436e1f13f9022bf28f491fc1",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/fc26a2ebf720e0b75a353d7e8fe206796671e00b",
"reference": "fc26a2ebf720e0b75a353d7e8fe206796671e00b",
"shasum": ""
},
"require": {
@ -273,31 +273,31 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.305.3"
"source": "https://github.com/aws/aws-sdk-php/tree/3.305.4"
},
"time": "2024-04-25T18:07:15+00:00"
"time": "2024-04-26T18:06:31+00:00"
},
{
"name": "brick/math",
"version": "0.11.0",
"version": "0.12.1",
"source": {
"type": "git",
"url": "https://github.com/brick/math.git",
"reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478"
"reference": "f510c0a40911935b77b86859eb5223d58d660df1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/brick/math/zipball/0ad82ce168c82ba30d1c01ec86116ab52f589478",
"reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478",
"url": "https://api.github.com/repos/brick/math/zipball/f510c0a40911935b77b86859eb5223d58d660df1",
"reference": "f510c0a40911935b77b86859eb5223d58d660df1",
"shasum": ""
},
"require": {
"php": "^8.0"
"php": "^8.1"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.2",
"phpunit/phpunit": "^9.0",
"vimeo/psalm": "5.0.0"
"phpunit/phpunit": "^10.1",
"vimeo/psalm": "5.16.0"
},
"type": "library",
"autoload": {
@ -315,12 +315,17 @@
"arithmetic",
"bigdecimal",
"bignum",
"bignumber",
"brick",
"math"
"decimal",
"integer",
"math",
"mathematics",
"rational"
],
"support": {
"issues": "https://github.com/brick/math/issues",
"source": "https://github.com/brick/math/tree/0.11.0"
"source": "https://github.com/brick/math/tree/0.12.1"
},
"funding": [
{
@ -328,7 +333,7 @@
"type": "github"
}
],
"time": "2023-01-15T23:15:59+00:00"
"time": "2023-11-29T23:19:16+00:00"
},
{
"name": "chrisjean/php-ico",
@ -2796,20 +2801,20 @@
},
{
"name": "ramsey/uuid",
"version": "4.7.5",
"version": "4.7.6",
"source": {
"type": "git",
"url": "https://github.com/ramsey/uuid.git",
"reference": "5f0df49ae5ad6efb7afa69e6bfab4e5b1e080d8e"
"reference": "91039bc1faa45ba123c4328958e620d382ec7088"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ramsey/uuid/zipball/5f0df49ae5ad6efb7afa69e6bfab4e5b1e080d8e",
"reference": "5f0df49ae5ad6efb7afa69e6bfab4e5b1e080d8e",
"url": "https://api.github.com/repos/ramsey/uuid/zipball/91039bc1faa45ba123c4328958e620d382ec7088",
"reference": "91039bc1faa45ba123c4328958e620d382ec7088",
"shasum": ""
},
"require": {
"brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11",
"brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12",
"ext-json": "*",
"php": "^8.0",
"ramsey/collection": "^1.2 || ^2.0"
@ -2864,7 +2869,7 @@
"keywords": ["guid", "identifier", "uuid"],
"support": {
"issues": "https://github.com/ramsey/uuid/issues",
"source": "https://github.com/ramsey/uuid/tree/4.7.5"
"source": "https://github.com/ramsey/uuid/tree/4.7.6"
},
"funding": [
{
@ -2876,7 +2881,7 @@
"type": "tidelift"
}
],
"time": "2023-11-08T05:53:05+00:00"
"time": "2024-04-27T21:32:50+00:00"
},
{
"name": "symfony/deprecation-contracts",
@ -3393,12 +3398,12 @@
"source": {
"type": "git",
"url": "https://github.com/yassinedoghri/podcast-feed.git",
"reference": "366ddcedfb4b89c7093d03b2398184435f930843"
"reference": "f34156e62c9eef8bd5561f8a585d99501e235505"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yassinedoghri/podcast-feed/zipball/366ddcedfb4b89c7093d03b2398184435f930843",
"reference": "366ddcedfb4b89c7093d03b2398184435f930843",
"url": "https://api.github.com/repos/yassinedoghri/podcast-feed/zipball/f34156e62c9eef8bd5561f8a585d99501e235505",
"reference": "f34156e62c9eef8bd5561f8a585d99501e235505",
"shasum": ""
},
"require": {
@ -3434,7 +3439,7 @@
"issues": "https://github.com/yassinedoghri/podcast-feed/issues",
"source": "https://github.com/yassinedoghri/podcast-feed/tree/main"
},
"time": "2023-06-22T13:54:05+00:00"
"time": "2024-04-28T16:17:41+00:00"
}
],
"packages-dev": [

View File

@ -15,7 +15,8 @@ $routes->add('scheduled-video-clips', 'SchedulerController::generateVideoClips',
// Admin area routes
$routes->group(
config(Admin::class)->gateway,
config('Admin')
->gateway,
[
'namespace' => 'Modules\Admin\Controllers',
],

View File

@ -11,7 +11,6 @@ declare(strict_types=1);
namespace Modules\Admin\Controllers;
use CodeIgniter\HTTP\RedirectResponse;
use Config\App;
use Config\Services;
class AboutController extends BaseController
@ -23,7 +22,7 @@ class AboutController extends BaseController
'version' => CP_VERSION,
'php_version' => PHP_VERSION,
'os' => PHP_OS,
'languages' => implode(', ', config(App::class)->supportedLocales),
'languages' => implode(', ', config('App')->supportedLocales),
];
return view('settings/about', [

View File

@ -13,7 +13,6 @@ namespace Modules\Admin\Controllers;
use App\Models\EpisodeModel;
use App\Models\PodcastModel;
use CodeIgniter\I18n\Time;
use Config\App;
use Modules\Media\Models\MediaModel;
class DashboardController extends BaseController
@ -51,7 +50,7 @@ class DashboardController extends BaseController
->get()
->getResultArray()[0];
$appStorageLimit = config(App::class)
$appStorageLimit = config('App')
->storageLimit;
if ($appStorageLimit === null || $appStorageLimit < 0) {
$storageLimitBytes = disk_total_space('./');
@ -71,7 +70,7 @@ class DashboardController extends BaseController
->id;
}
$bandwidthLimit = config(App::class)
$bandwidthLimit = config('App')
->bandwidthLimit;
$data = [

View File

@ -855,7 +855,7 @@ class EpisodeController extends BaseController
// set podcast is_published_on_hubs to false to trigger websub push
(new PodcastModel())->update($this->episode->podcast->id, [
'is_published_on_hubs' => false,
'is_published_on_hubs' => 0,
]);
$db->transComplete();

View File

@ -32,7 +32,6 @@ use Modules\Analytics\Models\AnalyticsPodcastModel;
use Modules\Analytics\Models\AnalyticsWebsiteByBrowserModel;
use Modules\Analytics\Models\AnalyticsWebsiteByEntryPageModel;
use Modules\Analytics\Models\AnalyticsWebsiteByRefererModel;
use Modules\Auth\Config\AuthGroups;
use Modules\Media\Entities\Image;
use Modules\Media\FileManagers\FileManagerInterface;
use Modules\Media\Models\MediaModel;
@ -244,7 +243,7 @@ class PodcastController extends BaseController
// generate podcast roles and permissions
// before setting current user as podcast admin
config(AuthGroups::class)
config('AuthGroups')
->generatePodcastAuthorizations($newPodcastId);
add_podcast_group(auth()->user(), (int) $newPodcastId, setting('AuthGroups.mostPowerfulPodcastGroup'));

View File

@ -18,10 +18,8 @@ use App\Models\EpisodeModel;
use App\Models\PodcastModel;
use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\HTTP\RedirectResponse;
use Config\Colors;
use Modules\Media\Entities\Transcript;
use Modules\Media\Models\MediaModel;
use Modules\MediaClipper\Config\MediaClipper;
class VideoClipsController extends BaseController
{
@ -91,7 +89,7 @@ class VideoClipsController extends BaseController
return view('episode/video_clips_list', $data);
}
public function view($videoClipId): string
public function view(string $videoClipId): string
{
$videoClip = (new ClipModel())->getVideoClipById((int) $videoClipId);
@ -146,8 +144,8 @@ class VideoClipsController extends BaseController
'title' => 'required',
'start_time' => 'required|greater_than_equal_to[0]',
'duration' => 'required|greater_than[0]',
'format' => 'required|in_list[' . implode(',', array_keys(config(MediaClipper::class)->formats)) . ']',
'theme' => 'required|in_list[' . implode(',', array_keys(config(Colors::class)->themes)) . ']',
'format' => 'required|in_list[' . implode(',', array_keys(config('MediaClipper')->formats)) . ']',
'theme' => 'required|in_list[' . implode(',', array_keys(config('Colors')->themes)) . ']',
];
if (! $this->validate($rules)) {
@ -160,7 +158,7 @@ class VideoClipsController extends BaseController
$validData = $this->validator->getValidated();
$themeName = $validData['theme'];
$themeColors = config(MediaClipper::class)
$themeColors = config('MediaClipper')
->themes[$themeName];
$theme = [
'name' => $themeName,

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'الرئيسية',
'podcasts' => 'بودكاستات',
'episodes' => 'حلقات',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'roll-istor',
config(Admin::class)
config('Admin')
->gateway => 'Degemer',
'podcasts' => 'podkastoù',
'episodes' => 'rannoù',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'Ruta de navegació',
config(Admin::class)
config('Admin')
->gateway => 'Inici',
'podcasts' => 'podcasts',
'episodes' => 'episodis',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'brødkrumme',
config(Admin::class)
config('Admin')
->gateway => 'Hjem',
'podcasts' => 'podcasts',
'episodes' => 'episoder',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'Pfad',
config(Admin::class)
config('Admin')
->gateway => 'Startseite',
'podcasts' => 'Podcasts',
'episodes' => 'Folgen',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'διαδρομή (Breadcrumb)',
config(Admin::class)
config('Admin')
->gateway => 'Αρχική σελίδα',
'podcasts' => 'podcasts',
'episodes' => 'επεισόδια',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Home',
'podcasts' => 'podcasts',
'episodes' => 'episodes',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'ruta de navegación',
config(Admin::class)
config('Admin')
->gateway => 'Inicio',
'podcasts' => 'podcasts',
'episodes' => 'episodios',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Home',
'podcasts' => 'podcasts',
'episodes' => 'episodes',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Home',
'podcasts' => 'podcasts',
'episodes' => 'episodes',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'Fil dAriane',
config(Admin::class)
config('Admin')
->gateway => 'Accueil',
'podcasts' => 'podcasts',
'episodes' => 'épisodes',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'fil dAriane',
config(Admin::class)
config('Admin')
->gateway => 'Accueil',
'podcasts' => 'podcasts',
'episodes' => 'épisodes',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Home',
'podcasts' => 'podcasts',
'episodes' => 'episodes',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Home',
'podcasts' => 'podcasts',
'episodes' => 'episodes',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Home',
'podcasts' => 'podcasts',
'episodes' => 'episodes',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'menú',
config(Admin::class)
config('Admin')
->gateway => 'Inicio',
'podcasts' => 'podcasts',
'episodes' => 'episodios',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Home',
'podcasts' => 'podcasts',
'episodes' => 'episodes',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Home',
'podcasts' => 'podcasts',
'episodes' => 'episodi',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Home',
'podcasts' => 'podcasts',
'episodes' => 'episodes',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Home',
'podcasts' => 'podcasts',
'episodes' => 'episodes',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Home',
'podcasts' => 'podcasts',
'episodes' => 'episodes',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'kruimelpad',
config(Admin::class)
config('Admin')
->gateway => 'Hoofdpagina',
'podcasts' => 'podcasts',
'episodes' => 'afleveringen',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'navigeringslenke',
config(Admin::class)
config('Admin')
->gateway => 'Heim',
'podcasts' => 'podkastar',
'episodes' => 'episodar',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Home',
'podcasts' => 'podcasts',
'episodes' => 'episodes',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'okruszki',
config(Admin::class)
config('Admin')
->gateway => 'Początek',
'podcasts' => 'podcasty',
'episodes' => 'odcinki',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Início',
'podcasts' => 'podcasts',
'episodes' => 'episódios',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Home',
'podcasts' => 'podcasts',
'episodes' => 'episodes',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Home',
'podcasts' => 'podcasts',
'episodes' => 'episodes',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'навигационная цепочка',
config(Admin::class)
config('Admin')
->gateway => 'Главная',
'podcasts' => 'подкасты',
'episodes' => 'выпуски',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'omrvinky',
config(Admin::class)
config('Admin')
->gateway => 'Úvod',
'podcasts' => 'podcasty',
'episodes' => 'časti',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb polja',
config(Admin::class)
config('Admin')
->gateway => 'Početna',
'podcasts' => 'podkasti',
'episodes' => 'epizode',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Hem',
'podcasts' => 'podcasts',
'episodes' => 'avsnitt',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Home',
'podcasts' => 'podcasts',
'episodes' => 'episodes',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => '面包屑导航',
config(Admin::class)
config('Admin')
->gateway => '主页',
'podcasts' => '播客',
'episodes' => '剧集',

View File

@ -2,8 +2,6 @@
declare(strict_types=1);
use Modules\Admin\Config\Admin;
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -12,7 +10,7 @@ use Modules\Admin\Config\Admin;
return [
'label' => 'breadcrumb',
config(Admin::class)
config('Admin')
->gateway => 'Home',
'podcasts' => 'podcasts',
'episodes' => 'episodes',

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
use Modules\Analytics\Config\Analytics;
use CodeIgniter\Router\RouteCollection;
/**
* @copyright 2021 Ad Aures
@ -27,17 +27,17 @@ $routes->addPlaceholder(
$routes->group('', [
'namespace' => 'Modules\Analytics\Controllers',
], static function ($routes): void {
$routes->group(config(Analytics::class)->gateway . '/(:num)/(:class)', static function ($routes): void {
$routes->group(config('Analytics')->gateway . '/(:num)/(:class)', static function ($routes): void {
$routes->get('/', 'AnalyticsController::getData/$1/$2', [
'as' => 'analytics-full-data',
'filter' => config(Analytics::class)
'filter' => config('Analytics')
->routeFilters[
'analytics-full-data'
],
]);
$routes->get('(:filter)', 'AnalyticsController::getData/$1/$2/$3', [
'as' => 'analytics-data',
'filter' => config(Analytics::class)
'filter' => config('Analytics')
->routeFilters['analytics-data'],
]);
$routes->get(
@ -45,14 +45,14 @@ $routes->group('', [
'AnalyticsController::getData/$1/$2/$3/$4',
[
'as' => 'analytics-filtered-data',
'filter' => config(Analytics::class)
'filter' => config('Analytics')
->routeFilters[
'analytics-filtered-data'
],
],
);
});
$routes->get(config(Analytics::class)->gateway . '/(:class)/(:filter)', 'AnalyticsController::getData/$1/$2', [
$routes->get(config('Analytics')->gateway . '/(:class)/(:filter)', 'AnalyticsController::getData/$1/$2', [
'as' => 'analytics-data-instance',
]);

View File

@ -31,11 +31,13 @@ class AnalyticsController extends Controller
}
if (! is_numeric($params[0])) {
// @phpstan-ignore-next-line
$this->analyticsModel = model('Analytics' . $params[0] . 'Model');
$this->methodName = 'getData' . $params[1];
return $this->{$method}();
}
// @phpstan-ignore-next-line
$this->analyticsModel = model('Analytics' . $params[1] . 'Model');
$this->methodName = 'getData' . (count($params) >= 3 ? $params[2] : '');

View File

@ -27,7 +27,7 @@ use CodeIgniter\Entity\Entity;
class AnalyticsPodcasts extends Entity
{
/**
* @var string[]
* @var list<string>
*/
protected $dates = ['date', 'created_at', 'updated_at'];

View File

@ -26,7 +26,7 @@ use CodeIgniter\Entity\Entity;
class AnalyticsPodcastsByCountry extends Entity
{
/**
* @var string[]
* @var list<string>
*/
protected $dates = ['date', 'created_at', 'updated_at'];

View File

@ -25,7 +25,7 @@ use CodeIgniter\Entity\Entity;
class AnalyticsPodcastsByEpisode extends Entity
{
/**
* @var string[]
* @var list<string>
*/
protected $dates = ['date', 'created_at', 'updated_at'];

View File

@ -25,7 +25,7 @@ use CodeIgniter\Entity\Entity;
class AnalyticsPodcastsByHour extends Entity
{
/**
* @var string[]
* @var list<string>
*/
protected $dates = ['date', 'created_at', 'updated_at'];

View File

@ -28,7 +28,7 @@ use CodeIgniter\Entity\Entity;
class AnalyticsPodcastsByPlayer extends Entity
{
/**
* @var string[]
* @var list<string>
*/
protected $dates = ['date', 'created_at', 'updated_at'];

View File

@ -28,7 +28,7 @@ use CodeIgniter\Entity\Entity;
class AnalyticsPodcastsByRegion extends Entity
{
/**
* @var string[]
* @var list<string>
*/
protected $dates = ['date', 'created_at', 'updated_at'];

View File

@ -30,7 +30,7 @@ use Opawg\UserAgentsV2Php\UserAgentsRSS;
class AnalyticsPodcastsByService extends Entity
{
/**
* @var string[]
* @var list<string>
*/
protected $dates = ['date', 'created_at', 'updated_at'];

View File

@ -24,7 +24,7 @@ use CodeIgniter\Entity\Entity;
class AnalyticsPodcastsBySubscription extends Entity
{
/**
* @var string[]
* @var list<string>
*/
protected $dates = ['date', 'created_at', 'updated_at'];

View File

@ -24,7 +24,7 @@ use CodeIgniter\Entity\Entity;
class AnalyticsUnknownUserAgent extends Entity
{
/**
* @var string[]
* @var list<string>
*/
protected $dates = ['created_at', 'updated_at'];

View File

@ -25,7 +25,7 @@ use CodeIgniter\Entity\Entity;
class AnalyticsWebsiteByBrowser extends Entity
{
/**
* @var string[]
* @var list<string>
*/
protected $dates = ['date', 'created_at', 'updated_at'];

View File

@ -25,7 +25,7 @@ use CodeIgniter\Entity\Entity;
class AnalyticsWebsiteByEntryPage extends Entity
{
/**
* @var string[]
* @var list<string>
*/
protected $dates = ['date', 'created_at', 'updated_at'];

View File

@ -25,7 +25,7 @@ use CodeIgniter\Entity\Entity;
class AnalyticsWebsiteByReferer extends Entity
{
/**
* @var string[]
* @var list<string>
*/
protected $dates = ['date', 'created_at', 'updated_at'];

View File

@ -11,7 +11,6 @@ declare(strict_types=1);
use AdAures\Ipcat\IpDb;
use Config\Services;
use GeoIp2\Database\Reader;
use Modules\Analytics\Config\Analytics;
use Opawg\UserAgentsV2Php\UserAgents;
use WhichBrowser\Parser;
@ -41,11 +40,12 @@ if (! function_exists('client_ip')) {
*/
function client_ip(): string
{
if (! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
$superglobals = service('superglobals');
if (! empty($superglobals->server('HTTP_X_FORWARDED_FOR'))) {
return $superglobals->server('HTTP_X_FORWARDED_FOR');
}
return $_SERVER['REMOTE_ADDR'];
return $superglobals->server('REMOTE_ADDR');
}
}
@ -109,7 +109,8 @@ if (! function_exists('set_user_session_player')) {
if (! $session->has('player')) {
$playerFound = null;
$userAgent = $_SERVER['HTTP_USER_AGENT'];
$userAgent = service('superglobals')
->server('HTTP_USER_AGENT');
try {
$playerFound = UserAgents::find($userAgent);
@ -175,7 +176,8 @@ if (! function_exists('set_user_session_referer')) {
{
$session = Services::session();
$newreferer = $_SERVER['HTTP_REFERER'] ?? '- Direct -';
$newreferer = service('superglobals')
->server('HTTP_REFERER') ?? '- Direct -';
$newreferer =
parse_url((string) $newreferer, PHP_URL_HOST) ===
parse_url(current_url(false), PHP_URL_HOST)
@ -195,7 +197,8 @@ if (! function_exists('set_user_session_entry_page')) {
{
$session = Services::session();
$entryPage = $_SERVER['REQUEST_URI'];
$entryPage = service('superglobals')
->server('REQUEST_URI');
if (! $session->has('entryPage')) {
$session->set('entryPage', $entryPage);
}
@ -243,10 +246,11 @@ if (! function_exists('podcast_hit')) {
$session->get('player')['bot'] = true;
}
$superglobals = service('superglobals');
//We get the HTTP header field `Range`:
$httpRange = $_SERVER['HTTP_RANGE'] ?? null;
$httpRange = $superglobals->server('HTTP_RANGE') ?? null;
$salt = config(Analytics::class)
$salt = config('Analytics')
->salt;
// We create a sha1 hash for this Salt+Current_Date+IP_Address+User_Agent+Episode_ID (used to count only once multiple episode downloads):
$episodeListenerHashId =
@ -254,11 +258,14 @@ if (! function_exists('podcast_hit')) {
sha1(
$salt . '_' . date(
'Y-m-d'
) . '_' . $clientIp . '_' . $_SERVER['HTTP_USER_AGENT'] . '_' . $episodeId
) . '_' . $clientIp . '_' . $superglobals->server('HTTP_USER_AGENT') . '_' . $episodeId
);
// The cache expires at midnight:
$secondsToMidnight = strtotime('tomorrow') - time();
/** @var int|null $downloadedBytes */
$downloadedBytes = cache($episodeListenerHashId);
if ($downloadedBytes === null) {
// If it was never downloaded that means that zero bytes were downloaded:
$downloadedBytes = 0;
@ -301,13 +308,16 @@ if (! function_exists('podcast_hit')) {
sha1(
$salt . '_' . date(
'Y-m-d'
) . '_' . $clientIp . '_' . $_SERVER['HTTP_USER_AGENT'] . '_' . $podcastId
) . '_' . $clientIp . '_' . $superglobals->server('HTTP_USER_AGENT') . '_' . $podcastId
);
$newListener = 1;
// Has this listener already downloaded an episode today:
/** @var int|null $downloadsByUser */
$downloadsByUser = cache($podcastListenerHashId);
// We add one download
if ($downloadsByUser) {
if ($downloadsByUser === null) {
$newListener = 0;
++$downloadsByUser;
} else {

View File

@ -12,7 +12,6 @@ declare(strict_types=1);
namespace Modules\Analytics\Models;
use App\Entities\Media\BaseMedia;
use CodeIgniter\Model;
use Modules\Analytics\Entities\AnalyticsPodcasts;
use Modules\Media\Models\MediaModel;
@ -263,7 +262,7 @@ class AnalyticsPodcastModel extends Model
/**
* Get total storage
*
* @return BaseMedia[]
* @return AnalyticsPodcasts[]
*/
public function getDataTotalStorageByMonth(): array
{

View File

@ -15,7 +15,7 @@ namespace Modules\Analytics\Models;
use CodeIgniter\Model;
use Modules\Analytics\Entities\AnalyticsUnknownUserAgent;
class AnalyticsUnknownUserAgentModel extends Model
class AnalyticsUnknownUserAgentsModel extends Model
{
/**
* @var string

View File

@ -8,6 +8,9 @@ use Modules\Api\Rest\V1\Filters\ApiFilter;
class Registrar
{
/**
* @return array<string, mixed>
*/
public static function Filters(): array
{
return [

View File

@ -9,7 +9,7 @@ use CodeIgniter\Router\RouteCollection;
/** @var RouteCollection $routes */
$routes->group(
config(RestApi::class)
config('RestApi')
->gateway . 'podcasts',
[
'namespace' => 'Modules\Api\Rest\V1\Controllers',
@ -23,7 +23,7 @@ $routes->group(
);
$routes->group(
config(RestApi::class)
config('RestApi')
->gateway . 'episodes',
[
'namespace' => 'Modules\Api\Rest\V1\Controllers',

View File

@ -5,17 +5,16 @@ declare(strict_types=1);
namespace Modules\Api\Rest\V1\Config;
use CodeIgniter\Config\BaseService;
use Config\Exceptions as ExceptionsConfig;
use Modules\Api\Rest\V1\Core\Exceptions;
use Modules\Api\Rest\V1\Core\RestApiExceptions;
class Services extends BaseService
{
public static function restApiExceptions(bool $getShared = true)
public static function restApiExceptions(bool $getShared = true): RestApiExceptions
{
if ($getShared) {
return static::getSharedInstance('restApiExceptions');
}
return new Exceptions(config(ExceptionsConfig::class), static::request(), static::response());
return new RestApiExceptions(config('Exceptions'));
}
}

View File

@ -8,8 +8,7 @@ use App\Entities\Episode;
use App\Models\EpisodeModel;
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Controller;
use CodeIgniter\HTTP\Response;
use Modules\Api\Rest\V1\Config\RestApi;
use CodeIgniter\HTTP\ResponseInterface;
use Modules\Api\Rest\V1\Config\Services;
class EpisodeController extends Controller
@ -21,7 +20,7 @@ class EpisodeController extends Controller
Services::restApiExceptions()->initialize();
}
public function list(): Response
public function list(): ResponseInterface
{
$query = $this->request->getGet('query');
$order = $this->request->getGet('order') ?? 'newest';
@ -46,7 +45,7 @@ class EpisodeController extends Controller
}
$data = $builder->findAll(
(int) ($this->request->getGet('limit') ?? config(RestApi::class)->limit),
(int) ($this->request->getGet('limit') ?? config('RestApi')->limit),
(int) $this->request->getGet('offset')
);
@ -57,7 +56,7 @@ class EpisodeController extends Controller
return $this->respond($data);
}
public function view(int $id): Response
public function view(int $id): ResponseInterface
{
$episode = (new EpisodeModel())->getEpisodeById($id);
@ -65,6 +64,7 @@ class EpisodeController extends Controller
return $this->failNotFound('Episode not found');
}
// @phpstan-ignore-next-line
return $this->respond(static::mapEpisode($episode));
}

View File

@ -6,13 +6,13 @@ namespace Modules\Api\Rest\V1\Controllers;
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Controller;
use CodeIgniter\HTTP\Response;
use CodeIgniter\HTTP\ResponseInterface;
class ExceptionController extends Controller
{
use ResponseTrait;
public function notFound(): Response
public function notFound(): ResponseInterface
{
return $this->failNotFound('Podcast not found');
}

View File

@ -8,7 +8,7 @@ use App\Entities\Podcast;
use App\Models\PodcastModel;
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Controller;
use CodeIgniter\HTTP\Response;
use CodeIgniter\HTTP\ResponseInterface;
use Modules\Api\Rest\V1\Config\Services;
class PodcastController extends Controller
@ -20,7 +20,7 @@ class PodcastController extends Controller
Services::restApiExceptions()->initialize();
}
public function list(): Response
public function list(): ResponseInterface
{
$data = (new PodcastModel())->findAll();
array_map(static function ($podcast): void {
@ -29,13 +29,14 @@ class PodcastController extends Controller
return $this->respond($data);
}
public function view(int $id): Response
public function view(int $id): ResponseInterface
{
$podcast = (new PodcastModel())->getPodcastById($id);
if (! $podcast instanceof Podcast) {
return $this->failNotFound('Podcast not found');
}
// @phpstan-ignore-next-line
return $this->respond(self::mapPodcast($podcast));
}
@ -50,7 +51,7 @@ class PodcastController extends Controller
$categories = [$podcast->getCategory(), ...$podcast->getOtherCategories()];
foreach ($categories as $category) {
$category->translated = lang('Podcast.category_options.' . $category->code, [], null, false);
$category->translated = lang('Podcast.category_options.' . $category->code);
}
$podcast->categories = $categories;

View File

@ -4,9 +4,10 @@ declare(strict_types=1);
namespace Modules\Api\Rest\V1\Core;
use CodeIgniter\Debug\Exceptions;
use Throwable;
class Exceptions extends \CodeIgniter\Debug\Exceptions
class RestApiExceptions extends Exceptions
{
protected function render(Throwable $exception, int $statusCode): void
{

View File

@ -21,7 +21,7 @@ class ApiFilter implements FilterInterface
public function before(RequestInterface $request, $arguments = null)
{
/** @var RestApi $restApiConfig */
$restApiConfig = config(RestApi::class);
$restApiConfig = config('RestApi');
if (! $restApiConfig->enabled) {
throw PageNotFoundException::forPageNotFound();

View File

@ -6,8 +6,6 @@ namespace Modules\Auth;
use CodeIgniter\Router\RouteCollection;
use CodeIgniter\Shield\Auth as ShieldAuth;
use Modules\Auth\Config\Auth as AuthConfig;
use Modules\Auth\Config\AuthRoutes;
class Auth extends ShieldAuth
{
@ -18,13 +16,15 @@ class Auth extends ShieldAuth
* Usage (in Config/Routes.php):
* - auth()->routes($routes);
* - auth()->routes($routes, ['except' => ['login', 'register']])
*
* @param array{except?:list<string>} $config
*/
public function routes(RouteCollection &$routes, array $config = []): void
{
$authRoutes = config(AuthRoutes::class)
$authRoutes = config('AuthRoutes')
->routes;
$routes->group(config(AuthConfig::class)->gateway, [
$routes->group(config('Auth')->gateway, [
'namespace' => 'Modules\Auth\Controllers',
], static function (RouteCollection $routes) use ($authRoutes, $config): void {
foreach ($authRoutes as $name => $row) {

View File

@ -44,7 +44,12 @@ class RolesDoc extends BaseCommand
{
// loop over all files in path
$defaultFile = glob(ROOTPATH . 'docs/src/getting-started/auth.md');
$localizedFiles = glob(ROOTPATH . 'docs/src/**/getting-started/auth.md') ?? [];
$localizedFiles = glob(ROOTPATH . 'docs/src/**/getting-started/auth.md');
if (! $localizedFiles) {
$localizedFiles = [];
}
$files = array_merge($defaultFile, $localizedFiles);
CLI::write(implode(', ', $files));
@ -74,7 +79,7 @@ class RolesDoc extends BaseCommand
}
}
protected function handleInstanceRoles($authGroups, string $fileContents, string $pattern): string
protected function handleInstanceRoles(AuthGroups $authGroups, string $fileContents, string $pattern): string
{
$instanceMatrix = $authGroups->matrix;
return $this->renderCommentBlock(
@ -88,7 +93,7 @@ class RolesDoc extends BaseCommand
);
}
protected function handleInstancePermissions($authGroups, string $fileContents, string $pattern): string
protected function handleInstancePermissions(AuthGroups $authGroups, string $fileContents, string $pattern): string
{
return $this->renderCommentBlock(
$fileContents,
@ -101,7 +106,7 @@ class RolesDoc extends BaseCommand
);
}
protected function handlePodcastRoles($authGroups, string $fileContents, string $pattern): string
protected function handlePodcastRoles(AuthGroups $authGroups, string $fileContents, string $pattern): string
{
$podcastMatrix = $authGroups->podcastMatrix;
return $this->renderCommentBlock(
@ -115,7 +120,7 @@ class RolesDoc extends BaseCommand
);
}
protected function handlePodcastPermissions($authGroups, string $fileContents, string $pattern): string
protected function handlePodcastPermissions(AuthGroups $authGroups, string $fileContents, string $pattern): string
{
return $this->renderCommentBlock(
$fileContents,
@ -128,6 +133,10 @@ class RolesDoc extends BaseCommand
);
}
/**
* @param array<string> $tableHeading
* @param array<string, string>|array<string, array<string, string>> $data
*/
private function renderCommentBlock(
string $fileContents,
string $pattern,
@ -171,13 +180,9 @@ class RolesDoc extends BaseCommand
return $newFileContents;
}
private function detectLocaleFromPath($fileKey): string
private function detectLocaleFromPath(string $fileKey): string
{
preg_match(
'~docs\/src\/(?:([a-z]{2}(?:-[A-Za-z]{2,})?)\/)getting-started\/auth\.md~',
(string) $fileKey,
$match
);
preg_match('~docs\/src\/(?:([a-z]{2}(?:-[A-Za-z]{2,})?)\/)getting-started\/auth\.md~', $fileKey, $match);
if ($match === []) {
return 'en';

View File

@ -6,8 +6,9 @@ namespace Modules\Auth\Config;
use CodeIgniter\Shield\Authentication\Actions\ActionInterface;
use CodeIgniter\Shield\Authentication\Actions\Email2FA;
use CodeIgniter\Shield\Authentication\AuthenticatorInterface;
use CodeIgniter\Shield\Config\Auth as ShieldAuth;
use Modules\Admin\Config\Admin;
use CodeIgniter\Shield\Entities\User;
use Modules\Auth\Models\UserModel;
class Auth extends ShieldAuth
@ -123,7 +124,7 @@ class Auth extends ShieldAuth
{
parent::__construct();
$adminGateway = config(Admin::class)
$adminGateway = config('Admin')
->gateway;
$this->redirects = [
@ -155,14 +156,16 @@ class Auth extends ShieldAuth
// activate user upon magic-link login as it is done via email
if (! auth()->user()->active) {
/** @var Session $authenticator */
/** @var AuthenticatorInterface $authenticator */
$authenticator = auth('session')
->getAuthenticator();
$user = $authenticator->getUser();
// Set the user active now
$user->activate();
if ($user instanceof User) {
// Set the user active now
$user->activate();
}
}
// prompt user to change their password

View File

@ -200,7 +200,7 @@ class AuthGroups extends ShieldAuthGroups
/**
* Fill groups, permissions and matrix based on
*/
public function __construct($locale = null)
public function __construct()
{
parent::__construct();
@ -228,7 +228,7 @@ class AuthGroups extends ShieldAuthGroups
*/
$podcasts = (new PodcastModel())->findAll();
foreach ($podcasts as $podcast) {
$this->generatePodcastAuthorizations($podcast->id, $locale);
$this->generatePodcastAuthorizations($podcast->id);
}
}

View File

@ -8,6 +8,9 @@ use CodeIgniter\Shield\Config\AuthRoutes as ShieldAuthRoutes;
class AuthRoutes extends ShieldAuthRoutes
{
/**
* @var array<string, array<array<string>>>
*/
public array $routes = [
'register' => [
['get', 'register', 'RegisterController::registerView', 'register'],

View File

@ -31,6 +31,8 @@ class AuthToken extends ShieldAuthToken
* The name of Header that the Authorization token should be found.
* According to the specs, this should be `Authorization`, but rare
* circumstances might need a different header.
*
* @var array<string, string>
*/
public array $authenticatorHeader = [
'tokens' => 'Authorization',

View File

@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Modules\Auth\Config;
use CodeIgniter\Router\RouteCollection;
use Modules\Admin\Config\Admin;
/**
* @var RouteCollection $routes
@ -16,7 +15,7 @@ service('auth')
// Admin routes for users and podcast contributors
$routes->group(
config(Admin::class)
config('Admin')
->gateway,
[
'namespace' => 'Modules\Auth\Controllers',

View File

@ -6,7 +6,6 @@ namespace Modules\Auth\Config;
use Config\Services as BaseService;
use Modules\Auth\Auth;
use Modules\Auth\Config\Auth as AuthConfig;
class Services extends BaseService
{
@ -20,7 +19,7 @@ class Services extends BaseService
return self::getSharedInstance('auth');
}
$config = config(AuthConfig::class);
$config = config('Auth');
return new Auth($config);
}

View File

@ -115,6 +115,7 @@ class ContributorController extends BaseController
public function attemptCreate(): RedirectResponse
{
/** @var User $user */
$user = (new UserModel())->find((int) $this->request->getPost('user'));
if (get_podcast_group($user, $this->podcast->id)) {

View File

@ -8,8 +8,7 @@ use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Shield\Controllers\MagicLinkController as ShieldMagicLinkController;
use Modules\Auth\Config\Auth;
use Modules\Auth\Models\UserModel;
use CodeIgniter\Shield\Entities\User;
use Psr\Log\LoggerInterface;
use ViewThemes\Theme;
@ -33,7 +32,7 @@ class MagicLinkController extends ShieldMagicLinkController
public function setPasswordView(): string | RedirectResponse
{
if (! session('magicLogin')) {
return redirect()->to(config(Auth::class)->loginRedirect());
return redirect()->to(config('Auth')->loginRedirect());
}
return view(setting('Auth.views')['magic-link-set-password']);
@ -54,17 +53,16 @@ class MagicLinkController extends ShieldMagicLinkController
$validData = $this->validator->getValidated();
// set new password to user
auth()
->user()
->password = $validData['new_password'];
$user = auth()
->user();
$userModel = new UserModel();
if (! $userModel->update(auth()->user()->id, auth()->user())) {
return redirect()
->back()
->withInput()
->with('errors', $userModel->errors());
if ($user instanceof User) {
// set new password to user
$user->password = $validData['new_password'];
$userModel = auth()
->getProvider();
$userModel->save($user);
}
// remove magic login session to reinstate normal check
@ -73,7 +71,7 @@ class MagicLinkController extends ShieldMagicLinkController
}
// Success!
return redirect()->to(config(Auth::class)->loginRedirect())
return redirect()->to(config('Auth')->loginRedirect())
->with('message', lang('MyAccount.messages.passwordChangeSuccess'));
}
}

View File

@ -11,8 +11,8 @@ declare(strict_types=1);
namespace Modules\Auth\Controllers;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\Shield\Entities\User;
use Modules\Admin\Controllers\BaseController;
use Modules\Auth\Models\UserModel;
class MyAccountController extends BaseController
{
@ -60,17 +60,16 @@ class MyAccountController extends BaseController
->with('error', lang('MyAccount.messages.wrongPasswordError'));
}
// set new password to user
auth()
->user()
->password = $validData['new_password'];
$user = auth()
->user();
$userModel = new UserModel();
if (! $userModel->update(auth()->user()->id, auth()->user())) {
return redirect()
->back()
->withInput()
->with('errors', $userModel->errors());
if ($user instanceof User) {
// set new password to user
$user->password = $validData['new_password'];
$userModel = auth()
->getProvider();
$userModel->save($user);
}
// Success!

View File

@ -16,7 +16,6 @@ use CodeIgniter\I18n\Time;
use CodeIgniter\Shield\Authentication\Authenticators\Session;
use CodeIgniter\Shield\Entities\User;
use CodeIgniter\Shield\Exceptions\ValidationException;
use CodeIgniter\Shield\Models\UserIdentityModel;
use Modules\Admin\Controllers\BaseController;
use Modules\Auth\Models\UserModel;
@ -115,8 +114,7 @@ class UserController extends BaseController
// **** SEND WELCOME LINK FOR FIRST LOGIN ****
/** @var UserIdentityModel $identityModel */
$identityModel = model(UserIdentityModel::class);
$identityModel = model('UserIdentityModel');
// Delete any previous magic-link identities
$identityModel->deleteIdentitiesByType($user, Session::ID_TYPE_MAGIC_LINK);
@ -137,7 +135,7 @@ class UserController extends BaseController
$email->setTo($user->email);
$email->setSubject(lang('Auth.welcomeSubject', [
'siteName' => setting('App.siteName'),
], null, false));
]));
$email->setMessage(view(setting('Auth.views')['welcome-email'], [
'token' => $token,
], [

View File

@ -16,7 +16,7 @@ use CodeIgniter\Shield\Models\UserModel as ShieldUserModel;
class UserModel extends ShieldUserModel
{
/**
* @var string[]
* @var list<string>
*/
protected $allowedFields = [
'username',

View File

@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Modules\Fediverse\Commands;
use CodeIgniter\CLI\BaseCommand;
use Modules\Fediverse\Models\ActivityModel;
class Broadcast extends BaseCommand
{
@ -20,7 +19,7 @@ class Broadcast extends BaseCommand
helper('fediverse');
// retrieve scheduled activities from database
$scheduledActivities = model(ActivityModel::class, false)
$scheduledActivities = model('ActivityModel', false)
->getScheduledActivities();
// Send activity to all followers
@ -43,7 +42,7 @@ class Broadcast extends BaseCommand
}
// set activity post to delivered
model(ActivityModel::class, false)
model('ActivityModel', false)
->update($scheduledActivity->id, [
'status' => 'delivered',
]);

Some files were not shown because too many files have changed in this diff Show More