Skip to content

Commit

Permalink
fix: Apply rector changes
Browse files Browse the repository at this point in the history
  • Loading branch information
neznaika0 authored and dgvirtual committed Feb 5, 2025
1 parent 526bf3c commit c56e9bf
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 25 deletions.
11 changes: 4 additions & 7 deletions src/Assets/Controllers/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Bonfire\Assets\Controllers;

use CodeIgniter\Controller;
use CodeIgniter\Exceptions\PageNotFoundException;

/**
* Responsible for serving css/js/image assets from
Expand Down Expand Up @@ -48,26 +49,22 @@ public function serve(...$segments)
$count = count($fileparts);
// Must be at least a name and extension
if ($count < 2) {
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
throw PageNotFoundException::forPageNotFound();
}
$ext = $fileparts[$count - 1];

// To keep backward compatibility, we will assume there might not be
// a separator defined in user's config
$separator = config('Assets')->separator ?? '~~';
$parts = explode($separator, $filename);
if (count($parts) === 2) {
$filename = $parts[0] . '.' . $ext;
} else {
$filename = $origFilename;
}
$filename = count($parts) === 2 ? $parts[0] . '.' . $ext : $origFilename;
$baseAssetFolders = config('Assets')->folders; // get list of folders with assets
$targetBaseAssetFolder = array_shift($segments); // from segments choose the first one as main folder
$folder = $baseAssetFolders[$targetBaseAssetFolder] ?? ROOTPATH . '/somer^3andomWhatever'; // point to folder in the website or a non-existent folder within root path

$path = $folder . '/' . implode('/', $segments) . '/' . $filename;
if (! is_file($path) || empty($folder)) {
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
throw PageNotFoundException::forPageNotFound();
}

return $this->response->download($origFilename, file_get_contents($path), true)->inline();
Expand Down
4 changes: 1 addition & 3 deletions src/Recycler/Controllers/RecycleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ public function viewResource()
->paginate(setting('Site.perPage'));

// localize resources if possible
$resources = array_map(function ($resource) {
return $this->localizeResource($resource);
}, $resources);
$resources = array_map(fn ($resource) => $this->localizeResource($resource), $resources);

return $this->render($this->viewPrefix . 'listResource', [
'resources' => $resources,
Expand Down
8 changes: 4 additions & 4 deletions src/Tools/Controllers/LogsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public function index()
// Define the regular expression pattern for log files
$logPattern = '/^log-\d{4}-\d{2}-\d{2}\.log$/';
// Filter the array removing index.html and other files that do not match
$logs = array_filter($logs, function ($filename) use ($logPattern) {
return preg_match($logPattern, $filename);
});
$logs = array_filter($logs, static fn ($filename) => preg_match($logPattern, $filename));

$result = $this->logsHandler->paginateLogs($logs, $this->logsLimit);
// Cycle through the $result array and attach the content property
$counter = count($result['logs']);

// Cycle through the $result array and attach the content property
for ($i = 0; $i < count($result['logs']); $i++) {
for ($i = 0; $i < $counter; $i++) {
if ($result['logs'][$i] === 'index.html') {
unset($result['logs'][$i]);
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Language/it/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
'deleteAllConfirm' => 'Sei sicuro di voler eliminare tutti i file di registro?',
'deleteSuccess' => 'File eliminati con successo.',
'deleteAllSuccess' => 'Tutti i file sono stati eliminati con successo.',
'deleteError' => 'Impossibile eseguire l\'eliminazione.',
'deleteError' => "Impossibile eseguire l'eliminazione.",
];
12 changes: 6 additions & 6 deletions src/Tools/Libraries/Logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Bonfire\Tools\Libraries;

use DateTime;

/**
* Provides view cells for Users
*/
Expand Down Expand Up @@ -111,7 +113,7 @@ public function countLogLevels($filePath): string
$fileContent = file_get_contents($filePath);

if ($fileContent === false) {
throw new Exception("Unable to read the file: $filePath");
throw new Exception("Unable to read the file: {$filePath}");
}

// Count occurrences of each level
Expand All @@ -120,9 +122,7 @@ public function countLogLevels($filePath): string
}

// Remove entries with value 0
$counts = array_filter($counts, function ($value) {
return $value > 0;
});
$counts = array_filter($counts, static fn ($value) => $value > 0);

$counts = array_reverse($counts);

Expand Down Expand Up @@ -189,7 +189,7 @@ public function getAdjacentLogFiles($currentLogFileBasename, $logsPath): array
{
// Extract the date from the current log file name
preg_match('/log-(\d{4}-\d{2}-\d{2})/', $currentLogFileBasename, $matches);
$currentDate = new \DateTime($matches[1]);
$currentDate = new DateTime($matches[1]);

// Retrieve the list of log files in the directory
$logFiles = glob($logsPath . '/log-*.log');
Expand Down Expand Up @@ -252,7 +252,7 @@ private function getLogDate($logLineStart)
private function getLogLineStart($logLine)
{
preg_match(self::LOG_LINE_START_PATTERN, $logLine, $matches);
if (! empty($matches)) {
if ($matches !== []) {
return $matches[0];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Users/Language/it/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
'groups' => 'Gruppi',
'selectGroups' => 'Seleziona uno o più gruppi a cui l\'utente apparterrà',
'cannotAddAdminGroups' => 'Non è possibile aggiungere o rimuovere gruppi con privilegi di amministratore con i tuoi attuali permessi',
'groupListDisabled' => 'Gruppi a cui l\'utente appartiene (non hai il permesso di modificare l\'elenco)',
'groupListDisabled' => "Gruppi a cui l'utente appartiene (non hai il permesso di modificare l'elenco)",
'saveUser' => 'Salva Utente',
// permissions
'perms' => 'Permessi Utente',
Expand Down
2 changes: 1 addition & 1 deletion src/Users/SearchProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function search(string $term, int $limit = 10, ?array $post = null): arra
if (!empty($searchInMeta)) {
// TODO: find a better way to access both of these variables -
// Entity to which the data is assigned and table name to join meta_info with
$query->joinMetaInfo('Bonfire\Users\User', 'users');
$query->joinMetaInfo(User::class, 'users');
}

$query->like('first_name', $term, 'right', true, true)
Expand Down
3 changes: 2 additions & 1 deletion src/View/ComponentRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Bonfire\View;

use Throwable;
use RuntimeException;

class ComponentRenderer
Expand Down Expand Up @@ -129,7 +130,7 @@ private function renderPairedTags(string $output): string
? $component->withView($view)->withData($attributes)->render()
: $this->renderView($view, $attributes);
}, $output, -1, $replaceCount);
} catch (\Throwable $e) {
} catch (Throwable $e) {
break;
}
} while (!empty($replaceCount));
Expand Down
2 changes: 1 addition & 1 deletion src/Views/Auth/magic_link_message.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?= $this->extend(config('Auth')->views['layout']) ?>
<?php echo $this->extend(config('Auth')->views['layout']) ?>

<?= $this->section('title') ?><?= lang('Auth.useMagicLink') ?> <?= $this->endSection() ?>

Expand Down

0 comments on commit c56e9bf

Please sign in to comment.