Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #45

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
php:
preset: laravel
disabled:
- unused_use
finder:
exclude:
- "legacy"
not-name:
- "index.php"
- "server.php"
js:
finder:
exclude:
- "legacy"
not-name:
- "webpack.mix.js"
css: true
preset: laravel
enabled:
- concat_with_spaces
disabled:
- no_unused_imports
- concat_without_spaces
finder:
exclude:
- "legacy"
- "modules"
- "node_modules"
- "nova"
- "nova-components"
- "storage"
- "spark"
- "vendor"
not-name:
- "index.php"
- "server.php"
- "*.blade.php"
- "_ide_helper.php"
4 changes: 2 additions & 2 deletions app/Console/Commands/GenerateHtaccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GenerateHtaccess extends Command
*
* @var string
*/
protected $description = "Génère un fichier .htaccess au répertoire racine, "
protected $description = 'Génère un fichier .htaccess au répertoire racine, '
. "selon la configuration de l'application";

/**
Expand All @@ -33,7 +33,7 @@ public function handle(): int
$template = file_get_contents(resource_path('templates/htaccess-template.txt'));

$directoryPath = config('app.directory_path');
if(! empty($directoryPath)) {
if (! empty($directoryPath)) {
$directoryPath = '/' . $directoryPath;
}

Expand Down
14 changes: 8 additions & 6 deletions app/Console/Commands/InitializeDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class InitializeDatabase extends Initializer
*
* @var string
*/
protected $description = "Initialise la base de données en créant le schéma de la base et les données";
protected $description = 'Initialise la base de données en créant le schéma de la base et les données';

/**
* Execute the console command.
Expand All @@ -30,22 +30,24 @@ class InitializeDatabase extends Initializer
public function handle(): int
{
// Vérifier que les conditions d'exécution du script d'initialisation de la DB sont ok.
if(! File::exists('.env')) {
if (! File::exists('.env')) {
$this->error("Vous devez initialiser l'environnement au préalable.");

return 1;
}

// Eviter l'exécution en prod.
if(app()->environment() === 'production') {
$this->error("Vous ne pouvez pas initialiser la base de données dans un environnement "
. "de production.");
if (app()->environment() === 'production') {
$this->error('Vous ne pouvez pas initialiser la base de données dans un environnement '
. 'de production.');

return 1;
}

// Exécuter effectivement la commande d'initialisation de la DB.
$this->call('monde:update');
$this->call('db:seed');
$this->info("Base de données initialisée avec succès.");
$this->info('Base de données initialisée avec succès.');

return 0;
}
Expand Down
5 changes: 3 additions & 2 deletions app/Console/Commands/InitializeEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ class InitializeEnvironment extends Initializer
public function handle(): int
{
// Vérifier que les conditions d'exécution du script d'initialisation sont ok.
if(File::exists('.env')) {
if (File::exists('.env')) {
$this->error("Vous ne pouvez pas initialiser l'application car un fichier .env existe déjà.");

return 1;
}

Expand Down Expand Up @@ -63,7 +64,7 @@ private function generateKey(): void

private function generateLegacyHashKey(): void
{
$this->line("Génération de la clé de hachage (legacy) : LEGACY_SALT");
$this->line('Génération de la clé de hachage (legacy) : LEGACY_SALT');

$path = base_path('.env');
$salt = Str::random(32);
Expand Down
18 changes: 9 additions & 9 deletions app/Console/Commands/Initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ protected function initTestingEnv(): void
{
$this->line('Copie de .env --> .env.testing');

if(! File::exists(base_path('.env'))) {
throw new FileNotFoundException("Fichier .env non existant.");
if (! File::exists(base_path('.env'))) {
throw new FileNotFoundException('Fichier .env non existant.');
}

$testingPath = base_path('.env.testing');
Expand All @@ -31,20 +31,20 @@ protected function initTestingEnv(): void
/**
* Modifie la valeur d'une clé dans un fichier .env.
*
* @param string $path
* @param string $key
* @param string $newValue
* @param string|null $oldValue
* @param string $path
* @param string $key
* @param string $newValue
* @param string|null $oldValue
* @return bool Renvoie <code>true</code> en cas de succès lors de l'écriture de la nouvelle valeur,
* <code>false</code> sinon.
*/
protected function saveEnvValueToFile(string $path, string $key, string $newValue, ?string $oldValue = null): bool
{
if($oldValue === null) {
if ($oldValue === null) {
$oldValue = '';
}

if(!file_exists($path)) {
if (! file_exists($path)) {
return false;
}

Expand All @@ -54,6 +54,6 @@ protected function saveEnvValueToFile(string $path, string $key, string $newValu
file_get_contents($path)
));

return !($success === false);
return ! ($success === false);
}
}
13 changes: 8 additions & 5 deletions app/Console/Commands/OverrideVendorFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ class OverrideVendorFiles extends Command

