@@ -61,7 +61,7 @@ |
||
61 | 61 | |
62 | 62 | protected function voteOnUser(string $attribute, $subject, User $user): bool |
63 | 63 | { |
64 | - if (! is_a($subject, PartLot::class, true)) { |
|
64 | + if (!is_a($subject, PartLot::class, true)) { |
|
65 | 65 | throw new \RuntimeException('This voter can only handle PartLot objects!'); |
66 | 66 | } |
67 | 67 |
@@ -69,7 +69,7 @@ |
||
69 | 69 | $user->getUsername(), |
70 | 70 | $user->getFullName(), |
71 | 71 | $user->getEmail(), |
72 | - $user->getGroup() !== null ? $user->getGroup()->getName() . ' (ID: ' . $user->getGroup()->getID() . ')' : 'No group', |
|
72 | + $user->getGroup() !== null ? $user->getGroup()->getName().' (ID: '.$user->getGroup()->getID().')' : 'No group', |
|
73 | 73 | $user->isDisabled() ? 'Yes' : 'No', |
74 | 74 | ]); |
75 | 75 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | $io = new SymfonyStyle($input, $output); |
64 | 64 | |
65 | - $io->info('Target schema version number: '. PermissionData::CURRENT_SCHEMA_VERSION); |
|
65 | + $io->info('Target schema version number: '.PermissionData::CURRENT_SCHEMA_VERSION); |
|
66 | 66 | |
67 | 67 | //Retrieve all users and groups |
68 | 68 | $users = $this->em->getRepository(User::class)->findAll(); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | - $io->info('Found '. count($groups_to_upgrade) .' groups and '. count($users_to_upgrade) .' users that need an update.'); |
|
85 | + $io->info('Found '.count($groups_to_upgrade).' groups and '.count($users_to_upgrade).' users that need an update.'); |
|
86 | 86 | if (empty($groups_to_upgrade) && empty($users_to_upgrade)) { |
87 | 87 | $io->success('All users and group permissions schemas are up-to-date. No update needed.'); |
88 | 88 | |
@@ -91,27 +91,27 @@ discard block |
||
91 | 91 | |
92 | 92 | //List all users and groups that need an update |
93 | 93 | $io->section('Groups that need an update:'); |
94 | - $io->listing(array_map(function (Group $group) { |
|
95 | - return $group->getName() . ' (ID: '. $group->getID() .', Current version: ' . $group->getPermissions()->getSchemaVersion() . ')'; |
|
94 | + $io->listing(array_map(function(Group $group) { |
|
95 | + return $group->getName().' (ID: '.$group->getID().', Current version: '.$group->getPermissions()->getSchemaVersion().')'; |
|
96 | 96 | }, $groups_to_upgrade)); |
97 | 97 | |
98 | 98 | $io->section('Users that need an update:'); |
99 | - $io->listing(array_map(function (User $user) { |
|
100 | - return $user->getUsername() . ' (ID: '. $user->getID() .', Current version: ' . $user->getPermissions()->getSchemaVersion() . ')'; |
|
99 | + $io->listing(array_map(function(User $user) { |
|
100 | + return $user->getUsername().' (ID: '.$user->getID().', Current version: '.$user->getPermissions()->getSchemaVersion().')'; |
|
101 | 101 | }, $users_to_upgrade)); |
102 | 102 | |
103 | - if(!$io->confirm('Continue with the update?', false)) { |
|
103 | + if (!$io->confirm('Continue with the update?', false)) { |
|
104 | 104 | $io->warning('Update aborted.'); |
105 | 105 | return 0; |
106 | 106 | } |
107 | 107 | |
108 | 108 | //Update all users and groups |
109 | 109 | foreach ($groups_to_upgrade as $group) { |
110 | - $io->writeln('Updating group '. $group->getName() .' (ID: '. $group->getID() .') to schema version '. PermissionData::CURRENT_SCHEMA_VERSION .'...', OutputInterface::VERBOSITY_VERBOSE); |
|
110 | + $io->writeln('Updating group '.$group->getName().' (ID: '.$group->getID().') to schema version '.PermissionData::CURRENT_SCHEMA_VERSION.'...', OutputInterface::VERBOSITY_VERBOSE); |
|
111 | 111 | $this->permissionSchemaUpdater->upgradeSchema($group); |
112 | 112 | } |
113 | 113 | foreach ($users_to_upgrade as $user) { |
114 | - $io->writeln('Updating user '. $user->getUsername() .' (ID: '. $user->getID() .') to schema version '. PermissionData::CURRENT_SCHEMA_VERSION .'...', OutputInterface::VERBOSITY_VERBOSE); |
|
114 | + $io->writeln('Updating user '.$user->getUsername().' (ID: '.$user->getID().') to schema version '.PermissionData::CURRENT_SCHEMA_VERSION.'...', OutputInterface::VERBOSITY_VERBOSE); |
|
115 | 115 | $this->permissionSchemaUpdater->upgradeSchema($user); |
116 | 116 | } |
117 | 117 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $all_users = $input->getOption('all'); |
61 | 61 | $disabling = $input->getOption('disable'); |
62 | 62 | |
63 | - if(!$all_users && empty($usernames)) { |
|
63 | + if (!$all_users && empty($usernames)) { |
|
64 | 64 | $io->error('No users given! You have to pass atleast one username or use the --all option to use all users!'); |
65 | 65 | return self::FAILURE; |
66 | 66 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $repo = $this->entityManager->getRepository(User::class); |
69 | 69 | |
70 | 70 | $users = []; |
71 | - if($all_users) { //If we requested to change all users at once, then get all users from repo |
|
71 | + if ($all_users) { //If we requested to change all users at once, then get all users from repo |
|
72 | 72 | $users = $repo->findAll(); |
73 | 73 | } else { //Otherwise, fetch the users from DB |
74 | 74 | foreach ($usernames as $username) { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | return [$user->getFullName(true), $user->isDisabled() ? 'Disabled' : 'Enabled']; |
92 | 92 | }, $users)); |
93 | 93 | |
94 | - if(!$io->confirm('Do you want to continue?')) { |
|
94 | + if (!$io->confirm('Do you want to continue?')) { |
|
95 | 95 | $io->warning('Aborting!'); |
96 | 96 | return self::SUCCESS; |
97 | 97 | } |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | $inherit = !$input->getOption('noInherit') && !$edit_mode; //Show the non inherited perms in edit mode |
72 | 72 | |
73 | 73 | //Find user |
74 | - $io->note('Finding user with username: ' . $username); |
|
74 | + $io->note('Finding user with username: '.$username); |
|
75 | 75 | $user = $this->userRepository->findByEmailOrName($username); |
76 | 76 | if ($user === null) { |
77 | - $io->error('No user found with username: ' . $username); |
|
77 | + $io->error('No user found with username: '.$username); |
|
78 | 78 | return Command::FAILURE; |
79 | 79 | } |
80 | 80 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | $edit_mapping = $this->renderPermissionTable($output, $user, $inherit); |
84 | 84 | |
85 | - while($edit_mode) { |
|
85 | + while ($edit_mode) { |
|
86 | 86 | $index_to_edit = $io->ask('Which permission do you want to edit? Enter the index (e.g. 2-4) to edit, * for all permissions or "q" to quit', 'q'); |
87 | 87 | if ($index_to_edit === 'q') { |
88 | 88 | break; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $io->warning('You are about to edit all permissions. This will overwrite all permissions!'); |
98 | 98 | } else { |
99 | 99 | [$perm_to_edit, $op_to_edit] = $edit_mapping[$index_to_edit]; |
100 | - $io->note('Editing permission ' . $perm_to_edit . ' with operation <options=bold>' . $op_to_edit); |
|
100 | + $io->note('Editing permission '.$perm_to_edit.' with operation <options=bold>'.$op_to_edit); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 |
@@ -52,19 +52,19 @@ |
||
52 | 52 | { |
53 | 53 | $io = new SymfonyStyle($input, $output); |
54 | 54 | |
55 | - $message = 'Part-DB version: '. $this->versionManager->getVersion()->toString(); |
|
55 | + $message = 'Part-DB version: '.$this->versionManager->getVersion()->toString(); |
|
56 | 56 | |
57 | 57 | if ($this->gitVersionInfo->getGitBranchName() !== null) { |
58 | - $message .= ' Git branch: '. $this->gitVersionInfo->getGitBranchName(); |
|
59 | - $message .= ', Git commit: '. $this->gitVersionInfo->getGitCommitHash(); |
|
58 | + $message .= ' Git branch: '.$this->gitVersionInfo->getGitBranchName(); |
|
59 | + $message .= ', Git commit: '.$this->gitVersionInfo->getGitCommitHash(); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $io->success($message); |
63 | 63 | |
64 | 64 | $io->info('PHP version: '.PHP_VERSION); |
65 | - $io->info('Symfony version: ' . $this->getApplication()->getVersion()); |
|
66 | - $io->info('OS: '. php_uname()); |
|
67 | - $io->info('PHP extension: '. implode(', ', get_loaded_extensions())); |
|
65 | + $io->info('Symfony version: '.$this->getApplication()->getVersion()); |
|
66 | + $io->info('OS: '.php_uname()); |
|
67 | + $io->info('PHP extension: '.implode(', ', get_loaded_extensions())); |
|
68 | 68 | |
69 | 69 | return 0; |
70 | 70 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | //Check PHP versions |
72 | 72 | $io->isVerbose() && $io->comment('Checking PHP version...'); |
73 | 73 | if (PHP_VERSION_ID < 80100) { |
74 | - $io->warning('You are using PHP '. PHP_VERSION .'. This will work, but a newer version is recommended.'); |
|
74 | + $io->warning('You are using PHP '.PHP_VERSION.'. This will work, but a newer version is recommended.'); |
|
75 | 75 | } else { |
76 | 76 | !$only_issues && $io->success('PHP version is sufficient.'); |
77 | 77 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | { |
99 | 99 | //Check if APP_ENV is set to prod |
100 | 100 | $io->isVerbose() && $io->comment('Checking debug mode...'); |
101 | - if($this->params->get('kernel.debug')) { |
|
101 | + if ($this->params->get('kernel.debug')) { |
|
102 | 102 | $io->warning('You have activated debug mode, this is will leak informations in a production environment.'); |
103 | 103 | } else { |
104 | 104 | !$only_issues && $io->success('Debug mode disabled.'); |
@@ -110,36 +110,36 @@ discard block |
||
110 | 110 | { |
111 | 111 | //Get all installed PHP extensions |
112 | 112 | $extensions = get_loaded_extensions(); |
113 | - $io->isVerbose() && $io->comment('Your PHP installation has '. count($extensions) .' extensions installed: '. implode(', ', $extensions)); |
|
113 | + $io->isVerbose() && $io->comment('Your PHP installation has '.count($extensions).' extensions installed: '.implode(', ', $extensions)); |
|
114 | 114 | |
115 | 115 | $db_drivers_count = 0; |
116 | - if(!in_array('pdo_mysql', $extensions)) { |
|
116 | + if (!in_array('pdo_mysql', $extensions)) { |
|
117 | 117 | $io->error('pdo_mysql is not installed. You will not be able to use MySQL databases.'); |
118 | 118 | } else { |
119 | 119 | !$only_issues && $io->success('PHP extension pdo_mysql is installed.'); |
120 | 120 | $db_drivers_count++; |
121 | 121 | } |
122 | 122 | |
123 | - if(!in_array('pdo_sqlite', $extensions)) { |
|
123 | + if (!in_array('pdo_sqlite', $extensions)) { |
|
124 | 124 | $io->error('pdo_sqlite is not installed. You will not be able to use SQLite. databases'); |
125 | 125 | } else { |
126 | 126 | !$only_issues && $io->success('PHP extension pdo_sqlite is installed.'); |
127 | 127 | $db_drivers_count++; |
128 | 128 | } |
129 | 129 | |
130 | - $io->isVerbose() && $io->comment('You have '. $db_drivers_count .' database drivers installed.'); |
|
130 | + $io->isVerbose() && $io->comment('You have '.$db_drivers_count.' database drivers installed.'); |
|
131 | 131 | if ($db_drivers_count === 0) { |
132 | 132 | $io->error('You have no database drivers installed. You have to install at least one database driver!'); |
133 | 133 | } |
134 | 134 | |
135 | - if(!in_array('curl', $extensions)) { |
|
135 | + if (!in_array('curl', $extensions)) { |
|
136 | 136 | $io->warning('curl extension is not installed. Install curl extension for better performance'); |
137 | 137 | } else { |
138 | 138 | !$only_issues && $io->success('PHP extension curl is installed.'); |
139 | 139 | } |
140 | 140 | |
141 | 141 | $gd_installed = in_array('gd', $extensions); |
142 | - if(!$gd_installed) { |
|
142 | + if (!$gd_installed) { |
|
143 | 143 | $io->error('GD is not installed. GD is required for image processing.'); |
144 | 144 | } else { |
145 | 145 | !$only_issues && $io->success('PHP extension GD is installed.'); |
@@ -149,19 +149,19 @@ discard block |
||
149 | 149 | $io->isVerbose() && $io->comment('Checking if GD has jpeg support...'); |
150 | 150 | if ($gd_installed) { |
151 | 151 | $gd_info = gd_info(); |
152 | - if($gd_info['JPEG Support'] === false) { |
|
152 | + if ($gd_info['JPEG Support'] === false) { |
|
153 | 153 | $io->warning('Your GD does not have jpeg support. You will not be able to generate thumbnails of jpeg images.'); |
154 | 154 | } else { |
155 | 155 | !$only_issues && $io->success('GD has jpeg support.'); |
156 | 156 | } |
157 | 157 | |
158 | - if($gd_info['PNG Support'] === false) { |
|
158 | + if ($gd_info['PNG Support'] === false) { |
|
159 | 159 | $io->warning('Your GD does not have png support. You will not be able to generate thumbnails of png images.'); |
160 | 160 | } else { |
161 | 161 | !$only_issues && $io->success('GD has png support.'); |
162 | 162 | } |
163 | 163 | |
164 | - if($gd_info['WebP Support'] === false) { |
|
164 | + if ($gd_info['WebP Support'] === false) { |
|
165 | 165 | $io->warning('Your GD does not have WebP support. You will not be able to generate thumbnails of WebP images.'); |
166 | 166 | } else { |
167 | 167 | !$only_issues && $io->success('GD has WebP support.'); |
@@ -86,7 +86,7 @@ |
||
86 | 86 | if ($action === 'generate_label') { |
87 | 87 | $targets = implode(',', array_map(static fn (Part $part) => $part->getID(), $selected_parts)); |
88 | 88 | } else { //For lots we have to extract the part lots |
89 | - $targets = implode(',', array_map(static function (Part $part) { |
|
89 | + $targets = implode(',', array_map(static function(Part $part) { |
|
90 | 90 | //We concat the lot IDs of every part with a comma (which are later concated with a comma too per part) |
91 | 91 | return implode(',', array_map(static fn (PartLot $lot) => $lot->getID(), $part->getPartLots()->toArray())); |
92 | 92 | }, $selected_parts)); |
@@ -117,8 +117,8 @@ |
||
117 | 117 | */ |
118 | 118 | public function formatBytes(int $bytes, int $precision = 2): string |
119 | 119 | { |
120 | - $size = ['B','kB','MB','GB','TB','PB','EB','ZB','YB']; |
|
120 | + $size = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; |
|
121 | 121 | $factor = floor((strlen((string) $bytes) - 1) / 3); |
122 | - return sprintf("%.{$precision}f", $bytes / pow(1024, $factor)) . ' ' . @$size[$factor]; |
|
122 | + return sprintf("%.{$precision}f", $bytes / pow(1024, $factor)).' '.@$size[$factor]; |
|
123 | 123 | } |
124 | 124 | } |