Skip to content

Commit

Permalink
Merge pull request #540 from dgvirtual/feature/cs-fixer-enforce-array…
Browse files Browse the repository at this point in the history
…-lineup

Enforce array and adjecent values lineup, cleanup cs-fixer config
  • Loading branch information
dgvirtual authored Feb 5, 2025
2 parents c56e9bf + 0e449da commit 916bad0
Show file tree
Hide file tree
Showing 30 changed files with 111 additions and 110 deletions.
27 changes: 14 additions & 13 deletions .config/.php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,23 @@
'build',
'Views',
])
;

$overrides = [
'yoda_style' => ['identical' => false],
];

$options = [
'finder' => $finder,
'cacheFile' => '../build/.php-cs-fixer.cache',
];
->append([
__FILE__,
__DIR__ . '/rector.php',
]);

return (new Config())
->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'operators' => [
'=>' => 'align_single_space_minimal',
'=' => 'align_single_space_minimal',
],
],
'line_ending' => false,
])
->setCacheFile(__DIR__.'/../build/.php-cs-fixer.cache')
->setCacheFile(__DIR__ . '/../build/.php-cs-fixer.cache')
->setFinder($finder)
;
10 changes: 5 additions & 5 deletions src/Assets/Controllers/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public function serve(...$segments)