/**
* Indique l'emplacement source => destination des fichiers à override.
*
* @var string[]
*/
protected $fileCopies = [
'app/Overrides/Searchable/SearchResult.php' => 'vendor/spatie/laravel-searchable/src/SearchResult.php'
'app/Overrides/Searchable/SearchResult.php' => 'vendor/spatie/laravel-searchable/src/SearchResult.php',
];

/**
Expand All @@ -40,6 +41,7 @@ class OverrideVendorFiles extends Command
public function handle(): int
{
$this->copyFiles();

return 0;
}

Expand All @@ -51,12 +53,13 @@ private function copyFiles(): void
$backupPath = storage_path('app/copy-backup/' . Str::random(6));
mkdir($backupPath, 0777, true);
} catch(\Exception $e) {
$this->error("Impossible de créer le dossier.");
$this->error('Impossible de créer le dossier.');

return;
}

try {
foreach($this->fileCopies as $origin => $destination) {
foreach ($this->fileCopies as $origin => $destination) {
$this->line("Copie de $origin ==> $destination");

$fileBackupPath = $backupPath . '/' . basename($destination);
Expand All @@ -65,9 +68,9 @@ private function copyFiles(): void
copy($destinationPath, $fileBackupPath);
copy($originPath, $destinationPath);
}
$this->info("Copies réalisées avec succès.");
$this->info('Copies réalisées avec succès.');
} catch(\Exception $e) {
$this->error("Une des copies a échoué.");
$this->error('Une des copies a échoué.');
}
}
}
9 changes: 5 additions & 4 deletions app/Console/Commands/RegenerateInfluences.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class RegenerateInfluences extends Command
*
* @var string
*/
protected $description = "Régénère les influences générées par les entités influençables.";
protected $description = 'Régénère les influences générées par les entités influençables.';

/**
* Execute the console command.
*
* @param RegenerateInfluenceService $regenerateInfluenceService
* @param RegenerateInfluenceService $regenerateInfluenceService
* @return int
*/
public function handle(RegenerateInfluenceService $regenerateInfluenceService): int
Expand All @@ -37,11 +37,12 @@ public function handle(RegenerateInfluenceService $regenerateInfluenceService):
$regenerateInfluenceService->regenerate();
$this->info('Influences regénérées avec succès ('
. $regenerateInfluenceService->influenceCount() . ' influence(s) actuellement dans la base de données).');
}
catch (\Throwable $ex) {
} catch (\Throwable $ex) {
$this->error("Une erreur s'est produite : " . $ex->getMessage());

return 1;
}

