style(ecs): add easy-coding-standard to enforce coding style rules for php

- update .devcontainer settings: remove auto-formatting
for php + set intelephense as default formatter
- remove prettier php plugin as it lacks php 8 support
- add captain hook action for checking style pre-commit
- fix style with ecs on all files except views
This commit is contained in:
Yassine Doghri 2021-05-19 16:35:13 +00:00
commit aa1612342e
No known key found for this signature in database
GPG key ID: 3E7F89498B960C9F
230 changed files with 3420 additions and 5884 deletions

View file

@ -8,33 +8,28 @@
namespace App\Controllers\Admin;
use CodeIgniter\HTTP\RedirectResponse;
use App\Entities\Podcast;
use CodeIgniter\Exceptions\PageNotFoundException;
use App\Models\PlatformModel;
use App\Models\PodcastModel;
use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\HTTP\RedirectResponse;
use Config\Services;
class PodcastPlatformController extends BaseController
{
/**
* @var Podcast|null
*/
protected ?Podcast $podcast;
public function _remap(string $method, string ...$params): mixed
{
if (count($params) === 0) {
return $this->$method();
return $this->{$method}();
}
if (
($this->podcast = (new PodcastModel())->getPodcastById(
(int) $params[0],
)) !== null
($this->podcast = (new PodcastModel())->getPodcastById((int) $params[0],)) !== null
) {
unset($params[0]);
return $this->$method(...$params);
return $this->{$method}(...$params);
}
throw PageNotFoundException::forPageNotFound();
@ -52,19 +47,17 @@ class PodcastPlatformController extends BaseController
$data = [
'podcast' => $this->podcast,
'platformType' => $platformType,
'platforms' => (new PlatformModel())->getPlatformsWithLinks(
$this->podcast->id,
$platformType,
),
'platforms' => (new PlatformModel())->getPlatformsWithLinks($this->podcast->id, $platformType,),
];
replace_breadcrumb_params([0 => $this->podcast->title]);
replace_breadcrumb_params([
0 => $this->podcast->title,
]);
return view('admin/podcast/platforms', $data);
}
public function attemptPlatformsUpdate(
string $platformType
): RedirectResponse {
public function attemptPlatformsUpdate(string $platformType): RedirectResponse
{
$platformModel = new PlatformModel();
$validation = Services::validation();
@ -78,7 +71,7 @@ class PodcastPlatformController extends BaseController
if ($podcastPlatformUrl === null) {
continue;
}
if (!$validation->check($podcastPlatformUrl, 'validate_url')) {
if (! $validation->check($podcastPlatformUrl, 'validate_url')) {
continue;
}
$podcastsPlatformsData[] = [
@ -88,36 +81,28 @@ class PodcastPlatformController extends BaseController
'link_content' => $podcastPlatform['content'],
'is_visible' =>
array_key_exists('visible', $podcastPlatform) &&
$podcastPlatform['visible'] == 'yes',
$podcastPlatform['visible'] === 'yes',
'is_on_embeddable_player' =>
array_key_exists(
'on_embeddable_player',
$podcastPlatform,
) && $podcastPlatform['on_embeddable_player'] == 'yes',
) && $podcastPlatform['on_embeddable_player'] === 'yes',
];
return redirect()
->back()
->with('message', lang('Platforms.messages.updateSuccess'));
}
$platformModel->savePodcastPlatforms(
$this->podcast->id,
$platformType,
$podcastsPlatformsData,
);
$platformModel->savePodcastPlatforms($this->podcast->id, $platformType, $podcastsPlatformsData,);
return redirect()
->back()
->with('message', lang('Platforms.messages.updateSuccess'));
}
public function removePodcastPlatform(
string $platformSlug
): RedirectResponse {
(new PlatformModel())->removePodcastPlatform(
$this->podcast->id,
$platformSlug,
);
public function removePodcastPlatform(string $platformSlug): RedirectResponse
{
(new PlatformModel())->removePodcastPlatform($this->podcast->id, $platformSlug,);
return redirect()
->back()