Skip to content

Commit

Permalink
fix code styles
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Nov 25, 2024
1 parent 4e2c859 commit 936dcbf
Show file tree
Hide file tree
Showing 20 changed files with 559 additions and 425 deletions.
21 changes: 12 additions & 9 deletions app/Command/CheckTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Illuminate\Console\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Finder\Finder;

#[AsCommand(
name: 'translations:check-unused',
Expand All @@ -21,6 +21,7 @@ class CheckTranslations extends Command
protected $description = 'Scan codebase for unused translation strings';

protected $translations = [];

protected $usedTranslations = [];

public function handle()
Expand All @@ -42,8 +43,9 @@ public function handle()
private function parseLanguageFile(): void
{
$langFile = app_path('Language/en-US.ini');
if (!file_exists($langFile)) {
$this->error('Language file not found: ' . $langFile);
if (! file_exists($langFile)) {
$this->error('Language file not found: '.$langFile);

return;
}

Expand All @@ -60,10 +62,10 @@ private function scanFiles(): void
$excludeDirs = explode(',', $this->option('exclude'));

if ($this->option('debug')) {
$this->info('Excluding directories: ' . implode(', ', $excludeDirs));
$this->info('Excluding directories: '.implode(', ', $excludeDirs));
}

$finder = new Finder();
$finder = new Finder;
$finder->files()
->in(app_path())
->name('*.php')
Expand Down Expand Up @@ -97,18 +99,18 @@ private function scanFileForTranslations($file): void
preg_quote($key, '/'), // Direct key usage
preg_quote("'$key'", '/'), // Single quoted
preg_quote("\"$key\"", '/'), // Double quoted
preg_quote('__("' . $key . '")', '/'), // PHP translation function
preg_quote('__("'.$key.'")', '/'), // PHP translation function
preg_quote("__('$key')", '/'), // PHP translation function
preg_quote('$tpl->__("' . $key . '")', '/'), // Template translation
preg_quote('$tpl->__(\'' . $key . '\')', '/'), // Template translation
preg_quote('$tpl->__("'.$key.'")', '/'), // Template translation
preg_quote('$tpl->__(\''.$key.'\')', '/'), // Template translation
];

if ($this->option('debug')) {
$this->line("Scanning file: {$filePath}");
}

foreach ($patterns as $pattern) {
if (preg_match('/' . $pattern . '/', $content)) {
if (preg_match('/'.$pattern.'/', $content)) {
if ($this->option('debug')) {
$this->line(" - Found usage of key: {$key}");
}
Expand All @@ -125,6 +127,7 @@ private function generateReport(): void

if (empty($unusedTranslations)) {
$this->info('No unused translations found.');

return;
}

Expand Down
1 change: 0 additions & 1 deletion app/Core/Configuration/laravelConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@
],
],


],
/*
|--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion app/Core/Http/HttpKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class HttpKernel extends Kernel
* @var array<string, class-string|string>
*/
protected $middlewareAliases = [
'auth' => \Leantime\Core\Middleware\AuthCheck::class,
'auth' => \Leantime\Core\Middleware\AuthCheck::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
Expand Down
2 changes: 1 addition & 1 deletion app/Core/Middleware/AuthCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function handle(IncomingRequest $request, Closure $next): Response

$loginRedirect = self::dispatch_filter('loginRoute', 'auth.login', ['request' => $request]);

if ( $request instanceof ApiRequest) {
if ($request instanceof ApiRequest) {
self::dispatchEvent('before_api_request', ['application' => app()], 'leantime.core.middleware.apiAuth.handle');
}
$authCheckResponse = $this->authenticate($request, array_keys($this->config->get('auth.guards')), $loginRedirect, $next);
Expand Down
10 changes: 3 additions & 7 deletions app/Core/Providers/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@

namespace Leantime\Core\Providers;

use Illuminate\Contracts\Auth\Factory as AuthFactory;
use Illuminate\Support\ServiceProvider;
use Leantime\Domain\Api\Services\Api;
use Leantime\Domain\Auth\Guards\ApiGuard;
use Leantime\Domain\Auth\Guards\LeantimeGuard;
use Leantime\Domain\Auth\Providers\LeantimeUserProvider;
use Leantime\Domain\Auth\Services\Auth as AuthService;
use Leantime\Domain\Oidc\Services\Oidc as OidcService;
use Illuminate\Support\Facades\Auth;

class Authentication extends ServiceProvider
{

/**
* Register any application services.
*
Expand Down Expand Up @@ -47,9 +43,9 @@ public function boot()

$this->app['auth']->extend('jsonRpc', function ($app, $name, array $config) {
return new ApiGuard(
$app['auth']->createUserProvider($config['provider']),
$app->make(\Leantime\Domain\Api\Services\Api::class),
$app['request']
$app['auth']->createUserProvider($config['provider']),
$app->make(\Leantime\Domain\Api\Services\Api::class),
$app['request']
);
});
}
Expand Down
1 change: 0 additions & 1 deletion app/Core/Providers/Logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Leantime\Core\Providers;

use Illuminate\Container\Container;
use Illuminate\Log;
use Illuminate\Support\ServiceProvider;

Expand Down
1 change: 0 additions & 1 deletion app/Core/Providers/RateLimiter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Leantime\Core\Providers;

use Illuminate\Container\Container;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\ServiceProvider;

Expand Down
2 changes: 1 addition & 1 deletion app/Core/Providers/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function register()
// Set cluster specific options
$app['config']->set('redis.options', [
'cluster' => 'redis',
'parameters' => ['timeout' => 1.0]
'parameters' => ['timeout' => 1.0],
]);
} else {
$app['config']->set('redis.cache', $cacheConfig);
Expand Down
11 changes: 7 additions & 4 deletions app/Domain/Auth/Guards/LeantimeGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

namespace Leantime\Domain\Auth\Guards;

use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Contracts\Auth\Authenticatable;
use Leantime\Domain\Auth\Services\Auth as AuthService;

class LeantimeGuard implements Guard
{
protected $provider;

protected $user;

protected AuthService $authService;

public function __construct(UserProvider $provider, AuthService $authService)
Expand All @@ -26,7 +28,7 @@ public function check()

public function guest()
{
return !$this->check();
return ! $this->check();
}

public function user()
Expand All @@ -42,7 +44,8 @@ public function user()
return $this->user;
}

public function hasUser() {
public function hasUser()
{
return $this->user ? true : false;
}

Expand All @@ -64,7 +67,7 @@ public function validate(array $credentials = [])
public function setUser(Authenticatable $user)
{
$this->user = $user;

return $this;
}

}
3 changes: 2 additions & 1 deletion app/Domain/Auth/Services/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,8 @@ public function getRememberTokenName()
return 'remember_token';
}

public function getUserById($id) {
public function getUserById($id)
{
return (object) $this->userRepo->getUser($id);
}
}
1 change: 0 additions & 1 deletion app/Domain/Help/Composers/Helpermodal.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public function with(): array

$currentModal = $this->helperService->getHelperModalByRoute($action);


if (
$completedOnboarding == '1'
&& $currentModal !== 'notfound'
Expand Down
Loading

0 comments on commit 936dcbf

Please sign in to comment.