return 0;
}
}
1 change: 1 addition & 0 deletions app/Console/Commands/UpdateProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function handle(): int
{
$this->copyFiles();
$this->migrateDatabase();

return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param Schedule $schedule
* @param Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule): void
Expand All @@ -30,7 +30,7 @@ protected function schedule(Schedule $schedule): void
*/
protected function commands(): void
{
$this->load(__DIR__.'/Commands');
$this->load(__DIR__ . '/Commands');

require base_path('routes/console.php');
}
Expand Down
2 changes: 1 addition & 1 deletion app/Events/Infrastructure/InfrastructureJudged.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class InfrastructureJudged implements InfluencableEvent
/**
* Create a new event instance.
*
* @param Infrastructure $infrastructure
* @param Infrastructure $infrastructure
*/
public function __construct(Infrastructure $infrastructure)
{
Expand Down
2 changes: 1 addition & 1 deletion app/Events/Organisation/MembershipChanged.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MembershipChanged
/**
* Create a new event instance.
*
* @param Organisation $organisation
* @param Organisation $organisation
*/
public function __construct(Organisation $organisation)
{
Expand Down
2 changes: 1 addition & 1 deletion app/Events/Organisation/TypeMigrated.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TypeMigrated
/**
* Create a new event instance.
*
* @param Organisation $organisation
* @param Organisation $organisation
*/
public function __construct(Organisation $organisation)
{
Expand Down
2 changes: 1 addition & 1 deletion app/Events/Patrimoine/PatrimoineCategorized.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PatrimoineCategorized implements InfluencableEvent
/**
* Create a new event instance.
*
* @param Patrimoine $patrimoine
* @param Patrimoine $patrimoine
*/
public function __construct(Patrimoine $patrimoine)
{
Expand Down
2 changes: 1 addition & 1 deletion app/Events/Pays/MapUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MapUpdated implements InfluencableEvent
/**
* Create a new event instance.
*
* @param Pays $pays
* @param Pays $pays
*/
public function __construct(Pays $pays)
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct()
/** @var Authenticatable&CustomUser|null $user */
$user = $auth->user();

if(! $auth->check() || ! $user?->hasMinPermission('admin')) {
if (! $auth->check() || ! $user?->hasMinPermission('admin')) {
abort(403);
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/Api/ResourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
class ResourceController extends Controller
{
/**
* /resource
* /resource.
*
* Ressources générées par les entités.
*
* @param Request $request
* @param string $type
* @param Request $request
* @param string $type
* @return ResourceCollection
*
* @urlParam type string required Type de l'entité générant des ressources. Prend les valeurs "ville", "pays",
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/Api/ResourceableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
class ResourceableController extends Controller
{
/**
* /resourceable
* /resourceable.
*
* Liste d'entités générant des ressources.
*
* @param Request $request
* @param string $type
* @param Request $request
* @param string $type
* @return ResourceCollection
*
* @urlParam type string required Type de l'entité générant des ressources. Prend les valeurs "ville", "pays",
Expand Down
10 changes: 5 additions & 5 deletions app/Http/Controllers/BackOfficeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class BackOfficeController extends Controller
{
public function __construct()
{
$this->middleware(function(Request $request, \Closure $next): mixed {
if(! auth()->user()?->hasMinPermission('ocgc')) {
$this->middleware(function (Request $request, \Closure $next): mixed {
if (! auth()->user()?->hasMinPermission('ocgc')) {
abort(403);
}

Expand All @@ -25,8 +25,8 @@ public function __construct()
}

/**
* @param Manager $featureManager
* @param RegenerateInfluenceService $regenerateInfluenceService
* @param Manager $featureManager
* @param RegenerateInfluenceService $regenerateInfluenceService
* @return View
*/
public function advancedParameters(
Expand Down Expand Up @@ -58,7 +58,7 @@ public function purgeCache(): RedirectResponse
}

/**
* @param RegenerateInfluenceService $regenerateInfluenceService
* @param RegenerateInfluenceService $regenerateInfluenceService
* @return RedirectResponse
*/
public function regenerateInfluences(RegenerateInfluenceService $regenerateInfluenceService): RedirectResponse
Expand Down
Loading
Loading