diff --git a/ecs.yaml b/ecs.yaml
index 8224ff08..28ea9362 100644
--- a/ecs.yaml
+++ b/ecs.yaml
@@ -6,5 +6,5 @@ parameters:
- "clean-code"
- "common"
# very nice to have ↓
- - "symplify"
+ #- "symplify"
- "symfony"
\ No newline at end of file
diff --git a/src/Command/CleanAttachmentsCommand.php b/src/Command/CleanAttachmentsCommand.php
index 49572f76..0f4f6128 100644
--- a/src/Command/CleanAttachmentsCommand.php
+++ b/src/Command/CleanAttachmentsCommand.php
@@ -1,4 +1,7 @@
setDescription('Lists (and deletes if wanted) attachments files that are not used anymore (abandoned files).')
@@ -59,7 +62,7 @@ class CleanAttachmentsCommand extends Command
' These files are not needed and can eventually deleted.');
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): void
{
$io = new SymfonyStyle($input, $output);
@@ -84,7 +87,7 @@ class CleanAttachmentsCommand extends Command
foreach ($finder as $file) {
//If not attachment object uses this file, print it
- if (0 == \count($this->reverseSearch->findAttachmentsByFile($file))) {
+ if (0 === \count($this->reverseSearch->findAttachmentsByFile($file))) {
$file_list[] = $file;
$table->addRow([
$fs->makePathRelative($file->getPathname(), $mediaPath),
@@ -99,7 +102,7 @@ class CleanAttachmentsCommand extends Command
$continue = $io->confirm(sprintf('Found %d abandoned files. Do you want to delete them? This can not be undone!', \count($file_list)), false);
- if (!$continue) {
+ if (! $continue) {
//We are finished here, when no files should be deleted
return;
}
diff --git a/src/Command/ConvertBBCodeCommand.php b/src/Command/ConvertBBCodeCommand.php
index 30f007eb..cdb7c072 100644
--- a/src/Command/ConvertBBCodeCommand.php
+++ b/src/Command/ConvertBBCodeCommand.php
@@ -1,4 +1,7 @@
setDescription('Converts BBCode used in old Part-DB versions to newly used Markdown')
@@ -97,7 +100,7 @@ class ConvertBBCodeCommand extends Command
];
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): void
{
$io = new SymfonyStyle($input, $output);
$targets = $this->getTargetsLists();
@@ -126,7 +129,7 @@ class ConvertBBCodeCommand extends Command
//In verbose mode print the names of the entities
foreach ($results as $result) {
- /* @var NamedDBElement $result */
+ /** @var NamedDBElement $result */
$io->writeln(
'Convert entity: '.$result->getName().' ('.$result->getIDString().')',
OutputInterface::VERBOSITY_VERBOSE
@@ -135,7 +138,7 @@ class ConvertBBCodeCommand extends Command
//Retrieve bbcode from entity
$bbcode = $this->propertyAccessor->getValue($result, $property);
//Check if the current property really contains BBCode
- if (!preg_match(static::BBCODE_REGEX, $bbcode)) {
+ if (! preg_match(static::BBCODE_REGEX, $bbcode)) {
continue;
}
$io->writeln(
@@ -156,7 +159,7 @@ class ConvertBBCodeCommand extends Command
}
//If we are not in dry run, save changes to DB
- if (!$input->getOption('dry-run')) {
+ if (! $input->getOption('dry-run')) {
$this->em->flush();
$io->success('Changes saved to DB successfully!');
}
diff --git a/src/Command/SetPasswordCommand.php b/src/Command/SetPasswordCommand.php
index 986ee857..5e2ecf92 100644
--- a/src/Command/SetPasswordCommand.php
+++ b/src/Command/SetPasswordCommand.php
@@ -1,4 +1,7 @@
setDescription('Sets the password of a user')
@@ -54,18 +57,16 @@ class SetPasswordCommand extends Command
;
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): void
{
$io = new SymfonyStyle($input, $output);
$user_name = $input->getArgument('user');
- /**
- * @var User
- */
+ /** @var User */
$users = $this->entityManager->getRepository(User::class)->findBy(['name' => $user_name]);
$user = $users[0];
- if (null == $user) {
+ if (null === $user) {
$io->error(sprintf('No user with the given username %s found in the database!', $user_name));
return;
@@ -77,14 +78,14 @@ class SetPasswordCommand extends Command
sprintf('You are going to change the password of %s with ID %d. Proceed?',
$user->getFullName(true), $user->getID()));
- if (!$proceed) {
+ if (! $proceed) {
return;
}
$success = false;
$new_password = '';
- while (!$success) {
+ while (! $success) {
$pw1 = $io->askHidden('Please enter new password:');
$pw2 = $io->askHidden('Please confirm:');
if ($pw1 !== $pw2) {
diff --git a/src/Command/UpdateExchangeRatesCommand.php b/src/Command/UpdateExchangeRatesCommand.php
index 108255a1..90d1f3ac 100644
--- a/src/Command/UpdateExchangeRatesCommand.php
+++ b/src/Command/UpdateExchangeRatesCommand.php
@@ -1,4 +1,7 @@
setDescription('Updates the currency exchange rates.')
@@ -62,7 +65,7 @@ class UpdateExchangeRatesCommand extends Command
null);
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): void
{
$io = new SymfonyStyle($input, $output);
@@ -88,7 +91,7 @@ class UpdateExchangeRatesCommand extends Command
$repo = $this->em->getRepository(Currency::class);
$candidates = [];
- if (!empty($iso_code)) {
+ if (! empty($iso_code)) {
$candidates = $repo->findBy(['iso_code' => $iso_code]);
} else {
$candidates = $repo->findAll();
diff --git a/src/Configuration/PermissionsConfiguration.php b/src/Configuration/PermissionsConfiguration.php
index b3d41011..99269353 100644
--- a/src/Configuration/PermissionsConfiguration.php
+++ b/src/Configuration/PermissionsConfiguration.php
@@ -1,4 +1,7 @@
arrayNode('perms')
->arrayPrototype()
->children()
- ->scalarNode('label')->end()
- ->scalarNode('group')->end()
- ->arrayNode('operations')
- ->arrayPrototype()
- ->children()
- ->scalarNode('name')->end()
- ->scalarNode('label')->end()
- ->scalarNode('bit')->end()
- ->arrayNode('alsoSet')
- ->beforeNormalization()->castToArray()->end()->scalarPrototype()->end();
+ ->scalarNode('label')->end()
+ ->scalarNode('group')->end()
+ ->arrayNode('operations')
+ ->arrayPrototype()
+ ->children()
+ ->scalarNode('name')->end()
+ ->scalarNode('label')->end()
+ ->scalarNode('bit')->end()
+ ->arrayNode('alsoSet')
+ ->beforeNormalization()->castToArray()->end()->scalarPrototype()->end();
return $treeBuilder;
}
diff --git a/src/Controller/AdminPages/AttachmentTypeController.php b/src/Controller/AdminPages/AttachmentTypeController.php
index af26ad1a..aa00a8a4 100644
--- a/src/Controller/AdminPages/AttachmentTypeController.php
+++ b/src/Controller/AdminPages/AttachmentTypeController.php
@@ -1,4 +1,7 @@
handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
//Check if we editing a user and if we need to change the password of it
- if ($entity instanceof User && !empty($form['new_password']->getData())) {
+ if ($entity instanceof User && ! empty($form['new_password']->getData())) {
$password = $this->passwordEncoder->encodePassword($entity, $form['new_password']->getData());
$entity->setPassword($password);
//By default the user must change the password afterwards
@@ -90,11 +93,12 @@ abstract class BaseAdminController extends AbstractController
//Upload passed files
$attachments = $form['attachments'];
foreach ($attachments as $attachment) {
- /** @var $attachment FormInterface */
+ /** @var FormInterface $attachment */
$options = [
'secure_attachment' => $attachment['secureFile']->getData(),
'download_url' => $attachment['downloadURL']->getData(),
];
+
try {
$this->attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
} catch (AttachmentDownloadException $ex) {
@@ -112,7 +116,7 @@ abstract class BaseAdminController extends AbstractController
//Rebuild form, so it is based on the updated data. Important for the parent field!
//We can not use dynamic form events here, because the parent entity list is build from database!
$form = $this->createForm($this->form_class, $entity, ['attachment_class' => $this->attachment_class]);
- } elseif ($form->isSubmitted() && !$form->isValid()) {
+ } elseif ($form->isSubmitted() && ! $form->isValid()) {
$this->addFlash('error', 'entity.edit_flash.invalid');
}
@@ -136,7 +140,7 @@ abstract class BaseAdminController extends AbstractController
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
- if ($new_entity instanceof User && !empty($form['new_password']->getData())) {
+ if ($new_entity instanceof User && ! empty($form['new_password']->getData())) {
$password = $this->passwordEncoder->encodePassword($new_entity, $form['new_password']->getData());
$new_entity->setPassword($password);
//By default the user must change the password afterwards
@@ -146,11 +150,12 @@ abstract class BaseAdminController extends AbstractController
//Upload passed files
$attachments = $form['attachments'];
foreach ($attachments as $attachment) {
- /** @var $attachment FormInterface */
+ /** @var FormInterface $attachment */
$options = [
'secure_attachment' => $attachment['secureFile']->getData(),
'download_url' => $attachment['downloadURL']->getData(),
];
+
try {
$this->attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
} catch (AttachmentDownloadException $ex) {
@@ -168,7 +173,7 @@ abstract class BaseAdminController extends AbstractController
return $this->redirectToRoute($this->route_base.'_edit', ['id' => $new_entity->getID()]);
}
- if ($form->isSubmitted() && !$form->isValid()) {
+ if ($form->isSubmitted() && ! $form->isValid()) {
$this->addFlash('error', 'entity.created_flash.invalid');
}
@@ -187,7 +192,7 @@ abstract class BaseAdminController extends AbstractController
$errors = $importer->fileToDBEntities($file, $this->entity_class, $options);
foreach ($errors as $name => $error) {
- /* @var $error ConstraintViolationList */
+ /** @var ConstraintViolationList $error */
$this->addFlash('error', $name.':'.$error);
}
}
diff --git a/src/Controller/AdminPages/CategoryController.php b/src/Controller/AdminPages/CategoryController.php
index cb7a0a34..04fe4e86 100644
--- a/src/Controller/AdminPages/CategoryController.php
+++ b/src/Controller/AdminPages/CategoryController.php
@@ -1,4 +1,7 @@
isFileExisting($attachment)) {
+ if (! $helper->isFileExisting($attachment)) {
throw new \RuntimeException('The file associated with the attachment is not existing!');
}
@@ -79,7 +82,7 @@ class AttachmentFileController extends AbstractController
throw new \RuntimeException('You can not download external attachments!');
}
- if (!$helper->isFileExisting($attachment)) {
+ if (! $helper->isFileExisting($attachment)) {
throw new \RuntimeException('The file associated with the attachment is not existing!');
}
diff --git a/src/Controller/GroupController.php b/src/Controller/GroupController.php
index c3bbbabe..a998ea78 100644
--- a/src/Controller/GroupController.php
+++ b/src/Controller/GroupController.php
@@ -1,4 +1,7 @@
$attachment['secureFile']->getData(),
'download_url' => $attachment['downloadURL']->getData(),
];
+
try {
$attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
} catch (AttachmentDownloadException $ex) {
@@ -100,7 +103,7 @@ class PartController extends AbstractController
$this->addFlash('info', 'part.edited_flash');
//Reload form, so the SIUnitType entries use the new part unit
$form = $this->createForm(PartBaseType::class, $part);
- } elseif ($form->isSubmitted() && !$form->isValid()) {
+ } elseif ($form->isSubmitted() && ! $form->isValid()) {
$this->addFlash('error', 'part.edited_flash.invalid');
}
@@ -163,11 +166,12 @@ class PartController extends AbstractController
//Upload passed files
$attachments = $form['attachments'];
foreach ($attachments as $attachment) {
- /** @var $attachment FormInterface */
+ /** @var FormInterface $attachment */
$options = [
'secure_attachment' => $attachment['secureFile']->getData(),
'download_url' => $attachment['downloadURL']->getData(),
];
+
try {
$attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
} catch (AttachmentDownloadException $ex) {
@@ -185,7 +189,7 @@ class PartController extends AbstractController
return $this->redirectToRoute('part_edit', ['id' => $new_part->getID()]);
}
- if ($form->isSubmitted() && !$form->isValid()) {
+ if ($form->isSubmitted() && ! $form->isValid()) {
$this->addFlash('error', 'part.created_flash.invalid');
}
diff --git a/src/Controller/PartListsController.php b/src/Controller/PartListsController.php
index 5d34ffad..695843de 100644
--- a/src/Controller/PartListsController.php
+++ b/src/Controller/PartListsController.php
@@ -1,4 +1,7 @@
render('Parts/lists/search_list.html.twig', [
- 'datatable' => $table,
- 'keyword' => $search,
- ]);
+ 'datatable' => $table,
+ 'keyword' => $search,
+ ]);
}
/**
diff --git a/src/Controller/RedirectController.php b/src/Controller/RedirectController.php
index 57cb0a8a..76ba53e3 100644
--- a/src/Controller/RedirectController.php
+++ b/src/Controller/RedirectController.php
@@ -1,4 +1,7 @@
getUser();
- if (($user instanceof User) && !empty($user->getLanguage())) {
+ if (($user instanceof User) && ! empty($user->getLanguage())) {
$locale = $user->getLanguage();
}
@@ -63,7 +66,7 @@ class RedirectController extends AbstractController
$new_url = $request->getUriForPath('/'.$locale.$request->getPathInfo());
//If either mod_rewrite is not enabled or the index.php version is enforced, add index.php to the string
- if (($this->enforce_index_php || !$this->checkIfModRewriteAvailable())
+ if (($this->enforce_index_php || ! $this->checkIfModRewriteAvailable())
&& false === strpos($new_url, 'index.php')) {
//Like Request::getUriForPath only with index.php
$new_url = $request->getSchemeAndHttpHost().$request->getBaseUrl().'/index.php/'.$locale.$request->getPathInfo();
@@ -81,7 +84,7 @@ class RedirectController extends AbstractController
*/
public function checkIfModRewriteAvailable()
{
- if (!\function_exists('apache_get_modules')) {
+ if (! \function_exists('apache_get_modules')) {
//If we can not check for apache modules, we just hope for the best and assume url rewriting is available
//If you want to enforce index.php versions of the url, you can override this via ENV vars.
return true;
diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php
index bdfd1941..ecbae653 100644
--- a/src/Controller/SecurityController.php
+++ b/src/Controller/SecurityController.php
@@ -1,4 +1,7 @@
allow_email_pw_reset) {
+ if (! $this->allow_email_pw_reset) {
throw new AccessDeniedHttpException('The password reset via email is disabled!');
}
@@ -109,9 +112,9 @@ class SecurityController extends AbstractController
/**
* @Route("/pw_reset/new_pw/{user}/{token}", name="pw_reset_new_pw")
*/
- public function pwResetNewPw(PasswordResetManager $passwordReset, Request $request, string $user = null, string $token = null)
+ public function pwResetNewPw(PasswordResetManager $passwordReset, Request $request, ?string $user = null, ?string $token = null)
{
- if (!$this->allow_email_pw_reset) {
+ if (! $this->allow_email_pw_reset) {
throw new AccessDeniedHttpException('The password reset via email is disabled!');
}
@@ -149,7 +152,7 @@ class SecurityController extends AbstractController
$data = $form->getData();
//Try to set the new password
$success = $passwordReset->setNewPassword($data['username'], $data['token'], $data['new_password']);
- if (!$success) {
+ if (! $success) {
$this->addFlash('error', 'pw_reset.new_pw.error');
} else {
$this->addFlash('success', 'pw_reset.new_pw.success');
@@ -166,7 +169,7 @@ class SecurityController extends AbstractController
/**
* @Route("/logout", name="logout")
*/
- public function logout()
+ public function logout(): void
{
throw new \RuntimeException('Will be intercepted before getting here');
}
diff --git a/src/Controller/TreeController.php b/src/Controller/TreeController.php
index f8f4de1b..4d6434c0 100644
--- a/src/Controller/TreeController.php
+++ b/src/Controller/TreeController.php
@@ -1,4 +1,7 @@
treeGenerator->getTreeView(Category::class, $category);
@@ -72,7 +75,7 @@ class TreeController extends AbstractController
* @Route("/footprint/{id}", name="tree_footprint")
* @Route("/footprints")
*/
- public function footprintTree(Footprint $footprint = null)
+ public function footprintTree(?Footprint $footprint = null)
{
$tree = $this->treeGenerator->getTreeView(Footprint::class, $footprint);
@@ -83,7 +86,7 @@ class TreeController extends AbstractController
* @Route("/location/{id}", name="tree_location")
* @Route("/locations")
*/
- public function locationTree(Storelocation $location = null)
+ public function locationTree(?Storelocation $location = null)
{
$tree = $this->treeGenerator->getTreeView(Storelocation::class, $location);
@@ -94,7 +97,7 @@ class TreeController extends AbstractController
* @Route("/manufacturer/{id}", name="tree_manufacturer")
* @Route("/manufacturers")
*/
- public function manufacturerTree(Manufacturer $manufacturer = null)
+ public function manufacturerTree(?Manufacturer $manufacturer = null)
{
$tree = $this->treeGenerator->getTreeView(Manufacturer::class, $manufacturer);
@@ -105,7 +108,7 @@ class TreeController extends AbstractController
* @Route("/supplier/{id}", name="tree_supplier")
* @Route("/suppliers")
*/
- public function supplierTree(Supplier $supplier = null)
+ public function supplierTree(?Supplier $supplier = null)
{
$tree = $this->treeGenerator->getTreeView(Supplier::class, $supplier);
@@ -116,7 +119,7 @@ class TreeController extends AbstractController
* @Route("/device/{id}", name="tree_device")
* @Route("/devices")
*/
- public function deviceTree(Device $device = null)
+ public function deviceTree(?Device $device = null)
{
$tree = $this->treeGenerator->getTreeView(Device::class, $device, '');
diff --git a/src/Controller/TypeaheadController.php b/src/Controller/TypeaheadController.php
index df9d4b19..3e9b5801 100644
--- a/src/Controller/TypeaheadController.php
+++ b/src/Controller/TypeaheadController.php
@@ -1,4 +1,7 @@
$val) {
diff --git a/src/Controller/UserSettingsController.php b/src/Controller/UserSettingsController.php
index f9e40d9c..3e1cea83 100644
--- a/src/Controller/UserSettingsController.php
+++ b/src/Controller/UserSettingsController.php
@@ -1,4 +1,7 @@
denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
- if (!$user instanceof User) {
+ if (! $user instanceof User) {
return new \RuntimeException('This controller only works only for Part-DB User objects!');
}
if (empty($user->getBackupCodes())) {
$this->addFlash('error', 'tfa_backup.no_codes_enabled');
+
throw new \RuntimeException('You do not have any backup codes enabled, therefore you can not view them!');
}
@@ -91,7 +95,7 @@ class UserSettingsController extends AbstractController
//When user change its settings, he should be logged in fully.
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
- if (!$user instanceof User) {
+ if (! $user instanceof User) {
throw new \RuntimeException('This controller only works only for Part-DB User objects!');
}
@@ -103,12 +107,14 @@ class UserSettingsController extends AbstractController
$u2f = $key_repo->find($key_id);
if (null === $u2f) {
$this->addFlash('danger', 'tfa_u2f.u2f_delete.not_existing');
+
throw new \RuntimeException('Key not existing!');
}
//User can only delete its own U2F keys
if ($u2f->getUser() !== $user) {
$this->addFlash('danger', 'tfa_u2f.u2f_delete.access_denied');
+
throw new \RuntimeException('You can only delete your own U2F keys!');
}
@@ -138,7 +144,7 @@ class UserSettingsController extends AbstractController
//When user change its settings, he should be logged in fully.
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
- if (!$user instanceof User) {
+ if (! $user instanceof User) {
return new \RuntimeException('This controller only works only for Part-DB User objects!');
}
@@ -158,9 +164,7 @@ class UserSettingsController extends AbstractController
*/
public function userSettings(Request $request, EntityManagerInterface $em, UserPasswordEncoderInterface $passwordEncoder, GoogleAuthenticator $googleAuthenticator, BackupCodeManager $backupCodeManager)
{
- /**
- * @var User
- */
+ /** @var User */
$user = $this->getUser();
$page_need_reload = false;
@@ -168,7 +172,7 @@ class UserSettingsController extends AbstractController
//When user change its settings, he should be logged in fully.
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
- if (!$user instanceof User) {
+ if (! $user instanceof User) {
throw new \RuntimeException('This controller only works only for Part-DB User objects!');
}
@@ -180,7 +184,7 @@ class UserSettingsController extends AbstractController
$form->handleRequest($request);
- if ($form->isSubmitted() && $form->isValid() && !$this->demo_mode) {
+ if ($form->isSubmitted() && $form->isValid() && ! $this->demo_mode) {
//Check if user theme setting has changed
if ($user->getTheme() !== $em->getUnitOfWork()->getOriginalEntityData($user)['theme']) {
$page_need_reload = true;
@@ -217,9 +221,9 @@ class UserSettingsController extends AbstractController
'attr' => ['autocomplete' => 'new-password'],
],
'constraints' => [new Length([
- 'min' => 6,
- 'max' => 128,
- ])],
+ 'min' => 6,
+ 'max' => 128,
+ ])],
])
->add('submit', SubmitType::class, ['label' => 'save'])
->getForm();
@@ -227,7 +231,7 @@ class UserSettingsController extends AbstractController
$pw_form->handleRequest($request);
//Check if password if everything was correct, then save it to User and DB
- if ($pw_form->isSubmitted() && $pw_form->isValid() && !$this->demo_mode) {
+ if ($pw_form->isSubmitted() && $pw_form->isValid() && ! $this->demo_mode) {
$password = $passwordEncoder->encodePassword($user, $pw_form['new_password']->getData());
$user->setPassword($password);
@@ -242,14 +246,14 @@ class UserSettingsController extends AbstractController
//Handle 2FA things
$google_form = $this->createForm(TFAGoogleSettingsType::class, $user);
$google_enabled = $user->isGoogleAuthenticatorEnabled();
- if (!$form->isSubmitted() && !$google_enabled) {
+ if (! $form->isSubmitted() && ! $google_enabled) {
$user->setGoogleAuthenticatorSecret($googleAuthenticator->generateSecret());
$google_form->get('googleAuthenticatorSecret')->setData($user->getGoogleAuthenticatorSecret());
}
$google_form->handleRequest($request);
- if ($google_form->isSubmitted() && $google_form->isValid() && !$this->demo_mode) {
- if (!$google_enabled) {
+ if ($google_form->isSubmitted() && $google_form->isValid() && ! $this->demo_mode) {
+ if (! $google_enabled) {
//Save 2FA settings (save secrets)
$user->setGoogleAuthenticatorSecret($google_form->get('googleAuthenticatorSecret')->getData());
$backupCodeManager->enableBackupCodes($user);
@@ -277,7 +281,7 @@ class UserSettingsController extends AbstractController
])->getForm();
$backup_form->handleRequest($request);
- if ($backup_form->isSubmitted() && $backup_form->isValid() && !$this->demo_mode) {
+ if ($backup_form->isSubmitted() && $backup_form->isValid() && ! $this->demo_mode) {
$backupCodeManager->regenerateBackupCodes($user);
$em->flush();
$this->addFlash('success', 'user.settings.2fa.backup_codes.regenerated');
diff --git a/src/DataFixtures/AppFixtures.php b/src/DataFixtures/AppFixtures.php
index 5a92bd37..4f7e9bfc 100644
--- a/src/DataFixtures/AppFixtures.php
+++ b/src/DataFixtures/AppFixtures.php
@@ -1,4 +1,7 @@
persist($product);
diff --git a/src/DataFixtures/DataStructureFixtures.php b/src/DataFixtures/DataStructureFixtures.php
index 67ef9215..b5815554 100644
--- a/src/DataFixtures/DataStructureFixtures.php
+++ b/src/DataFixtures/DataStructureFixtures.php
@@ -1,4 +1,7 @@
em->getClassMetadata($class)->getTableName();
- $this->em->getConnection()->exec("ALTER TABLE `$table_name` AUTO_INCREMENT = 1;");
+ $this->em->getConnection()->exec("ALTER TABLE `${table_name}` AUTO_INCREMENT = 1;");
/** @var StructuralDBElement $node1 */
$node1 = new $class();
diff --git a/src/DataFixtures/GroupFixtures.php b/src/DataFixtures/GroupFixtures.php
index 5f7125cd..02895987 100644
--- a/src/DataFixtures/GroupFixtures.php
+++ b/src/DataFixtures/GroupFixtures.php
@@ -1,4 +1,7 @@
setName('admins');
//Perm values taken from Version 1
$admins->getPermissions()->setRawPermissionValues([
- 'system' => '21', 'groups' => '1365', 'users' => '87381', 'self' => '85', 'config' => '85',
- 'database' => '21', 'parts' => '1431655765', 'parts_name' => '5', 'parts_description' => '5',
- 'parts_footprint' => '5', 'parts_manufacturer' => '5', 'parts_comment' => '5', 'parts_order' => '5',
- 'parts_orderdetails' => '341', 'parts_prices' => '341', 'parts_attachments' => '341', 'devices' => '5461',
- 'devices_parts' => '325', 'storelocations' => '5461', 'footprints' => '5461', 'categories' => '5461',
- 'suppliers' => '5461', 'manufacturers' => '5461', 'attachment_types' => '1365', 'tools' => '1365',
- 'labels' => '21', 'parts_category' => '5', 'parts_minamount' => '5', 'parts_lots' => '85', 'parts_tags' => '5',
- 'parts_unit' => '5', 'parts_mass' => '5', 'parts_status' => '5', 'parts_mpn' => '5', 'currencies' => '5461',
- 'measurement_units' => '5461',
+ 'system' => 21, 'groups' => 1365, 'users' => 87381, 'self' => 85, 'config' => 85,
+ 'database' => 21, 'parts' => 1431655765, 'parts_name' => 5, 'parts_description' => 5,
+ 'parts_footprint' => 5, 'parts_manufacturer' => 5, 'parts_comment' => 5, 'parts_order' => 5,
+ 'parts_orderdetails' => 341, 'parts_prices' => 341, 'parts_attachments' => 341, 'devices' => 5461,
+ 'devices_parts' => 325, 'storelocations' => 5461, 'footprints' => 5461, 'categories' => 5461,
+ 'suppliers' => 5461, 'manufacturers' => 5461, 'attachment_types' => 1365, 'tools' => 1365,
+ 'labels' => 21, 'parts_category' => 5, 'parts_minamount' => 5, 'parts_lots' => 85, 'parts_tags' => 5,
+ 'parts_unit' => 5, 'parts_mass' => 5, 'parts_status' => 5, 'parts_mpn' => 5, 'currencies' => 5461,
+ 'measurement_units' => 5461,
]);
$this->setReference(self::ADMINS, $admins);
$manager->persist($admins);
@@ -53,15 +56,15 @@ class GroupFixtures extends Fixture
$readonly = new Group();
$readonly->setName('readonly');
$readonly->getPermissions()->setRawPermissionValues([
- 'system' => '2', 'groups' => '2730', 'users' => '43690', 'self' => '25', 'config' => '170',
- 'database' => '42', 'parts' => '2778027689', 'parts_name' => '9', 'parts_description' => '9',
- 'parts_footprint' => '9', 'parts_manufacturer' => '9', 'parts_comment' => '9', 'parts_order' => '9',
- 'parts_orderdetails' => '681', 'parts_prices' => '681', 'parts_attachments' => '681', 'devices' => '1705',
- 'devices_parts' => '649', 'storelocations' => '1705', 'footprints' => '1705', 'categories' => '1705',
- 'suppliers' => '1705', 'manufacturers' => '1705', 'attachment_types' => '681', 'tools' => '1366',
- 'labels' => '165', 'parts_category' => '9', 'parts_minamount' => '9', 'parts_lots' => '169', 'parts_tags' => '9',
- 'parts_unit' => '9', 'parts_mass' => '9', 'parts_status' => '9', 'parts_mpn' => '9', 'currencies' => '9897',
- 'measurement_units' => '9897',
+ 'system' => 2, 'groups' => 2730, 'users' => 43690, 'self' => 25, 'config' => 170,
+ 'database' => 42, 'parts' => 2778027689, 'parts_name' => 9, 'parts_description' => 9,
+ 'parts_footprint' => 9, 'parts_manufacturer' => 9, 'parts_comment' => 9, 'parts_order' => 9,
+ 'parts_orderdetails' => 681, 'parts_prices' => 681, 'parts_attachments' => 681, 'devices' => 1705,
+ 'devices_parts' => 649, 'storelocations' => 1705, 'footprints' => 1705, 'categories' => 1705,
+ 'suppliers' => 1705, 'manufacturers' => 1705, 'attachment_types' => 681, 'tools' => 1366,
+ 'labels' => 165, 'parts_category' => 9, 'parts_minamount' => 9, 'parts_lots' => 169, 'parts_tags' => 9,
+ 'parts_unit' => 9, 'parts_mass' => 9, 'parts_status' => 9, 'parts_mpn' => 9, 'currencies' => 9897,
+ 'measurement_units' => 9897,
]);
$this->setReference(self::READONLY, $readonly);
$manager->persist($readonly);
@@ -69,15 +72,15 @@ class GroupFixtures extends Fixture
$users = new Group();
$users->setName('users');
$users->getPermissions()->setRawPermissionValues([
- 'system' => '42', 'groups' => '2730', 'users' => '43690', 'self' => '89', 'config' => '105',
- 'database' => '41', 'parts' => '1431655765', 'parts_name' => '5', 'parts_description' => '5',
- 'parts_footprint' => '5', 'parts_manufacturer' => '5', 'parts_comment' => '5', 'parts_order' => '5',
- 'parts_orderdetails' => '341', 'parts_prices' => '341', 'parts_attachments' => '341', 'devices' => '5461',
- 'devices_parts' => '325', 'storelocations' => '5461', 'footprints' => '5461', 'categories' => '5461',
- 'suppliers' => '5461', 'manufacturers' => '5461', 'attachment_types' => '1365', 'tools' => '1365',
- 'labels' => '85', 'parts_category' => '5', 'parts_minamount' => '5', 'parts_lots' => '85', 'parts_tags' => '5',
- 'parts_unit' => '5', 'parts_mass' => '5', 'parts_status' => '5', 'parts_mpn' => '5', 'currencies' => '5461',
- 'measurement_units' => '5461',
+ 'system' => 42, 'groups' => 2730, 'users' => 43690, 'self' => 89, 'config' => 105,
+ 'database' => 41, 'parts' => 1431655765, 'parts_name' => 5, 'parts_description' => 5,
+ 'parts_footprint' => 5, 'parts_manufacturer' => 5, 'parts_comment' => 5, 'parts_order' => 5,
+ 'parts_orderdetails' => 341, 'parts_prices' => 341, 'parts_attachments' => 341, 'devices' => 5461,
+ 'devices_parts' => 325, 'storelocations' => 5461, 'footprints' => 5461, 'categories' => 5461,
+ 'suppliers' => 5461, 'manufacturers' => 5461, 'attachment_types' => 1365, 'tools' => 1365,
+ 'labels' => 85, 'parts_category' => 5, 'parts_minamount' => 5, 'parts_lots' => 85, 'parts_tags' => 5,
+ 'parts_unit' => 5, 'parts_mass' => 5, 'parts_status' => 5, 'parts_mpn' => 5, 'currencies' => 5461,
+ 'measurement_units' => 5461,
]);
$this->setReference(self::USERS, $users);
$manager->persist($users);
diff --git a/src/DataFixtures/UserFixtures.php b/src/DataFixtures/UserFixtures.php
index d917e976..0584650f 100644
--- a/src/DataFixtures/UserFixtures.php
+++ b/src/DataFixtures/UserFixtures.php
@@ -1,4 +1,7 @@
encoder = $encoder;
}
- public function load(ObjectManager $manager)
+ public function load(ObjectManager $manager): void
{
//Reset autoincrement
$this->em->getConnection()->exec('ALTER TABLE `users` AUTO_INCREMENT = 1;');
diff --git a/src/DataTables/Adapter/CustomORMAdapter.php b/src/DataTables/Adapter/CustomORMAdapter.php
index 72bb2730..764a4088 100644
--- a/src/DataTables/Adapter/CustomORMAdapter.php
+++ b/src/DataTables/Adapter/CustomORMAdapter.php
@@ -1,4 +1,7 @@
hydrationMode = isset($options['hydrate']) ? $options['hydrate'] : Query::HYDRATE_OBJECT;
+ $this->hydrationMode = $options['hydrate'] ?? Query::HYDRATE_OBJECT;
}
- protected function prepareQuery(AdapterQuery $query)
+ protected function prepareQuery(AdapterQuery $query): void
{
parent::prepareQuery($query);
$query->setIdentifierPropertyPath(null);
@@ -57,7 +60,7 @@ class CustomORMAdapter extends ORMAdapter
$builder = $query->get('qb');
$state = $query->getState();
// Apply definitive view state for current 'page' of the table
- foreach ($state->getOrderBy() as list($column, $direction)) {
+ foreach ($state->getOrderBy() as [$column, $direction]) {
/** @var AbstractColumn $column */
if ($column->isOrderable()) {
$builder->addOrderBy($column->getOrderField(), $direction);
diff --git a/src/DataTables/AttachmentDataTable.php b/src/DataTables/AttachmentDataTable.php
index 8d2befdc..8e741a68 100644
--- a/src/DataTables/AttachmentDataTable.php
+++ b/src/DataTables/AttachmentDataTable.php
@@ -1,4 +1,7 @@
attachmentURLGenerator = $attachmentURLGenerator;
}
- protected function getQuery(QueryBuilder $builder)
- {
- $builder->distinct()->select('attachment')
- ->addSelect('attachment_type')
- //->addSelect('element')
- ->from(Attachment::class, 'attachment')
- ->leftJoin('attachment.attachment_type', 'attachment_type');
- //->leftJoin('attachment.element', 'element');
- }
-
- public function configure(DataTable $dataTable, array $options)
+ public function configure(DataTable $dataTable, array $options): void
{
$dataTable->add('picture', TextColumn::class, [
'label' => '',
'render' => function ($value, Attachment $context) {
if ($context->isPicture()
- && !$context->isExternal()
+ && ! $context->isExternal()
&& $this->attachmentHelper->isFileExisting($context)) {
return sprintf(
'
',
@@ -204,9 +197,19 @@ class AttachmentDataTable implements DataTableTypeInterface
$dataTable->createAdapter(ORMAdapter::class, [
'entity' => Attachment::class,
- 'query' => function (QueryBuilder $builder) {
+ 'query' => function (QueryBuilder $builder): void {
$this->getQuery($builder);
},
]);
}
+
+ protected function getQuery(QueryBuilder $builder): void
+ {
+ $builder->distinct()->select('attachment')
+ ->addSelect('attachment_type')
+ //->addSelect('element')
+ ->from(Attachment::class, 'attachment')
+ ->leftJoin('attachment.attachment_type', 'attachment_type');
+ //->leftJoin('attachment.element', 'element');
+ }
}
diff --git a/src/DataTables/Column/EntityColumn.php b/src/DataTables/Column/EntityColumn.php
index 3e4aa233..b8994e5f 100644
--- a/src/DataTables/Column/EntityColumn.php
+++ b/src/DataTables/Column/EntityColumn.php
@@ -1,4 +1,7 @@
urlGenerator->listPartsURL($entity),
$value
);
- } else {
- return sprintf('%s', $value);
}
+
+ return sprintf('%s', $value);
}
};
});
diff --git a/src/DataTables/Column/LocaleDateTimeColumn.php b/src/DataTables/Column/LocaleDateTimeColumn.php
index 1ef0056d..d01e2c3d 100644
--- a/src/DataTables/Column/LocaleDateTimeColumn.php
+++ b/src/DataTables/Column/LocaleDateTimeColumn.php
@@ -1,4 +1,7 @@
options['nullValue'];
- } elseif (!$value instanceof \DateTimeInterface) {
+ } elseif (! $value instanceof \DateTimeInterface) {
$value = new \DateTime((string) $value);
}
@@ -60,9 +60,6 @@ class LocaleDateTimeColumn extends AbstractColumn
return $formatter->format($value->getTimestamp());
}
- /**
- * {@inheritdoc}
- */
protected function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
diff --git a/src/DataTables/Column/MarkdownColumn.php b/src/DataTables/Column/MarkdownColumn.php
index 689c2412..f60ebe90 100644
--- a/src/DataTables/Column/MarkdownColumn.php
+++ b/src/DataTables/Column/MarkdownColumn.php
@@ -1,4 +1,7 @@
%s',
$this->urlGenerator->viewURL($attachment),
@@ -87,7 +90,7 @@ class PartAttachmentsColumn extends AbstractColumn
return $tmp;
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
}
diff --git a/src/DataTables/Column/TagsColumn.php b/src/DataTables/Column/TagsColumn.php
index d8527ca2..eb7ff8c3 100644
--- a/src/DataTables/Column/TagsColumn.php
+++ b/src/DataTables/Column/TagsColumn.php
@@ -1,4 +1,7 @@
attachmentURLGenerator = $attachmentURLGenerator;
}
- protected function getQuery(QueryBuilder $builder)
- {
- $builder->distinct()->select('part')
- ->addSelect('category')
- ->addSelect('footprint')
- ->addSelect('manufacturer')
- ->addSelect('partUnit')
- ->addSelect('master_picture_attachment')
- ->addSelect('footprint_attachment')
- ->addSelect('partLots')
- ->addSelect('orderdetails')
- ->addSelect('attachments')
- ->addSelect('storelocations')
- ->from(Part::class, 'part')
- ->leftJoin('part.category', 'category')
- ->leftJoin('part.master_picture_attachment', 'master_picture_attachment')
- ->leftJoin('part.partLots', 'partLots')
- ->leftJoin('partLots.storage_location', 'storelocations')
- ->leftJoin('part.footprint', 'footprint')
- ->leftJoin('footprint.master_picture_attachment', 'footprint_attachment')
- ->leftJoin('part.manufacturer', 'manufacturer')
- ->leftJoin('part.orderdetails', 'orderdetails')
- ->leftJoin('part.attachments', 'attachments')
- ->leftJoin('part.partUnit', 'partUnit');
- }
-
- protected function buildCriteria(QueryBuilder $builder, array $options)
- {
- $em = $builder->getEntityManager();
-
- if (isset($options['category'])) {
- $category = $options['category'];
- $list = $this->treeBuilder->typeToNodesList(Category::class, $category);
- $list[] = $category;
-
- $builder->andWhere('part.category IN (:cid)')->setParameter('cid', $list);
- }
-
- if (isset($options['footprint'])) {
- $category = $options['footprint'];
- $list = $this->treeBuilder->typeToNodesList(Footprint::class, $category);
- $list[] = $category;
-
- $builder->andWhere('part.footprint IN (:cid)')->setParameter('cid', $list);
- }
-
- if (isset($options['manufacturer'])) {
- $category = $options['manufacturer'];
- $list = $this->treeBuilder->typeToNodesList(Manufacturer::class, $category);
- $list[] = $category;
-
- $builder->andWhere('part.manufacturer IN (:cid)')->setParameter('cid', $list);
- }
-
- if (isset($options['storelocation'])) {
- $location = $options['storelocation'];
- $list = $this->treeBuilder->typeToNodesList(Storelocation::class, $location);
- $list[] = $location;
-
- $builder->andWhere('partLots.storage_location IN (:cid)')->setParameter('cid', $list);
- }
-
- if (isset($options['supplier'])) {
- $supplier = $options['supplier'];
- $list = $this->treeBuilder->typeToNodesList(Supplier::class, $supplier);
- $list[] = $supplier;
-
- $builder->andWhere('orderdetails.supplier IN (:cid)')->setParameter('cid', $list);
- }
-
- if (isset($options['tag'])) {
- $builder->andWhere('part.tags LIKE :tag')->setParameter('tag', '%'.$options['tag'].'%');
- }
-
- if (isset($options['search'])) {
- $builder->AndWhere('part.name LIKE :search')->orWhere('part.description LIKE :search')->orWhere('part.comment LIKE :search')
- ->setParameter('search', '%'.$options['search'].'%');
- }
- }
-
- public function configure(DataTable $dataTable, array $options)
+ public function configure(DataTable $dataTable, array $options): void
{
$dataTable
->add('picture', TextColumn::class, [
@@ -293,16 +216,96 @@ class PartsDataTable implements DataTableTypeInterface
->addOrderBy('name')
->createAdapter(CustomORMAdapter::class, [
- 'query' => function (QueryBuilder $builder) {
+ 'query' => function (QueryBuilder $builder): void {
$this->getQuery($builder);
},
'entity' => Part::class,
'criteria' => [
- function (QueryBuilder $builder) use ($options) {
+ function (QueryBuilder $builder) use ($options): void {
$this->buildCriteria($builder, $options);
},
new SearchCriteriaProvider(),
],
]);
}
+
+ protected function getQuery(QueryBuilder $builder): void
+ {
+ $builder->distinct()->select('part')
+ ->addSelect('category')
+ ->addSelect('footprint')
+ ->addSelect('manufacturer')
+ ->addSelect('partUnit')
+ ->addSelect('master_picture_attachment')
+ ->addSelect('footprint_attachment')
+ ->addSelect('partLots')
+ ->addSelect('orderdetails')
+ ->addSelect('attachments')
+ ->addSelect('storelocations')
+ ->from(Part::class, 'part')
+ ->leftJoin('part.category', 'category')
+ ->leftJoin('part.master_picture_attachment', 'master_picture_attachment')
+ ->leftJoin('part.partLots', 'partLots')
+ ->leftJoin('partLots.storage_location', 'storelocations')
+ ->leftJoin('part.footprint', 'footprint')
+ ->leftJoin('footprint.master_picture_attachment', 'footprint_attachment')
+ ->leftJoin('part.manufacturer', 'manufacturer')
+ ->leftJoin('part.orderdetails', 'orderdetails')
+ ->leftJoin('part.attachments', 'attachments')
+ ->leftJoin('part.partUnit', 'partUnit');
+ }
+
+ protected function buildCriteria(QueryBuilder $builder, array $options): void
+ {
+ $em = $builder->getEntityManager();
+
+ if (isset($options['category'])) {
+ $category = $options['category'];
+ $list = $this->treeBuilder->typeToNodesList(Category::class, $category);
+ $list[] = $category;
+
+ $builder->andWhere('part.category IN (:cid)')->setParameter('cid', $list);
+ }
+
+ if (isset($options['footprint'])) {
+ $category = $options['footprint'];
+ $list = $this->treeBuilder->typeToNodesList(Footprint::class, $category);
+ $list[] = $category;
+
+ $builder->andWhere('part.footprint IN (:cid)')->setParameter('cid', $list);
+ }
+
+ if (isset($options['manufacturer'])) {
+ $category = $options['manufacturer'];
+ $list = $this->treeBuilder->typeToNodesList(Manufacturer::class, $category);
+ $list[] = $category;
+
+ $builder->andWhere('part.manufacturer IN (:cid)')->setParameter('cid', $list);
+ }
+
+ if (isset($options['storelocation'])) {
+ $location = $options['storelocation'];
+ $list = $this->treeBuilder->typeToNodesList(Storelocation::class, $location);
+ $list[] = $location;
+
+ $builder->andWhere('partLots.storage_location IN (:cid)')->setParameter('cid', $list);
+ }
+
+ if (isset($options['supplier'])) {
+ $supplier = $options['supplier'];
+ $list = $this->treeBuilder->typeToNodesList(Supplier::class, $supplier);
+ $list[] = $supplier;
+
+ $builder->andWhere('orderdetails.supplier IN (:cid)')->setParameter('cid', $list);
+ }
+
+ if (isset($options['tag'])) {
+ $builder->andWhere('part.tags LIKE :tag')->setParameter('tag', '%'.$options['tag'].'%');
+ }
+
+ if (isset($options['search'])) {
+ $builder->AndWhere('part.name LIKE :search')->orWhere('part.description LIKE :search')->orWhere('part.comment LIKE :search')
+ ->setParameter('search', '%'.$options['search'].'%');
+ }
+ }
}
diff --git a/src/Entity/Attachments/Attachment.php b/src/Entity/Attachments/Attachment.php
index 30cc7219..4c1da00c 100644
--- a/src/Entity/Attachments/Attachment.php
+++ b/src/Entity/Attachments/Attachment.php
@@ -68,6 +68,11 @@ abstract class Attachment extends NamedDBElement
/** @var array Placeholders for attachments which using built in files. */
public const BUILTIN_PLACEHOLDER = ['%FOOTPRINTS%', '%FOOTPRINTS3D%'];
+ /**
+ * @var string The class of the element that can be passed to this attachment. Must be overridden in subclasses.
+ */
+ public const ALLOWED_ELEMENT_CLASS = '';
+
/**
* @var bool
* @ORM\Column(type="boolean")
@@ -99,11 +104,6 @@ abstract class Attachment extends NamedDBElement
*/
protected $attachment_type;
- /**
- * @var string The class of the element that can be passed to this attachment. Must be overridden in subclasses.
- */
- public const ALLOWED_ELEMENT_CLASS = '';
-
public function __construct()
{
//parent::__construct();
@@ -170,7 +170,7 @@ abstract class Attachment extends NamedDBElement
return true;
}
- return !\in_array($tmp[0], array_merge(static::INTERNAL_PLACEHOLDER, static::BUILTIN_PLACEHOLDER), false);
+ return ! \in_array($tmp[0], array_merge(static::INTERNAL_PLACEHOLDER, static::BUILTIN_PLACEHOLDER), false);
}
/**
@@ -221,7 +221,7 @@ abstract class Attachment extends NamedDBElement
return null;
}
- if (!empty($this->original_filename)) {
+ if (! empty($this->original_filename)) {
return strtolower(pathinfo($this->original_filename, PATHINFO_EXTENSION));
}
@@ -244,7 +244,7 @@ abstract class Attachment extends NamedDBElement
*/
public function getURL(): ?string
{
- if (!$this->isExternal() && !$this->isBuiltIn()) {
+ if (! $this->isExternal() && ! $this->isBuiltIn()) {
return null;
}
@@ -257,7 +257,7 @@ abstract class Attachment extends NamedDBElement
*/
public function getHost(): ?string
{
- if (!$this->isExternal()) {
+ if (! $this->isExternal()) {
return null;
}
@@ -287,7 +287,7 @@ abstract class Attachment extends NamedDBElement
}
//If we have a stored original filename, then use it
- if (!empty($this->original_filename)) {
+ if (! empty($this->original_filename)) {
return $this->original_filename;
}
@@ -362,8 +362,8 @@ abstract class Attachment extends NamedDBElement
*/
public function setElement(AttachmentContainingDBElement $element): self
{
- if (!is_a($element, static::ALLOWED_ELEMENT_CLASS)) {
- throw new \InvalidArgumentException(sprintf('The element associated with a %s must be a %s!', \get_class($this), static::ALLOWED_ELEMENT_CLASS));
+ if (! is_a($element, static::ALLOWED_ELEMENT_CLASS)) {
+ throw new \InvalidArgumentException(sprintf('The element associated with a %s must be a %s!', static::class, static::ALLOWED_ELEMENT_CLASS));
}
$this->element = $element;
@@ -404,7 +404,7 @@ abstract class Attachment extends NamedDBElement
public function setURL(?string $url): self
{
//Only set if the URL is not empty
- if (!empty($url)) {
+ if (! empty($url)) {
if (false !== strpos($url, '%BASE%') || false !== strpos($url, '%MEDIA%')) {
throw new \InvalidArgumentException('You can not reference internal files via the url field! But nice try!');
}
@@ -443,10 +443,10 @@ abstract class Attachment extends NamedDBElement
/**
* Check if a string is a URL and is valid.
*
- * @param $string string The string which should be checked
- * @param bool $path_required If true, the string must contain a path to be valid. (e.g. foo.bar would be invalid, foo.bar/test.php would be valid).
- * @param $only_http bool Set this to true, if only HTTPS or HTTP schemata should be allowed.
- * *Caution: When this is set to false, a attacker could use the file:// schema, to get internal server files, like /etc/passwd.*
+ * @param string $string The string which should be checked
+ * @param bool $path_required If true, the string must contain a path to be valid. (e.g. foo.bar would be invalid, foo.bar/test.php would be valid).
+ * @param bool $only_http Set this to true, if only HTTPS or HTTP schemata should be allowed.
+ * *Caution: When this is set to false, a attacker could use the file:// schema, to get internal server files, like /etc/passwd.*
*
* @return bool True if the string is a valid URL. False, if the string is not an URL or invalid.
*/
diff --git a/src/Entity/Attachments/AttachmentTypeAttachment.php b/src/Entity/Attachments/AttachmentTypeAttachment.php
index 50d8e824..8a6ff0f8 100644
--- a/src/Entity/Attachments/AttachmentTypeAttachment.php
+++ b/src/Entity/Attachments/AttachmentTypeAttachment.php
@@ -1,4 +1,7 @@
id = null;
+ }
+
/**
* Get the ID. The ID can be zero, or even negative (for virtual elements). If an element is virtual, can be
* checked with isVirtualElement().
@@ -86,10 +92,4 @@ abstract class DBElement
* @return string The ID as a string;
*/
abstract public function getIDString(): string;
-
- public function __clone()
- {
- //Set ID to null, so that an new entry is created
- $this->id = null;
- }
}
diff --git a/src/Entity/Base/MasterAttachmentTrait.php b/src/Entity/Base/MasterAttachmentTrait.php
index 912a1567..63d74cae 100644
--- a/src/Entity/Base/MasterAttachmentTrait.php
+++ b/src/Entity/Base/MasterAttachmentTrait.php
@@ -1,4 +1,7 @@
getName();
+ }
+
/********************************************************************************
*
* Getters
@@ -80,15 +91,4 @@ abstract class NamedDBElement extends DBElement
return $this;
}
-
- /******************************************************************************
- *
- * Helpers
- *
- ******************************************************************************/
-
- public function __toString()
- {
- return $this->getName();
- }
}
diff --git a/src/Entity/Base/StructuralDBElement.php b/src/Entity/Base/StructuralDBElement.php
index d99a17db..7da3305b 100644
--- a/src/Entity/Base/StructuralDBElement.php
+++ b/src/Entity/Base/StructuralDBElement.php
@@ -113,11 +113,11 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
*/
public function isChildOf(self $another_element): bool
{
- $class_name = \get_class($this);
+ $class_name = static::class;
//Check if both elements compared, are from the same type
// (we have to check inheritance, or we get exceptions when using doctrine entities (they have a proxy type):
- if (!is_a($another_element, $class_name) && !is_a($this, \get_class($another_element))) {
+ if (! is_a($another_element, $class_name) && ! is_a($this, \get_class($another_element))) {
throw new \InvalidArgumentException('isChildOf() only works for objects of the same type!');
}
@@ -201,7 +201,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
*/
public function getFullPath(string $delimiter = self::PATH_DELIMITER_ARROW): string
{
- if (!\is_array($this->full_path_strings)) {
+ if (! \is_array($this->full_path_strings)) {
$this->full_path_strings = [];
$this->full_path_strings[] = $this->getName();
$element = $this;
@@ -233,7 +233,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
$tmp[] = $this;
//We only allow 20 levels depth
- while (!end($tmp)->isRoot() && \count($tmp) < 20) {
+ while (! end($tmp)->isRoot() && \count($tmp) < 20) {
$tmp[] = end($tmp)->parent;
}
@@ -243,8 +243,6 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
/**
* Get all sub elements of this element.
*
- * @param bool $recursive if true, the search is recursive
- *
* @return Collection all subelements as an array of objects (sorted by their full path)
*/
public function getSubelements(): iterable
diff --git a/src/Entity/Base/TimestampTrait.php b/src/Entity/Base/TimestampTrait.php
index 30e79455..aa3ebf71 100644
--- a/src/Entity/Base/TimestampTrait.php
+++ b/src/Entity/Base/TimestampTrait.php
@@ -1,4 +1,7 @@
part instanceof Part && !$this->part->useFloatAmount()) {
+ if ($this->part instanceof Part && ! $this->part->useFloatAmount()) {
return round($this->amount);
}
diff --git a/src/Entity/Parts/PartTraits/AdvancedPropertyTrait.php b/src/Entity/Parts/PartTraits/AdvancedPropertyTrait.php
index 870dbaa2..e26d93a0 100644
--- a/src/Entity/Parts/PartTraits/AdvancedPropertyTrait.php
+++ b/src/Entity/Parts/PartTraits/AdvancedPropertyTrait.php
@@ -1,4 +1,7 @@
partUnit instanceof MeasurementUnit) {
- return !$this->partUnit->isInteger();
+ return ! $this->partUnit->isInteger();
}
//When no part unit is set, treat it as part count, and so use the integer value.
diff --git a/src/Entity/Parts/PartTraits/ManufacturerTrait.php b/src/Entity/Parts/PartTraits/ManufacturerTrait.php
index a59a01d7..34dbc843 100644
--- a/src/Entity/Parts/PartTraits/ManufacturerTrait.php
+++ b/src/Entity/Parts/PartTraits/ManufacturerTrait.php
@@ -1,4 +1,7 @@
getObsolete()) {
+ if (! $orderdetails->getObsolete()) {
return false;
}
}
diff --git a/src/Entity/PriceInformations/Currency.php b/src/Entity/PriceInformations/Currency.php
index 2aa0bf7b..e7818a82 100644
--- a/src/Entity/PriceInformations/Currency.php
+++ b/src/Entity/PriceInformations/Currency.php
@@ -1,4 +1,7 @@
orderdetail && $this->orderdetail->getPart() && !$this->orderdetail->getPart()->useFloatAmount()) {
+ if ($this->orderdetail && $this->orderdetail->getPart() && ! $this->orderdetail->getPart()->useFloatAmount()) {
$tmp = round($this->price_related_quantity);
return $tmp < 1 ? 1 : $tmp;
@@ -203,7 +203,7 @@ class Pricedetail extends DBElement
*/
public function getMinDiscountQuantity(): float
{
- if ($this->orderdetail && $this->orderdetail->getPart() && !$this->orderdetail->getPart()->useFloatAmount()) {
+ if ($this->orderdetail && $this->orderdetail->getPart() && ! $this->orderdetail->getPart()->useFloatAmount()) {
$tmp = round($this->min_discount_quantity);
return $tmp < 1 ? 1 : $tmp;
diff --git a/src/Entity/UserSystem/Group.php b/src/Entity/UserSystem/Group.php
index 879d0ab9..b209d02f 100644
--- a/src/Entity/UserSystem/Group.php
+++ b/src/Entity/UserSystem/Group.php
@@ -1,4 +1,7 @@
$permission_name);
+ return isset($this->{$permission_name});
}
/**
@@ -312,11 +315,11 @@ class PermissionsEmbed
*/
public function getBitValue(string $permission_name, int $bit_n): int
{
- if (!$this->isValidPermissionName($permission_name)) {
+ if (! $this->isValidPermissionName($permission_name)) {
throw new \InvalidArgumentException(sprintf('No permission with the name "%s" is existing!', $permission_name));
}
- $perm_int = $this->$permission_name;
+ $perm_int = (int) $this->{$permission_name};
return static::readBitPair($perm_int, $bit_n);
}
@@ -382,11 +385,11 @@ class PermissionsEmbed
*/
public function setBitValue(string $permission_name, int $bit_n, int $new_value): self
{
- if (!$this->isValidPermissionName($permission_name)) {
+ if (! $this->isValidPermissionName($permission_name)) {
throw new \InvalidArgumentException('No permission with the given name is existing!');
}
- $this->$permission_name = static::writeBitPair($this->$permission_name, $bit_n, $new_value);
+ $this->{$permission_name} = static::writeBitPair($this->{$permission_name}, $bit_n, $new_value);
return $this;
}
@@ -401,11 +404,11 @@ class PermissionsEmbed
*/
public function getRawPermissionValue(string $permission_name): int
{
- if (!$this->isValidPermissionName($permission_name)) {
+ if (! $this->isValidPermissionName($permission_name)) {
throw new \InvalidArgumentException('No permission with the given name is existing!');
}
- return $this->$permission_name;
+ return $this->{$permission_name};
}
/**
@@ -418,11 +421,11 @@ class PermissionsEmbed
*/
public function setRawPermissionValue(string $permission_name, int $value): self
{
- if (!$this->isValidPermissionName($permission_name)) {
+ if (! $this->isValidPermissionName($permission_name)) {
throw new \InvalidArgumentException(sprintf('No permission with the given name %s is existing!', $permission_name));
}
- $this->$permission_name = $value;
+ $this->{$permission_name} = $value;
return $this;
}
@@ -436,9 +439,9 @@ class PermissionsEmbed
*
* @return $this
*/
- public function setRawPermissionValues(array $values, array $values2 = null): self
+ public function setRawPermissionValues(array $values, ?array $values2 = null): self
{
- if (!empty($values2)) {
+ if (! empty($values2)) {
$values = array_combine($values, $values2);
}
@@ -452,12 +455,12 @@ class PermissionsEmbed
/**
* Reads a bit pair from $data.
*
- * @param $data int The data from where the bits should be extracted from
- * @param $n int The number of the lower bit (of the pair) that should be read. Starting from zero.
+ * @param int|string $data The data from where the bits should be extracted from
+ * @param int $n The number of the lower bit (of the pair) that should be read. Starting from zero.
*
* @return int the value of the bit pair
*/
- final protected static function readBitPair(int $data, int $n): int
+ final protected static function readBitPair($data, int $n): int
{
Assert::lessThanEq($n, 31, '$n must be smaller than 32, because only a 32bit int is used! Got %s.');
if (0 !== $n % 2) {
@@ -471,9 +474,9 @@ class PermissionsEmbed
/**
* Writes a bit pair in the given $data and returns it.
*
- * @param $data int The data which should be modified
- * @param $n int The number of the lower bit of the pair which should be written
- * @param $new int The new value of the pair
+ * @param int $data The data which should be modified
+ * @param int $n The number of the lower bit of the pair which should be written
+ * @param int $new The new value of the pair
*
* @return int the new data with the modified pair
*/
diff --git a/src/Entity/UserSystem/U2FKey.php b/src/Entity/UserSystem/U2FKey.php
index dff64e20..36eff11e 100644
--- a/src/Entity/UserSystem/U2FKey.php
+++ b/src/Entity/UserSystem/U2FKey.php
@@ -1,4 +1,7 @@
counter = $data->counter;
}
- /** {@inheritdoc} */
public function getKeyHandle()
{
return $this->keyHandle;
}
- /** {@inheritdoc} */
- public function setKeyHandle($keyHandle)
+ public function setKeyHandle($keyHandle): void
{
$this->keyHandle = $keyHandle;
}
- /** {@inheritdoc} */
public function getPublicKey()
{
return $this->publicKey;
}
- /** {@inheritdoc} */
- public function setPublicKey($publicKey)
+ public function setPublicKey($publicKey): void
{
$this->publicKey = $publicKey;
}
- /** {@inheritdoc} */
public function getCertificate()
{
return $this->certificate;
}
- /** {@inheritdoc} */
- public function setCertificate($certificate)
+ public function setCertificate($certificate): void
{
$this->certificate = $certificate;
}
- /** {@inheritdoc} */
public function getCounter()
{
return $this->counter;
}
- /** {@inheritdoc} */
- public function setCounter($counter)
+ public function setCounter($counter): void
{
$this->counter = $counter;
}
- /** {@inheritdoc} */
public function getName()
{
return $this->name;
}
- /** {@inheritdoc} */
- public function setName($name)
+ public function setName($name): void
{
$this->name = $name;
}
diff --git a/src/Entity/UserSystem/User.php b/src/Entity/UserSystem/User.php
index 196aa4d0..b77dee82 100644
--- a/src/Entity/UserSystem/User.php
+++ b/src/Entity/UserSystem/User.php
@@ -266,6 +266,19 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
$this->u2fKeys = new ArrayCollection();
}
+ /**
+ * Returns a string representation of this user (the full name).
+ * E.g. 'Jane Doe (j.doe) [DISABLED].
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ $tmp = $this->isDisabled() ? ' [DISABLED]' : '';
+
+ return $this->getFullName(true).$tmp;
+ }
+
/**
* Checks if the current user, is the user which represents the not logged in (anonymous) users.
*
@@ -330,7 +343,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* @see UserInterface
*/
- public function getSalt()
+ public function getSalt(): void
{
// not needed when using the "bcrypt" algorithm in security.yaml
}
@@ -338,7 +351,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* @see UserInterface
*/
- public function eraseCredentials()
+ public function eraseCredentials(): void
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
@@ -503,7 +516,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
public function setName(string $new_name): NamedDBElement
{
// Anonymous user is not allowed to change its username
- if (!$this->isAnonymousUser()) {
+ if (! $this->isAnonymousUser()) {
$this->name = $new_name;
}
@@ -646,8 +659,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Change the timezone of this user.
*
- * @param string $timezone|null The new timezone (e.g. 'Europe/Berlin') or null to use the system wide one.
- *
* @return $this
*/
public function setTimezone(?string $timezone): self
@@ -706,19 +717,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
return $this;
}
- /**
- * Returns a string representation of this user (the full name).
- * E.g. 'Jane Doe (j.doe) [DISABLED].
- *
- * @return string
- */
- public function __toString()
- {
- $tmp = $this->isDisabled() ? ' [DISABLED]' : '';
-
- return $this->getFullName(true).$tmp;
- }
-
/**
* Return true if the user should do two-factor authentication.
*
@@ -771,7 +769,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
*/
public function isBackupCode(string $code): bool
{
- return \in_array($code, $this->backupCodes);
+ return \in_array($code, $this->backupCodes, true);
}
/**
@@ -781,7 +779,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
*/
public function invalidateBackupCode(string $code): void
{
- $key = array_search($code, $this->backupCodes);
+ $key = array_search($code, $this->backupCodes, true);
if (false !== $key) {
unset($this->backupCodes[$key]);
}
@@ -883,9 +881,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
$this->u2fKeys->removeElement($key);
}
- /**
- * {@inheritdoc}
- */
public function getPreferredTwoFactorProvider(): ?string
{
//If U2F is available then prefer it
diff --git a/src/EntityListeners/AttachmentDeleteListener.php b/src/EntityListeners/AttachmentDeleteListener.php
index 363653e0..459db6f9 100644
--- a/src/EntityListeners/AttachmentDeleteListener.php
+++ b/src/EntityListeners/AttachmentDeleteListener.php
@@ -1,4 +1,7 @@
hasChangedField('path')) {
//Dont delete file if the attachment uses a builtin ressource:
@@ -70,7 +73,7 @@ class AttachmentDeleteListener
*
* @PostRemove
*/
- public function postRemoveHandler(Attachment $attachment, LifecycleEventArgs $event)
+ public function postRemoveHandler(Attachment $attachment, LifecycleEventArgs $event): void
{
//Dont delete file if the attachment uses a builtin ressource:
if ($attachment->isBuiltIn()) {
diff --git a/src/EntityListeners/TreeCacheInvalidationListener.php b/src/EntityListeners/TreeCacheInvalidationListener.php
index eae8b023..764c5961 100644
--- a/src/EntityListeners/TreeCacheInvalidationListener.php
+++ b/src/EntityListeners/TreeCacheInvalidationListener.php
@@ -1,4 +1,7 @@
flashBag = $flashBag;
}
- public function onLogin(InteractiveLoginEvent $event)
+ public function onLogin(InteractiveLoginEvent $event): void
{
$this->flashBag->add('notice', $this->translator->trans('flash.login_successful'));
}
diff --git a/src/EventSubscriber/LogoutOnDisabledUserListener.php b/src/EventSubscriber/LogoutOnDisabledUserListener.php
index da4be4ca..73cb8949 100644
--- a/src/EventSubscriber/LogoutOnDisabledUserListener.php
+++ b/src/EventSubscriber/LogoutOnDisabledUserListener.php
@@ -1,4 +1,7 @@
urlGenerator = $urlGenerator;
}
- public function onRequest(RequestEvent $event)
+ public function onRequest(RequestEvent $event): void
{
$user = $this->security->getUser();
if ($user instanceof User && $user->isDisabled()) {
diff --git a/src/EventSubscriber/MailFromListener.php b/src/EventSubscriber/MailFromListener.php
index 7e6a400e..3843b3eb 100644
--- a/src/EventSubscriber/MailFromListener.php
+++ b/src/EventSubscriber/MailFromListener.php
@@ -1,4 +1,7 @@
security->getUser();
$request = $event->getRequest();
- if (!$event->isMasterRequest()) {
+ if (! $event->isMasterRequest()) {
return;
}
- if (!$user instanceof User) {
+ if (! $user instanceof User) {
return;
}
//Abort if we dont need to redirect the user.
- if (!$user->isNeedPwChange() && !static::TFARedirectNeeded($user)) {
+ if (! $user->isNeedPwChange() && ! static::TFARedirectNeeded($user)) {
return;
}
@@ -123,16 +125,13 @@ class PasswordChangeNeededSubscriber implements EventSubscriberInterface
{
$tfa_enabled = $user->isU2FAuthEnabled() || $user->isGoogleAuthenticatorEnabled();
- if (null !== $user->getGroup() && $user->getGroup()->isEnforce2FA() && !$tfa_enabled) {
+ if (null !== $user->getGroup() && $user->getGroup()->isEnforce2FA() && ! $tfa_enabled) {
return true;
}
return false;
}
- /**
- * {@inheritdoc}
- */
public static function getSubscribedEvents()
{
return [
diff --git a/src/EventSubscriber/SymfonyDebugToolbarSubscriber.php b/src/EventSubscriber/SymfonyDebugToolbarSubscriber.php
index dcc07a05..0797bbfb 100644
--- a/src/EventSubscriber/SymfonyDebugToolbarSubscriber.php
+++ b/src/EventSubscriber/SymfonyDebugToolbarSubscriber.php
@@ -1,4 +1,7 @@
'onKernelResponse'];
}
- public function onKernelResponse(FilterResponseEvent $event)
+ public function onKernelResponse(FilterResponseEvent $event): void
{
- if (!$this->kernel->getParameter('kernel.debug')) {
+ if (! $this->kernel->getParameter('kernel.debug')) {
return;
}
diff --git a/src/EventSubscriber/TimezoneListener.php b/src/EventSubscriber/TimezoneListener.php
index eb44bdda..9a237351 100644
--- a/src/EventSubscriber/TimezoneListener.php
+++ b/src/EventSubscriber/TimezoneListener.php
@@ -1,4 +1,7 @@
security = $security;
}
- public function setTimeZone(ControllerEvent $event)
+ public function setTimeZone(ControllerEvent $event): void
{
$timezone = null;
//Check if the user has set a timezone
$user = $this->security->getUser();
- if ($user instanceof User && !empty($user->getTimezone())) {
+ if ($user instanceof User && ! empty($user->getTimezone())) {
$timezone = $user->getTimezone();
}
//Fill with default value if needed
- if (null === $timezone && !empty($this->default_timezone)) {
+ if (null === $timezone && ! empty($this->default_timezone)) {
$timezone = $this->default_timezone;
}
diff --git a/src/EventSubscriber/U2FRegistrationSubscriber.php b/src/EventSubscriber/U2FRegistrationSubscriber.php
index 02565844..263e1093 100644
--- a/src/EventSubscriber/U2FRegistrationSubscriber.php
+++ b/src/EventSubscriber/U2FRegistrationSubscriber.php
@@ -1,4 +1,7 @@
demo_mode) {
+ if (! $this->demo_mode) {
$user = $event->getUser();
$registration = $event->getRegistration();
$newKey = new U2FKey();
diff --git a/src/Exceptions/AttachmentDownloadException.php b/src/Exceptions/AttachmentDownloadException.php
index 4d5ab139..f29f94d7 100644
--- a/src/Exceptions/AttachmentDownloadException.php
+++ b/src/Exceptions/AttachmentDownloadException.php
@@ -1,4 +1,7 @@
getID();
@@ -48,7 +51,7 @@ class AttachmentTypeAdminForm extends BaseEntityAdminForm
'help' => 'attachment_type.edit.filetype_filter.help',
'attr' => ['placeholder' => 'attachment_type.edit.filetype_filter.placeholder'],
'empty_data' => '',
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
//Normalize data before writing it to database
$builder->get('filetype_filter')->addViewTransformer(new CallbackTransformer(
diff --git a/src/Form/AdminPages/BaseEntityAdminForm.php b/src/Form/AdminPages/BaseEntityAdminForm.php
index 60361b5a..79bfeda8 100644
--- a/src/Form/AdminPages/BaseEntityAdminForm.php
+++ b/src/Form/AdminPages/BaseEntityAdminForm.php
@@ -1,4 +1,7 @@
params = $params;
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver); // TODO: Change the autogenerated stub
$resolver->setRequired('attachment_class');
}
- public function buildForm(FormBuilderInterface $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options): void
{
/** @var StructuralDBElement $entity */
$entity = $options['data'];
@@ -65,22 +68,22 @@ class BaseEntityAdminForm extends AbstractType
$builder
->add('name', TextType::class, ['empty_data' => '', 'label' => 'name.label',
'attr' => ['placeholder' => 'part.name.placeholder'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
->add('parent', StructuralEntityType::class, ['class' => \get_class($entity),
'required' => false, 'label' => 'parent.label',
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ])
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ])
->add('not_selectable', CheckboxType::class, ['required' => false,
'label' => 'entity.edit.not_selectable',
'help' => 'entity.edit.not_selectable.help',
'label_attr' => ['class' => 'checkbox-custom'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
->add('comment', CKEditorType::class, ['required' => false, 'empty_data' => '',
'label' => 'comment.label',
'attr' => ['rows' => 4], 'help' => 'bbcode.hint',
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$this->additionalFormElements($builder, $options, $entity);
@@ -90,7 +93,7 @@ class BaseEntityAdminForm extends AbstractType
'allow_add' => true,
'allow_delete' => true,
'label' => false,
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'entry_options' => [
'data_class' => $options['attachment_class'],
],
@@ -99,7 +102,7 @@ class BaseEntityAdminForm extends AbstractType
$builder->add('master_picture_attachment', MasterPictureAttachmentType::class, [
'required' => false,
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'label' => 'part.edit.master_attachment',
'entity' => $entity,
]);
@@ -108,12 +111,12 @@ class BaseEntityAdminForm extends AbstractType
$builder->add('save', SubmitType::class, [
'label' => $is_new ? 'entity.create' : 'entity.edit.save',
'attr' => ['class' => $is_new ? 'btn-success' : ''],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
->add('reset', ResetType::class, ['label' => 'entity.edit.reset',
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
}
- protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
+ protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
{
//Empty for Base
}
diff --git a/src/Form/AdminPages/CategoryAdminForm.php b/src/Form/AdminPages/CategoryAdminForm.php
index e2c63eeb..873c07ed 100644
--- a/src/Form/AdminPages/CategoryAdminForm.php
+++ b/src/Form/AdminPages/CategoryAdminForm.php
@@ -1,4 +1,7 @@
getID();
@@ -36,44 +39,44 @@ class CategoryAdminForm extends BaseEntityAdminForm
'label' => 'category.edit.disable_footprints',
'help' => 'category.edit.disable_footprints.help',
'label_attr' => ['class' => 'checkbox-custom'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('disable_manufacturers', CheckboxType::class, ['required' => false,
'label' => 'category.edit.disable_manufacturers',
'help' => 'category.edit.disable_manufacturers.help',
'label_attr' => ['class' => 'checkbox-custom'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('disable_autodatasheets', CheckboxType::class, ['required' => false,
'label' => 'category.edit.disable_autodatasheets',
'help' => 'category.edit.disable_autodatasheets.help',
'label_attr' => ['class' => 'checkbox-custom'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('disable_properties', CheckboxType::class, ['required' => false,
'label' => 'category.edit.disable_properties',
'help' => 'category.edit.disable_properties.help',
'label_attr' => ['class' => 'checkbox-custom'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('partname_hint', TextType::class, ['required' => false, 'empty_data' => '',
'label' => 'category.edit.partname_hint',
'attr' => ['placeholder' => 'category.edit.partname_hint.placeholder'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('partname_regex', TextType::class, ['required' => false, 'empty_data' => '',
'label' => 'category.edit.partname_regex',
'attr' => ['placeholder' => 'category.edit.partname_regex.placeholder'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('default_description', TextType::class, ['required' => false, 'empty_data' => '',
'label' => 'category.edit.default_description',
'attr' => ['placeholder' => 'category.edit.default_description.placeholder'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('default_comment', TextType::class, ['required' => false, 'empty_data' => '',
'label' => 'category.edit.default_comment',
'attr' => ['placeholder' => 'category.edit.default_comment.placeholder'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
}
}
diff --git a/src/Form/AdminPages/CompanyForm.php b/src/Form/AdminPages/CompanyForm.php
index 80ef8e93..adc3ddac 100644
--- a/src/Form/AdminPages/CompanyForm.php
+++ b/src/Form/AdminPages/CompanyForm.php
@@ -1,4 +1,7 @@
getID();
$builder->add('address', TextareaType::class, [
'label' => 'company.edit.address',
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => 'company.edit.address.placeholder'], 'required' => false,
'empty_data' => '',
]);
$builder->add('phone_number', TelType::class, [
'label' => 'company.edit.phone_number',
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => 'company.edit.phone_number.placeholder'],
'required' => false,
'empty_data' => '',
@@ -51,21 +54,21 @@ class CompanyForm extends BaseEntityAdminForm
$builder->add('fax_number', TelType::class, [
'label' => 'company.edit.fax_number',
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => 'company.fax_number.placeholder'], 'required' => false,
'empty_data' => '',
]);
$builder->add('email_address', EmailType::class, [
'label' => 'company.edit.email',
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => 'company.edit.email.placeholder'], 'required' => false,
'empty_data' => '',
]);
$builder->add('website', UrlType::class, [
'label' => 'company.edit.website',
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => 'company.edit.website.placeholder'], 'required' => false,
'empty_data' => '',
]);
@@ -73,7 +76,7 @@ class CompanyForm extends BaseEntityAdminForm
$builder->add('auto_product_url', UrlType::class, [
'label' => 'company.edit.auto_product_url',
'help' => 'company.edit.auto_product_url.help',
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => 'company.edit.auto_product_url.placeholder'],
'required' => false,
'empty_data' => '',
diff --git a/src/Form/AdminPages/CurrencyAdminForm.php b/src/Form/AdminPages/CurrencyAdminForm.php
index 7c2393fd..5cd5353b 100644
--- a/src/Form/AdminPages/CurrencyAdminForm.php
+++ b/src/Form/AdminPages/CurrencyAdminForm.php
@@ -1,4 +1,7 @@
getID();
@@ -37,13 +40,13 @@ class CurrencyAdminForm extends BaseEntityAdminForm
'label' => 'currency.edit.iso_code',
'preferred_choices' => ['EUR', 'USD', 'GBP', 'JPY', 'CNY'],
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('exchange_rate', MoneyType::class, [
'required' => false,
'label' => 'currency.edit.exchange_rate',
'currency' => $this->params->get('default_currency'),
'scale' => 6,
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
}
}
diff --git a/src/Form/AdminPages/FootprintAdminForm.php b/src/Form/AdminPages/FootprintAdminForm.php
index 284b473d..db3e0561 100644
--- a/src/Form/AdminPages/FootprintAdminForm.php
+++ b/src/Form/AdminPages/FootprintAdminForm.php
@@ -1,4 +1,7 @@
add('footprint_3d', MasterPictureAttachmentType::class, [
'required' => false,
- 'disabled' => !$this->security->isGranted(null === $entity->getID() ? 'create' : 'edit', $entity),
+ 'disabled' => ! $this->security->isGranted(null === $entity->getID() ? 'create' : 'edit', $entity),
'label' => 'footprint.edit.3d_model',
'filter' => '3d_model',
'entity' => $entity,
diff --git a/src/Form/AdminPages/GroupAdminForm.php b/src/Form/AdminPages/GroupAdminForm.php
index f2099468..a489d2f9 100644
--- a/src/Form/AdminPages/GroupAdminForm.php
+++ b/src/Form/AdminPages/GroupAdminForm.php
@@ -1,4 +1,7 @@
getID();
@@ -36,13 +39,13 @@ class GroupAdminForm extends BaseEntityAdminForm
'label' => 'group.edit.enforce_2fa',
'help' => 'entity.edit.enforce_2fa.help',
'label_attr' => ['class' => 'checkbox-custom'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
]);
$builder->add('permissions', PermissionsType::class, [
'mapped' => false,
'data' => $builder->getData(),
- 'disabled' => !$this->security->isGranted('edit_permissions', $entity),
+ 'disabled' => ! $this->security->isGranted('edit_permissions', $entity),
]);
}
}
diff --git a/src/Form/AdminPages/ImportType.php b/src/Form/AdminPages/ImportType.php
index 790af5ae..3f6e7bd7 100644
--- a/src/Form/AdminPages/ImportType.php
+++ b/src/Form/AdminPages/ImportType.php
@@ -1,4 +1,7 @@
security = $security;
}
- public function buildForm(FormBuilderInterface $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options): void
{
$data = $options['data'];
//Disable import if user is not allowed to create elements.
$entity = new $data['entity_class']();
$perm_name = 'create';
- $disabled = !$this->security->isGranted($perm_name, $entity);
+ $disabled = ! $this->security->isGranted($perm_name, $entity);
$builder
diff --git a/src/Form/AdminPages/MassCreationForm.php b/src/Form/AdminPages/MassCreationForm.php
index 9cecd3dc..06a54912 100644
--- a/src/Form/AdminPages/MassCreationForm.php
+++ b/src/Form/AdminPages/MassCreationForm.php
@@ -1,4 +1,7 @@
security = $security;
}
- public function buildForm(FormBuilderInterface $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options): void
{
$data = $options['data'];
//Disable import if user is not allowed to create elements.
$entity = new $data['entity_class']();
$perm_name = 'create';
- $disabled = !$this->security->isGranted($perm_name, $entity);
+ $disabled = ! $this->security->isGranted($perm_name, $entity);
$builder
->add('lines', TextareaType::class, ['data' => '',
@@ -66,8 +69,8 @@ class MassCreationForm extends AbstractType
//Buttons
$builder->add('create', SubmitType::class, [
- 'label' => 'entity.mass_creation.btn',
- 'disabled' => $disabled,
- ]);
+ 'label' => 'entity.mass_creation.btn',
+ 'disabled' => $disabled,
+ ]);
}
}
diff --git a/src/Form/AdminPages/MeasurementUnitAdminForm.php b/src/Form/AdminPages/MeasurementUnitAdminForm.php
index ffb8b80e..61e42c7d 100644
--- a/src/Form/AdminPages/MeasurementUnitAdminForm.php
+++ b/src/Form/AdminPages/MeasurementUnitAdminForm.php
@@ -1,4 +1,7 @@
getID();
@@ -36,17 +39,17 @@ class MeasurementUnitAdminForm extends BaseEntityAdminForm
'label' => 'measurement_unit.edit.is_integer',
'help' => 'measurement_unit.edit.is_integer.help',
'label_attr' => ['class' => 'checkbox-custom'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('use_si_prefix', CheckboxType::class, ['required' => false,
'label' => 'measurement_unit.edit.use_si_prefix',
'help' => 'measurement_unit.edit.use_si_prefix.help',
'label_attr' => ['class' => 'checkbox-custom'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('unit', TextType::class, ['required' => false,
'label' => 'measurement_unit.edit.unit_symbol',
'attr' => ['placeholder' => 'measurement_unit.edit.unit_symbol.placeholder'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
}
}
diff --git a/src/Form/AdminPages/StorelocationAdminForm.php b/src/Form/AdminPages/StorelocationAdminForm.php
index f6490855..19c67d81 100644
--- a/src/Form/AdminPages/StorelocationAdminForm.php
+++ b/src/Form/AdminPages/StorelocationAdminForm.php
@@ -1,4 +1,7 @@
getID();
@@ -38,27 +41,27 @@ class StorelocationAdminForm extends BaseEntityAdminForm
'label' => 'storelocation.edit.is_full.label',
'help' => 'storelocation.edit.is_full.help',
'label_attr' => ['class' => 'checkbox-custom'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
$builder->add('limit_to_existing_parts', CheckboxType::class, [
'required' => false,
'label' => 'storelocation.limit_to_existing.label',
'help' => 'storelocation.limit_to_existing.help',
'label_attr' => ['class' => 'checkbox-custom'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
$builder->add('only_single_part', CheckboxType::class, [
'required' => false,
'label' => 'storelocation.only_single_part.label',
'help' => 'storelocation.only_single_part.help',
'label_attr' => ['class' => 'checkbox-custom'],
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
$builder->add('storage_type', StructuralEntityType::class, [
'required' => false,
'label' => 'storelocation.storage_type.label',
'help' => 'storelocation.storage_type.help',
'class' => MeasurementUnit::class, 'disable_not_selectable' => true,
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
}
}
diff --git a/src/Form/AdminPages/SupplierForm.php b/src/Form/AdminPages/SupplierForm.php
index 326e09ea..d56006f8 100644
--- a/src/Form/AdminPages/SupplierForm.php
+++ b/src/Form/AdminPages/SupplierForm.php
@@ -1,4 +1,7 @@
getID();
@@ -40,14 +43,14 @@ class SupplierForm extends CompanyForm
'required' => false,
'label' => 'supplier.edit.default_currency',
'disable_not_selectable' => true,
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
$builder->add('shipping_costs', MoneyType::class, [
'required' => false,
'currency' => $this->params->get('default_currency'),
'scale' => 3,
'label' => 'supplier.shipping_costs.label',
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity),
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity),
]);
}
}
diff --git a/src/Form/AttachmentFormType.php b/src/Form/AttachmentFormType.php
index 5922ed4a..f1547a00 100644
--- a/src/Form/AttachmentFormType.php
+++ b/src/Form/AttachmentFormType.php
@@ -1,4 +1,7 @@
allow_attachments_download = $allow_attachments_downloads;
}
- public function buildForm(FormBuilderInterface $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('name', TextType::class, [
'label' => 'attachment.edit.name',
@@ -94,7 +97,7 @@ class AttachmentFormType extends AbstractType
$builder->add('downloadURL', CheckboxType::class, ['required' => false,
'label' => 'attachment.edit.download_url',
'mapped' => false,
- 'disabled' => !$this->allow_attachments_download,
+ 'disabled' => ! $this->allow_attachments_download,
'attr' => ['class' => 'form-control-sm'],
'label_attr' => ['class' => 'checkbox-custom'], ]);
@@ -114,7 +117,7 @@ class AttachmentFormType extends AbstractType
//Check the secure file checkbox, if file is in securefile location
$builder->get('secureFile')->addEventListener(
FormEvents::PRE_SET_DATA,
- function (FormEvent $event) {
+ function (FormEvent $event): void {
$attachment = $event->getForm()->getParent()->getData();
if ($attachment instanceof Attachment) {
$event->setData($attachment->isSecure());
@@ -123,7 +126,7 @@ class AttachmentFormType extends AbstractType
);
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Attachment::class,
diff --git a/src/Form/Part/OrderdetailType.php b/src/Form/Part/OrderdetailType.php
index 5471e9a2..e2db6890 100644
--- a/src/Form/Part/OrderdetailType.php
+++ b/src/Form/Part/OrderdetailType.php
@@ -1,4 +1,7 @@
security = $security;
}
- public function buildForm(FormBuilderInterface $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options): void
{
/** @var Orderdetail $orderdetail */
$orderdetail = $builder->getData();
@@ -76,7 +79,7 @@ class OrderdetailType extends AbstractType
]);
//Add pricedetails after we know the data, so we can set the default currency
- $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options) {
+ $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options): void {
/** @var Orderdetail $orderdetail */
$orderdetail = $event->getData();
@@ -94,14 +97,14 @@ class OrderdetailType extends AbstractType
'prototype_data' => $dummy_pricedetail,
'by_reference' => false,
'entry_options' => [
- 'disabled' => !$this->security->isGranted('@parts_prices.edit'),
+ 'disabled' => ! $this->security->isGranted('@parts_prices.edit'),
'measurement_unit' => $options['measurement_unit'],
],
]);
});
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Orderdetail::class,
diff --git a/src/Form/Part/PartBaseType.php b/src/Form/Part/PartBaseType.php
index 2a86c48a..7e7908aa 100644
--- a/src/Form/Part/PartBaseType.php
+++ b/src/Form/Part/PartBaseType.php
@@ -1,4 +1,7 @@
urlGenerator = $urlGenerator;
}
- public function buildForm(FormBuilderInterface $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options): void
{
/** @var Part $part */
$part = $builder->getData();
@@ -79,7 +82,7 @@ class PartBaseType extends AbstractType
'empty_data' => '',
'label' => 'part.edit.name',
'attr' => ['placeholder' => 'part.edit.name.placeholder'],
- 'disabled' => !$this->security->isGranted('name.edit', $part),
+ 'disabled' => ! $this->security->isGranted('name.edit', $part),
])
->add('description', CKEditorType::class, [
'required' => false,
@@ -87,26 +90,26 @@ class PartBaseType extends AbstractType
'label' => 'part.edit.description',
'config_name' => 'description_config',
'attr' => ['placeholder' => 'part.edit.description.placeholder', 'rows' => 2],
- 'disabled' => !$this->security->isGranted('description.edit', $part),
+ 'disabled' => ! $this->security->isGranted('description.edit', $part),
])
->add('minAmount', SIUnitType::class, [
'attr' => ['min' => 0, 'placeholder' => 'part.editmininstock.placeholder'],
'label' => 'part.edit.mininstock',
'measurement_unit' => $part->getPartUnit(),
- 'disabled' => !$this->security->isGranted('minamount.edit', $part),
+ 'disabled' => ! $this->security->isGranted('minamount.edit', $part),
])
->add('category', StructuralEntityType::class, [
'class' => Category::class,
'label' => 'part.edit.category',
'disable_not_selectable' => true,
- 'disabled' => !$this->security->isGranted('category.edit', $part),
+ 'disabled' => ! $this->security->isGranted('category.edit', $part),
])
->add('footprint', StructuralEntityType::class, [
'class' => Footprint::class,
'required' => false,
'label' => 'part.edit.footprint',
'disable_not_selectable' => true,
- 'disabled' => !$this->security->isGranted('footprint.edit', $part),
+ 'disabled' => ! $this->security->isGranted('footprint.edit', $part),
])
->add('tags', TextType::class, [
'required' => false,
@@ -115,7 +118,7 @@ class PartBaseType extends AbstractType
'attr' => [
'class' => 'tagsinput',
'data-autocomplete' => $this->urlGenerator->generate('typeahead_tags', ['query' => 'QUERY']), ],
- 'disabled' => !$this->security->isGranted('tags.edit', $part),
+ 'disabled' => ! $this->security->isGranted('tags.edit', $part),
]);
//Manufacturer section
@@ -124,24 +127,24 @@ class PartBaseType extends AbstractType
'required' => false,
'label' => 'part.edit.manufacturer.label',
'disable_not_selectable' => true,
- 'disabled' => !$this->security->isGranted('manufacturer.edit', $part),
- ])
+ 'disabled' => ! $this->security->isGranted('manufacturer.edit', $part),
+ ])
->add('manufacturer_product_url', UrlType::class, [
'required' => false,
'empty_data' => '',
'label' => 'part.edit.manufacturer_url.label',
- 'disabled' => !$this->security->isGranted('mpn.edit', $part),
+ 'disabled' => ! $this->security->isGranted('mpn.edit', $part),
])
->add('manufacturer_product_number', TextType::class, [
'required' => false,
'empty_data' => '',
'label' => 'part.edit.mpn',
- 'disabled' => !$this->security->isGranted('mpn.edit', $part), ])
+ 'disabled' => ! $this->security->isGranted('mpn.edit', $part), ])
->add('manufacturing_status', ChoiceType::class, [
'label' => 'part.edit.manufacturing_status',
'choices' => $status_choices,
'required' => false,
- 'disabled' => !$this->security->isGranted('status.edit', $part),
+ 'disabled' => ! $this->security->isGranted('status.edit', $part),
]);
//Advanced section
@@ -149,26 +152,26 @@ class PartBaseType extends AbstractType
'label_attr' => ['class' => 'checkbox-custom'],
'required' => false,
'label' => 'part.edit.needs_review',
- 'disabled' => !$this->security->isGranted('edit', $part),
+ 'disabled' => ! $this->security->isGranted('edit', $part),
])
->add('favorite', CheckboxType::class, [
'label_attr' => ['class' => 'checkbox-custom'],
'required' => false,
'label' => 'part.edit.is_favorite',
- 'disabled' => !$this->security->isGranted('change_favorite', $part),
+ 'disabled' => ! $this->security->isGranted('change_favorite', $part),
])
->add('mass', SIUnitType::class, [
'unit' => 'g',
'label' => 'part.edit.mass',
'required' => false,
- 'disabled' => !$this->security->isGranted('mass.edit', $part),
+ 'disabled' => ! $this->security->isGranted('mass.edit', $part),
])
->add('partUnit', StructuralEntityType::class, [
'class' => MeasurementUnit::class,
'required' => false,
'disable_not_selectable' => true,
'label' => 'part.edit.partUnit',
- 'disabled' => !$this->security->isGranted('unit.edit', $part),
+ 'disabled' => ! $this->security->isGranted('unit.edit', $part),
]);
//Comment section
@@ -176,7 +179,7 @@ class PartBaseType extends AbstractType
'required' => false,
'label' => 'part.edit.comment',
'attr' => ['rows' => 4],
- 'disabled' => !$this->security->isGranted('comment.edit', $part), 'empty_data' => '',
+ 'disabled' => ! $this->security->isGranted('comment.edit', $part), 'empty_data' => '',
]);
//Part Lots section
@@ -187,7 +190,7 @@ class PartBaseType extends AbstractType
'label' => false,
'entry_options' => [
'measurement_unit' => $part->getPartUnit(),
- 'disabled' => !$this->security->isGranted('lots.edit', $part),
+ 'disabled' => ! $this->security->isGranted('lots.edit', $part),
],
'by_reference' => false,
]);
@@ -200,14 +203,14 @@ class PartBaseType extends AbstractType
'label' => false,
'entry_options' => [
'data_class' => PartAttachment::class,
- 'disabled' => !$this->security->isGranted('attachments.edit', $part),
+ 'disabled' => ! $this->security->isGranted('attachments.edit', $part),
],
'by_reference' => false,
]);
$builder->add('master_picture_attachment', MasterPictureAttachmentType::class, [
'required' => false,
- 'disabled' => !$this->security->isGranted('attachments.edit', $part),
+ 'disabled' => ! $this->security->isGranted('attachments.edit', $part),
'label' => 'part.edit.master_attachment',
'entity' => $part,
]);
@@ -222,7 +225,7 @@ class PartBaseType extends AbstractType
'prototype_data' => new Orderdetail(),
'entry_options' => [
'measurement_unit' => $part->getPartUnit(),
- 'disabled' => !$this->security->isGranted('orderdetails.edit', $part),
+ 'disabled' => ! $this->security->isGranted('orderdetails.edit', $part),
],
]);
@@ -232,7 +235,7 @@ class PartBaseType extends AbstractType
->add('reset', ResetType::class, ['label' => 'part.edit.reset']);
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Part::class,
diff --git a/src/Form/Part/PartLotType.php b/src/Form/Part/PartLotType.php
index 96b21b36..229c600b 100644
--- a/src/Form/Part/PartLotType.php
+++ b/src/Form/Part/PartLotType.php
@@ -1,4 +1,7 @@
security = $security;
}
- public function buildForm(FormBuilderInterface $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('description', TextType::class, [
'label' => 'part_lot.edit.description',
@@ -89,7 +92,7 @@ class PartLotType extends AbstractType
]);
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => PartLot::class,
diff --git a/src/Form/Part/PricedetailType.php b/src/Form/Part/PricedetailType.php
index 8a65d502..57c89445 100644
--- a/src/Form/Part/PricedetailType.php
+++ b/src/Form/Part/PricedetailType.php
@@ -1,4 +1,7 @@
add('min_discount_quantity', SIUnitType::class, [
@@ -57,7 +60,7 @@ class PricedetailType extends AbstractType
]);
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Pricedetail::class,
diff --git a/src/Form/Permissions/PermissionGroupType.php b/src/Form/Permissions/PermissionGroupType.php
index e0ce75ac..311ab362 100644
--- a/src/Form/Permissions/PermissionGroupType.php
+++ b/src/Form/Permissions/PermissionGroupType.php
@@ -1,4 +1,7 @@
perm_structure = $resolver->getPermissionStructure();
}
- public function buildForm(FormBuilderInterface $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options): void
{
$permissions = $this->perm_structure['perms'];
@@ -66,7 +69,7 @@ class PermissionGroupType extends AbstractType
}
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
@@ -77,7 +80,7 @@ class PermissionGroupType extends AbstractType
$resolver->setDefault('inherit', false);
$resolver->setDefault('label', function (Options $options) {
- if (!empty($this->perm_structure['groups'][$options['group_name']]['label'])) {
+ if (! empty($this->perm_structure['groups'][$options['group_name']]['label'])) {
return $this->perm_structure['groups'][$options['group_name']]['label'];
}
diff --git a/src/Form/Permissions/PermissionType.php b/src/Form/Permissions/PermissionType.php
index 2b06c806..5f406136 100644
--- a/src/Form/Permissions/PermissionType.php
+++ b/src/Form/Permissions/PermissionType.php
@@ -1,4 +1,7 @@
perm_structure = $resolver->getPermissionStructure();
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
@@ -50,7 +53,7 @@ class PermissionType extends AbstractType
});
$resolver->setDefault('label', function (Options $options) {
- if (!empty($this->perm_structure['perms'][$options['perm_name']]['label'])) {
+ if (! empty($this->perm_structure['perms'][$options['perm_name']]['label'])) {
return $this->perm_structure['perms'][$options['perm_name']]['label'];
}
@@ -58,7 +61,7 @@ class PermissionType extends AbstractType
});
$resolver->setDefault('multi_checkbox', function (Options $options) {
- return !$options['disabled'];
+ return ! $options['disabled'];
});
$resolver->setDefaults([
@@ -66,7 +69,7 @@ class PermissionType extends AbstractType
]);
}
- public function buildForm(FormBuilderInterface $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options): void
{
$operations = $this->perm_structure['perms'][$options['perm_name']]['operations'];
@@ -82,7 +85,7 @@ class PermissionType extends AbstractType
$builder->setDataMapper(new PermissionsMapper($this->resolver, $options['inherit']));
}
- public function buildView(FormView $view, FormInterface $form, array $options)
+ public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['multi_checkbox'] = $options['multi_checkbox'];
}
diff --git a/src/Form/Permissions/PermissionsMapper.php b/src/Form/Permissions/PermissionsMapper.php
index 7d98bf07..91b2157b 100644
--- a/src/Form/Permissions/PermissionsMapper.php
+++ b/src/Form/Permissions/PermissionsMapper.php
@@ -1,4 +1,7 @@
inherit) {
@@ -96,7 +99,7 @@ class PermissionsMapper implements DataMapperInterface
* @param mixed $viewData The compound form's view data that get mapped
* its children model data
*/
- public function mapFormsToData($forms, &$viewData)
+ public function mapFormsToData($forms, &$viewData): void
{
if ($this->inherit) {
throw new \RuntimeException('The permission type is readonly when it is showing read only data!');
diff --git a/src/Form/Permissions/PermissionsType.php b/src/Form/Permissions/PermissionsType.php
index e8a2775b..7ad4f260 100644
--- a/src/Form/Permissions/PermissionsType.php
+++ b/src/Form/Permissions/PermissionsType.php
@@ -1,4 +1,7 @@
perm_structure = $resolver->getPermissionStructure();
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'show_legend' => true,
'constraints' => function (Options $options) {
- if (!$options['disabled']) {
+ if (! $options['disabled']) {
return [new NoLockout()];
}
@@ -56,12 +59,12 @@ class PermissionsType extends AbstractType
]);
}
- public function buildView(FormView $view, FormInterface $form, array $options)
+ public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['show_legend'] = $options['show_legend'];
}
- public function buildForm(FormBuilderInterface $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options): void
{
$groups = $this->perm_structure['groups'];
diff --git a/src/Form/TFAGoogleSettingsType.php b/src/Form/TFAGoogleSettingsType.php
index 4f7e0173..518e90e1 100644
--- a/src/Form/TFAGoogleSettingsType.php
+++ b/src/Form/TFAGoogleSettingsType.php
@@ -1,4 +1,7 @@
addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
+ $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void {
$form = $event->getForm();
/** @var User $user */
$user = $event->getData();
//Only show setup fields, when google authenticator is not enabled
- if (!$user->isGoogleAuthenticatorEnabled()) {
+ if (! $user->isGoogleAuthenticatorEnabled()) {
$form->add(
'google_confirmation',
TextType::class,
@@ -82,10 +85,10 @@ class TFAGoogleSettingsType extends AbstractType
//$builder->add('cancel', ResetType::class);
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
- 'data_class' => User::class,
- ]);
+ 'data_class' => User::class,
+ ]);
}
}
diff --git a/src/Form/Type/CurrencyEntityType.php b/src/Form/Type/CurrencyEntityType.php
index 6ae6c538..674c6796 100644
--- a/src/Form/Type/CurrencyEntityType.php
+++ b/src/Form/Type/CurrencyEntityType.php
@@ -1,4 +1,7 @@
base_currency = $base_currency;
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
//Important to call the parent resolver!
parent::configureOptions($resolver);
@@ -91,7 +94,7 @@ class CurrencyEntityType extends StructuralEntityType
/** @var Currency $choice */
$tmp = [];
- if (!empty($choice->getIsoCode())) {
+ if (! empty($choice->getIsoCode())) {
//Show the name of the currency
$tmp += ['data-subtext' => $choice->getName()];
}
diff --git a/src/Form/Type/MasterPictureAttachmentType.php b/src/Form/Type/MasterPictureAttachmentType.php
index 25ebb117..5e8446d8 100644
--- a/src/Form/Type/MasterPictureAttachmentType.php
+++ b/src/Form/Type/MasterPictureAttachmentType.php
@@ -1,4 +1,7 @@
setRequired('entity');
$resolver->setAllowedTypes('entity', AttachmentContainingDBElement::class);
@@ -44,9 +47,9 @@ class MasterPictureAttachmentType extends AbstractType
/** @var Attachment $choice */
$tmp = ['data-subtext' => $choice->getFilename() ?? 'URL'];
- if ('picture' === $options['filter'] && !$choice->isPicture()) {
+ if ('picture' === $options['filter'] && ! $choice->isPicture()) {
$tmp += ['disabled' => 'disabled'];
- } elseif ('3d_model' === $options['filter'] && !$choice->is3DModel()) {
+ } elseif ('3d_model' === $options['filter'] && ! $choice->is3DModel()) {
$tmp += ['disabled' => 'disabled'];
}
diff --git a/src/Form/Type/SIUnitType.php b/src/Form/Type/SIUnitType.php
index 0e9d1f61..3a848396 100644
--- a/src/Form/Type/SIUnitType.php
+++ b/src/Form/Type/SIUnitType.php
@@ -1,4 +1,7 @@
si_formatter = $SIFormatter;
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'measurement_unit' => null,
@@ -85,20 +88,20 @@ class SIUnitType extends AbstractType implements DataMapperInterface
//Options which allows us, to limit the input using HTML5 number input
$resolver->setDefaults([
- 'min' => 0,
- 'max' => '',
- 'step' => function (Options $options) {
- if (true === $options['is_integer']) {
- return 1;
- }
+ 'min' => 0,
+ 'max' => '',
+ 'step' => function (Options $options) {
+ if (true === $options['is_integer']) {
+ return 1;
+ }
- return 'any';
- },
- 'html5' => true,
- ]);
+ return 'any';
+ },
+ 'html5' => true,
+ ]);
}
- public function buildForm(FormBuilderInterface $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('value', NumberType::class, [
@@ -121,13 +124,13 @@ class SIUnitType extends AbstractType implements DataMapperInterface
$builder->setDataMapper($this);
}
- public function buildView(FormView $view, FormInterface $form, array $options)
+ public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['sm'] = false;
//Check if we need to make this thing small
if (isset($options['attr']['class'])) {
- $view->vars['sm'] = (false !== strpos($options['attr']['class'], 'form-control-sm'));
+ $view->vars['sm'] = false !== strpos($options['attr']['class'], 'form-control-sm');
}
$view->vars['unit'] = $options['unit'];
@@ -196,7 +199,7 @@ class SIUnitType extends AbstractType implements DataMapperInterface
*
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported
*/
- public function mapFormsToData($forms, &$viewData)
+ public function mapFormsToData($forms, &$viewData): void
{
//Convert both fields to a single float value.
diff --git a/src/Form/Type/StructuralEntityType.php b/src/Form/Type/StructuralEntityType.php
index dc44bc7d..b3a0ae8e 100644
--- a/src/Form/Type/StructuralEntityType.php
+++ b/src/Form/Type/StructuralEntityType.php
@@ -1,4 +1,7 @@
builder = $builder;
}
- public function buildForm(FormBuilderInterface $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addModelTransformer(new CallbackTransformer(
function ($value) use ($options) {
@@ -66,7 +69,7 @@ class StructuralEntityType extends AbstractType
}));
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setRequired(['class']);
$resolver->setDefaults([
@@ -97,44 +100,6 @@ class StructuralEntityType extends AbstractType
});
}
- protected function generateChoiceAttr(StructuralDBElement $choice, $key, $value): array
- {
- $tmp = [];
-
- if ($this->options['show_fullpath_in_subtext'] && null != $choice->getParent()) {
- $tmp += ['data-subtext' => $choice->getParent()->getFullPath()];
- }
-
- //Disable attribute if the choice is marked as not selectable
- if ($this->options['disable_not_selectable'] && $choice->isNotSelectable()) {
- $tmp += ['disabled' => 'disabled'];
- }
-
- if ($choice instanceof AttachmentType) {
- $tmp += ['data-filetype_filter' => $choice->getFiletypeFilter()];
- }
-
- return $tmp;
- }
-
- protected function generateChoiceLabels(StructuralDBElement $choice, $key, $value): string
- {
- /** @var StructuralDBElement|null $parent */
- $parent = $this->options['subentities_of'];
-
- /*** @var StructuralDBElement $choice */
- $level = $choice->getLevel();
- //If our base entity is not the root level, we need to change the level, to get zero position
- if (null !== $this->options['subentities_of']) {
- $level -= $parent->getLevel() - 1;
- }
-
- $tmp = str_repeat(' ', $choice->getLevel()); //Use 3 spaces for intendation
- $tmp .= htmlspecialchars($choice->getName());
-
- return $tmp;
- }
-
/**
* Gets the entries from database and return an array of them.
*
@@ -144,15 +109,10 @@ class StructuralEntityType extends AbstractType
{
$this->options = $options;
- $choices = $this->builder->typeToNodesList($options['class'], null);
-
- /* @var StructuralDBElementRepository $repo */
- /*$repo = $this->em->getRepository($options['class']);
- $choices = $repo->toNodesList(null); */
- return $choices;
+ return $this->builder->typeToNodesList($options['class'], null);
}
- public function buildView(FormView $view, FormInterface $form, array $options)
+ public function buildView(FormView $view, FormInterface $form, array $options): void
{
//Allow HTML in labels. You must override the 'choice_widget_options' block, so that can work
//See extendedBootstrap4_layout.html.twig for that...
@@ -253,4 +213,42 @@ class StructuralEntityType extends AbstractType
return $this->em->find($options['class'], $value->getID());
}
+
+ protected function generateChoiceAttr(StructuralDBElement $choice, $key, $value): array
+ {
+ $tmp = [];
+
+ if ($this->options['show_fullpath_in_subtext'] && null !== $choice->getParent()) {
+ $tmp += ['data-subtext' => $choice->getParent()->getFullPath()];
+ }
+
+ //Disable attribute if the choice is marked as not selectable
+ if ($this->options['disable_not_selectable'] && $choice->isNotSelectable()) {
+ $tmp += ['disabled' => 'disabled'];
+ }
+
+ if ($choice instanceof AttachmentType) {
+ $tmp += ['data-filetype_filter' => $choice->getFiletypeFilter()];
+ }
+
+ return $tmp;
+ }
+
+ protected function generateChoiceLabels(StructuralDBElement $choice, $key, $value): string
+ {
+ /** @var StructuralDBElement|null $parent */
+ $parent = $this->options['subentities_of'];
+
+ /*** @var StructuralDBElement $choice */
+ $level = $choice->getLevel();
+ //If our base entity is not the root level, we need to change the level, to get zero position
+ if (null !== $this->options['subentities_of']) {
+ $level -= $parent->getLevel() - 1;
+ }
+
+ $tmp = str_repeat(' ', $choice->getLevel()); //Use 3 spaces for intendation
+ $tmp .= htmlspecialchars($choice->getName());
+
+ return $tmp;
+ }
}
diff --git a/src/Form/Type/TriStateCheckboxType.php b/src/Form/Type/TriStateCheckboxType.php
index c6989766..37aff40c 100644
--- a/src/Form/Type/TriStateCheckboxType.php
+++ b/src/Form/Type/TriStateCheckboxType.php
@@ -1,4 +1,7 @@
addViewTransformer($this);
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'label_attr' => ['class' => 'checkbox-custom checkbox-inline'],
@@ -50,10 +53,7 @@ class TriStateCheckboxType extends AbstractType implements DataTransformerInterf
return 'tristate';
}
- /**
- * {@inheritdoc}
- */
- public function buildView(FormView $view, FormInterface $form, array $options)
+ public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars = array_replace($view->vars, [
'value' => $form->getViewData(),
diff --git a/src/Form/UserAdminForm.php b/src/Form/UserAdminForm.php
index 7414cdb1..cff3812e 100644
--- a/src/Form/UserAdminForm.php
+++ b/src/Form/UserAdminForm.php
@@ -1,4 +1,7 @@
security = $security;
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver); // TODO: Change the autogenerated stub
$resolver->setRequired('attachment_class');
}
- public function buildForm(FormBuilderInterface $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options): void
{
/** @var StructuralDBElement $entity */
$entity = $options['data'];
@@ -71,7 +74,7 @@ class UserAdminForm extends AbstractType
'empty_data' => '',
'label' => 'user.username.label',
'attr' => ['placeholder' => 'user.username.placeholder'],
- 'disabled' => !$this->security->isGranted('edit_username', $entity),
+ 'disabled' => ! $this->security->isGranted('edit_username', $entity),
])
->add('group', StructuralEntityType::class, [
@@ -79,13 +82,13 @@ class UserAdminForm extends AbstractType
'required' => false,
'label' => 'group.label',
'disable_not_selectable' => true,
- 'disabled' => !$this->security->isGranted('change_group', $entity), ])
+ 'disabled' => ! $this->security->isGranted('change_group', $entity), ])
->add('first_name', TextType::class, [
'empty_data' => '',
'label' => 'user.firstName.label',
'attr' => ['placeholder' => 'user.firstName.placeholder'], 'required' => false,
- 'disabled' => !$this->security->isGranted('edit_infos', $entity),
+ 'disabled' => ! $this->security->isGranted('edit_infos', $entity),
])
->add('last_name', TextType::class, [
@@ -93,7 +96,7 @@ class UserAdminForm extends AbstractType
'label' => 'user.lastName.label',
'attr' => ['placeholder' => 'user.lastName.placeholder'],
'required' => false,
- 'disabled' => !$this->security->isGranted('edit_infos', $entity),
+ 'disabled' => ! $this->security->isGranted('edit_infos', $entity),
])
->add('email', TextType::class, [
@@ -101,14 +104,14 @@ class UserAdminForm extends AbstractType
'label' => 'user.email.label',
'attr' => ['placeholder' => 'user.email.placeholder'],
'required' => false,
- 'disabled' => !$this->security->isGranted('edit_infos', $entity), ])
+ 'disabled' => ! $this->security->isGranted('edit_infos', $entity), ])
->add('department', TextType::class, [
'empty_data' => '',
'label' => 'user.department.label',
'attr' => ['placeholder' => 'user.department.placeholder'],
'required' => false,
- 'disabled' => !$this->security->isGranted('edit_infos', $entity),
+ 'disabled' => ! $this->security->isGranted('edit_infos', $entity),
])
//Config section
@@ -118,7 +121,7 @@ class UserAdminForm extends AbstractType
'placeholder' => 'user_settings.language.placeholder',
'label' => 'user.language_select',
'preferred_choices' => ['en', 'de'],
- 'disabled' => !$this->security->isGranted('change_user_settings', $entity),
+ 'disabled' => ! $this->security->isGranted('change_user_settings', $entity),
])
->add('timezone', TimezoneType::class, [
'required' => false,
@@ -126,7 +129,7 @@ class UserAdminForm extends AbstractType
'placeholder' => 'user_settings.timezone.placeholder',
'label' => 'user.timezone.label',
'preferred_choices' => ['Europe/Berlin'],
- 'disabled' => !$this->security->isGranted('change_user_settings', $entity),
+ 'disabled' => ! $this->security->isGranted('change_user_settings', $entity),
])
->add('theme', ChoiceType::class, [
'required' => false,
@@ -137,12 +140,12 @@ class UserAdminForm extends AbstractType
'attr' => ['class' => 'selectpicker'],
'placeholder' => 'user_settings.theme.placeholder',
'label' => 'user.theme.label',
- 'disabled' => !$this->security->isGranted('change_user_settings', $entity),
+ 'disabled' => ! $this->security->isGranted('change_user_settings', $entity),
])
->add('currency', CurrencyEntityType::class, [
'required' => false,
'label' => 'user.currency.label',
- 'disabled' => !$this->security->isGranted('change_user_settings', $entity),
+ 'disabled' => ! $this->security->isGranted('change_user_settings', $entity),
])
->add('new_password', RepeatedType::class, [
@@ -152,7 +155,7 @@ class UserAdminForm extends AbstractType
'invalid_message' => 'password_must_match',
'required' => false,
'mapped' => false,
- 'disabled' => !$this->security->isGranted('set_password', $entity),
+ 'disabled' => ! $this->security->isGranted('set_password', $entity),
'constraints' => [new Length([
'min' => 6,
'max' => 128,
@@ -163,14 +166,14 @@ class UserAdminForm extends AbstractType
'required' => false,
'label_attr' => ['class' => 'checkbox-custom'],
'label' => 'user.edit.needs_pw_change',
- 'disabled' => !$this->security->isGranted('set_password', $entity),
+ 'disabled' => ! $this->security->isGranted('set_password', $entity),
])
->add('disabled', CheckboxType::class, [
'required' => false,
'label_attr' => ['class' => 'checkbox-custom'],
'label' => 'user.edit.user_disabled',
- 'disabled' => !$this->security->isGranted('set_password', $entity)
+ 'disabled' => ! $this->security->isGranted('set_password', $entity)
|| $entity === $this->security->getUser(),
])
@@ -178,7 +181,7 @@ class UserAdminForm extends AbstractType
->add('permissions', PermissionsType::class, [
'mapped' => false,
'data' => $builder->getData(),
- 'disabled' => !$this->security->isGranted('edit_permissions', $entity),
+ 'disabled' => ! $this->security->isGranted('edit_permissions', $entity),
])
;
/*->add('comment', CKEditorType::class, ['required' => false,
@@ -197,7 +200,7 @@ class UserAdminForm extends AbstractType
'data_class' => $options['attachment_class'],
],
'by_reference' => false,
- 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
+ 'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
]);
//Buttons
@@ -210,7 +213,7 @@ class UserAdminForm extends AbstractType
]);
}
- protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
+ protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
{
//Empty for Base
}
diff --git a/src/Form/UserSettingsType.php b/src/Form/UserSettingsType.php
index 35583b17..a73be03b 100644
--- a/src/Form/UserSettingsType.php
+++ b/src/Form/UserSettingsType.php
@@ -1,4 +1,7 @@
demo_mode = $demo_mode;
}
- public function buildForm(FormBuilderInterface $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', TextType::class, [
'label' => 'user.username.label',
- 'disabled' => !$this->security->isGranted('edit_username', $options['data']) || $this->demo_mode,
+ 'disabled' => ! $this->security->isGranted('edit_username', $options['data']) || $this->demo_mode,
])
->add('first_name', TextType::class, [
'required' => false,
'label' => 'user.firstName.label',
- 'disabled' => !$this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
+ 'disabled' => ! $this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
])
->add('last_name', TextType::class, [
'required' => false,
'label' => 'user.lastName.label',
- 'disabled' => !$this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
+ 'disabled' => ! $this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
])
->add('department', TextType::class, [
'required' => false,
'label' => 'user.department.label',
- 'disabled' => !$this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
+ 'disabled' => ! $this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
])
->add('email', EmailType::class, [
'required' => false,
'label' => 'user.email.label',
- 'disabled' => !$this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
+ 'disabled' => ! $this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
])
->add('language', LanguageType::class, [
'disabled' => $this->demo_mode,
@@ -80,7 +83,7 @@ class UserSettingsType extends AbstractType
'placeholder' => 'user_settings.language.placeholder',
'label' => 'user.language_select',
'preferred_choices' => ['en', 'de'],
- ])
+ ])
->add('timezone', TimezoneType::class, [
'disabled' => $this->demo_mode,
'required' => false,
@@ -88,7 +91,7 @@ class UserSettingsType extends AbstractType
'placeholder' => 'user_settings.timezone.placeholder',
'label' => 'user.timezone.label',
'preferred_choices' => ['Europe/Berlin'],
- ])
+ ])
->add('theme', ChoiceType::class, [
'disabled' => $this->demo_mode,
'required' => false,
@@ -99,7 +102,7 @@ class UserSettingsType extends AbstractType
},
'placeholder' => 'user_settings.theme.placeholder',
'label' => 'user.theme.label',
- ])
+ ])
->add('currency', CurrencyEntityType::class, [
'disabled' => $this->demo_mode,
'required' => false,
@@ -111,7 +114,7 @@ class UserSettingsType extends AbstractType
->add('reset', ResetType::class, ['label' => 'reset']);
}
- public function configureOptions(OptionsResolver $resolver)
+ public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => User::class,
diff --git a/src/Helpers/BBCodeToMarkdownConverter.php b/src/Helpers/BBCodeToMarkdownConverter.php
index 994edaa0..7f6b96a7 100644
--- a/src/Helpers/BBCodeToMarkdownConverter.php
+++ b/src/Helpers/BBCodeToMarkdownConverter.php
@@ -1,4 +1,7 @@
|StructuralDBElement[]
- */
public function __construct($nodes)
{
parent::__construct($nodes);
}
- /**
- * {@inheritdoc}
- */
public function hasChildren()
{
/** @var StructuralDBElement $element */
$element = $this->current();
- return !empty($element->getSubelements());
+ return ! empty($element->getSubelements());
}
- /**
- * {@inheritdoc}
- */
public function getChildren()
{
/** @var StructuralDBElement $element */
diff --git a/src/Helpers/Trees/TreeViewNode.php b/src/Helpers/Trees/TreeViewNode.php
index 66a0a7ad..b00647e1 100644
--- a/src/Helpers/Trees/TreeViewNode.php
+++ b/src/Helpers/Trees/TreeViewNode.php
@@ -1,4 +1,7 @@
state) {
+ if (null === $this->state) {
$this->state = new TreeViewNodeState();
}
@@ -178,7 +181,7 @@ class TreeViewNode implements \JsonSerializable
public function setSelected(?bool $selected): self
{
//Lazy loading of state, so it does not need to get serialized and transfered, when it is empty.
- if (null == $this->state) {
+ if (null === $this->state) {
$this->state = new TreeViewNodeState();
}
@@ -195,7 +198,7 @@ class TreeViewNode implements \JsonSerializable
public function addTag(string $new_tag): self
{
//Lazy loading tags
- if (null == $this->tags) {
+ if (null === $this->tags) {
$this->tags = [];
}
@@ -204,9 +207,6 @@ class TreeViewNode implements \JsonSerializable
return $this;
}
- /**
- * {@inheritdoc}
- */
public function jsonSerialize()
{
$ret = [
diff --git a/src/Helpers/Trees/TreeViewNodeIterator.php b/src/Helpers/Trees/TreeViewNodeIterator.php
index 88a44429..ffd7c260 100644
--- a/src/Helpers/Trees/TreeViewNodeIterator.php
+++ b/src/Helpers/Trees/TreeViewNodeIterator.php
@@ -1,4 +1,7 @@
current();
- return !empty($element->getNodes());
+ return ! empty($element->getNodes());
}
- /**
- * {@inheritdoc}
- */
public function getChildren()
{
/** @var TreeViewNode $element */
diff --git a/src/Helpers/Trees/TreeViewNodeState.php b/src/Helpers/Trees/TreeViewNodeState.php
index b4d60709..1f0affdf 100644
--- a/src/Helpers/Trees/TreeViewNodeState.php
+++ b/src/Helpers/Trees/TreeViewNodeState.php
@@ -1,4 +1,7 @@
selected = $selected;
}
- /**
- * {@inheritdoc}
- */
public function jsonSerialize()
{
$ret = [];
diff --git a/src/Helpers/UTCDateTimeType.php b/src/Helpers/UTCDateTimeType.php
index 92074367..6d564d5f 100644
--- a/src/Helpers/UTCDateTimeType.php
+++ b/src/Helpers/UTCDateTimeType.php
@@ -1,4 +1,7 @@
getName(), $platform->getDateTimeFormatString());
}
diff --git a/src/Kernel.php b/src/Kernel.php
index 4aed333e..c181c716 100644
--- a/src/Kernel.php
+++ b/src/Kernel.php
@@ -1,4 +1,7 @@
addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
$container->setParameter('container.dumper.inline_class_loader', true);
@@ -56,7 +59,7 @@ class Kernel extends BaseKernel
$loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
}
- protected function configureRoutes(RouteCollectionBuilder $routes)
+ protected function configureRoutes(RouteCollectionBuilder $routes): void
{
$confDir = $this->getProjectDir().'/config';
diff --git a/src/Migrations/Version1.php b/src/Migrations/Version1.php
index b721ceaa..aa8020b0 100644
--- a/src/Migrations/Version1.php
+++ b/src/Migrations/Version1.php
@@ -165,7 +165,7 @@ EOD;
21840,21840,21840,21840,21840,21520,21520,21520,20480,21520,20480,
20480,20480,20480,20480,21504,20480),
(
- 2,'admin', '$admin_pw','','',
+ 2,'admin', '${admin_pw}','','',
'','',1,1,21845,21845,21845,21,85,21,349525,21845,21845,21845,21845
,21845,21845,21845,21845,21845,21845,21845,21845,21845,21845,21845,
21845,21845,21845,21845,21845,21845);
diff --git a/src/Migrations/Version20190902140506.php b/src/Migrations/Version20190902140506.php
index ac0b6d82..d0e47752 100644
--- a/src/Migrations/Version20190902140506.php
+++ b/src/Migrations/Version20190902140506.php
@@ -185,8 +185,8 @@ final class Version20190902140506 extends AbstractMigration
'orderdetails', 'pricedetails', 'storelocations', 'suppliers', ];
foreach ($tables as $table) {
- $this->addSql("UPDATE $table SET datetime_added = NOW() WHERE datetime_added = '0000-00-00 00:00:00'");
- $this->addSql("UPDATE $table SET last_modified = datetime_added WHERE last_modified = '0000-00-00 00:00:00'");
+ $this->addSql("UPDATE ${table} SET datetime_added = NOW() WHERE datetime_added = '0000-00-00 00:00:00'");
+ $this->addSql("UPDATE ${table} SET last_modified = datetime_added WHERE last_modified = '0000-00-00 00:00:00'");
}
//Set the dbVersion to a high value, to prevent the old Part-DB versions to upgrade DB!
diff --git a/src/Repository/NamedDBElementRepository.php b/src/Repository/NamedDBElementRepository.php
index b8710499..ad4ec7e5 100644
--- a/src/Repository/NamedDBElementRepository.php
+++ b/src/Repository/NamedDBElementRepository.php
@@ -1,4 +1,7 @@
findBy([], ['name' => 'ASC']);
foreach ($entities as $entity) {
- /** @var $entity NamedDBElement */
+ /** @var NamedDBElement $entity */
$node = new TreeViewNode($entity->getName(), null, null);
$node->setId($entity->getID());
$result[] = $node;
diff --git a/src/Repository/PartRepository.php b/src/Repository/PartRepository.php
index e5a8370d..91762310 100644
--- a/src/Repository/PartRepository.php
+++ b/src/Repository/PartRepository.php
@@ -1,5 +1,7 @@
perm_cache = [];
}
+ /**
+ * @PostLoad
+ * @ORM\PostUpdate()
+ * This function is called after doctrine filled, the entity properties with db values.
+ * We use this, to check if the user is allowed to access these properties, and if not, we write a placeholder
+ * into the element properties, so that a user only gets non sensitve data.
+ *
+ * This function is also called after an entity was updated, so we dont show the original data to user,
+ * after an update.
+ */
+ public function postLoadHandler(DBElement $element, LifecycleEventArgs $event): void
+ {
+ //Do nothing if security is disabled
+ if ($this->disabled) {
+ return;
+ }
+
+ //Read Annotations and properties.
+ $reflectionClass = new ReflectionClass($element);
+ $properties = $reflectionClass->getProperties();
+
+ foreach ($properties as $property) {
+ /** @var ColumnSecurity */
+ $annotation = $this->reader->getPropertyAnnotation(
+ $property,
+ ColumnSecurity::class
+ );
+
+ //Check if user is allowed to read info, otherwise apply placeholder
+ if ((null !== $annotation) && ! $this->isGranted('read', $annotation, $element)) {
+ $property->setAccessible(true);
+ $value = $annotation->getPlaceholder();
+
+ //Detach placeholder entities, so we dont get cascade errors
+ if ($value instanceof DBElement) {
+ $this->em->detach($value);
+ }
+
+ $property->setValue($element, $value);
+ }
+ }
+ }
+
+ /**
+ * @ORM\PreFlush()
+ * This function is called before flushing. We use it, to remove all placeholders.
+ * We do it here and not in preupdate, because this is called before calculating the changeset,
+ * and so we dont get problems with orphan removal.
+ */
+ public function preFlushHandler(DBElement $element, PreFlushEventArgs $eventArgs): void
+ {
+ //Do nothing if security is disabled
+ if ($this->disabled) {
+ return;
+ }
+
+ $em = $eventArgs->getEntityManager();
+ $unitOfWork = $eventArgs->getEntityManager()->getUnitOfWork();
+
+ $reflectionClass = new ReflectionClass($element);
+ $properties = $reflectionClass->getProperties();
+
+ $old_data = $unitOfWork->getOriginalEntityData($element);
+
+ foreach ($properties as $property) {
+ $annotation = $this->reader->getPropertyAnnotation(
+ $property,
+ ColumnSecurity::class
+ );
+
+ $changed = false;
+
+ //Only set the field if it has an annotation
+ if (null !== $annotation) {
+ $property->setAccessible(true);
+
+ //If the user is not allowed to edit or read this property, reset all values.
+ if ((! $this->isGranted('read', $annotation, $element)
+ || ! $this->isGranted('edit', $annotation, $element))) {
+ //Set value to old value, so that there a no change to this property
+ if (isset($old_data[$property->getName()])) {
+ $property->setValue($element, $old_data[$property->getName()]);
+ $changed = true;
+ }
+ }
+
+ if ($changed) {
+ //Schedule for update, so the post update method will be called
+ $unitOfWork->scheduleForUpdate($element);
+ }
+ }
+ }
+ }
+
/**
* This function checks if the current script is run from web or from a terminal.
*
@@ -70,7 +167,7 @@ class ElementPermissionListener
*/
protected function isRunningFromCLI()
{
- if (empty($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['HTTP_USER_AGENT']) && \count($_SERVER['argv']) > 0) {
+ if (empty($_SERVER['REMOTE_ADDR']) && ! isset($_SERVER['HTTP_USER_AGENT']) && \count($_SERVER['argv']) > 0) {
return true;
}
@@ -103,106 +200,10 @@ class ElementPermissionListener
}
//Check if we have already have saved the permission, otherwise save it to cache
- if (!isset($this->perm_cache[$mode][\get_class($element)][$operation])) {
+ if (! isset($this->perm_cache[$mode][\get_class($element)][$operation])) {
$this->perm_cache[$mode][\get_class($element)][$operation] = $this->security->isGranted($operation, $element);
}
return $this->perm_cache[$mode][\get_class($element)][$operation];
}
-
- /**
- * @PostLoad
- * @ORM\PostUpdate()
- * This function is called after doctrine filled, the entity properties with db values.
- * We use this, to check if the user is allowed to access these properties, and if not, we write a placeholder
- * into the element properties, so that a user only gets non sensitve data.
- *
- * This function is also called after an entity was updated, so we dont show the original data to user,
- * after an update.
- */
- public function postLoadHandler(DBElement $element, LifecycleEventArgs $event)
- {
- //Do nothing if security is disabled
- if ($this->disabled) {
- return;
- }
-
- //Read Annotations and properties.
- $reflectionClass = new ReflectionClass($element);
- $properties = $reflectionClass->getProperties();
-
- foreach ($properties as $property) {
- /**
- * @var ColumnSecurity
- */
- $annotation = $this->reader->getPropertyAnnotation(
- $property,
- ColumnSecurity::class
- );
-
- //Check if user is allowed to read info, otherwise apply placeholder
- if ((null !== $annotation) && !$this->isGranted('read', $annotation, $element)) {
- $property->setAccessible(true);
- $value = $annotation->getPlaceholder();
-
- //Detach placeholder entities, so we dont get cascade errors
- if ($value instanceof DBElement) {
- $this->em->detach($value);
- }
-
- $property->setValue($element, $value);
- }
- }
- }
-
- /**
- * @ORM\PreFlush()
- * This function is called before flushing. We use it, to remove all placeholders.
- * We do it here and not in preupdate, because this is called before calculating the changeset,
- * and so we dont get problems with orphan removal.
- */
- public function preFlushHandler(DBElement $element, PreFlushEventArgs $eventArgs)
- {
- //Do nothing if security is disabled
- if ($this->disabled) {
- return;
- }
-
- $em = $eventArgs->getEntityManager();
- $unitOfWork = $eventArgs->getEntityManager()->getUnitOfWork();
-
- $reflectionClass = new ReflectionClass($element);
- $properties = $reflectionClass->getProperties();
-
- $old_data = $unitOfWork->getOriginalEntityData($element);
-
- foreach ($properties as $property) {
- $annotation = $this->reader->getPropertyAnnotation(
- $property,
- ColumnSecurity::class
- );
-
- $changed = false;
-
- //Only set the field if it has an annotation
- if (null !== $annotation) {
- $property->setAccessible(true);
-
- //If the user is not allowed to edit or read this property, reset all values.
- if ((!$this->isGranted('read', $annotation, $element)
- || !$this->isGranted('edit', $annotation, $element))) {
- //Set value to old value, so that there a no change to this property
- if (isset($old_data[$property->getName()])) {
- $property->setValue($element, $old_data[$property->getName()]);
- $changed = true;
- }
- }
-
- if ($changed) {
- //Schedule for update, so the post update method will be called
- $unitOfWork->scheduleForUpdate($element);
- }
- }
- }
- }
}
diff --git a/src/Security/Interfaces/HasPermissionsInterface.php b/src/Security/Interfaces/HasPermissionsInterface.php
index 9e533ca9..1501756f 100644
--- a/src/Security/Interfaces/HasPermissionsInterface.php
+++ b/src/Security/Interfaces/HasPermissionsInterface.php
@@ -1,4 +1,7 @@
entityManager->getRepository(User::class);
$user = $repo->getAnonymousUser();
if (null === $user) {
diff --git a/src/Security/Voter/GroupVoter.php b/src/Security/Voter/GroupVoter.php
index e96491cc..867ae769 100644
--- a/src/Security/Voter/GroupVoter.php
+++ b/src/Security/Voter/GroupVoter.php
@@ -1,4 +1,7 @@
siFormatter = $siFormatter;
}
- protected function configureOptions(OptionsResolver $resolver)
+ /**
+ * Formats the given value using the measurement unit and options.
+ *
+ * @param MeasurementUnit|null $unit The measurement unit, whose unit symbol should be used for formatting.
+ * If set to null, it is assumed that the part amount is measured in pieces.
+ *
+ * @return string The formatted string
+ *
+ * @throws \InvalidArgumentException thrown if $value is not numeric
+ */
+ public function format($value, ?MeasurementUnit $unit = null, array $options = [])
+ {
+ if (! is_numeric($value)) {
+ throw new \InvalidArgumentException('$value must be an numeric value!');
+ }
+ $value = (float) $value;
+
+ //Find out what options to use
+ $resolver = new OptionsResolver();
+ $resolver->setDefault('measurement_unit', $unit);
+ $this->configureOptions($resolver);
+
+ $options = $resolver->resolve($options);
+
+ if ($options['is_integer']) {
+ $value = round($value);
+ }
+
+ //If the measurement unit uses a SI prefix format it that way.
+ if ($options['show_prefix']) {
+ return $this->siFormatter->format($value, $options['unit'], $options['decimals']);
+ }
+
+ //Otherwise just output it
+ if (! empty($options['unit'])) {
+ $format_string = '%.'.$options['decimals'].'f '.$options['unit'];
+ } else { //Dont add space after number if no unit was specified
+ $format_string = '%.'.$options['decimals'].'f';
+ }
+
+ return sprintf($format_string, $value);
+ }
+
+ protected function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'show_prefix' => function (Options $options) {
@@ -85,48 +131,4 @@ class AmountFormatter
return $value;
});
}
-
- /**
- * Formats the given value using the measurement unit and options.
- *
- * @param $value float|int The value that should be formatted. Must be numeric.
- * @param MeasurementUnit|null $unit The measurement unit, whose unit symbol should be used for formatting.
- * If set to null, it is assumed that the part amount is measured in pieces.
- *
- * @return string The formatted string
- *
- * @throws \InvalidArgumentException thrown if $value is not numeric
- */
- public function format($value, ?MeasurementUnit $unit = null, array $options = [])
- {
- if (!is_numeric($value)) {
- throw new \InvalidArgumentException('$value must be an numeric value!');
- }
- $value = (float) $value;
-
- //Find out what options to use
- $resolver = new OptionsResolver();
- $resolver->setDefault('measurement_unit', $unit);
- $this->configureOptions($resolver);
-
- $options = $resolver->resolve($options);
-
- if ($options['is_integer']) {
- $value = round($value);
- }
-
- //If the measurement unit uses a SI prefix format it that way.
- if ($options['show_prefix']) {
- return $this->siFormatter->format($value, $options['unit'], $options['decimals']);
- }
-
- //Otherwise just output it
- if (!empty($options['unit'])) {
- $format_string = '%.'.$options['decimals'].'f '.$options['unit'];
- } else { //Dont add space after number if no unit was specified
- $format_string = '%.'.$options['decimals'].'f';
- }
-
- return sprintf($format_string, $value);
- }
}
diff --git a/src/Services/Attachments/AttachmentManager.php b/src/Services/Attachments/AttachmentManager.php
index 332ce773..e898db0e 100644
--- a/src/Services/Attachments/AttachmentManager.php
+++ b/src/Services/Attachments/AttachmentManager.php
@@ -1,4 +1,7 @@
isExternal() || !$this->isFileExisting($attachment)) {
+ if ($attachment->isExternal() || ! $this->isFileExisting($attachment)) {
return null;
}
@@ -117,7 +120,7 @@ class AttachmentManager
return null;
}
- if (!$this->isFileExisting($attachment)) {
+ if (! $this->isFileExisting($attachment)) {
return null;
}
@@ -138,7 +141,7 @@ class AttachmentManager
{
$bytes = $this->getFileSize($attachment);
- if (null == $bytes) {
+ if (null === $bytes) {
return null;
}
diff --git a/src/Services/Attachments/AttachmentPathResolver.php b/src/Services/Attachments/AttachmentPathResolver.php
index 5ba6ad34..c76eba0b 100644
--- a/src/Services/Attachments/AttachmentPathResolver.php
+++ b/src/Services/Attachments/AttachmentPathResolver.php
@@ -1,4 +1,7 @@
models_path;
}
+
+ /**
+ * Create an array usable for preg_replace out of an array of placeholders or pathes.
+ * Slashes and other chars become escaped.
+ * For example: '%TEST%' becomes '/^%TEST%/'.
+ */
+ protected function arrayToRegexArray(array $array): array
+ {
+ $ret = [];
+
+ foreach ($array as $item) {
+ $item = str_replace(['\\'], ['/'], $item);
+ $ret[] = '/'.preg_quote($item, '/').'/';
+ }
+
+ return $ret;
+ }
}
diff --git a/src/Services/Attachments/AttachmentReverseSearch.php b/src/Services/Attachments/AttachmentReverseSearch.php
index f5262550..0e95e5bc 100644
--- a/src/Services/Attachments/AttachmentReverseSearch.php
+++ b/src/Services/Attachments/AttachmentReverseSearch.php
@@ -1,4 +1,7 @@
'supplier', UserAttachment::class => 'user', ];
}
- protected function configureOptions(OptionsResolver $resolver): void
- {
- $resolver->setDefaults([
- //If no preview image was set yet, the new uploaded file will become the preview image
- 'become_preview_if_empty' => true,
- //When an URL is given download the URL
- 'download_url' => false,
- 'secure_attachment' => false,
- ]);
- }
-
/**
* Generates a filename for the given attachment and extension.
* The filename contains a random id, so every time this function is called you get an unique name.
@@ -125,7 +117,7 @@ class AttachmentSubmitHandler
}
//Ensure the given attachment class is known to mapping
- if (!isset($this->folder_mapping[\get_class($attachment)])) {
+ if (! isset($this->folder_mapping[\get_class($attachment)])) {
throw new \InvalidArgumentException('The given attachment class is not known! The passed class was: '.\get_class($attachment));
}
//Ensure the attachment has an assigned element
@@ -178,6 +170,17 @@ class AttachmentSubmitHandler
return $attachment;
}
+ protected function configureOptions(OptionsResolver $resolver): void
+ {
+ $resolver->setDefaults([
+ //If no preview image was set yet, the new uploaded file will become the preview image
+ 'become_preview_if_empty' => true,
+ //When an URL is given download the URL
+ 'download_url' => false,
+ 'secure_attachment' => false,
+ ]);
+ }
+
/**
* Move the given attachment to secure location (or back to public folder) if needed.
*
@@ -200,13 +203,13 @@ class AttachmentSubmitHandler
//Determine the old filepath
$old_path = $this->pathResolver->placeholderToRealPath($attachment->getPath());
- if (!file_exists($old_path)) {
+ if (! file_exists($old_path)) {
return $attachment;
}
$filename = basename($old_path);
//If the basename is not one of the new unique on, we have to save the old filename
- if (!preg_match('/\w+-\w{13}\./', $filename)) {
+ if (! preg_match('/\w+-\w{13}\./', $filename)) {
//Save filename to attachment field
$attachment->setFilename($attachment->getFilename());
}
@@ -236,7 +239,7 @@ class AttachmentSubmitHandler
protected function downloadURL(Attachment $attachment, array $options): Attachment
{
//Check if we are allowed to download files
- if (!$this->allow_attachments_downloads) {
+ if (! $this->allow_attachments_downloads) {
throw new \RuntimeException('Download of attachments is not allowed!');
}
@@ -286,7 +289,7 @@ class AttachmentSubmitHandler
//Check if we have a extension given
$pathinfo = pathinfo($filename);
- if (!empty($pathinfo['extension'])) {
+ if (! empty($pathinfo['extension'])) {
$new_ext = $pathinfo['extension'];
} else { //Otherwise we have to guess the extension for the new file, based on its content
$new_ext = $this->mimeTypes->getExtensions($this->mimeTypes->guessMimeType($tmp_path))[0] ?? 'tmp';
diff --git a/src/Services/Attachments/AttachmentURLGenerator.php b/src/Services/Attachments/AttachmentURLGenerator.php
index d2f43f68..e29ab08f 100644
--- a/src/Services/Attachments/AttachmentURLGenerator.php
+++ b/src/Services/Attachments/AttachmentURLGenerator.php
@@ -1,4 +1,7 @@
isPicture()) {
+ if (! $attachment->isPicture()) {
throw new \InvalidArgumentException('Thumbnail creation only works for picture attachments!');
}
diff --git a/src/Services/Attachments/BuiltinAttachmentsFinder.php b/src/Services/Attachments/BuiltinAttachmentsFinder.php
index ec818b45..3e7b2fb0 100644
--- a/src/Services/Attachments/BuiltinAttachmentsFinder.php
+++ b/src/Services/Attachments/BuiltinAttachmentsFinder.php
@@ -1,4 +1,7 @@
cache = $cache;
}
- protected function configureOptions(OptionsResolver $resolver)
- {
- $resolver->setDefaults([
- 'limit' => 15, //Given only 15 entries
- //'allowed_extensions' => [], //Filter the filenames. For example ['jpg', 'jpeg'] to only get jpegs.
- //'placeholders' => Attachment::BUILTIN_PLACEHOLDER, //By default use all builtin ressources,
- 'empty_returns_all' => false, //Return the whole list of ressources when empty keyword is given
- ]);
- }
-
/**
* Returns a list of all builtin ressources.
* The array is a list of the relative filenames using the %PLACEHOLDERS%.
@@ -138,4 +131,14 @@ class BuiltinAttachmentsFinder
return preg_grep($regex, $base_list);
}
+
+ protected function configureOptions(OptionsResolver $resolver): void
+ {
+ $resolver->setDefaults([
+ 'limit' => 15, //Given only 15 entries
+ //'allowed_extensions' => [], //Filter the filenames. For example ['jpg', 'jpeg'] to only get jpegs.
+ //'placeholders' => Attachment::BUILTIN_PLACEHOLDER, //By default use all builtin ressources,
+ 'empty_returns_all' => false, //Return the whole list of ressources when empty keyword is given
+ ]);
+ }
}
diff --git a/src/Services/Attachments/FileTypeFilterTools.php b/src/Services/Attachments/FileTypeFilterTools.php
index de257410..12391031 100644
--- a/src/Services/Attachments/FileTypeFilterTools.php
+++ b/src/Services/Attachments/FileTypeFilterTools.php
@@ -1,4 +1,7 @@
get('format') ?? 'json';
//Check if we have one of the supported formats
- if (!\in_array($format, ['json', 'csv', 'yaml', 'xml'])) {
+ if (! \in_array($format, ['json', 'csv', 'yaml', 'xml'], true)) {
throw new \InvalidArgumentException('Given format is not supported!');
}
//Check export verbosity level
$level = $request->get('level') ?? 'extended';
- if (!\in_array($level, ['simple', 'extended', 'full'])) {
+ if (! \in_array($level, ['simple', 'extended', 'full'], true)) {
throw new \InvalidArgumentException('Given level is not supported!');
}
@@ -80,9 +82,11 @@ class EntityExporter
switch ($format) {
case 'xml':
$content_type = 'application/xml';
+
break;
case 'json':
$content_type = 'application/json';
+
break;
}
@@ -104,7 +108,7 @@ class EntityExporter
$response->headers->set('Content-Type', $content_type);
//If view option is not specified, then download the file.
- if (!$request->get('view')) {
+ if (! $request->get('view')) {
if ($entity instanceof NamedDBElement) {
$entity_name = $entity->getName();
} elseif (\is_array($entity)) {
diff --git a/src/Services/EntityImporter.php b/src/Services/EntityImporter.php
index 908f0a66..b992ebc4 100644
--- a/src/Services/EntityImporter.php
+++ b/src/Services/EntityImporter.php
@@ -1,4 +1,7 @@
validator = $validator;
}
- protected function configureOptions(OptionsResolver $resolver)
- {
- $resolver->setDefaults([
- 'csv_separator' => ';',
- 'format' => 'json',
- 'preserve_children' => true,
- 'parent' => null,
- 'abort_on_validation_error' => true,
- ]);
- }
-
/**
* Creates many entries at once, based on a (text) list of name.
* The created enties are not persisted to database yet, so you have to do it yourself.
@@ -68,10 +60,10 @@ class EntityImporter
//Expand every line to a single entry:
$names = explode("\n", $lines);
- if (!is_a($class_name, StructuralDBElement::class, true)) {
+ if (! is_a($class_name, StructuralDBElement::class, true)) {
throw new \InvalidArgumentException('$class_name must be a StructuralDBElement type!');
}
- if (null !== $parent && !is_a($parent, $class_name)) {
+ if (null !== $parent && ! is_a($parent, $class_name)) {
throw new \InvalidArgumentException('$parent must have the same type as specified in $class_name!');
}
@@ -84,7 +76,7 @@ class EntityImporter
//Skip empty lines (StrucuralDBElements must have a name)
continue;
}
- /** @var $entity StructuralDBElement */
+ /** @var StructuralDBElement $entity */
//Create new element with given name
$entity = new $class_name();
$entity->setName($name);
@@ -127,7 +119,7 @@ class EntityImporter
//Iterate over each $entity write it to DB.
foreach ($entities as $entity) {
- /* @var StructuralDBElement $entity */
+ /** @var StructuralDBElement $entity */
//Move every imported entity to the selected parent
$entity->setParent($options['parent']);
@@ -143,7 +135,7 @@ class EntityImporter
}
//Save changes to database, when no error happened, or we should continue on error.
- if (empty($errors) || false == $options['abort_on_validation_error']) {
+ if (empty($errors) || false === $options['abort_on_validation_error']) {
$this->em->flush();
}
@@ -182,7 +174,7 @@ class EntityImporter
['groups' => $groups, 'csv_delimiter' => $options['csv_separator']]);
//Ensure we have an array of entitity elements.
- if (!\is_array($entities)) {
+ if (! \is_array($entities)) {
$entities = [$entities];
}
@@ -194,16 +186,27 @@ class EntityImporter
return $entities;
}
+ protected function configureOptions(OptionsResolver $resolver): void
+ {
+ $resolver->setDefaults([
+ 'csv_separator' => ';',
+ 'format' => 'json',
+ 'preserve_children' => true,
+ 'parent' => null,
+ 'abort_on_validation_error' => true,
+ ]);
+ }
+
/**
* This functions corrects the parent setting based on the children value of the parent.
*
* @param iterable $entities the list of entities that should be fixed
* @param null $parent the parent, to which the entity should be set
*/
- protected function correctParentEntites(iterable $entities, $parent = null)
+ protected function correctParentEntites(iterable $entities, $parent = null): void
{
foreach ($entities as $entity) {
- /* @var $entity StructuralDBElement */
+ /** @var StructuralDBElement $entity */
$entity->setParent($parent);
//Do the same for the children of entity
$this->correctParentEntites($entity->getChildren(), $entity);
diff --git a/src/Services/EntityURLGenerator.php b/src/Services/EntityURLGenerator.php
index e6e27381..2dccb348 100644
--- a/src/Services/EntityURLGenerator.php
+++ b/src/Services/EntityURLGenerator.php
@@ -1,4 +1,7 @@
attachmentURLGenerator = $attachmentURLGenerator;
}
- /**
- * Finds the controller name for the class of the entity using the given map.
- * Throws an exception if the entity class is not known to the map.
- *
- * @param array $map The map that should be used for determing the controller
- * @param $entity mixed The entity for which the controller name should be determined
- *
- * @return string The name of the controller fitting the entity class
- *
- * @throws EntityNotSupportedException
- */
- protected function mapToController(array $map, $entity): string
- {
- $class = \get_class($entity);
-
- //Check if we have an direct mapping for the given class
- if (!\array_key_exists($class, $map)) {
- //Check if we need to check inheritance by looping through our map
- foreach ($map as $key => $value) {
- if (is_a($entity, $key)) {
- return $map[$key];
- }
- }
-
- throw new EntityNotSupportedException(sprintf('The given entity is not supported yet! Passed class type: %s', \get_class($entity)));
- }
-
- return $map[$class];
- }
-
/**
* Generates an URL to the page using the given page type and element.
* For the given types, the [type]URL() functions are called (e.g. infoURL()).
* Not all entity class and $type combinations are supported.
*
- * @param $entity mixed The element for which the page should be generated
- * @param string $type The page type. Currently supported: 'info', 'edit', 'create', 'clone', 'list'/'list_parts'
+ * @param mixed $entity The element for which the page should be generated
+ * @param string $type The page type. Currently supported: 'info', 'edit', 'create', 'clone', 'list'/'list_parts'
*
* @return string the link to the desired page
*
@@ -157,7 +130,7 @@ class EntityURLGenerator
/**
* Generates an URL to a page, where info about this entity can be viewed.
*
- * @param $entity mixed The entity for which the info should be generated
+ * @param mixed $entity The entity for which the info should be generated
*
* @return string The URL to the info page
*
@@ -188,7 +161,7 @@ class EntityURLGenerator
/**
* Generates an URL to a page, where this entity can be edited.
*
- * @param $entity mixed The entity for which the edit link should be generated
+ * @param mixed $entity The entity for which the edit link should be generated
*
* @return string the URL to the edit page
*
@@ -217,7 +190,7 @@ class EntityURLGenerator
/**
* Generates an URL to a page, where a entity of this type can be created.
*
- * @param $entity mixed The entity for which the link should be generated
+ * @param mixed $entity The entity for which the link should be generated
*
* @return string the URL to the page
*
@@ -247,7 +220,7 @@ class EntityURLGenerator
* Generates an URL to a page, where a new entity can be created, that has the same informations as the
* given entity (element cloning).
*
- * @param $entity mixed The entity for which the link should be generated
+ * @param mixed $entity The entity for which the link should be generated
*
* @return string the URL to the page
*
@@ -265,7 +238,7 @@ class EntityURLGenerator
/**
* Generates an URL to a page, where all parts are listed, which are contained in the given element.
*
- * @param $entity mixed The entity for which the link should be generated
+ * @param mixed $entity The entity for which the link should be generated
*
* @return string the URL to the page
*
@@ -303,4 +276,34 @@ class EntityURLGenerator
return $this->urlGenerator->generate($this->mapToController($map, $entity), ['id' => $entity->getID()]);
}
+
+ /**
+ * Finds the controller name for the class of the entity using the given map.
+ * Throws an exception if the entity class is not known to the map.
+ *
+ * @param array $map The map that should be used for determing the controller
+ * @param mixed $entity The entity for which the controller name should be determined
+ *
+ * @return string The name of the controller fitting the entity class
+ *
+ * @throws EntityNotSupportedException
+ */
+ protected function mapToController(array $map, $entity): string
+ {
+ $class = \get_class($entity);
+
+ //Check if we have an direct mapping for the given class
+ if (! \array_key_exists($class, $map)) {
+ //Check if we need to check inheritance by looping through our map
+ foreach ($map as $key => $value) {
+ if (is_a($entity, $key)) {
+ return $map[$key];
+ }
+ }
+
+ throw new EntityNotSupportedException(sprintf('The given entity is not supported yet! Passed class type: %s', \get_class($entity)));
+ }
+
+ return $map[$class];
+ }
}
diff --git a/src/Services/FAIconGenerator.php b/src/Services/FAIconGenerator.php
index e5363a1a..80b8e944 100644
--- a/src/Services/FAIconGenerator.php
+++ b/src/Services/FAIconGenerator.php
@@ -1,4 +1,7 @@
base_currency;
- if (null !== $currency && !empty($currency->getIsoCode())) {
+ if (null !== $currency && ! empty($currency->getIsoCode())) {
$iso_code = $currency->getIsoCode();
}
diff --git a/src/Services/PasswordResetManager.php b/src/Services/PasswordResetManager.php
index bc643224..7657aa31 100644
--- a/src/Services/PasswordResetManager.php
+++ b/src/Services/PasswordResetManager.php
@@ -1,4 +1,7 @@
em = $em;
$this->mailer = $mailer;
- /* @var PasswordEncoderInterface passwordEncoder */
+ /** @var PasswordEncoderInterface passwordEncoder */
$this->passwordEncoder = $encoderFactory->getEncoder(User::class);
$this->translator = $translator;
$this->userPasswordEncoder = $userPasswordEncoder;
@@ -70,7 +73,7 @@ class PasswordResetManager
$expiration_date->add(date_interval_create_from_date_string('1 day'));
$user->setPwResetExpires($expiration_date);
- if (!empty($user->getEmail())) {
+ if (! empty($user->getEmail())) {
$address = new Address($user->getEmail(), $user->getFullName());
$mail = new TemplatedEmail();
$mail->to($address);
@@ -118,7 +121,7 @@ class PasswordResetManager
}
//Check if token is valid
- if (!$this->passwordEncoder->isPasswordValid($user->getPwResetToken(), $token, null)) {
+ if (! $this->passwordEncoder->isPasswordValid($user->getPwResetToken(), $token, null)) {
return false;
}
diff --git a/src/Services/PermissionResolver.php b/src/Services/PermissionResolver.php
index 1d757023..72aa58c5 100644
--- a/src/Services/PermissionResolver.php
+++ b/src/Services/PermissionResolver.php
@@ -1,4 +1,7 @@
permission_structure;
}
- protected function generatePermissionStructure()
- {
- $cache = new ConfigCache($this->cache_file, $this->is_debug);
-
- //Check if the cache is fresh, else regenerate it.
- if (!$cache->isFresh()) {
- $permission_file = __DIR__.'/../../config/permissions.yaml';
-
- //Read the permission config file...
- $config = Yaml::parse(
- file_get_contents($permission_file)
- );
-
- $configs = [$config];
-
- //... And parse it
- $processor = new Processor();
- $databaseConfiguration = new PermissionsConfiguration();
- $processedConfiguration = $processor->processConfiguration(
- $databaseConfiguration,
- $configs
- );
-
- //Permission file is our file resource (it is used to invalidate cache)
- $resources = [];
- $resources[] = new FileResource($permission_file);
-
- //Var export the structure and write it to cache file.
- $cache->write(
- sprintf('cache_file;
- }
-
/**
* Check if a user/group is allowed to do the specified operation for the permission.
*
@@ -144,7 +110,7 @@ class PermissionResolver
}
$parent = $user->getGroup();
- while (null != $parent) { //The top group, has parent == null
+ while (null !== $parent) { //The top group, has parent == null
//Check if our current element gives a info about disallow/allow
$allowed = $this->dontInherit($parent, $permission, $operation);
if (null !== $allowed) {
@@ -189,7 +155,7 @@ class PermissionResolver
*/
public function listOperationsForPermission(string $permission): array
{
- if (!$this->isValidPermission($permission)) {
+ if (! $this->isValidPermission($permission)) {
throw new \InvalidArgumentException(sprintf('A permission with that name is not existing! Got %s.', $permission));
}
$operations = $this->permission_structure['perms'][$permission]['operations'];
@@ -222,4 +188,41 @@ class PermissionResolver
return $this->isValidPermission($permission) &&
isset($this->permission_structure['perms'][$permission]['operations'][$operation]);
}
+
+ protected function generatePermissionStructure()
+ {
+ $cache = new ConfigCache($this->cache_file, $this->is_debug);
+
+ //Check if the cache is fresh, else regenerate it.
+ if (! $cache->isFresh()) {
+ $permission_file = __DIR__.'/../../config/permissions.yaml';
+
+ //Read the permission config file...
+ $config = Yaml::parse(
+ file_get_contents($permission_file)
+ );
+
+ $configs = [$config];
+
+ //... And parse it
+ $processor = new Processor();
+ $databaseConfiguration = new PermissionsConfiguration();
+ $processedConfiguration = $processor->processConfiguration(
+ $databaseConfiguration,
+ $configs
+ );
+
+ //Permission file is our file resource (it is used to invalidate cache)
+ $resources = [];
+ $resources[] = new FileResource($permission_file);
+
+ //Var export the structure and write it to cache file.
+ $cache->write(
+ sprintf('cache_file;
+ }
}
diff --git a/src/Services/PricedetailHelper.php b/src/Services/PricedetailHelper.php
index 30361294..6039549c 100644
--- a/src/Services/PricedetailHelper.php
+++ b/src/Services/PricedetailHelper.php
@@ -1,4 +1,7 @@
getPrefixByMagnitude($this->getMagnitude($value));
- $ret = [
+ return [
'value' => $value / $tmp[0],
'prefix_magnitude' => log10($tmp[0]),
'prefix' => $tmp[1],
];
-
- return $ret;
}
/**
diff --git a/src/Services/StructuralElementRecursionHelper.php b/src/Services/StructuralElementRecursionHelper.php
index c55c3d5d..8d3e43c1 100644
--- a/src/Services/StructuralElementRecursionHelper.php
+++ b/src/Services/StructuralElementRecursionHelper.php
@@ -1,4 +1,7 @@
getChildren();
//If we should call from top we execute the func here.
- if (!$call_from_bottom) {
+ if (! $call_from_bottom) {
$func($element);
}
@@ -80,7 +83,7 @@ class StructuralElementRecursionHelper
{
$em = $this->em;
- $this->execute($element, static function (StructuralDBElement $element) use ($em) {
+ $this->execute($element, static function (StructuralDBElement $element) use ($em): void {
$em->remove($element);
});
diff --git a/src/Services/TFA/BackupCodeGenerator.php b/src/Services/TFA/BackupCodeGenerator.php
index 19debe40..ad0617b2 100644
--- a/src/Services/TFA/BackupCodeGenerator.php
+++ b/src/Services/TFA/BackupCodeGenerator.php
@@ -1,4 +1,7 @@
getBackupCodes())) {
$this->regenerateBackupCodes($user);
@@ -49,7 +52,7 @@ class BackupCodeManager
/**
* Disable (remove) the backup codes when no other 2 factor authentication methods are enabled.
*/
- public function disableBackupCodesIfUnused(User $user)
+ public function disableBackupCodesIfUnused(User $user): void
{
if ($user->isGoogleAuthenticatorEnabled()) {
return;
@@ -64,7 +67,7 @@ class BackupCodeManager
*
* @param User $user The user for which the backup codes should be regenerated
*/
- public function regenerateBackupCodes(User $user)
+ public function regenerateBackupCodes(User $user): void
{
$codes = $this->backupCodeGenerator->generateCodeSet();
$user->setBackupCodes($codes);
diff --git a/src/Services/TagFinder.php b/src/Services/TagFinder.php
index 65947ddf..0a42f68c 100644
--- a/src/Services/TagFinder.php
+++ b/src/Services/TagFinder.php
@@ -1,4 +1,7 @@
em = $entityManager;
}
- protected function configureOptions(OptionsResolver $resolver)
- {
- $resolver->setDefaults([
- 'query_limit' => 75,
- 'return_limit' => 25,
- 'min_keyword_length' => 3,
- ]);
- }
-
/**
* Search tags that begins with the certain keyword.
*
@@ -91,4 +85,13 @@ class TagFinder
//Limit the returned tag count to specified value.
return \array_slice($results, 0, $options['return_limit']);
}
+
+ protected function configureOptions(OptionsResolver $resolver): void
+ {
+ $resolver->setDefaults([
+ 'query_limit' => 75,
+ 'return_limit' => 25,
+ 'min_keyword_length' => 3,
+ ]);
+ }
}
diff --git a/src/Services/TranslationExtractor/PermissionExtractor.php b/src/Services/TranslationExtractor/PermissionExtractor.php
index 8abecab5..d890cef0 100644
--- a/src/Services/TranslationExtractor/PermissionExtractor.php
+++ b/src/Services/TranslationExtractor/PermissionExtractor.php
@@ -1,4 +1,7 @@
finished) {
+ if (! $this->finished) {
//Extract for every group...
foreach ($this->permission_structure['groups'] as $group) {
if (isset($group['label'])) {
diff --git a/src/Services/Trees/NodesListBuilder.php b/src/Services/Trees/NodesListBuilder.php
index 4c20e30a..25171026 100644
--- a/src/Services/Trees/NodesListBuilder.php
+++ b/src/Services/Trees/NodesListBuilder.php
@@ -1,4 +1,7 @@
getID() : '0';
+ $parent_id = null !== $parent ? $parent->getID() : '0';
// Backslashes are not allowed in cache keys
$secure_class_name = str_replace('\\', '_', $class_name);
$key = 'list_'.$this->keyGenerator->generateKey().'_'.$secure_class_name.$parent_id;
- $ret = $this->cache->get($key, function (ItemInterface $item) use ($class_name, $parent, $secure_class_name) {
+ return $this->cache->get($key, function (ItemInterface $item) use ($class_name, $parent, $secure_class_name) {
// Invalidate when groups, a element with the class or the user changes
$item->tag(['groups', 'tree_list', $this->keyGenerator->generateKey(), $secure_class_name]);
- /**
- * @var StructuralDBElementRepository
- */
+ /** @var StructuralDBElementRepository */
$repo = $this->em->getRepository($class_name);
return $repo->toNodesList($parent);
});
-
- return $ret;
}
}
diff --git a/src/Services/Trees/ToolsTreeBuilder.php b/src/Services/Trees/ToolsTreeBuilder.php
index d607e41d..414ec679 100644
--- a/src/Services/Trees/ToolsTreeBuilder.php
+++ b/src/Services/Trees/ToolsTreeBuilder.php
@@ -1,4 +1,7 @@
urlGenerator->createURL(new $class());
$new_node = new TreeViewNode($this->translator->trans('entity.tree.new'), $href);
//When the id of the selected element is null, then we have a new element, and we need to select "new" node
- if (null == $selectedElement || null == $selectedElement->getID()) {
+ if (null === $selectedElement || null === $selectedElement->getID()) {
$new_node->setSelected(true);
}
$head[] = $new_node;
@@ -88,16 +91,16 @@ class TreeViewGenerator
$treeIterator = new TreeViewNodeIterator($generic);
$recursiveIterator = new \RecursiveIteratorIterator($treeIterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($recursiveIterator as $item) {
- /** @var $item TreeViewNode */
+ /** @var TreeViewNode $item */
if (null !== $selectedElement && $item->getId() === $selectedElement->getID()) {
$item->setSelected(true);
}
- if (!empty($item->getNodes())) {
+ if (! empty($item->getNodes())) {
$item->addTag((string) \count($item->getNodes()));
}
- if (!empty($href_type)) {
+ if (! empty($href_type)) {
$entity = $this->em->getPartialReference($class, $item->getId());
$item->setHref($this->urlGenerator->getURL($entity, $href_type));
}
@@ -118,10 +121,10 @@ class TreeViewGenerator
*/
public function getGenericTree(string $class, ?StructuralDBElement $parent = null): array
{
- if (!is_a($class, NamedDBElement::class, true)) {
+ if (! is_a($class, NamedDBElement::class, true)) {
throw new \InvalidArgumentException('$class must be a class string that implements StructuralDBElement or NamedDBElement!');
}
- if (null !== $parent && !is_a($parent, $class)) {
+ if (null !== $parent && ! is_a($parent, $class)) {
throw new \InvalidArgumentException('$parent must be of the type $class!');
}
@@ -136,13 +139,11 @@ class TreeViewGenerator
$secure_class_name = str_replace('\\', '_', $class);
$key = 'treeview_'.$this->keyGenerator->generateKey().'_'.$secure_class_name;
- $ret = $this->cache->get($key, function (ItemInterface $item) use ($repo, $parent, $secure_class_name) {
+ return $this->cache->get($key, function (ItemInterface $item) use ($repo, $parent, $secure_class_name) {
// Invalidate when groups, a element with the class or the user changes
$item->tag(['groups', 'tree_treeview', $this->keyGenerator->generateKey(), $secure_class_name]);
return $repo->getGenericNodeTree($parent);
});
-
- return $ret;
}
}
diff --git a/src/Services/UserCacheKeyGenerator.php b/src/Services/UserCacheKeyGenerator.php
index 27455f8d..d20199d4 100644
--- a/src/Services/UserCacheKeyGenerator.php
+++ b/src/Services/UserCacheKeyGenerator.php
@@ -1,4 +1,7 @@
entityURLGenerator->getURL($entity, $method);
}
- public function formatCurrency($amount, Currency $currency = null, int $decimals = 5)
+ public function formatCurrency($amount, ?Currency $currency = null, int $decimals = 5)
{
return $this->moneyFormatter->format($amount, $currency, $decimals);
}
diff --git a/src/Validator/Constraints/AllowedFileExtension.php b/src/Validator/Constraints/AllowedFileExtension.php
index f28084b7..b7e201d0 100644
--- a/src/Validator/Constraints/AllowedFileExtension.php
+++ b/src/Validator/Constraints/AllowedFileExtension.php
@@ -1,4 +1,7 @@
filterTools->isExtensionAllowed(
+ if (! $this->filterTools->isExtensionAllowed(
$attachment_type->getFiletypeFilter(),
$value->getClientOriginalExtension()
)) {
diff --git a/src/Validator/Constraints/NoLockout.php b/src/Validator/Constraints/NoLockout.php
index 33cb9ba5..717b46b2 100644
--- a/src/Validator/Constraints/NoLockout.php
+++ b/src/Validator/Constraints/NoLockout.php
@@ -1,4 +1,7 @@
allowed_placeholders, false)) {
+ if (! empty($tmp) && \in_array($tmp[0], $constraint->allowed_placeholders, false)) {
return;
}
diff --git a/src/Validator/Constraints/ValidFileFilter.php b/src/Validator/Constraints/ValidFileFilter.php
index 01525376..d55a6d2e 100644
--- a/src/Validator/Constraints/ValidFileFilter.php
+++ b/src/Validator/Constraints/ValidFileFilter.php
@@ -1,4 +1,7 @@
filterTools->validateFilterString($value)) {
+ if (! $this->filterTools->validateFilterString($value)) {
$this->context->buildViolation('validator.file_type_filter.invalid')
->addViolation();
}
diff --git a/src/Validator/Constraints/ValidGoogleAuthCode.php b/src/Validator/Constraints/ValidGoogleAuthCode.php
index 895c6726..4902a94c 100644
--- a/src/Validator/Constraints/ValidGoogleAuthCode.php
+++ b/src/Validator/Constraints/ValidGoogleAuthCode.php
@@ -1,4 +1,7 @@
googleAuthenticator = $googleAuthenticator;
}
- /**
- * {@inheritdoc}
- */
- public function validate($value, Constraint $constraint)
+ public function validate($value, Constraint $constraint): void
{
- if (!$constraint instanceof ValidGoogleAuthCode) {
+ if (! $constraint instanceof ValidGoogleAuthCode) {
throw new UnexpectedTypeException($constraint, ValidGoogleAuthCode::class);
}
@@ -51,11 +51,11 @@ class ValidGoogleAuthCodeValidator extends ConstraintValidator
return;
}
- if (!\is_string($value)) {
+ if (! \is_string($value)) {
throw new UnexpectedValueException($value, 'string');
}
- if (!ctype_digit($value)) {
+ if (! ctype_digit($value)) {
$this->context->addViolation('validator.google_code.only_digits_allowed');
}
@@ -71,7 +71,7 @@ class ValidGoogleAuthCodeValidator extends ConstraintValidator
$user = $this->context->getObject()->getParent()->getData();
//Check if the given code is valid
- if (!$this->googleAuthenticator->checkCode($user, $value)) {
+ if (! $this->googleAuthenticator->checkCode($user, $value)) {
$this->context->addViolation('validator.google_code.wrong_code');
}
}
diff --git a/src/Validator/Constraints/ValidPartLot.php b/src/Validator/Constraints/ValidPartLot.php
index a6003c3d..047fe704 100644
--- a/src/Validator/Constraints/ValidPartLot.php
+++ b/src/Validator/Constraints/ValidPartLot.php
@@ -1,4 +1,7 @@
atPath('amount')->addViolation();
}
- if (!$parts->contains($value->getPart())) {
+ if (! $parts->contains($value->getPart())) {
$this->context->buildViolation('validator.part_lot.location_full')
->atPath('storage_location')->addViolation();
}
@@ -76,7 +79,7 @@ class ValidPartLotValidator extends ConstraintValidator
//Check for onlyExisting
if ($value->getStorageLocation()->isLimitToExistingParts()) {
- if (!$parts->contains($value->getPart())) {
+ if (! $parts->contains($value->getPart())) {
$this->context->buildViolation('validator.part_lot.only_existing')
->atPath('storage_location')->addViolation();
}
@@ -84,7 +87,7 @@ class ValidPartLotValidator extends ConstraintValidator
//Check for only single part
if ($value->getStorageLocation()->isLimitToExistingParts()) {
- if (($parts->count() > 0) && !$parts->contains($value->getPart())) {
+ if (($parts->count() > 0) && ! $parts->contains($value->getPart())) {
$this->context->buildViolation('validator.part_lot.single_part')
->atPath('storage_location')->addViolation();
}
diff --git a/src/Validator/Constraints/ValidPermission.php b/src/Validator/Constraints/ValidPermission.php
index 16556433..9f920ffe 100644
--- a/src/Validator/Constraints/ValidPermission.php
+++ b/src/Validator/Constraints/ValidPermission.php
@@ -1,4 +1,7 @@
perm_structure['perms'] as $perm_key => $permission) {
foreach ($permission['operations'] as $op_key => $op) {
- if (!empty($op['alsoSet']) &&
+ if (! empty($op['alsoSet']) &&
true === $this->resolver->dontInherit($perm_holder, $perm_key, $op_key)) {
//Set every op listed in also Set
foreach ($op['alsoSet'] as $set_also) {