Fixed some inspection issues.

This commit is contained in:
Jan Böhmer 2020-08-21 22:43:37 +02:00
parent 6caf605fe2
commit e01b06fb85
80 changed files with 173 additions and 218 deletions

View file

@ -66,6 +66,7 @@ body {
/** Hide scrollbar in old Firefox and Edge **/
-ms-overflow-style: none;
overflow: -moz-scrollbars-none;
/*noinspection CssUnknownProperty*/
scrollbar-width: none;
}
@ -764,7 +765,6 @@ div.dataTables_wrapper div.dataTables_info {
margin-top: 4px;
padding: 4px 0;
background-color: #fff;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, 0.2);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
@ -805,7 +805,7 @@ div.dataTables_wrapper div.dataTables_info {
.markdown pre {
display: block;
padding: 9.5px;
padding: 10px;
margin: 0 0 10px;
font-size: 13px;
line-height: 1.42857143;
@ -825,7 +825,7 @@ div.dataTables_wrapper div.dataTables_info {
.markdown blockquote {
padding: 10px 10px;
margin: 0 0 10px;
font-size: 17.5px;
font-size: 18px;
border-left: 5px solid #aaa;
}

View file

@ -148,7 +148,7 @@ class CleanAttachmentsCommand extends Command
*
* @return bool
*/
protected function removeEmptySubFolders($path)
protected function removeEmptySubFolders($path): bool
{
$empty = true;
foreach (glob($path.DIRECTORY_SEPARATOR.'*') as $file) {

View file

@ -52,7 +52,7 @@ final class PermissionsConfiguration implements ConfigurationInterface
*
* @return TreeBuilder The tree builder
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('permissions');
$rootNode = $treeBuilder->getRootNode();

View file

@ -113,12 +113,10 @@ class AttachmentTypeController extends BaseAdminController
protected function deleteCheck(AbstractNamedDBElement $entity): bool
{
if ($entity instanceof AttachmentType) {
if ($entity->getAttachmentsForType()->count() > 0) {
$this->addFlash('error', 'entity.delete.must_not_contain_attachments');
if (($entity instanceof AttachmentType) && $entity->getAttachmentsForType()->count() > 0) {
$this->addFlash('error', 'entity.delete.must_not_contain_attachments');
return false;
}
return false;
}
return true;

View file

@ -192,7 +192,7 @@ abstract class BaseAdminController extends AbstractController
$form_options = [
'attachment_class' => $this->attachment_class,
'parameter_class' => $this->parameter_class,
'disabled' => null !== $timeTravel_timestamp ? true : false,
'disabled' => null !== $timeTravel_timestamp,
];
//Disable editing of options, if user is not allowed to use twig...
@ -476,7 +476,7 @@ abstract class BaseAdminController extends AbstractController
return $exporter->exportEntityFromRequest($entities, $request);
}
protected function _exportEntity(AbstractNamedDBElement $entity, EntityExporter $exporter, Request $request): \Symfony\Component\HttpFoundation\Response
protected function _exportEntity(AbstractNamedDBElement $entity, EntityExporter $exporter, Request $request): Response
{
$this->denyAccessUnlessGranted('read', $entity);

View file

@ -187,12 +187,10 @@ class CurrencyController extends BaseAdminController
public function deleteCheck(AbstractNamedDBElement $entity): bool
{
if ($entity instanceof Currency) {
if ($entity->getPricedetails()->count() > 0) {
$this->addFlash('error', 'entity.delete.must_not_contain_prices');
if (($entity instanceof Currency) && $entity->getPricedetails()->count() > 0) {
$this->addFlash('error', 'entity.delete.must_not_contain_prices');
return false;
}
return false;
}
return true;

View file

@ -82,7 +82,7 @@ class ManufacturerController extends BaseAdminController
*
* @return Response
*/
public function edit(Manufacturer $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null)
public function edit(Manufacturer $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
{
return $this->_edit($entity, $request, $em, $timestamp);
}

View file

@ -72,7 +72,7 @@ class MeasurementUnitController extends BaseAdminController
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function delete(Request $request, MeasurementUnit $entity, StructuralElementRecursionHelper $recursionHelper)
public function delete(Request $request, MeasurementUnit $entity, StructuralElementRecursionHelper $recursionHelper): \Symfony\Component\HttpFoundation\RedirectResponse
{
return $this->_delete($request, $entity, $recursionHelper);
}
@ -83,7 +83,7 @@ class MeasurementUnitController extends BaseAdminController
*
* @return Response
*/
public function edit(MeasurementUnit $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null)
public function edit(MeasurementUnit $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
{
return $this->_edit($entity, $request, $em, $timestamp);
}

View file

@ -49,6 +49,7 @@ use App\Services\EntityExporter;
use App\Services\EntityImporter;
use App\Services\StructuralElementRecursionHelper;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@ -70,7 +71,7 @@ class StorelocationController extends BaseAdminController
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function delete(Request $request, Storelocation $entity, StructuralElementRecursionHelper $recursionHelper)
public function delete(Request $request, Storelocation $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
{
return $this->_delete($request, $entity, $recursionHelper);
}
@ -81,7 +82,7 @@ class StorelocationController extends BaseAdminController
*
* @return Response
*/
public function edit(Storelocation $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null)
public function edit(Storelocation $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
{
return $this->_edit($entity, $request, $em, $timestamp);
}

View file

@ -50,6 +50,7 @@ use App\Services\EntityExporter;
use App\Services\EntityImporter;
use App\Services\StructuralElementRecursionHelper;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@ -71,7 +72,7 @@ class SupplierController extends BaseAdminController
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function delete(Request $request, Supplier $entity, StructuralElementRecursionHelper $recursionHelper)
public function delete(Request $request, Supplier $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
{
return $this->_delete($request, $entity, $recursionHelper);
}
@ -82,7 +83,7 @@ class SupplierController extends BaseAdminController
*
* @return Response
*/
public function edit(Supplier $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null)
public function edit(Supplier $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
{
return $this->_edit($entity, $request, $em, $timestamp);
}

View file

@ -114,12 +114,10 @@ class GroupController extends BaseAdminController
public function deleteCheck(AbstractNamedDBElement $entity): bool
{
if ($entity instanceof Group) {
if ($entity->getUsers()->count() > 0) {
$this->addFlash('error', 'entity.delete.must_not_contain_users');
if (($entity instanceof Group) && $entity->getUsers()->count() > 0) {
$this->addFlash('error', 'entity.delete.must_not_contain_users');
return false;
}
return false;
}
return true;

View file

@ -34,9 +34,9 @@ use App\Services\LabelSystem\LabelGenerator;
use App\Services\Misc\RangeParser;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -65,7 +65,7 @@ class LabelController extends AbstractController
* @Route("/dialog", name="label_dialog")
* @Route("/{profile}/dialog", name="label_dialog_profile")
*/
public function generator(Request $request, ?LabelProfile $profile = null)
public function generator(Request $request, ?LabelProfile $profile = null): Response
{
$this->denyAccessUnlessGranted('@labels.create_labels');

View file

@ -75,7 +75,7 @@ class TypeaheadController extends AbstractController
*
* @return JsonResponse
*/
public function builtInResources(Request $request, BuiltinAttachmentsFinder $finder)
public function builtInResources(Request $request, BuiltinAttachmentsFinder $finder): JsonResponse
{
$query = $request->get('query');
$array = $finder->find($query);
@ -106,7 +106,7 @@ class TypeaheadController extends AbstractController
*
* @return JsonResponse
*/
public function tags(string $query, TagFinder $finder)
public function tags(string $query, TagFinder $finder): JsonResponse
{
$array = $finder->searchTags($query);

View file

@ -58,6 +58,7 @@ use InvalidArgumentException;
use Omines\DataTablesBundle\DataTableFactory;
use Symfony\Component\Asset\Packages;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@ -100,7 +101,7 @@ class UserController extends AdminPages\BaseAdminController
*
* @throws \Exception
*/
public function edit(User $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null)
public function edit(User $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
{
//Handle 2FA disabling
@ -170,7 +171,7 @@ class UserController extends AdminPages\BaseAdminController
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function delete(Request $request, User $entity, StructuralElementRecursionHelper $recursionHelper)
public function delete(Request $request, User $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
{
if (User::ID_ANONYMOUS === $entity->getID()) {
throw new InvalidArgumentException('You can not delete the anonymous user! It is needed for permission checking without a logged in user');

View file

@ -153,7 +153,7 @@ class FetchJoinORMAdapter extends ORMAdapter
$query->setIdentifierPropertyPath($this->mapFieldToPropertyPath($identifier, $aliases));
}
protected function getSimpleTotalCount(QueryBuilder $queryBuilder)
protected function getSimpleTotalCount(QueryBuilder $queryBuilder): int
{
/** The paginator count queries can be rather slow, so when query for total count (100ms or longer),
* just return the entity count.

View file

@ -191,8 +191,8 @@ class ORMAdapter extends AbstractAdapter
;
}
$query = $builder->getQuery();
$event = new ORMAdapterQueryEvent($query);
$q = $builder->getQuery();
$event = new ORMAdapterQueryEvent($q);
$state->getDataTable()->getEventDispatcher()->dispatch($event, ORMAdapterEvents::PRE_QUERY);
foreach ($query->iterate([], $this->hydrationMode) as $result) {
@ -301,7 +301,7 @@ class ORMAdapter extends AbstractAdapter
->setDefaults([
'hydrate' => Query::HYDRATE_OBJECT,
'query' => [],
'criteria' => function (Options $options) {
'criteria' => static function (Options $options) {
return [new SearchCriteriaProvider()];
},
])
@ -324,7 +324,9 @@ class ORMAdapter extends AbstractAdapter
{
if ($provider instanceof QueryBuilderProcessorInterface) {
return $provider;
} elseif (is_callable($provider)) {
}
if (is_callable($provider)) {
return new class($provider) implements QueryBuilderProcessorInterface {
private $callable;

View file

@ -79,7 +79,7 @@ class EntityColumn extends AbstractColumn
$resolver->setRequired('property');
$resolver->setDefault('field', function (Options $option) {
$resolver->setDefault('field', static function (Options $option) {
return $option['property'].'.name';
});

View file

@ -78,7 +78,7 @@ class IconLinkColumn extends AbstractColumn
return $provider;
}
if (is_callable($provider)) {
return call_user_func($provider, $value, $context);
return $provider($value, $context);
}
return false;
@ -91,7 +91,7 @@ class IconLinkColumn extends AbstractColumn
return $provider;
}
if (is_callable($provider)) {
return call_user_func($provider, $value, $context);
return $provider($value, $context);
}
return null;
@ -104,7 +104,7 @@ class IconLinkColumn extends AbstractColumn
return $provider;
}
if (is_callable($provider)) {
return call_user_func($provider, $value, $context);
return $provider($value, $context);
}
return null;
@ -117,7 +117,7 @@ class IconLinkColumn extends AbstractColumn
return $provider;
}
if (is_callable($provider)) {
return call_user_func($provider, $value, $context);
return $provider($value, $context);
}
return null;

View file

@ -102,7 +102,7 @@ class LogDataTable implements DataTableTypeInterface
$optionsResolver->setAllowedTypes('filter_elements', ['array', 'object']);
$optionsResolver->setAllowedTypes('mode', 'string');
$optionsResolver->setNormalizer('filter_elements', function (Options $options, $value) {
$optionsResolver->setNormalizer('filter_elements', static function (Options $options, $value) {
if (!is_array($value)) {
return [$value];
}
@ -121,7 +121,7 @@ class LogDataTable implements DataTableTypeInterface
$dataTable->add('symbol', TextColumn::class, [
'label' => '',
'render' => function ($value, AbstractLogEntry $context) {
'render' => static function ($value, AbstractLogEntry $context) {
switch ($context->getLevelString()) {
case LogLevel::DEBUG:
$symbol = 'fa-bug';
@ -191,7 +191,7 @@ class LogDataTable implements DataTableTypeInterface
'label' => $this->translator->trans('log.level'),
'visible' => 'system_log' === $options['mode'],
'propertyPath' => 'levelString',
'render' => function (string $value, AbstractLogEntry $context) {
'render' => static function (string $value, AbstractLogEntry $context) {
return $value;
},
]);

View file

@ -118,7 +118,7 @@ final class PartsDataTable implements DataTableTypeInterface
$optionsResolver->setAllowedTypes('search', ['null', 'string']);
//Configure search options
$optionsResolver->setDefault('search_options', function (OptionsResolver $resolver): void {
$optionsResolver->setDefault('search_options', static function (OptionsResolver $resolver): void {
$resolver->setDefaults([
'name' => true,
'category' => true,

View file

@ -92,7 +92,7 @@ class LabelProfile extends AttachmentContainingDBElement
return $this->comment;
}
public function setComment(string $new_comment): string
public function setComment(string $new_comment): self
{
$this->comment = $new_comment;

View file

@ -93,11 +93,7 @@ class SecurityEventLogEntry extends AbstractLogEntry
public function getEventType(): string
{
$key = $this->extra['e'];
if (isset(static::SECURITY_TYPE_MAPPING[$key])) {
return static::SECURITY_TYPE_MAPPING[$key];
}
return 'unkown';
return static::SECURITY_TYPE_MAPPING[$key] ?? 'unkown';
}
/**

View file

@ -41,7 +41,7 @@ trait ParametersTrait
*
* @psalm-return Collection<int, PartParameter>
*/
public function getParameters(): \Doctrine\Common\Collections\Collection
public function getParameters(): Collection
{
return $this->parameters;
}

View file

@ -331,7 +331,8 @@ class EventLoggerSubscriber implements EventSubscriber
$old_data = $this->filterFieldRestrictions($entity, $old_data);
//Restrict length of string fields, to save memory...
$old_data = array_map(function ($value) {
$old_data = array_map(
static function ($value) {
if (is_string($value)) {
return mb_strimwidth($value, 0, self::MAX_STRING_LENGTH, '...');
}
@ -350,10 +351,6 @@ class EventLoggerSubscriber implements EventSubscriber
protected function validEntity(object $entity): bool
{
//Dont log logentries itself!
if ($entity instanceof AbstractDBElement && !$entity instanceof AbstractLogEntry) {
return true;
}
return false;
return $entity instanceof AbstractDBElement && !$entity instanceof AbstractLogEntry;
}
}

View file

@ -46,7 +46,7 @@ final class SecurityEventLoggerSubscriber implements EventSubscriberInterface
$this->eventLogger = $eventLogger;
}
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
SecurityEvents::U2F_ADDED => 'u2f_added',

View file

@ -71,7 +71,7 @@ final class SetMailFromSubscriber implements EventSubscriberInterface
}
}
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
// should be the last one to allow header changes by other listeners first

View file

@ -75,7 +75,7 @@ final class SymfonyDebugToolbarSubscriber implements EventSubscriberInterface
*
* @return array The event names to listen to
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return ['kernel.response' => 'onKernelResponse'];
}

View file

@ -102,7 +102,7 @@ final class LoginSuccessSubscriber implements EventSubscriberInterface
*
* @return array The event names to listen to
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [SecurityEvents::INTERACTIVE_LOGIN => 'onLogin'];
}

View file

@ -94,7 +94,7 @@ final class LogoutDisabledUserSubscriber implements EventSubscriberInterface
*
* @return array The event names to listen to
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [KernelEvents::REQUEST => 'onRequest'];
}

View file

@ -147,14 +147,10 @@ final class PasswordChangeNeededSubscriber implements EventSubscriberInterface
{
$tfa_enabled = $user->isU2FAuthEnabled() || $user->isGoogleAuthenticatorEnabled();
if (null !== $user->getGroup() && $user->getGroup()->isEnforce2FA() && !$tfa_enabled) {
return true;
}
return false;
return null !== $user->getGroup() && $user->getGroup()->isEnforce2FA() && !$tfa_enabled;
}
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
KernelEvents::REQUEST => 'redirectToSettingsIfNeeded',

View file

@ -101,7 +101,7 @@ final class SetUserTimezoneSubscriber implements EventSubscriberInterface
*
* @return array The event names to listen to
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
//Set the timezone shortly before executing the controller
return [

View file

@ -45,7 +45,7 @@ class SecurityEvent extends Event
*
* @return User
*/
public function getTargetUser()
public function getTargetUser(): User
{
return $this->targetUser;
}

View file

@ -76,7 +76,7 @@ class AttachmentTypeAdminForm extends BaseEntityAdminForm
//Normalize data before writing it to database
$builder->get('filetype_filter')->addViewTransformer(new CallbackTransformer(
function ($value) {
static function ($value) {
return $value;
},
function ($value) {

View file

@ -176,19 +176,18 @@ class AttachmentFormType extends AbstractType
$file_form = $form->get('file');
$file = $file_form->getData();
if ($attachment instanceof Attachment && $file instanceof UploadedFile && $attachment->getAttachmentType()) {
if (!$this->submitHandler->isValidFileExtension($attachment->getAttachmentType(), $file)) {
if ($attachment instanceof Attachment && $file instanceof UploadedFile && $attachment->getAttachmentType(
) && !$this->submitHandler->isValidFileExtension($attachment->getAttachmentType(), $file)) {
$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
$builder->get('secureFile')->addEventListener(
FormEvents::PRE_SET_DATA,
function (FormEvent $event): void {
static function (FormEvent $event): void {
$attachment = $event->getForm()->getParent()->getData();
if ($attachment instanceof Attachment) {
$event->setData($attachment->isSecure());

View file

@ -32,7 +32,6 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormConfigBuilder;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;

View file

@ -83,7 +83,7 @@ class LabelOptionsType extends AbstractType
'label_options.barcode_type.code93' => 'code93',
'label_options.barcode_type.datamatrix' => 'datamatrix',
],
'group_by' => function ($choice, $key, $value) {
'group_by' => static function ($choice, $key, $value) {
if (in_array($choice, ['qr', 'datamatrix'], true)) {
return 'label_options.barcode_type.2D';
}

View file

@ -42,7 +42,6 @@ declare(strict_types=1);
namespace App\Form\Part;
use App\Entity\Attachments\Attachment;
use App\Entity\Attachments\PartAttachment;
use App\Entity\Parameters\PartParameter;
use App\Entity\Parts\Category;

View file

@ -69,11 +69,8 @@ class PermissionGroupType extends AbstractType
if ($permission['group'] !== $options['group_name']) {
continue;
}
} else {
//Skip perrmissions without groups unless we have this as blanko group
if ('*' !== $options['group_name']) {
continue;
}
} elseif ('*' !== $options['group_name']) {
continue;
}
$builder->add($key, PermissionType::class, [
@ -91,7 +88,7 @@ class PermissionGroupType extends AbstractType
{
parent::configureOptions($resolver);
$resolver->setDefault('group_name', function (Options $options) {
$resolver->setDefault('group_name', static function (Options $options) {
return trim($options['name']);
});

View file

@ -66,7 +66,7 @@ class PermissionType extends AbstractType
{
parent::configureOptions($resolver);
$resolver->setDefault('perm_name', function (Options $options) {
$resolver->setDefault('perm_name', static function (Options $options) {
return $options['name'];
});
@ -78,7 +78,7 @@ class PermissionType extends AbstractType
return $options['name'];
});
$resolver->setDefault('multi_checkbox', function (Options $options) {
$resolver->setDefault('multi_checkbox', static function (Options $options) {
return !$options['disabled'];
});

View file

@ -72,7 +72,7 @@ final class PermissionsMapper implements DataMapperInterface
* @param mixed $viewData View data of the compound form being initialized
* @param FormInterface[]|Traversable $forms A list of {@link FormInterface} instances
*/
public function mapDataToForms($viewData, $forms): void
public function mapDataToForms($viewData, $forms)
{
foreach ($forms as $form) {
if ($this->inherit) {
@ -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!');

View file

@ -66,7 +66,7 @@ class PermissionsType extends AbstractType
{
$resolver->setDefaults([
'show_legend' => true,
'constraints' => function (Options $options) {
'constraints' => static function (Options $options) {
if (!$options['disabled']) {
return [new NoLockout()];
}

View file

@ -46,7 +46,6 @@ use App\Entity\UserSystem\User;
use App\Validator\Constraints\ValidGoogleAuthCode;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\ResetType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
@ -64,7 +63,7 @@ class TFAGoogleSettingsType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void {
$builder->addEventListener(FormEvents::PRE_SET_DATA, static function (FormEvent $event): void {
$form = $event->getForm();
/** @var User $user */
$user = $event->getData();

View file

@ -65,8 +65,8 @@ class MasterPictureAttachmentType extends AbstractType
'class' => 'selectpicker',
'title' => 'selectpicker.nothing_selected',
],
'choice_attr' => function (Options $options) {
return function ($choice, $key, $value) use ($options) {
'choice_attr' => static function (Options $options) {
return static function ($choice, $key, $value) use ($options) {
/** @var Attachment $choice */
$tmp = ['data-subtext' => $choice->getFilename() ?? 'URL'];
@ -80,8 +80,9 @@ class MasterPictureAttachmentType extends AbstractType
};
},
'choice_label' => 'name',
'choice_loader' => function (Options $options) {
return new CallbackChoiceLoader(function () use ($options) {
'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)');

View file

@ -69,7 +69,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
{
$resolver->setDefaults([
'measurement_unit' => null,
'show_prefix' => function (Options $options) {
'show_prefix' => static function (Options $options) {
if (null !== $options['measurement_unit']) {
/** @var MeasurementUnit $unit */
$unit = $options['measurement_unit'];
@ -79,7 +79,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
return false;
},
'is_integer' => function (Options $options) {
'is_integer' => static function (Options $options) {
if (null !== $options['measurement_unit']) {
/** @var MeasurementUnit $unit */
$unit = $options['measurement_unit'];
@ -89,7 +89,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
return false;
},
'unit' => function (Options $options) {
'unit' => static function (Options $options) {
if (null !== $options['measurement_unit']) {
/** @var MeasurementUnit $unit */
$unit = $options['measurement_unit'];
@ -111,7 +111,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
$resolver->setDefaults([
'min' => 0,
'max' => '',
'step' => function (Options $options) {
'step' => static function (Options $options) {
if (true === $options['is_integer']) {
return 1;
}
@ -185,7 +185,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
$forms['prefix']->setData(0);
}
return null;
return;
}
$data = $this->si_formatter->convertValue((float) $viewData);

View file

@ -44,13 +44,11 @@ namespace App\Form\Type;
use App\Entity\Attachments\AttachmentType;
use App\Entity\Base\AbstractStructuralDBElement;
use App\Repository\StructuralDBElementRepository;
use App\Services\Trees\NodesListBuilder;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader;
use Symfony\Component\Form\Exception;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
@ -58,7 +56,6 @@ use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Choice;
/**
* This class provides a choice form type similar to EntityType, with the difference, that the tree structure
@ -117,7 +114,7 @@ class StructuralEntityType extends AbstractType
$resolver->setDefault('empty_message', null);
$resolver->setDefault('attr', function (Options $options) {
$resolver->setDefault('attr', static function (Options $options) {
$tmp = [
'class' => 'selectpicker',
'data-live-search' => true,

View file

@ -49,7 +49,6 @@ use App\Entity\UserSystem\User;
use App\Form\Permissions\PermissionsType;
use App\Form\Type\CurrencyEntityType;
use App\Form\Type\StructuralEntityType;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@ -174,7 +173,7 @@ class UserAdminForm extends AbstractType
->add('theme', ChoiceType::class, [
'required' => false,
'choices' => User::AVAILABLE_THEMES,
'choice_label' => function ($entity, $key, $value) {
'choice_label' => static function ($entity, $key, $value) {
return $value;
},
'attr' => [

View file

@ -124,7 +124,7 @@ class UserSettingsType extends AbstractType
],
'choice_translation_domain' => false,
'choices' => User::AVAILABLE_THEMES,
'choice_label' => function ($entity, $key, $value) {
'choice_label' => static function ($entity, $key, $value) {
return $value;
},
'placeholder' => 'user_settings.theme.placeholder',

View file

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace App\Helpers;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@ -62,7 +61,7 @@ class LabelResponse extends Response
/**
* Automatically sets the Last-Modified header according the file modification date.
*/
public function setAutoLastModified()
public function setAutoLastModified(): LabelResponse
{
$this->setLastModified(new \DateTime());
@ -72,7 +71,7 @@ class LabelResponse extends Response
/**
* Automatically sets the ETag header according to the checksum of the file.
*/
public function setAutoEtag()
public function setAutoEtag(): LabelResponse
{
$this->setEtag(base64_encode(hash('sha256', $this->content, true)));
@ -88,7 +87,7 @@ class LabelResponse extends Response
*
* @return $this
*/
public function setContentDisposition($disposition, $filename, $filenameFallback = '')
public function setContentDisposition($disposition, $filename, $filenameFallback = ''): self
{
if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || false !== strpos($filename, '%'))) {
$encoding = mb_detect_encoding($filename, null, true) ?: '8bit';

View file

@ -54,7 +54,7 @@ final class StructuralDBElementIterator extends ArrayIterator implements Recursi
parent::__construct($nodes);
}
public function hasChildren()
public function hasChildren(): bool
{
/** @var AbstractStructuralDBElement $element */
$element = $this->current();

View file

@ -55,7 +55,7 @@ final class TreeViewNodeIterator extends ArrayIterator implements RecursiveItera
parent::__construct($nodes);
}
public function hasChildren()
public function hasChildren(): bool
{
/** @var TreeViewNode $element */
$element = $this->current();

View file

@ -52,7 +52,6 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Event\PreFlushEventArgs;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\PostLoad;
use Doctrine\ORM\Mapping\PreUpdate;
use function get_class;
use InvalidArgumentException;
use ReflectionClass;
@ -162,14 +161,14 @@ class ElementPermissionListener
$property->setAccessible(true);
//If the user is not allowed to edit or read this property, reset all values.
//Set value to old value, so that there a no change to this property
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()])) {
|| !$this->isGranted('edit', $annotation, $element)) && 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
@ -184,13 +183,9 @@ class ElementPermissionListener
*
* @return bool Returns true if the current programm is running from CLI (terminal)
*/
protected function isRunningFromCLI()
protected function isRunningFromCLI(): bool
{
if (empty($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['HTTP_USER_AGENT']) && count($_SERVER['argv']) > 0) {
return true;
}
return false;
return empty($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['HTTP_USER_AGENT']) && count($_SERVER['argv']) > 0;
}
/**

View file

@ -66,7 +66,7 @@ abstract class ExtendedVoter extends Voter
$this->entityManager = $entityManager;
}
final protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
final protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
$user = $token->getUser();

View file

@ -44,7 +44,6 @@ namespace App\Security\Voter;
use App\Entity\Parts\Part;
use App\Entity\UserSystem\User;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
/**
* A Voter that votes on Part entities.

View file

@ -76,16 +76,14 @@ class UserVoter extends ExtendedVoter
*/
protected function voteOnUser($attribute, $subject, User $user): bool
{
if ($subject instanceof User) {
//Check if the checked user is the user itself
if ($subject->getID() === $user->getID() &&
$this->resolver->isValidOperation('self', $attribute)) {
//Then we also need to check the self permission
$tmp = $this->resolver->inherit($user, 'self', $attribute) ?? false;
//But if the self value is not allowed then use just the user value:
if ($tmp) {
return $tmp;
}
//Check if the checked user is the user itself
if (($subject instanceof User) && $subject->getID() === $user->getID() &&
$this->resolver->isValidOperation('self', $attribute)) {
//Then we also need to check the self permission
$tmp = $this->resolver->inherit($user, 'self', $attribute) ?? false;
//But if the self value is not allowed then use just the user value:
if ($tmp) {
return $tmp;
}
}

View file

@ -70,7 +70,7 @@ class AmountFormatter
*
* @throws InvalidArgumentException thrown if $value is not numeric
*/
public function format($value, ?MeasurementUnit $unit = null, array $options = [])
public function format($value, ?MeasurementUnit $unit = null, array $options = []): string
{
if (!is_numeric($value)) {
throw new InvalidArgumentException('$value must be an numeric value!');
@ -106,7 +106,7 @@ class AmountFormatter
protected function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'show_prefix' => function (Options $options) {
'show_prefix' => static function (Options $options) {
if (null !== $options['measurement_unit']) {
/** @var MeasurementUnit $unit */
$unit = $options['measurement_unit'];
@ -116,7 +116,7 @@ class AmountFormatter
return false;
},
'is_integer' => function (Options $options) {
'is_integer' => static function (Options $options) {
if (null !== $options['measurement_unit']) {
/** @var MeasurementUnit $unit */
$unit = $options['measurement_unit'];
@ -126,7 +126,7 @@ class AmountFormatter
return true;
},
'unit' => function (Options $options) {
'unit' => static function (Options $options) {
if (null !== $options['measurement_unit']) {
/** @var MeasurementUnit $unit */
$unit = $options['measurement_unit'];
@ -144,7 +144,7 @@ class AmountFormatter
$resolver->setAllowedTypes('decimals', 'int');
$resolver->setNormalizer('decimals', function (Options $options, $value) {
$resolver->setNormalizer('decimals', static function (Options $options, $value) {
// If the unit is integer based, then dont show any decimals
if ($options['is_integer']) {
return 0;

View file

@ -48,7 +48,6 @@ use Doctrine\ORM\EntityManagerInterface;
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
use SplFileInfo;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\File\File;
/**
* This service provides functions to find attachments via an reverse search based on a file.

View file

@ -92,7 +92,7 @@ class FileTypeFilterTools
foreach ($elements as $element) {
$element = trim($element);
if (!preg_match('#^\.\w+$#', $element) // .ext is allowed
&& !preg_match('#^[-\w.]+\/[-\w.]+#', $element) //Explicit MIME type is allowed
&& !preg_match('#^[-\w.]+/[-\w.]+#', $element) //Explicit MIME type is allowed
&& !in_array($element, static::ALLOWED_MIME_PLACEHOLDERS, false)) { //image/* is allowed
return false;
}
@ -139,7 +139,7 @@ class FileTypeFilterTools
$element = 'video/*';
} elseif ('audio' === $element || 'audio/' === $element) {
$element = 'audio/*';
} elseif (!preg_match('#^[-\w.]+\/[-\w.*]+#', $element) && 0 !== strpos($element, '.')) {
} elseif (!preg_match('#^[-\w.]+/[-\w.*]+#', $element) && 0 !== strpos($element, '.')) {
//Convert jpg to .jpg
$element = '.'.$element;
}
@ -176,7 +176,7 @@ class FileTypeFilterTools
$extensions = array_merge($extensions, static::AUDIO_EXTS);
} elseif ('video/*' === $element) {
$extensions = array_merge($extensions, static::VIDEO_EXTS);
} elseif (preg_match('#^[-\w.]+\/[-\w.*]+#', $element)) {
} elseif (preg_match('#^[-\w.]+/[-\w.*]+#', $element)) {
$extensions = array_merge($extensions, $this->mimeTypes->getExtensions($element));
}
}

View file

@ -59,9 +59,10 @@ final class CustomEnvVarProcessor implements EnvVarProcessorInterface
return false;
}
}
return false;
}
public static function getProvidedTypes()
public static function getProvidedTypes(): array
{
return [
'validMailDSN' => 'bool',

View file

@ -51,13 +51,6 @@ use ReflectionException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\Serializer\Encoder\CsvEncoder;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Encoder\XmlEncoder;
use Symfony\Component\Serializer\Encoder\YamlEncoder;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\SerializerInterface;
/**
@ -166,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);

View file

@ -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 (empty($tmp)) {
if ($tmp === null) {
$this->em->persist($entity);
} else { //Log validation errors to global log.
$errors[$entity->getFullPath()] = $tmp;

View file

@ -58,7 +58,7 @@ class GitVersionInfo
*
* @return string|null The current git branch name. Null, if this is no Git installation
*/
public function getGitBranchName()
public function getGitBranchName(): ?string
{
if (is_file($this->project_dir.'/.git/HEAD')) {
$git = file($this->project_dir.'/.git/HEAD');
@ -83,7 +83,7 @@ class GitVersionInfo
*
* @return string|null The hash of the last commit, null If this is no Git installation
*/
public function getGitCommitHash(int $length = 7)
public function getGitCommitHash(int $length = 7): ?string
{
$filename = $this->project_dir.'/.git/refs/remotes/origin/'.$this->getGitBranchName();
if (is_file($filename)) {

View file

@ -78,7 +78,7 @@ final class LabelGenerator
*
* @return bool
*/
public function supports(LabelOptions $options, object $element)
public function supports(LabelOptions $options, object $element): bool
{
$supported_type = $options->getSupportedElement();
if (!isset(static::CLASS_SUPPORT_MAPPING[$supported_type])) {

View file

@ -68,7 +68,7 @@ final class LabelHTMLGenerator
$page = 1;
foreach ($elements as $element) {
if ('twig' === $options->getLinesMode() && isset($sandboxed_twig) && isset($current_user)) {
if (isset($sandboxed_twig, $current_user) && 'twig' === $options->getLinesMode()) {
try {
$lines = $sandboxed_twig->render(
'lines',
@ -103,7 +103,7 @@ final class LabelHTMLGenerator
]);
}
private function getPDFTitle(LabelOptions $options, object $element)
private function getPDFTitle(LabelOptions $options, object $element): string
{
if ($element instanceof NamedElementInterface) {
return $this->elementTypeNameGenerator->getTypeNameCombination($element, false);

View file

@ -44,7 +44,7 @@ final class PartLotProvider implements PlaceholderProviderInterface
{
if ($label_target instanceof PartLot) {
if ('[[LOT_ID]]' === $placeholder) {
return $label_target->getID() ?? 'unknown';
return (string) ($label_target->getID() ?? 'unknown');
}
if ('[[LOT_NAME]]' === $placeholder) {

View file

@ -147,13 +147,11 @@ class LogEntryExtraFormatter
);
}
if ($context instanceof LogWithEventUndoInterface) {
if ($context->isUndoEvent()) {
if ('undo' === $context->getUndoMode()) {
$array['log.undo_mode.undo'] = (string) $context->getUndoEventID();
} elseif ('revert' === $context->getUndoMode()) {
$array['log.undo_mode.revert'] = (string) $context->getUndoEventID();
}
if (($context instanceof LogWithEventUndoInterface) && $context->isUndoEvent()) {
if ('undo' === $context->getUndoMode()) {
$array['log.undo_mode.undo'] = (string) $context->getUndoEventID();
} elseif ('revert' === $context->getUndoMode()) {
$array['log.undo_mode.revert'] = (string) $context->getUndoEventID();
}
}
@ -192,7 +190,7 @@ class LogEntryExtraFormatter
$array['log.collection_deleted.deleted'] = sprintf(
'%s: %s (%s)',
$this->elementTypeNameGenerator->getLocalizedTypeLabel($context->getDeletedElementClass()),
$context->getOldName() ?? $context->getDeletedElementID(),
$context->getOldName() ?? (string) $context->getDeletedElementID(),
$context->getCollectionName()
);
}

View file

@ -152,11 +152,12 @@ class TimeTravel
foreach ($target_elements as $target_element) {
if (null !== $target_element && $element->getLastModified() >= $timestamp) {
//Remove the element from collection, if it did not existed at $timestamp
if (!$this->repo->getElementExistedAtTimestamp($target_element, $timestamp)) {
if ($target_elements instanceof Collection) {
if (!$this->repo->getElementExistedAtTimestamp(
$target_element,
$timestamp
) && $target_elements instanceof Collection) {
$target_elements->removeElement($target_element);
}
}
$this->revertEntityToTimestamp($target_element, $timestamp, $reverted_elements);
}
}
@ -183,11 +184,9 @@ class TimeTravel
foreach ($old_data as $field => $data) {
if ($metadata->hasField($field)) {
if ('big_decimal' === $metadata->getFieldMapping($field)['type']) {
//We need to convert the string to a BigDecimal first
if (!$data instanceof BigDecimal) {
$data = BigDecimal::of($data);
}
//We need to convert the string to a BigDecimal first
if (!$data instanceof BigDecimal && ('big_decimal' === $metadata->getFieldMapping($field)['type'])) {
$data = BigDecimal::of($data);
}
$this->setField($element, $field, $data);

View file

@ -67,7 +67,7 @@ class MoneyFormatter
*
* @return string
*/
public function format($value, ?Currency $currency = null, $decimals = 5, bool $show_all_digits = false)
public function format($value, ?Currency $currency = null, $decimals = 5, bool $show_all_digits = false): string
{
$iso_code = $this->base_currency;
if (null !== $currency && !empty($currency->getIsoCode())) {

View file

@ -85,7 +85,7 @@ class PricedetailHelper
} else {
// We have to sort the pricedetails manually
$array = $pricedetails->map(
function (Pricedetail $pricedetail) {
static function (Pricedetail $pricedetail) {
return $pricedetail->getMinDiscountQuantity();
}
)->toArray();

View file

@ -66,7 +66,7 @@ class TagFinder
*
* @return string[] an array containing the tags that match the given keyword
*/
public function searchTags(string $keyword, array $options = [])
public function searchTags(string $keyword, array $options = []): array
{
$results = [];
$keyword_regex = '/^'.preg_quote($keyword, '/').'/';

View file

@ -124,7 +124,7 @@ class TreeViewGenerator
}
//Translate text if text starts with $$
if ('$$' === substr($item->getText(), 0, 2)) {
if (strpos($item->getText(), '$$') === 0) {
$item->setText($this->translator->trans(substr($item->getText(), 2)));
}
}

View file

@ -111,7 +111,7 @@ class AppExtension extends AbstractExtension
public function getTests()
{
return [
new TwigTest('instanceof', function ($var, $instance) {
new TwigTest('instanceof', static function ($var, $instance) {
return $var instanceof $instance;
}),
];
@ -150,7 +150,7 @@ class AppExtension extends AbstractExtension
return $this->entityURLGenerator->getURL($entity, $method);
}
public function formatCurrency($amount, ?Currency $currency = null, int $decimals = 5)
public function formatCurrency($amount, ?Currency $currency = null, int $decimals = 5): string
{
if ($amount instanceof BigDecimal) {
$amount = (string) $amount;
@ -159,12 +159,12 @@ class AppExtension extends AbstractExtension
return $this->moneyFormatter->format($amount, $currency, $decimals);
}
public function siFormat($value, $unit, $decimals = 2, bool $show_all_digits = false)
public function siFormat($value, $unit, $decimals = 2, bool $show_all_digits = false): string
{
return $this->siformatter->format($value, $unit, $decimals, $show_all_digits);
return $this->siformatter->format($value, $unit, $decimals);
}
public function amountFormat($value, ?MeasurementUnit $unit, array $options = [])
public function amountFormat($value, ?MeasurementUnit $unit, array $options = []): string
{
return $this->amountFormatter->format($value, $unit, $options);
}

View file

@ -29,7 +29,7 @@ class BarcodeExtension extends AbstractExtension
public function getFilters()
{
return [
new TwigFilter('barcodeSVG', function (string $content, string $type = 'QRCODE') {
new TwigFilter('barcodeSVG', static function (string $content, string $type = 'QRCODE') {
$barcodeFactory = new Barcode();
$barcode = $barcodeFactory->getBarcodeObj($type, $content);

View file

@ -60,7 +60,8 @@ final class InheritanceSecurityPolicy implements SecurityPolicyInterface
{
$this->allowedMethods = [];
foreach ($methods as $class => $m) {
$this->allowedMethods[$class] = array_map(function ($value) { return strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); }, \is_array($m) ? $m : [$m]);
$this->allowedMethods[$class] = array_map(
static function ($value) { return strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); }, \is_array($m) ? $m : [$m]);
}
}

View file

@ -15,7 +15,7 @@ final class TypeLabelExtension extends AbstractExtension
$this->nameGenerator = $elementTypeNameGenerator;
}
public function getFunctions()
public function getFunctions(): array
{
return [
new TwigFunction('elementType', [$this->nameGenerator, 'getLocalizedTypeLabel']),

View file

@ -88,12 +88,14 @@ class NoLockoutValidator extends ConstraintValidator
$user = $this->entityManager->getRepository(User::class)->getAnonymousUser();
}
if ($user instanceof User) {
//Check if we the change_permission permission has changed from allow to disallow
if (false === ($this->resolver->inherit($user, 'users', 'edit_permissions') ?? false)) {
$this->context->addViolation($constraint->message);
}
}
//Check if we the change_permission permission has changed from allow to disallow
if (($user instanceof User) && false === ($this->resolver->inherit(
$user,
'users',
'edit_permissions'
) ?? false)) {
$this->context->addViolation($constraint->message);
}
}
}
}

View file

@ -60,9 +60,4 @@ class NoneOfItsChildren extends Constraint
* @var string The message used if it is tried to use one of the children for as parent
*/
public $children_message = 'validator.noneofitschild.children';
public function validatedBy()
{
return parent::validatedBy(); // TODO: Change the autogenerated stub
}
}

View file

@ -57,7 +57,7 @@ class SelectableValidator extends ConstraintValidator
* Checks if the passed value is valid.
*
* @param mixed $value The value that should be validated
* @param \Symfony\Component\Validator\Constraint $constraint The constraint for the validation
* @param Constraint $constraint The constraint for the validation
*/
public function validate($value, Constraint $constraint): void
{

View file

@ -104,20 +104,18 @@ class ValidPartLotValidator extends ConstraintValidator
}
//Check for onlyExisting
if ($value->getStorageLocation()->isLimitToExistingParts()) {
if (!$parts->contains($value->getPart())) {
$this->context->buildViolation('validator.part_lot.only_existing')
->atPath('storage_location')->addViolation();
}
if ($value->getStorageLocation()->isLimitToExistingParts() && !$parts->contains($value->getPart())) {
$this->context->buildViolation('validator.part_lot.only_existing')
->atPath('storage_location')->addViolation();
}
//Check for only single part
if ($value->getStorageLocation()->isOnlySinglePart()) {
if (($parts->count() > 0) && !$parts->contains($value->getPart())) {
if ($value->getStorageLocation()->isOnlySinglePart() && ($parts->count() > 0) && !$parts->contains(
$value->getPart()
)) {
$this->context->buildViolation('validator.part_lot.single_part')
->atPath('storage_location')->addViolation();
}
}
}
}
}

View file

@ -68,7 +68,7 @@ class RedirectControllerTest extends WebTestCase
$this->userRepo = $this->em->getRepository(User::class);
}
public function urlMatchDataProvider()
public function urlMatchDataProvider(): array
{
return [
['/', true],
@ -99,7 +99,7 @@ class RedirectControllerTest extends WebTestCase
$this->assertSame($expect_redirect, $response->isRedirect());
}
public function urlAddLocaleDataProvider()
public function urlAddLocaleDataProvider(): array
{
return [
//User locale, original target, redirect target

View file

@ -57,11 +57,11 @@ class PasswordChangeNeededSubscriberTest extends TestCase
//A user without a group must not redirect
$user->setGroup(null);
$this->assertFalse(\App\EventSubscriber\UserSystem\PasswordChangeNeededSubscriber::TFARedirectNeeded($user));
$this->assertFalse(PasswordChangeNeededSubscriber::TFARedirectNeeded($user));
//When the group does not enforce the redirect the user must not be redirected
$user->setGroup($group);
$this->assertFalse(\App\EventSubscriber\UserSystem\PasswordChangeNeededSubscriber::TFARedirectNeeded($user));
$this->assertFalse(PasswordChangeNeededSubscriber::TFARedirectNeeded($user));
//The user must be redirected if the group enforces 2FA and it does not have a method
$group->setEnforce2FA(true);