// 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);
$filename = count($parts) === 2 ? $parts[0] . '.' . $ext : $origFilename;
$baseAssetFolders = config('Assets')->folders; // get list of folders with assets
$separator = config('Assets')->separator ?? '~~';
$parts = explode($separator, $filename);
$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
$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)) {
Expand Down
6 changes: 3 additions & 3 deletions src/Commands/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ private function setAppUrl()

private function setDatabase()
{
$host = '';
$user = '';
$pass = '';
$host = '';
$user = '';
$pass = '';
$driver = CLI::prompt('Database driver:', ['MySQLi', 'Postgre', 'SQLite3', 'SQLSRV']);
$name = CLI::prompt('Database name:', 'bonfire');
if ($driver !== 'SQLite3') {
Expand Down
6 changes: 3 additions & 3 deletions src/Commands/Install/Publisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public function publishClass(string $className): void
$content = file_get_contents($file);

$replace = [
$namespace => 'Config',
'BaseConfig' => 'Bonfire' . $rawClassName,
'use CodeIgniter\Config\BaseConfig;' => "use {$className} as Bonfire{$rawClassName};",
$namespace => 'Config',
'BaseConfig' => 'Bonfire' . $rawClassName,
'use CodeIgniter\Config\BaseConfig;' => "use {$className} as Bonfire{$rawClassName};",
"class {$rawClassName} extends Shield{$rawClassName}" => "class {$rawClassName} extends Bonfire{$rawClassName}",
];

Expand Down
4 changes: 2 additions & 2 deletions src/Config/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
* the LICENSE file that was distributed with this source code.
*/
defined('BONFIRE_VERSION') || define('BONFIRE_VERSION', '2.0.0-dev');
defined('BFPATH') || define('BFPATH', realpath(__DIR__ . '/../') . '/');
defined('ADMIN_AREA') || define('ADMIN_AREA', 'admin');
defined('BFPATH') || define('BFPATH', realpath(__DIR__ . '/../') . '/');
defined('ADMIN_AREA') || define('ADMIN_AREA', 'admin');
2 changes: 1 addition & 1 deletion src/Consent/Controllers/ConsentSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function save()
'requireConsent' => 'permit_empty',
'consentLength' => 'required_with[requireConsent]|string',
'policyUrl' => 'required_with[requireConsent]|string',
'policyTitle' => 'required_with[requireConsent]|string',
'policyTitle' => 'required_with[requireConsent]|string',
'consentMessage' => 'required_with[requireConsent]|string',
'consents.*.name' => 'required_with[requireConsent]|string',
'consents.*.desc' => 'required_with[requireConsent]|string',
Expand Down
2 changes: 1 addition & 1 deletion src/Consent/Filters/ConsentFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function after(RequestInterface $request, ResponseInterface $response, $a
? $link
: site_url($link);
$policyTitle = setting('Consent.policyTitle');
$html = str_ireplace('{policy_url}', "<a href='{$link}' target='_blank'>{$policyTitle}</a>", $html);
$html = str_ireplace('{policy_url}', "<a href='{$link}' target='_blank'>{$policyTitle}</a>", $html);

$cssFile = setting('Consent.consentFormStyles');
$jsFile = setting('Consent.consentFormScripts');
Expand Down
2 changes: 1 addition & 1 deletion src/Consent/Language/en/Consent.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
*/

return [
'consentModTitle' => 'Consent',
'consentModTitle' => 'Consent',
];
2 changes: 1 addition & 1 deletion src/Consent/Language/it/Consent.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
*/

return [
'consentModTitle' => 'Consenso',
'consentModTitle' => 'Consenso',
];
2 changes: 1 addition & 1 deletion src/Consent/Language/lt/Consent.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
*/

return [
'consentModTitle' => 'Sutikimas (BDAR)',
'consentModTitle' => 'Sutikimas (BDAR)',
];
2 changes: 1 addition & 1 deletion src/Email/Language/en/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
*/

return [
'emailModTitle' => 'Email',
'emailModTitle' => 'Email',
];
2 changes: 1 addition & 1 deletion src/Email/Language/it/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
*/

return [
'emailModTitle' => 'Email',
'emailModTitle' => 'Email',
];
2 changes: 1 addition & 1 deletion src/Email/Language/lt/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
*/

return [
'emailModTitle' => 'El. laiškai',
'emailModTitle' => 'El. laiškai',
];
2 changes: 1 addition & 1 deletion src/Groups/Language/en/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
*/

return [
'groupsModTitle' => 'User Groups',
'groupsModTitle' => 'User Groups',
];
2 changes: 1 addition & 1 deletion src/Groups/Language/it/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
*/

return [
'groupsModTitle' => 'Ruoli',
'groupsModTitle' => 'Ruoli',
];
2 changes: 1 addition & 1 deletion src/Groups/Language/lt/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
*/

return [
'groupsModTitle' => 'Vartotojų grupės',
'groupsModTitle' => 'Vartotojų grupės',
];
8 changes: 4 additions & 4 deletions src/Recycler/Controllers/RecycleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ public function localizeResource(array $resource): array

//dd($resource);
foreach ($resource['columns'] as $colKey => $colName) {
$key = $resource['label'] . '.recycler.columns.' . $colName;
$value = lang($key);
$key = $resource['label'] . '.recycler.columns.' . $colName;
$value = lang($key);
$resource['localizedColumns'][$colKey] = $key == $value ? $resource['columns'][$colKey] : $value;
}

$key = $resource['label'] . '.recycler.label';
$value = lang($key);
$key = $resource['label'] . '.recycler.label';
$value = lang($key);
$resource['label'] = $key == $value ? $resource['label'] : $value;

return $resource;
Expand Down
2 changes: 1 addition & 1 deletion src/Recycler/Language/lt/Recycler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'restoreMsgContent' => 'Atkurti šį įrašą?',
'purgeMsgTitle' => 'Ištrinti amžiams',
'purgeMsgContent' => 'Ištrinti įrašą visam laikui?',
'resultLabel' => '{0, plural,
'resultLabel' => '{0, plural,
=0 {# įrašų}
=1 {# įrašas}
one {# įrašas}
Expand Down
4 changes: 2 additions & 2 deletions src/Tools/Controllers/LogsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ public function index()
unset($result['logs'][$i]);
continue;
}
$logFilePath = $this->logsPath . $result['logs'][$i];
$logFilePath = $this->logsPath . $result['logs'][$i];
$result['logs'][$i] = [
'filename' => $result['logs'][$i],
'content' => $this->logsHandler->countLogLevels($logFilePath),
'content' => $this->logsHandler->countLogLevels($logFilePath),
];
}

Expand Down
36 changes: 18 additions & 18 deletions src/Tools/Language/lt/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
*/

return [
'systemInfoModTitle' => 'Sistemos info',
'logsModTitle' => 'Žurnalai',
'log' => 'Žurnalas',
'empty' => 'Žurnalų failų nėra.',
'level' => 'Lygmuo',
'date' => 'Data',
'time' => 'Laikas',
'file' => 'Failo pavadinimas',
'content' => 'Turinys',
'deleteFile' => 'Trinti žurnalo failą',
'deleteSelected' => 'Trinti pažymėtus',
'deleteAll' => 'Trinti visus žurnalų failus',
'deleteConfirm' => 'Ar tikrai norite ištrinti šį failą?',
'deleteSelectedConfirm' => 'Ar tikrai norite ištrinti visus pažymėtus failus?',
'deleteAllConfirm' => 'Ar tikrai norite ištrinti visus žurnalų failus?',
'deleteSuccess' => 'Failas(-ai) sėkmingai ištrintas(-i).',
'deleteAllSuccess' => 'Visi failai buvo sėkmingai ištrinti.',
'deleteError' => 'Nepavyksta ištrinti.',
'systemInfoModTitle' => 'Sistemos info',
'logsModTitle' => 'Žurnalai',
'log' => 'Žurnalas',
'empty' => 'Žurnalų failų nėra.',
'level' => 'Lygmuo',
'date' => 'Data',
'time' => 'Laikas',
'file' => 'Failo pavadinimas',
'content' => 'Turinys',
'deleteFile' => 'Trinti žurnalo failą',
'deleteSelected' => 'Trinti pažymėtus',
'deleteAll' => 'Trinti visus žurnalų failus',
'deleteConfirm' => 'Ar tikrai norite ištrinti šį failą?',
'deleteSelectedConfirm' => 'Ar tikrai norite ištrinti visus pažymėtus failus?',
'deleteAllConfirm' => 'Ar tikrai norite ištrinti visus žurnalų failus?',
'deleteSuccess' => 'Failas(-ai) sėkmingai ištrintas(-i).',
'deleteAllSuccess' => 'Visi failai buvo sėkmingai ištrinti.',
'deleteError' => 'Nepavyksta ištrinti.',
];
6 changes: 3 additions & 3 deletions src/Tools/Libraries/Logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function countLogLevels($filePath): string
// Transform the array into a string with color codes
$result = [];
foreach ($counts as $level => $count) {
$class = self::$levelClasses[$level];
$class = self::$levelClasses[$level];
$result[] = '<span class="text-' . $class . '">' . $level . '</span>: ' . $count;
}

Expand Down Expand Up @@ -216,14 +216,14 @@ public function getAdjacentLogFiles($currentLogFileBasename, $logsPath): array

return [
'prev' => [
'link' => $previousLogFileBasename,
'link' => $previousLogFileBasename,
'label' => substr($previousLogFileBasename ?? '', 4, 10),
],
'curr' => [
'label' => substr($currentLogFileBasename, 4, 10),
],
'next' => [
'link' => $nextLogFileBasename,
'link' => $nextLogFileBasename,
'label' => substr($nextLogFileBasename ?? '', 4, 10),
],
];
Expand Down
4 changes: 2 additions & 2 deletions src/Users/Config/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class Users extends BaseConfig
* $avatarResizeFloor is the minimum size of an avatar (set to 32 as required by
* toolbar avatar size)
*/
public $avatarResize = false;
public $avatarSize = 140;
public $avatarResize = false;
public $avatarSize = 140;
public $avatarResizeFloor = 32;

/**
Expand Down
32 changes: 16 additions & 16 deletions src/Users/Database/Seeds/Seed100Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ class Seed100Users extends Seeder
{
public function run()
{
$faker = Factory::create();
$faker = Factory::create();
$groups = ['user', 'beta', 'developer'];

for ($i = 0; $i < 100; $i++) {
$timestamp = $faker->dateTimeBetween('-1 year', 'now')->format('Y-m-d H:i:s');
$firstName = $faker->firstName;
$lastName = $faker->lastName;
$username = substr($this->toAscii($firstName), 0, 5) . substr($this->toAscii($lastName), 0, 5);
$active = $faker->boolean;
$email = strtolower($this->toAscii($firstName) . '.' . $this->toAscii($lastName) . '@example.com');
$secret2 = $faker->sha256;
$lastName = $faker->lastName;
$username = substr($this->toAscii($firstName), 0, 5) . substr($this->toAscii($lastName), 0, 5);
$active = $faker->boolean;
$email = strtolower($this->toAscii($firstName) . '.' . $this->toAscii($lastName) . '@example.com');
$secret2 = $faker->sha256;

// Insert into users table
$this->db->table('users')->insert([
'first_name' => $firstName,
'last_name' => $lastName,
'username' => $username,
'active' => $active,
'created_at' => $timestamp,
'updated_at' => $timestamp,
'first_name' => $firstName,
'last_name' => $lastName,
'username' => $username,
'active' => $active,
'created_at' => $timestamp,
'updated_at' => $timestamp,
'last_active' => $timestamp,
]);

Expand All @@ -38,15 +38,15 @@ public function run()
// Insert into auth_identities table
$this->db->table('auth_identities')->insert([
'user_id' => $userId,
'type' => 'email_password',
'secret' => $email,
'type' => 'email_password',
'secret' => $email,
'secret2' => $secret2,
]);

// Insert into auth_groups_users table
$this->db->table('auth_groups_users')->insert([
'user_id' => $userId,
'group' => $faker->randomElement($groups),
'user_id' => $userId,
'group' => $faker->randomElement($groups),
'created_at' => $timestamp,
]);
}
Expand Down
16 changes: 8 additions & 8 deletions src/Users/Language/lt/Users.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

return [
'usersModTitle' => 'Vartotojai',
'editUser' => 'Keisti vartotoją',
'newUser' => 'Naujas vartotojas',
'users' => 'Vartotojai',
'user' => 'Vartotojas',
'userGenitive' => 'vartotojo',
'userAccusative' => 'vartotoją',
'usersModTitle' => 'Vartotojai',
'editUser' => 'Keisti vartotoją',
'newUser' => 'Naujas vartotojas',
'users' => 'Vartotojai',
'user' => 'Vartotojas',
'userGenitive' => 'vartotojo',
'userAccusative' => 'vartotoją',
'usersAccusative' => 'vartotojus',
'permissions' => 'Leidimai',
'permissions' => 'Leidimai',
// avatar
'deleteImageConfirm' => 'Ar tikrai norite pašalinti paveikslėlį? Jo atkurti nebus galima',
'deleteImage' => 'Ištrinti įkeltą paveikslėlį',
Expand Down
2 changes: 1 addition & 1 deletion src/Users/Models/UserModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class UserModel extends ShieldUsers
];

protected $allowCallbacks = true;
protected $beforeDelete = ['deleteAvatar'];
protected $beforeDelete = ['deleteAvatar'];

/**
* Performs additional setup when finding objects
Expand Down
6 changes: 3 additions & 3 deletions src/View/ComponentRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ private function renderPairedTags(string $output): string
do {
try {
$output = preg_replace_callback($pattern, function ($match) {
$view = $this->locateView($match['name']);
$attributes = $this->parseAttributes($match['attributes']);
$view = $this->locateView($match['name']);
$attributes = $this->parseAttributes($match['attributes']);
$attributes['slot'] = $match['slot'];
$component = $this->factory($match['name'], $view);
$component = $this->factory($match['name'], $view);

return $component instanceof Component
? $component->withView($view)->withData($attributes)->render()
Expand Down
Loading

0 comments on commit 916bad0

Please sign in to comment.