chore: update rector to latest and use parallel for faster processing

update composer dependencies to latest
This commit is contained in:
Yassine Doghri 2022-09-28 14:00:05 +00:00
parent 9eab54e085
commit b6114d3d93
33 changed files with 194 additions and 271 deletions

View File

@ -84,6 +84,7 @@ class Database extends Config
// Ensure that we always set the database group to 'tests' if
// we are currently running an automated test suite, so that
// we don't overwrite live data on accident.
/** @noRector RemoveAlwaysTrueIfConditionRector */
if (ENVIRONMENT === 'testing') {
$this->defaultGroup = 'tests';
}

View File

@ -28,7 +28,7 @@ use Modules\Auth\Entities\User;
* Events::on('create', [$myInstance, 'myMethod']);
*/
Events::on('pre_system', function () {
Events::on('pre_system', static function () {
// @phpstan-ignore-next-line
if (ENVIRONMENT !== 'testing') {
if (ini_get('zlib.output_compression')) {
@ -56,9 +56,8 @@ Events::on('pre_system', function () {
}
});
Events::on('login', function (User $user): void {
Events::on('login', static function (User $user): void {
helper('auth');
// set interact_as_actor_id value
$userPodcasts = $user->podcasts;
if ($userPodcasts = $user->podcasts) {
@ -66,9 +65,8 @@ Events::on('login', function (User $user): void {
}
});
Events::on('logout', function (User $user): void {
Events::on('logout', static function (User $user): void {
helper('auth');
// remove user's interact_as_actor session
remove_interact_as_actor();
});
@ -82,7 +80,7 @@ Events::on('logout', function (User $user): void {
* @param Actor $actor
* @param Actor $targetActor
*/
Events::on('on_follow', function ($actor, $targetActor): void {
Events::on('on_follow', static function ($actor, $targetActor): void {
if ($actor->is_podcast) {
cache()
->deleteMatching("podcast#{$actor->podcast->id}*");
@ -102,7 +100,7 @@ Events::on('on_follow', function ($actor, $targetActor): void {
* @param Actor $actor
* @param Actor $targetActor
*/
Events::on('on_undo_follow', function ($actor, $targetActor): void {
Events::on('on_undo_follow', static function ($actor, $targetActor): void {
if ($actor->is_podcast) {
cache()
->deleteMatching("podcast#{$actor->podcast->id}*");
@ -121,11 +119,10 @@ Events::on('on_undo_follow', function ($actor, $targetActor): void {
/**
* @param Post $post
*/
Events::on('on_post_add', function ($post): void {
Events::on('on_post_add', static function ($post): void {
model(EpisodeModel::class, false)->builder()
->where('id', $post->episode_id)
->increment('posts_count');
if ($post->actor->is_podcast) {
// Removing all of the podcast pages is a bit overkill, but works to avoid caching bugs
// same for other events below
@ -139,7 +136,7 @@ Events::on('on_post_add', function ($post): void {
/**
* @param Post $post
*/
Events::on('on_post_remove', function ($post): void {
Events::on('on_post_remove', static function ($post): void {
if ($episodeId = $post->episode_id) {
model(EpisodeModel::class, false)->builder()
->where('id', $episodeId)
@ -161,7 +158,7 @@ Events::on('on_post_remove', function ($post): void {
* @param Actor $actor
* @param Post $post
*/
Events::on('on_post_reblog', function ($actor, $post): void {
Events::on('on_post_reblog', static function ($actor, $post): void {
if ($post->actor->is_podcast) {
cache()
->deleteMatching("podcast#{$post->actor->podcast->id}*");
@ -177,7 +174,6 @@ Events::on('on_post_reblog', function ($actor, $post): void {
cache()
->deleteMatching("page_post#{$post->id}*");
if ($post->in_reply_to_id !== null) {
cache()->deleteMatching("page_post#{$post->in_reply_to_id}");
}
@ -186,9 +182,8 @@ Events::on('on_post_reblog', function ($actor, $post): void {
/**
* @param Post $reblogPost
*/
Events::on('on_post_undo_reblog', function ($reblogPost): void {
Events::on('on_post_undo_reblog', static function ($reblogPost): void {
$post = $reblogPost->reblog_of_post;
if ($post->actor->is_podcast) {
cache()
->deleteMatching("podcast#{$post->actor->podcast->id}*");
@ -200,7 +195,6 @@ Events::on('on_post_undo_reblog', function ($reblogPost): void {
->deleteMatching("page_post#{$post->id}*");
cache()
->deleteMatching("page_post#{$reblogPost->id}*");
if ($post->in_reply_to_id !== null) {
cache()->deleteMatching("page_post#{$post->in_reply_to_id}");
}
@ -216,9 +210,8 @@ Events::on('on_post_undo_reblog', function ($reblogPost): void {
/**
* @param Post $reply
*/
Events::on('on_post_reply', function ($reply): void {
Events::on('on_post_reply', static function ($reply): void {
$post = $reply->reply_to_post;
if ($post->in_reply_to_id === null) {
model(EpisodeModel::class, false)->builder()
->where('id', $post->episode_id)
@ -241,9 +234,8 @@ Events::on('on_post_reply', function ($reply): void {
/**
* @param Post $reply
*/
Events::on('on_reply_remove', function ($reply): void {
Events::on('on_reply_remove', static function ($reply): void {
$post = $reply->reply_to_post;
if ($post->in_reply_to_id === null) {
model(EpisodeModel::class, false)->builder()
->where('id', $post->episode_id)
@ -269,7 +261,7 @@ Events::on('on_reply_remove', function ($reply): void {
* @param Actor $actor
* @param Post $post
*/
Events::on('on_post_favourite', function ($actor, $post): void {
Events::on('on_post_favourite', static function ($actor, $post): void {
if ($post->actor->is_podcast) {
cache()
->deleteMatching("podcast#{$post->actor->podcast->id}*");
@ -279,7 +271,6 @@ Events::on('on_post_favourite', function ($actor, $post): void {
cache()
->deleteMatching("page_post#{$post->id}*");
if ($post->in_reply_to_id !== null) {
cache()->deleteMatching("page_post#{$post->in_reply_to_id}*");
}
@ -295,7 +286,7 @@ Events::on('on_post_favourite', function ($actor, $post): void {
* @param Actor $actor
* @param Post $post
*/
Events::on('on_post_undo_favourite', function ($actor, $post): void {
Events::on('on_post_undo_favourite', static function ($actor, $post): void {
if ($post->actor->is_podcast) {
cache()
->deleteMatching("podcast#{$post->actor->podcast->id}*");
@ -305,7 +296,6 @@ Events::on('on_post_undo_favourite', function ($actor, $post): void {
cache()
->deleteMatching("page_post#{$post->id}*");
if ($post->in_reply_to_id !== null) {
cache()->deleteMatching("page_post#{$post->in_reply_to_id}*");
}
@ -317,7 +307,7 @@ Events::on('on_post_undo_favourite', function ($actor, $post): void {
}
});
Events::on('on_block_actor', function (int $actorId): void {
Events::on('on_block_actor', static function (int $actorId): void {
cache()->deleteMatching('page_podcast*');
cache()
->deleteMatching('podcast*');
@ -325,7 +315,7 @@ Events::on('on_block_actor', function (int $actorId): void {
->deleteMatching('page_post*');
});
Events::on('on_unblock_actor', function (int $actorId): void {
Events::on('on_unblock_actor', static function (int $actorId): void {
cache()->deleteMatching('page_podcast*');
cache()
->deleteMatching('podcast*');
@ -333,7 +323,7 @@ Events::on('on_unblock_actor', function (int $actorId): void {
->deleteMatching('page_post*');
});
Events::on('on_block_domain', function (string $domainName): void {
Events::on('on_block_domain', static function (string $domainName): void {
cache()->deleteMatching('page_podcast*');
cache()
->deleteMatching('podcast*');
@ -341,7 +331,7 @@ Events::on('on_block_domain', function (string $domainName): void {
->deleteMatching('page_post*');
});
Events::on('on_unblock_domain', function (string $domainName): void {
Events::on('on_unblock_domain', static function (string $domainName): void {
cache()->deleteMatching('page_podcast*');
cache()
->deleteMatching('podcast*');

View File

@ -69,14 +69,13 @@ $routes->get('/', 'HomeController', [
$routes->get('.well-known/platforms', 'Platform');
// Podcast's Public routes
$routes->group('@(:podcastHandle)', function ($routes): void {
$routes->group('@(:podcastHandle)', static function ($routes): void {
$routes->get('/', 'PodcastController::activity/$1', [
'as' => 'podcast-activity',
]);
$routes->get('manifest.webmanifest', 'WebmanifestController::podcastManifest/$1', [
'as' => 'podcast-webmanifest',
]);
// override default Fediverse Library's actor route
$routes->options('/', 'ActivityPubController::preflight');
$routes->get('/', 'PodcastController::activity/$1', [
@ -116,7 +115,7 @@ $routes->group('@(:podcastHandle)', function ($routes): void {
],
'filter' => 'allow-cors',
]);
$routes->group('episodes/(:slug)', function ($routes): void {
$routes->group('episodes/(:slug)', static function ($routes): void {
$routes->options('/', 'ActivityPubController::preflight');
$routes->get('/', 'EpisodeController/$1/$2', [
'as' => 'episode',
@ -176,7 +175,7 @@ $routes->group('@(:podcastHandle)', function ($routes): void {
$routes->get('oembed.xml', 'EpisodeController::oembedXML/$1/$2', [
'as' => 'episode-oembed-xml',
]);
$routes->group('embed', function ($routes): void {
$routes->group('embed', static function ($routes): void {
$routes->get('/', 'EpisodeController::embed/$1/$2', [
'as' => 'embed',
]);
@ -185,7 +184,6 @@ $routes->group('@(:podcastHandle)', function ($routes): void {
],);
});
});
$routes->head('feed.xml', 'FeedController/$1', [
'as' => 'podcast_feed',
]);
@ -211,14 +209,13 @@ $routes->get('/pages/(:slug)', 'PageController/$1', [
/**
* Overwriting Fediverse routes file
*/
$routes->group('@(:podcastHandle)', function ($routes): void {
$routes->group('@(:podcastHandle)', static function ($routes): void {
$routes->post('posts/new', 'PostController::attemptCreate/$1', [
'as' => 'post-attempt-create',
'filter' => 'permission:podcast-manage_publications',
]);
// Post
$routes->group('posts/(:uuid)', function ($routes): void {
$routes->group('posts/(:uuid)', static function ($routes): void {
$routes->options('/', 'ActivityPubController::preflight');
$routes->get('/', 'PostController::view/$1/$2', [
'as' => 'post',
@ -249,13 +246,11 @@ $routes->group('@(:podcastHandle)', function ($routes): void {
],
'filter' => 'allow-cors',
]);
// Actions
$routes->post('action', 'PostController::attemptAction/$1/$2', [
'as' => 'post-attempt-action',
'filter' => 'permission:podcast-interact_as',
]);
$routes->post(
'block-actor',
'PostController::attemptBlockActor/$1/$2',
@ -276,7 +271,6 @@ $routes->group('@(:podcastHandle)', function ($routes): void {
'as' => 'post-attempt-delete',
'filter' => 'permission:podcast-manage_publications',
]);
$routes->get(
'remote/(:postAction)',
'PostController::remoteAction/$1/$2/$3',
@ -285,7 +279,6 @@ $routes->group('@(:podcastHandle)', function ($routes): void {
],
);
});
$routes->get('follow', 'ActorController::follow/$1', [
'as' => 'follow',
]);

View File

@ -29,7 +29,7 @@ class MapController extends BaseController
);
if (! ($found = cache($cacheName))) {
$found = view('pages/map', [], [
return view('pages/map', [], [
'cache' => DECADE,
'cache_name' => $cacheName,
]);

View File

@ -42,8 +42,8 @@ class Location extends Entity
$longitude = null;
if ($geo !== null) {
$geoArray = explode(',', substr($geo, 4));
$latitude = floatval($geoArray[0]);
$longitude = floatval($geoArray[1]);
$latitude = (float) $geoArray[0];
$longitude = (float) $geoArray[1];
}
parent::__construct([

View File

@ -50,7 +50,7 @@ if (! function_exists('data_table')) {
* @param mixed[] $data data to loop through and display in rows
* @param mixed ...$rest Any other argument to pass to the `cell` function
*/
function data_table(array $columns, array $data = [], string $class = '', ...$rest): string
function data_table(array $columns, array $data = [], string $class = '', mixed ...$rest): string
{
$table = new Table();

View File

@ -5,11 +5,8 @@ declare(strict_types=1);
if (! function_exists('form_textarea')) {
/**
* Adapted textarea field from CI4 core: without value escaping.
*
* @param mixed $data
* @param mixed $extra
*/
function form_textarea($data = '', string $value = '', $extra = ''): string
function form_textarea(mixed $data = '', string $value = '', mixed $extra = ''): string
{
$defaults = [
'name' => is_array($data) ? '' : $data,

View File

@ -34,7 +34,7 @@ if (! function_exists('icon')) {
}
if ($class !== '') {
$svgContents = str_replace('<svg', '<svg class="' . $class . '"', $svgContents);
return str_replace('<svg', '<svg class="' . $class . '"', $svgContents);
}
return $svgContents;
@ -53,7 +53,7 @@ if (! function_exists('svg')) {
{
$svgContents = file_get_contents('assets/images/' . $name . '.svg');
if ($class) {
$svgContents = str_replace('<svg', '<svg class="' . $class . '"', $svgContents);
return str_replace('<svg', '<svg class="' . $class . '"', $svgContents);
}
return $svgContents;

View File

@ -27,15 +27,10 @@ class SimpleRSSElement extends SimpleXMLElement
public function addChildWithCDATA(string $name, string $value = '', ?string $namespace = null): static
{
$newChild = parent::addChild($name, null, $namespace);
if ($newChild !== null) {
$node = dom_import_simplexml($newChild);
if ($node !== null) {
$no = $node->ownerDocument;
if ($no !== null) {
$node->appendChild($no->createCDATASection($value));
}
}
$node = dom_import_simplexml($newChild);
$no = $node->ownerDocument;
if ($no !== null) {
$node->appendChild($no->createCDATASection($value));
}
return $newChild;
@ -55,24 +50,19 @@ class SimpleRSSElement extends SimpleXMLElement
public function addChild($name, $value = null, $namespace = null, $escape = true): static
{
$newChild = parent::addChild($name, null, $namespace);
if ($newChild !== null) {
$node = dom_import_simplexml($newChild);
if ($node !== null) {
$no = $node->ownerDocument;
$value = $escape ? esc($value ?? '') : $value ?? '';
if (! $no instanceof DOMDocument) {
return $newChild;
}
if (is_array($value)) {
return $newChild;
}
$node->appendChild($no->createTextNode($value));
}
$node = dom_import_simplexml($newChild);
$no = $node->ownerDocument;
$value = $escape ? esc($value ?? '') : $value ?? '';
if (! $no instanceof DOMDocument) {
return $newChild;
}
if (is_array($value)) {
return $newChild;
}
$node->appendChild($no->createTextNode($value));
return $newChild;
}
}

View File

@ -246,7 +246,7 @@ class ComponentRenderer
*/
private function renderView(string $view, array $data): string
{
return (function (string $view, $data): string {
return (static function (string $view, $data): string {
extract($data);
ob_start();
eval('?>' . file_get_contents($view));

View File

@ -10,7 +10,7 @@ if (! function_exists('flatten_attributes')) {
*
* @param mixed $attributes string, array, object
*/
function flatten_attributes($attributes, bool $js = false): string
function flatten_attributes(mixed $attributes, bool $js = false): string
{
$atts = '';

View File

@ -64,7 +64,7 @@ class CategoryModel extends Model
$options = array_reduce(
$categories,
function (array $result, Category $category): array {
static function (array $result, Category $category): array {
$result[$category->id] = '';
if ($category->parent !== null) {
$result[$category->id] = lang(
@ -114,12 +114,11 @@ class CategoryModel extends Model
// prepare data for `podcasts_categories` table
$data = array_reduce(
$categoriesIds,
function (array $result, int $categoryId) use ($podcastId): array {
static function (array $result, int $categoryId) use ($podcastId): array {
$result[] = [
'podcast_id' => $podcastId,
'category_id' => $categoryId,
];
return $result;
},
[],

View File

@ -214,7 +214,7 @@ class EpisodeCommentModel extends UuidModel
$episodePostsReplies = $episodePostsRepliesBuilder->select(
'id, uri, episode_id, actor_id, in_reply_to_id, message, message_html, favourites_count as likes_count, replies_count, published_at as created_at, created_by, 1 as is_from_post'
)
->whereIn('in_reply_to_id', function (BaseBuilder $builder) use (&$episodeId): BaseBuilder {
->whereIn('in_reply_to_id', static function (BaseBuilder $builder) use (&$episodeId): BaseBuilder {
return $builder->select('id')
->from(config('Fediverse')->tablesPrefix . 'posts')
->where([

View File

@ -55,7 +55,7 @@ class LanguageModel extends Model
$options = array_reduce(
$languages,
function (array $result, Language $language): array {
static function (array $result, Language $language): array {
$result[$language->code] = $language->native_name;
return $result;
},

View File

@ -11,7 +11,6 @@ declare(strict_types=1);
namespace App\Models;
use App\Entities\Person;
use CodeIgniter\Database\Query;
use CodeIgniter\Model;
class PersonModel extends Model
@ -147,7 +146,7 @@ class PersonModel extends Model
$this->select('`id`, `full_name`')
->orderBy('`full_name`', 'ASC')
->findAll(),
function ($result, $person) {
static function ($result, $person) {
$result[$person->id] = $person->full_name;
return $result;
},
@ -255,7 +254,7 @@ class PersonModel extends Model
int $personId,
string $groupSlug,
string $roleSlug
): bool | Query {
): bool {
return $this->db->table('episodes_persons')
->insert([
'podcast_id' => $podcastId,
@ -266,12 +265,8 @@ class PersonModel extends Model
]);
}
public function addPodcastPerson(
int $podcastId,
int $personId,
string $groupSlug,
string $roleSlug
): bool | Query {
public function addPodcastPerson(int $podcastId, int $personId, string $groupSlug, string $roleSlug): bool
{
return $this->db->table('podcasts_persons')
->insert([
'podcast_id' => $podcastId,

View File

@ -20,7 +20,7 @@ class Icon extends Component
}
if ($this->attributes['class'] !== '') {
$svgContents = str_replace('<svg', '<svg class="' . $this->attributes['class'] . '"', $svgContents);
return str_replace('<svg', '<svg class="' . $this->attributes['class'] . '"', $svgContents);
}
return $svgContents;

View File

@ -18,20 +18,20 @@
"opawg/user-agents-php": "^v1.0",
"adaures/ipcat-php": "^v1.0.0",
"adaures/podcast-persons-taxonomy": "^v1.0.0",
"phpseclib/phpseclib": "~2.0.37",
"phpseclib/phpseclib": "~2.0.38",
"michalsn/codeigniter4-uuid": "dev-develop",
"essence/essence": "^3.5.4",
"codeigniter4/settings": "^v2.1.0",
"chrisjean/php-ico": "^1.0.4",
"melbahja/seo": "^v2.1.0"
"melbahja/seo": "^v2.1.1"
},
"require-dev": {
"mikey179/vfsstream": "^v1.6.11",
"phpunit/phpunit": "^9.5.24",
"phpunit/phpunit": "^9.5.25",
"captainhook/captainhook": "^5.10.11",
"symplify/easy-coding-standard": "^10.3.3",
"phpstan/phpstan": "^1.8.4",
"rector/rector": "^0.12.23",
"phpstan/phpstan": "^1.8.6",
"rector/rector": "^0.14.4",
"symplify/coding-standard": "^10.3.3"
},
"autoload": {
@ -47,8 +47,8 @@
"scripts": {
"test": "vendor/bin/phpunit",
"analyse": "vendor/bin/phpstan analyse --ansi",
"rector": "vendor/bin/rector process --dry-run --ansi",
"rector:fix": "vendor/bin/rector process --ansi",
"rector": "vendor/bin/rector process --dry-run --ansi --memory-limit=1G",
"rector:fix": "vendor/bin/rector process --ansi --memory-limit=1G",
"style": "vendor/bin/ecs check --ansi",
"style:fix": "vendor/bin/ecs check --fix --ansi",
"post-install-cmd": [

157
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": "ccfd204614b036fccba778ba59e771fa",
"content-hash": "e6899d9a3dfff0e17318420d4e3b22c5",
"packages": [
{
"name": "adaures/ipcat-php",
@ -778,16 +778,16 @@
},
{
"name": "kint-php/kint",
"version": "4.2.0",
"version": "4.2.2",
"source": {
"type": "git",
"url": "https://github.com/kint-php/kint.git",
"reference": "0518ee9e1b5b3c7bbf3c9ad837a6591e39dbfab0"
"reference": "9230c016c976ff446f0be5cf82272db278344f69"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/kint-php/kint/zipball/0518ee9e1b5b3c7bbf3c9ad837a6591e39dbfab0",
"reference": "0518ee9e1b5b3c7bbf3c9ad837a6591e39dbfab0",
"url": "https://api.github.com/repos/kint-php/kint/zipball/9230c016c976ff446f0be5cf82272db278344f69",
"reference": "9230c016c976ff446f0be5cf82272db278344f69",
"shasum": ""
},
"require": {
@ -829,9 +829,9 @@
"keywords": ["debug", "kint", "php"],
"support": {
"issues": "https://github.com/kint-php/kint/issues",
"source": "https://github.com/kint-php/kint/tree/4.2.0"
"source": "https://github.com/kint-php/kint/tree/4.2.2"
},
"time": "2022-08-27T12:15:40+00:00"
"time": "2022-09-24T10:11:09+00:00"
},
{
"name": "laminas/laminas-escaper",
@ -1264,16 +1264,16 @@
},
{
"name": "melbahja/seo",
"version": "v2.1.0",
"version": "v2.1.1",
"source": {
"type": "git",
"url": "https://github.com/melbahja/seo.git",
"reference": "0ef0a7c2b7191a3ec034a3291d76401880e28492"
"reference": "22b0b3273bf9c8867cadf018e4daa3e426525929"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/melbahja/seo/zipball/0ef0a7c2b7191a3ec034a3291d76401880e28492",
"reference": "0ef0a7c2b7191a3ec034a3291d76401880e28492",
"url": "https://api.github.com/repos/melbahja/seo/zipball/22b0b3273bf9c8867cadf018e4daa3e426525929",
"reference": "22b0b3273bf9c8867cadf018e4daa3e426525929",
"shasum": ""
},
"require": {
@ -1316,9 +1316,9 @@
],
"support": {
"issues": "https://github.com/melbahja/seo/issues",
"source": "https://github.com/melbahja/seo/tree/v2.1.0"
"source": "https://github.com/melbahja/seo/tree/v2.1.1"
},
"time": "2022-05-31T14:18:06+00:00"
"time": "2022-09-11T11:16:07+00:00"
},
{
"name": "michalsn/codeigniter4-uuid",
@ -1489,20 +1489,20 @@
},
{
"name": "nette/utils",
"version": "v3.2.7",
"version": "v3.2.8",
"source": {
"type": "git",
"url": "https://github.com/nette/utils.git",
"reference": "0af4e3de4df9f1543534beab255ccf459e7a2c99"
"reference": "02a54c4c872b99e4ec05c4aec54b5a06eb0f6368"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/utils/zipball/0af4e3de4df9f1543534beab255ccf459e7a2c99",
"reference": "0af4e3de4df9f1543534beab255ccf459e7a2c99",
"url": "https://api.github.com/repos/nette/utils/zipball/02a54c4c872b99e4ec05c4aec54b5a06eb0f6368",
"reference": "02a54c4c872b99e4ec05c4aec54b5a06eb0f6368",
"shasum": ""
},
"require": {
"php": ">=7.2 <8.2"
"php": ">=7.2 <8.3"
},
"conflict": {
"nette/di": "<3.0.6"
@ -1562,9 +1562,9 @@
],
"support": {
"issues": "https://github.com/nette/utils/issues",
"source": "https://github.com/nette/utils/tree/v3.2.7"
"source": "https://github.com/nette/utils/tree/v3.2.8"
},
"time": "2022-01-24T11:29:14+00:00"
"time": "2022-09-12T23:36:20+00:00"
},
{
"name": "opawg/user-agents-php",
@ -1979,20 +1979,20 @@
},
{
"name": "ramsey/uuid",
"version": "4.4.0",
"version": "4.5.1",
"source": {
"type": "git",
"url": "https://github.com/ramsey/uuid.git",
"reference": "373f7bacfcf3de038778ff27dcce5672ddbf4c8a"
"reference": "a161a26d917604dc6d3aa25100fddf2556e9f35d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ramsey/uuid/zipball/373f7bacfcf3de038778ff27dcce5672ddbf4c8a",
"reference": "373f7bacfcf3de038778ff27dcce5672ddbf4c8a",
"url": "https://api.github.com/repos/ramsey/uuid/zipball/a161a26d917604dc6d3aa25100fddf2556e9f35d",
"reference": "a161a26d917604dc6d3aa25100fddf2556e9f35d",
"shasum": ""
},
"require": {
"brick/math": "^0.8 || ^0.9 || ^0.10",
"brick/math": "^0.8.8 || ^0.9 || ^0.10",
"ext-ctype": "*",
"ext-json": "*",
"php": "^8.0",
@ -2013,12 +2013,13 @@
"php-mock/php-mock-mockery": "^1.3",
"php-parallel-lint/php-parallel-lint": "^1.1",
"phpbench/phpbench": "^1.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-mockery": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-mockery": "^1.1",
"phpstan/phpstan-phpunit": "^1.1",
"phpunit/phpunit": "^8.5 || ^9",
"slevomat/coding-standard": "^7.0",
"ramsey/composer-repl": "^1.4",
"slevomat/coding-standard": "^8.4",
"squizlabs/php_codesniffer": "^3.5",
"vimeo/psalm": "^4.9"
},
@ -2048,7 +2049,7 @@
"keywords": ["guid", "identifier", "uuid"],
"support": {
"issues": "https://github.com/ramsey/uuid/issues",
"source": "https://github.com/ramsey/uuid/tree/4.4.0"
"source": "https://github.com/ramsey/uuid/tree/4.5.1"
},
"funding": [
{
@ -2060,7 +2061,7 @@
"type": "tidelift"
}
],
"time": "2022-08-05T17:58:37+00:00"
"time": "2022-09-16T03:22:46+00:00"
},
{
"name": "symfony/deprecation-contracts",
@ -3356,16 +3357,16 @@
},
{
"name": "phpstan/phpstan",
"version": "1.8.4",
"version": "1.8.6",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "eed4c9da531f6ebb4787235b6fb486e2c20f34e5"
"reference": "c386ab2741e64cc9e21729f891b28b2b10fe6618"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/eed4c9da531f6ebb4787235b6fb486e2c20f34e5",
"reference": "eed4c9da531f6ebb4787235b6fb486e2c20f34e5",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/c386ab2741e64cc9e21729f891b28b2b10fe6618",
"reference": "c386ab2741e64cc9e21729f891b28b2b10fe6618",
"shasum": ""
},
"require": {
@ -3385,7 +3386,7 @@
"keywords": ["dev", "static analysis"],
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.8.4"
"source": "https://github.com/phpstan/phpstan/tree/1.8.6"
},
"funding": [
{
@ -3401,7 +3402,7 @@
"type": "tidelift"
}
],
"time": "2022-09-03T13:08:04+00:00"
"time": "2022-09-23T09:54:39+00:00"
},
{
"name": "phpunit/php-code-coverage",
@ -3690,16 +3691,16 @@
},
{
"name": "phpunit/phpunit",
"version": "9.5.24",
"version": "9.5.25",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "d0aa6097bef9fd42458a9b3c49da32c6ce6129c5"
"reference": "3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d0aa6097bef9fd42458a9b3c49da32c6ce6129c5",
"reference": "d0aa6097bef9fd42458a9b3c49da32c6ce6129c5",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d",
"reference": "3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d",
"shasum": ""
},
"require": {
@ -3721,14 +3722,14 @@
"phpunit/php-timer": "^5.0.2",
"sebastian/cli-parser": "^1.0.1",
"sebastian/code-unit": "^1.0.6",
"sebastian/comparator": "^4.0.5",
"sebastian/comparator": "^4.0.8",
"sebastian/diff": "^4.0.3",
"sebastian/environment": "^5.1.3",
"sebastian/exporter": "^4.0.3",
"sebastian/exporter": "^4.0.5",
"sebastian/global-state": "^5.0.1",
"sebastian/object-enumerator": "^4.0.3",
"sebastian/resource-operations": "^3.0.3",
"sebastian/type": "^3.1",
"sebastian/type": "^3.2",
"sebastian/version": "^3.0.2"
},
"suggest": {
@ -3760,7 +3761,7 @@
"keywords": ["phpunit", "testing", "xunit"],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.24"
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.25"
},
"funding": [
{
@ -3770,9 +3771,13 @@
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit",
"type": "tidelift"
}
],
"time": "2022-08-30T07:42:16+00:00"
"time": "2022-09-25T03:44:45+00:00"
},
{
"name": "psr/container",
@ -3827,38 +3832,36 @@
},
{
"name": "rector/rector",
"version": "0.12.23",
"version": "0.14.4",
"source": {
"type": "git",
"url": "https://github.com/rectorphp/rector.git",
"reference": "690b31768b322db886b35845f8452025eba2cacb"
"reference": "149764b07abdbfd23e98c4bb33fa6c49e2ad57cc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/rectorphp/rector/zipball/690b31768b322db886b35845f8452025eba2cacb",
"reference": "690b31768b322db886b35845f8452025eba2cacb",
"url": "https://api.github.com/repos/rectorphp/rector/zipball/149764b07abdbfd23e98c4bb33fa6c49e2ad57cc",
"reference": "149764b07abdbfd23e98c4bb33fa6c49e2ad57cc",
"shasum": ""
},
"require": {
"php": "^7.2|^8.0",
"phpstan/phpstan": "^1.6"
"phpstan/phpstan": "^1.8.3"
},
"conflict": {
"phpstan/phpdoc-parser": "<1.2",
"rector/rector-cakephp": "*",
"rector/rector-doctrine": "*",
"rector/rector-laravel": "*",
"rector/rector-nette": "*",
"rector/rector-php-parser": "*",
"rector/rector-phpoffice": "*",
"rector/rector-phpunit": "*",
"rector/rector-prefixed": "*",
"rector/rector-symfony": "*"
},
"bin": ["bin/rector"],
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "0.12-dev"
"dev-main": "0.14-dev"
}
},
"autoload": {
@ -3869,7 +3872,7 @@
"description": "Instant Upgrade and Automated Refactoring of any PHP code",
"support": {
"issues": "https://github.com/rectorphp/rector/issues",
"source": "https://github.com/rectorphp/rector/tree/0.12.23"
"source": "https://github.com/rectorphp/rector/tree/0.14.4"
},
"funding": [
{
@ -3877,7 +3880,7 @@
"type": "github"
}
],
"time": "2022-05-01T15:50:16+00:00"
"time": "2022-09-27T23:39:09+00:00"
},
{
"name": "sebastian/cli-parser",
@ -4036,16 +4039,16 @@
},
{
"name": "sebastian/comparator",
"version": "4.0.6",
"version": "4.0.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "55f4261989e546dc112258c7a75935a81a7ce382"
"reference": "fa0f136dd2334583309d32b62544682ee972b51a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382",
"reference": "55f4261989e546dc112258c7a75935a81a7ce382",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a",
"reference": "fa0f136dd2334583309d32b62544682ee972b51a",
"shasum": ""
},
"require": {
@ -4090,7 +4093,7 @@
"keywords": ["comparator", "compare", "equality"],
"support": {
"issues": "https://github.com/sebastianbergmann/comparator/issues",
"source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6"
"source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8"
},
"funding": [
{
@ -4098,7 +4101,7 @@
"type": "github"
}
],
"time": "2020-10-26T15:49:45+00:00"
"time": "2022-09-14T12:41:17+00:00"
},
{
"name": "sebastian/complexity",
@ -4267,16 +4270,16 @@
},
{
"name": "sebastian/exporter",
"version": "4.0.4",
"version": "4.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9"
"reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9",
"reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d",
"reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d",
"shasum": ""
},
"require": {
@ -4325,7 +4328,7 @@
"keywords": ["export", "exporter"],
"support": {
"issues": "https://github.com/sebastianbergmann/exporter/issues",
"source": "https://github.com/sebastianbergmann/exporter/tree/4.0.4"
"source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5"
},
"funding": [
{
@ -4333,7 +4336,7 @@
"type": "github"
}
],
"time": "2021-11-11T14:18:36+00:00"
"time": "2022-09-14T06:03:37+00:00"
},
{
"name": "sebastian/global-state",
@ -4662,16 +4665,16 @@
},
{
"name": "sebastian/type",
"version": "3.1.0",
"version": "3.2.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/type.git",
"reference": "fb44e1cc6e557418387ad815780360057e40753e"
"reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb44e1cc6e557418387ad815780360057e40753e",
"reference": "fb44e1cc6e557418387ad815780360057e40753e",
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e",
"reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e",
"shasum": ""
},
"require": {
@ -4683,7 +4686,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.1-dev"
"dev-master": "3.2-dev"
}
},
"autoload": {
@ -4702,7 +4705,7 @@
"homepage": "https://github.com/sebastianbergmann/type",
"support": {
"issues": "https://github.com/sebastianbergmann/type/issues",
"source": "https://github.com/sebastianbergmann/type/tree/3.1.0"
"source": "https://github.com/sebastianbergmann/type/tree/3.2.0"
},
"funding": [
{
@ -4710,7 +4713,7 @@
"type": "github"
}
],
"time": "2022-08-29T06:55:37+00:00"
"time": "2022-09-12T14:47:03+00:00"
},
{
"name": "sebastian/version",

View File

@ -18,12 +18,11 @@ $routes->group(
[
'namespace' => 'Modules\Admin\Controllers',
],
function ($routes): void {
static function ($routes): void {
$routes->get('/', 'DashboardController', [
'as' => 'admin',
]);
$routes->group('settings', function ($routes): void {
$routes->group('settings', static function ($routes): void {
$routes->get('/', 'SettingsController', [
'as' => 'settings-general',
'filter' => 'permission:settings-manage',
@ -53,8 +52,7 @@ $routes->group(
'filter' => 'permission:settings-manage',
]);
});
$routes->group('persons', function ($routes): void {
$routes->group('persons', static function ($routes): void {
$routes->get('/', 'PersonController', [
'as' => 'person-list',
'filter' => 'permission:person-list',
@ -66,7 +64,7 @@ $routes->group(
$routes->post('new', 'PersonController::attemptCreate', [
'filter' => 'permission:person-create',
]);
$routes->group('(:num)', function ($routes): void {
$routes->group('(:num)', static function ($routes): void {
$routes->get('/', 'PersonController::view/$1', [
'as' => 'person-view',
'filter' => 'permission:person-view',
@ -84,9 +82,8 @@ $routes->group(
]);
});
});
// Podcasts
$routes->group('podcasts', function ($routes): void {
$routes->group('podcasts', static function ($routes): void {
$routes->get('/', 'PodcastController::list', [
'as' => 'podcast-list',
]);
@ -104,10 +101,9 @@ $routes->group(
$routes->post('import', 'PodcastImportController::attemptImport', [
'filter' => 'permission:podcasts-import',
]);
// Podcast
// Use ids in admin area to help permission and group lookups
$routes->group('(:num)', function ($routes): void {
$routes->group('(:num)', static function ($routes): void {
$routes->get('/', 'PodcastController::view/$1', [
'as' => 'podcast-view',
'filter' => 'permission:podcasts-view,podcast-view',
@ -177,8 +173,7 @@ $routes->group(
'as' => 'podcast-update-feed',
'filter' => 'permission:podcasts-import',
]);
$routes->group('persons', function ($routes): void {
$routes->group('persons', static function ($routes): void {
$routes->get('/', 'PodcastPersonController/$1', [
'as' => 'podcast-persons-manage',
'filter' => 'permission:podcast-edit',
@ -190,7 +185,6 @@ $routes->group(
'filter' => 'permission:podcast-edit',
],
);
$routes->get(
'(:num)/remove',
'PodcastPersonController::remove/$1/$2',
@ -200,8 +194,7 @@ $routes->group(
],
);
});
$routes->group('analytics', function ($routes): void {
$routes->group('analytics', static function ($routes): void {
$routes->get('/', 'PodcastController::viewAnalytics/$1', [
'as' => 'podcast-analytics',
'filter' => 'permission:podcasts-view,podcast-view',
@ -255,9 +248,8 @@ $routes->group(
],
);
});
// Podcast episodes
$routes->group('episodes', function ($routes): void {
$routes->group('episodes', static function ($routes): void {
$routes->get('/', 'EpisodeController::list/$1', [
'as' => 'episode-list',
'filter' =>
@ -274,9 +266,8 @@ $routes->group(
'filter' => 'permission:podcast_episodes-create',
],
);
// Episode
$routes->group('(:num)', function ($routes): void {
$routes->group('(:num)', static function ($routes): void {
$routes->get('/', 'EpisodeController::view/$1/$2', [
'as' => 'episode-view',
'filter' =>
@ -474,8 +465,7 @@ $routes->group(
'filter' => 'permission:podcast_episodes-edit',
],
);
$routes->group('persons', function ($routes): void {
$routes->group('persons', static function ($routes): void {
$routes->get('/', 'EpisodePersonController/$1/$2', [
'as' => 'episode-persons-manage',
'filter' => 'permission:podcast_episodes-edit',
@ -498,8 +488,7 @@ $routes->group(
],
);
});
$routes->group('comments', function ($routes): void {
$routes->group('comments', static function ($routes): void {
$routes->post(
'new',
'EpisodeController::attemptCommentCreate/$1/$2',
@ -527,9 +516,8 @@ $routes->group(
});
});
});
// Podcast contributors
$routes->group('contributors', function ($routes): void {
$routes->group('contributors', static function ($routes): void {
$routes->get('/', 'ContributorController::list/$1', [
'as' => 'contributor-list',
'filter' =>
@ -547,9 +535,8 @@ $routes->group(
'permission:podcast-manage_contributors',
],
);
// Contributor
$routes->group('(:num)', function ($routes): void {
$routes->group('(:num)', static function ($routes): void {
$routes->get('/', 'ContributorController::view/$1/$2', [
'as' => 'contributor-view',
'filter' =>
@ -583,8 +570,7 @@ $routes->group(
);
});
});
$routes->group('platforms', function ($routes): void {
$routes->group('platforms', static function ($routes): void {
$routes->get(
'/',
'PodcastPlatformController::platforms/$1/podcasting',
@ -626,9 +612,8 @@ $routes->group(
],
);
});
// Podcast notifications
$routes->group('notifications', function ($routes): void {
$routes->group('notifications', static function ($routes): void {
$routes->get('/', 'NotificationController::list/$1', [
'as' => 'notification-list',
]);
@ -641,9 +626,8 @@ $routes->group(
});
});
});
// Instance wide Fediverse config
$routes->group('fediverse', function ($routes): void {
$routes->group('fediverse', static function ($routes): void {
$routes->get('/', 'FediverseController::dashboard', [
'as' => 'fediverse-dashboard',
]);
@ -664,9 +648,8 @@ $routes->group(
],
);
});
// Pages
$routes->group('pages', function ($routes): void {
$routes->group('pages', static function ($routes): void {
$routes->get('/', 'PageController::list', [
'as' => 'page-list',
]);
@ -677,8 +660,7 @@ $routes->group(
$routes->post('new', 'PageController::attemptCreate', [
'filter' => 'permission:pages-manage',
]);
$routes->group('(:num)', function ($routes): void {
$routes->group('(:num)', static function ($routes): void {
$routes->get('/', 'PageController::view/$1', [
'as' => 'page-view',
]);
@ -689,16 +671,14 @@ $routes->group(
$routes->post('edit', 'PageController::attemptEdit/$1', [
'filter' => 'permission:pages-manage',
]);
$routes->get('delete', 'PageController::delete/$1', [
'as' => 'page-delete',
'filter' => 'permission:pages-manage',
]);
});
});
// Users
$routes->group('users', function ($routes): void {
$routes->group('users', static function ($routes): void {
$routes->get('/', 'UserController::list', [
'as' => 'user-list',
'filter' => 'permission:users-list',
@ -710,9 +690,8 @@ $routes->group(
$routes->post('new', 'UserController::attemptCreate', [
'filter' => 'permission:users-create',
]);
// User
$routes->group('(:num)', function ($routes): void {
$routes->group('(:num)', static function ($routes): void {
$routes->get('/', 'UserController::view/$1', [
'as' => 'user-view',
'filter' => 'permission:users-view',
@ -746,9 +725,8 @@ $routes->group(
]);
});
});
// My account
$routes->group('my-account', function ($routes): void {
$routes->group('my-account', static function ($routes): void {
$routes->get('/', 'MyAccountController', [
'as' => 'my-account',
]);

View File

@ -81,7 +81,7 @@ class ContributorController extends BaseController
$users = (new UserModel())->findAll();
$userOptions = array_reduce(
$users,
function ($result, $user) {
static function ($result, $user) {
$result[$user->id] = $user->username;
return $result;
},
@ -91,7 +91,7 @@ class ContributorController extends BaseController
$roles = (new GroupModel())->getContributorRoles();
$roleOptions = array_reduce(
$roles,
function ($result, $role) {
static function ($result, $role) {
$result[$role->id] = lang('Contributor.roles.' . $role->name);
return $result;
},
@ -135,7 +135,7 @@ class ContributorController extends BaseController
$roles = (new GroupModel())->getContributorRoles();
$roleOptions = array_reduce(
$roles,
function ($result, $role) {
static function ($result, $role) {
$result[$role->id] = lang('Contributor.roles.' . $role->name);
return $result;
},

View File

@ -120,7 +120,7 @@ class UserController extends BaseController
$roles = (new GroupModel())->getUserRoles();
$roleOptions = array_reduce(
$roles,
function ($result, $role) {
static function ($result, $role) {
$result[$role->name] = lang('User.roles.' . $role->name);
return $result;
},

View File

@ -24,8 +24,8 @@ $routes->addPlaceholder(
$routes->group('', [
'namespace' => 'Modules\Analytics\Controllers',
], function ($routes): void {
$routes->group(config('Analytics')->gateway . '/(:num)/(:class)', function ($routes): void {
], 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')
@ -33,13 +33,11 @@ $routes->group('', [
'analytics-full-data'
],
]);
$routes->get('(:filter)', 'AnalyticsController::getData/$1/$2/$3', [
'as' => 'analytics-data',
'filter' => config('Analytics')
->routeFilters['analytics-data'],
]);
$routes->get(
'(:filter)/(:num)',
'AnalyticsController::getData/$1/$2/$3/$4',
@ -52,11 +50,9 @@ $routes->group('', [
],
);
});
$routes->get(config('Analytics')->gateway . '/(:class)/(:filter)', 'AnalyticsController::getData/$1/$2', [
'as' => 'analytics-data-instance',
]);
// Route for podcast audio file analytics (/audio/pack(podcast_id,episode_id,bytes_threshold,filesize,duration,date)/podcast_folder/filename.mp3)
$routes->head(
'audio/(:base64)/(:any)',

View File

@ -13,7 +13,7 @@ $routes->group(
'namespace' => 'Modules\Api\Rest\V1\Controllers',
'filter' => 'rest-api',
],
function ($routes): void {
static function ($routes): void {
$routes->get('/', 'PodcastController::list');
$routes->get('(:num)', 'PodcastController::view/$1');
$routes->get('(:any)', 'ExceptionController::notFound');

View File

@ -23,7 +23,7 @@ class PodcastController extends Controller
public function list(): Response
{
$data = (new PodcastModel())->findAll();
array_map(function ($podcast): void {
array_map(static function ($podcast): void {
$podcast->feed_url = $podcast->getFeedUrl();
}, $data);
return $this->respond($data);

View File

@ -15,7 +15,7 @@ $routes->group(
[
'namespace' => 'Modules\Auth\Controllers',
],
function ($routes): void {
static function ($routes): void {
// Login/out
$routes->get('login', 'AuthController::login', [
'as' => 'login',
@ -24,13 +24,11 @@ $routes->group(
$routes->get('logout', 'AuthController::logout', [
'as' => 'logout',
]);
// Registration
$routes->get('register', 'AuthController::register', [
'as' => 'register',
]);
$routes->post('register', 'AuthController::attemptRegister');
// Activation
$routes->get('activate-account', 'AuthController::activateAccount', [
'as' => 'activate-account',
@ -42,7 +40,6 @@ $routes->group(
'as' => 'resend-activate-account',
],
);
// Forgot/Resets
$routes->get('forgot', 'AuthController::forgotPassword', [
'as' => 'forgot',
@ -52,7 +49,6 @@ $routes->group(
'as' => 'reset-password',
]);
$routes->post('reset-password', 'AuthController::attemptReset');
// interacting as an actor
$routes->post('interact-as-actor', 'AuthController::attemptInteractAsActor', [
'as' => 'interact-as-actor',

View File

@ -23,19 +23,17 @@ $routes->addPlaceholder('postAction', '\bfavourite|\breblog|\breply');
$routes->group('', [
'namespace' => 'Modules\Fediverse\Controllers',
], function ($routes): void {
], static function ($routes): void {
// webfinger
$routes->get('.well-known/webfinger', 'WebFingerController', [
'as' => 'webfinger',
]);
// nodeInfo2
$routes->get('.well-known/x-nodeinfo2', 'NodeInfo2Controller', [
'as' => 'nodeInfo2',
]);
// Actor
$routes->group('@(:actorUsername)', function ($routes): void {
$routes->group('@(:actorUsername)', static function ($routes): void {
// Actor
$routes->get('/', 'ActorController/$1', [
'as' => 'actor',
@ -60,20 +58,16 @@ $routes->group('', [
'as' => 'activity',
]);
});
// Post
$routes->post('posts/new', 'PostController::attemptCreate/$1', [
'as' => 'post-attempt-create',
]);
$routes->get('posts/(:uuid)', 'PostController/$1', [
'as' => 'post',
]);
$routes->get('posts/(:uuid)/replies', 'PostController/$1', [
'as' => 'post-replies',
]);
$routes->post(
'posts/(:uuid)/remote/(:postAction)',
'PostController::attemptRemoteAction/$1/$2/$3',
@ -81,7 +75,6 @@ $routes->group('', [
'as' => 'post-attempt-remote-action',
],
);
// Blocking actors and domains
$routes->post(
'fediverse-block-actor',
@ -90,7 +83,6 @@ $routes->group('', [
'as' => 'fediverse-attempt-block-actor',
],
);
$routes->post(
'fediverse-block-domain',
'BlockController::attemptBlockDomain',
@ -98,7 +90,6 @@ $routes->group('', [
'as' => 'fediverse-attempt-block-domain',
],
);
$routes->post(
'fediverse-unblock-actor',
'BlockController::attemptUnblockActor',
@ -106,7 +97,6 @@ $routes->group('', [
'as' => 'fediverse-attempt-unblock-actor',
],
);
$routes->post(
'fediverse-unblock-domain',
'BlockController::attemptUnblockDomain',
@ -114,6 +104,5 @@ $routes->group('', [
'as' => 'fediverse-attempt-unblock-domain',
],
);
$routes->cli('scheduled-activities', 'SchedulerController::activity');
});

View File

@ -16,10 +16,7 @@ namespace Modules\Fediverse\Core;
abstract class AbstractObject
{
/**
* @param mixed $value
*/
public function set(string $property, $value): static
public function set(string $property, mixed $value): static
{
$this->{$property} = $value;
@ -45,7 +42,7 @@ abstract class AbstractObject
}
// removes all NULL, FALSE and Empty Strings but leaves 0 (zero) values
return array_filter($array, function ($value): bool {
return array_filter($array, static function ($value): bool {
return $value !== null && $value !== false && $value !== '';
});
}

View File

@ -362,17 +362,14 @@ if (! function_exists('linkify')) {
$text = match ($protocol) {
'http', 'https' => preg_replace_callback(
'~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i',
function (array $match) use ($protocol, &$links) {
static function (array $match) use ($protocol, &$links) {
if ($match[1] !== '' && $match[1] !== '0') {
$protocol = $match[1];
}
$link = $match[2] ?: $match[3];
helper('text');
$link = preg_replace('~^www\.(.+\.)~i', '$1', $link);
return '<' .
array_push(
$links,
@ -391,7 +388,7 @@ if (! function_exists('linkify')) {
),
'handle' => preg_replace_callback(
'~(?<!\w)@(?<username>\w++)(?:@(?<domain>(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]))?~',
function ($match) use (&$links) {
static function ($match) use (&$links) {
// check if host is set and look for actor in database
if (isset($match['host'])) {
if (
@ -449,7 +446,7 @@ if (! function_exists('linkify')) {
'~' .
preg_quote($protocol, '~') .
'://([^\s<]+?)(?<![\.,:])~i',
function (array $match) use ($protocol, &$links) {
static function (array $match) use ($protocol, &$links) {
return '<' .
array_push(
$links,
@ -472,7 +469,7 @@ if (! function_exists('linkify')) {
// Insert all links
return preg_replace_callback(
'~<(\d+)>~',
function ($match) use (&$links) {
static function ($match) use (&$links) {
return $links[$match[1] - 1];
},
$text,

View File

@ -13,7 +13,7 @@ $routes->group(
[
'namespace' => 'Modules\Install\Controllers',
],
function ($routes): void {
static function ($routes): void {
$routes->get('/', 'InstallController', [
'as' => 'install',
]);

View File

@ -121,10 +121,12 @@ class InstallController extends Controller
if (
$db->tableExists('users') &&
(new UserModel())->countAll() > 0
) {
) {
// if so, show a 404 page
throw PageNotFoundException::forPageNotFound();
}
/** @noRector */
} catch (DatabaseException) {
// Could not connect to the database
// show database config view to fix value
@ -355,7 +357,7 @@ class InstallController extends Controller
$replaced = false;
$keyVal = $key . '="' . $value . '"' . PHP_EOL;
$envData = array_map(
function ($line) use ($key, $keyVal, &$replaced) {
static function ($line) use ($key, $keyVal, &$replaced) {
if (str_starts_with($line, $key)) {
$replaced = true;
return $keyVal;

View File

@ -16,6 +16,6 @@ $routes = service('routes');
$routes->group('', [
'namespace' => 'Modules\WebSub\Controllers',
], function ($routes): void {
], static function ($routes): void {
$routes->cli('scheduled-websub-publish', 'WebSubController::publish');
});

View File

@ -20,6 +20,7 @@ class WebSubController extends Controller
{
public function publish(): void
{
/** @noRector RemoveAlwaysTrueIfConditionRector */
if (ENVIRONMENT !== 'production') {
return;
}

View File

@ -13,7 +13,7 @@ use Rector\Core\ValueObject\PhpVersion;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Php80\Rector\ClassMethod\OptionalParametersAfterRequiredRector;
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
use Rector\Set\ValueObject\SetList;
return static function (RectorConfig $rectorConfig): void {
@ -42,12 +42,13 @@ return static function (RectorConfig $rectorConfig): void {
// auto import fully qualified class names
$rectorConfig->importNames();
// TODO: add parallel run
// $rectorConfig->parallel();
$rectorConfig->phpVersion(PhpVersion::PHP_80);
$rectorConfig->skip([
// .mp3 files were somehow processed by rector, so skip all media files
__DIR__ . '/public/media/*',
__DIR__ . '/app/Views/errors/*',
// skip specific generated files
@ -59,6 +60,7 @@ return static function (RectorConfig $rectorConfig): void {
EncapsedStringsToSprintfRector::class,
UnSpreadOperatorRector::class,
ExplicitMethodCallOverMagicGetSetRector::class,
RemoveExtraParametersRector::class,
// skip rule in specific directory
StringClassNameToClassConstantRector::class => [
@ -69,9 +71,6 @@ return static function (RectorConfig $rectorConfig): void {
__DIR__ . '/app/Language/*',
__DIR__ . '/modules/*/Language/*',
],
OptionalParametersAfterRequiredRector::class => [
__DIR__ . '/app/Validation',
],
NewlineAfterStatementRector::class => [
__DIR__ . '/app/Views',