mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Fixed code style.
This commit is contained in:
parent
e01b06fb85
commit
e73a90a234
24 changed files with 30 additions and 58 deletions
|
@ -145,8 +145,6 @@ class CleanAttachmentsCommand extends Command
|
|||
* This function removes all empty folders inside $path. Taken from https://stackoverflow.com/a/1833681.
|
||||
*
|
||||
* @param string $path The path in which the empty folders should be deleted
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function removeEmptySubFolders($path): bool
|
||||
{
|
||||
|
|
|
@ -79,8 +79,6 @@ class ManufacturerController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="manufacturer_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Manufacturer $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||
{
|
||||
|
|
|
@ -69,8 +69,6 @@ class MeasurementUnitController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}", name="measurement_unit_delete", methods={"DELETE"})
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, MeasurementUnit $entity, StructuralElementRecursionHelper $recursionHelper): \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
{
|
||||
|
@ -80,8 +78,6 @@ class MeasurementUnitController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="measurement_unit_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(MeasurementUnit $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||
{
|
||||
|
|
|
@ -68,8 +68,6 @@ class StorelocationController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}", name="store_location_delete", methods={"DELETE"})
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, Storelocation $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
|
||||
{
|
||||
|
@ -79,8 +77,6 @@ class StorelocationController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="store_location_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Storelocation $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||
{
|
||||
|
|
|
@ -69,8 +69,6 @@ class SupplierController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}", name="supplier_delete", methods={"DELETE"})
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, Supplier $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
|
||||
{
|
||||
|
@ -80,8 +78,6 @@ class SupplierController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="supplier_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Supplier $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||
{
|
||||
|
|
|
@ -72,8 +72,6 @@ class TypeaheadController extends AbstractController
|
|||
|
||||
/**
|
||||
* @Route("/builtInResources/search", name="typeahead_builtInRessources")
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function builtInResources(Request $request, BuiltinAttachmentsFinder $finder): JsonResponse
|
||||
{
|
||||
|
@ -103,8 +101,6 @@ class TypeaheadController extends AbstractController
|
|||
|
||||
/**
|
||||
* @Route("/tags/search/{query}", name="typeahead_tags", requirements={"query"= ".+"})
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function tags(string $query, TagFinder $finder): JsonResponse
|
||||
{
|
||||
|
|
|
@ -97,8 +97,6 @@ class UserController extends AdminPages\BaseAdminController
|
|||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="user_edit")
|
||||
* @Route("/{id}/", requirements={"id"="\d+"})
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function edit(User $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||
|
@ -168,8 +166,6 @@ class UserController extends AdminPages\BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}", name="user_delete", methods={"DELETE"}, requirements={"id"="\d+"})
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, User $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
|
||||
{
|
||||
|
|
|
@ -93,6 +93,7 @@ class SecurityEventLogEntry extends AbstractLogEntry
|
|||
public function getEventType(): string
|
||||
{
|
||||
$key = $this->extra['e'];
|
||||
|
||||
return static::SECURITY_TYPE_MAPPING[$key] ?? 'unkown';
|
||||
}
|
||||
|
||||
|
|
|
@ -333,12 +333,12 @@ class EventLoggerSubscriber implements EventSubscriber
|
|||
//Restrict length of string fields, to save memory...
|
||||
$old_data = array_map(
|
||||
static function ($value) {
|
||||
if (is_string($value)) {
|
||||
return mb_strimwidth($value, 0, self::MAX_STRING_LENGTH, '...');
|
||||
}
|
||||
if (is_string($value)) {
|
||||
return mb_strimwidth($value, 0, self::MAX_STRING_LENGTH, '...');
|
||||
}
|
||||
|
||||
return $value;
|
||||
}, $old_data);
|
||||
return $value;
|
||||
}, $old_data);
|
||||
|
||||
$logEntry->setOldData($old_data);
|
||||
}
|
||||
|
|
|
@ -42,8 +42,6 @@ class SecurityEvent extends Event
|
|||
|
||||
/**
|
||||
* Returns the affected user.
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function getTargetUser(): User
|
||||
{
|
||||
|
|
|
@ -178,10 +178,10 @@ class AttachmentFormType extends AbstractType
|
|||
|
||||
if ($attachment instanceof Attachment && $file instanceof UploadedFile && $attachment->getAttachmentType(
|
||||
) && !$this->submitHandler->isValidFileExtension($attachment->getAttachmentType(), $file)) {
|
||||
$event->getForm()->get('file')->addError(
|
||||
$event->getForm()->get('file')->addError(
|
||||
new FormError($this->translator->trans('validator.file_ext_not_allowed'))
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Check the secure file checkbox, if file is in securefile location
|
||||
|
|
|
@ -119,7 +119,7 @@ final 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) :void
|
||||
public function mapFormsToData($forms, &$viewData): void
|
||||
{
|
||||
if ($this->inherit) {
|
||||
throw new RuntimeException('The permission type is readonly when it is showing read only data!');
|
||||
|
|
|
@ -83,13 +83,13 @@ class MasterPictureAttachmentType extends AbstractType
|
|||
'choice_loader' => static function (Options $options) {
|
||||
return new CallbackChoiceLoader(
|
||||
static function () use ($options) {
|
||||
$entity = $options['entity'];
|
||||
if (!$entity instanceof AttachmentContainingDBElement) {
|
||||
throw new \RuntimeException('$entity must have Attachments! (be of type AttachmentContainingDBElement)');
|
||||
}
|
||||
$entity = $options['entity'];
|
||||
if (!$entity instanceof AttachmentContainingDBElement) {
|
||||
throw new \RuntimeException('$entity must have Attachments! (be of type AttachmentContainingDBElement)');
|
||||
}
|
||||
|
||||
return $entity->getAttachments()->toArray();
|
||||
});
|
||||
return $entity->getAttachments()->toArray();
|
||||
});
|
||||
},
|
||||
]);
|
||||
|
||||
|
|
|
@ -166,9 +166,9 @@ class ElementPermissionListener
|
|||
|| !$this->isGranted('edit', $annotation, $element)) && isset(
|
||||
$old_data[$property->getName()]
|
||||
)) {
|
||||
$property->setValue($element, $old_data[$property->getName()]);
|
||||
$changed = true;
|
||||
}
|
||||
$property->setValue($element, $old_data[$property->getName()]);
|
||||
$changed = true;
|
||||
}
|
||||
|
||||
if ($changed) {
|
||||
//Schedule for update, so the post update method will be called
|
||||
|
|
|
@ -59,6 +59,7 @@ final class CustomEnvVarProcessor implements EnvVarProcessorInterface
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ class EntityExporter
|
|||
$disposition = $response->headers->makeDisposition(
|
||||
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
|
||||
$filename,
|
||||
$string = preg_replace('![^'.preg_quote('-','!').'a-z0-_9\s]+!', '', strtolower($filename))
|
||||
$string = preg_replace('![^'.preg_quote('-', '!').'a-z0-_9\s]+!', '', strtolower($filename))
|
||||
);
|
||||
// Set the content disposition
|
||||
$response->headers->set('Content-Disposition', $disposition);
|
||||
|
|
|
@ -151,7 +151,7 @@ class EntityImporter
|
|||
$tmp = $this->validator->validate($entity);
|
||||
|
||||
//When no validation error occured, persist entity to database (cascade must be set in entity)
|
||||
if ($tmp === null) {
|
||||
if (null === $tmp) {
|
||||
$this->em->persist($entity);
|
||||
} else { //Log validation errors to global log.
|
||||
$errors[$entity->getFullPath()] = $tmp;
|
||||
|
|
|
@ -75,8 +75,6 @@ final class LabelGenerator
|
|||
|
||||
/**
|
||||
* Check if the given LabelOptions can be used with $element.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function supports(LabelOptions $options, object $element): bool
|
||||
{
|
||||
|
|
|
@ -156,8 +156,8 @@ class TimeTravel
|
|||
$target_element,
|
||||
$timestamp
|
||||
) && $target_elements instanceof Collection) {
|
||||
$target_elements->removeElement($target_element);
|
||||
}
|
||||
$target_elements->removeElement($target_element);
|
||||
}
|
||||
$this->revertEntityToTimestamp($target_element, $timestamp, $reverted_elements);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,8 +64,6 @@ class MoneyFormatter
|
|||
* @param Currency|null $currency The currency that should be used for formatting. If null the global one is used
|
||||
* @param int $decimals the number of decimals that should be shown
|
||||
* @param bool $show_all_digits if set to true, all digits are shown, even if they are null
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function format($value, ?Currency $currency = null, $decimals = 5, bool $show_all_digits = false): string
|
||||
{
|
||||
|
|
|
@ -124,7 +124,7 @@ class TreeViewGenerator
|
|||
}
|
||||
|
||||
//Translate text if text starts with $$
|
||||
if (strpos($item->getText(), '$$') === 0) {
|
||||
if (0 === strpos($item->getText(), '$$')) {
|
||||
$item->setText($this->translator->trans(substr($item->getText(), 2)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,8 +94,8 @@ class NoLockoutValidator extends ConstraintValidator
|
|||
'users',
|
||||
'edit_permissions'
|
||||
) ?? false)) {
|
||||
$this->context->addViolation($constraint->message);
|
||||
}
|
||||
$this->context->addViolation($constraint->message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,8 +56,8 @@ class SelectableValidator extends ConstraintValidator
|
|||
/**
|
||||
* Checks if the passed value is valid.
|
||||
*
|
||||
* @param mixed $value The value that should be validated
|
||||
* @param Constraint $constraint The constraint for the validation
|
||||
* @param mixed $value The value that should be validated
|
||||
* @param Constraint $constraint The constraint for the validation
|
||||
*/
|
||||
public function validate($value, Constraint $constraint): void
|
||||
{
|
||||
|
|
|
@ -113,9 +113,9 @@ class ValidPartLotValidator extends ConstraintValidator
|
|||
if ($value->getStorageLocation()->isOnlySinglePart() && ($parts->count() > 0) && !$parts->contains(
|
||||
$value->getPart()
|
||||
)) {
|
||||
$this->context->buildViolation('validator.part_lot.single_part')
|
||||
$this->context->buildViolation('validator.part_lot.single_part')
|
||||
->atPath('storage_location')->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue