Your project must not contain invalid function or method calls 10

More information: https://insight.symfony.com/what-we-analyse/php.invalid_call

  1. 'trim' => true,
  2. ])
  3. ->setAllowedTypes('lookup_field', 'string')
  4. ->setNormalizer('lookup_field', function (Options $options, string $lookupField): string {
  5. // fails early, when form is built, if class or lookup field is invalid
  6. $this->getManager($options['class'], $lookupField);
    Parameter #1 $class of method JG\BatchEntityImportBundle\Form\Type\AbstractEntityLookupType::getManager() expects string, mixed given.
    Time to fix: about 9 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Jarosław Grygierek
  7. return $lookupField;
  8. });
  9. }
  1. $resolver
  2. ->setDefaults([
  3. 'label_field' => null,
  4. 'placeholder' => '---',
  5. 'translation_domain' => false,
  6. 'choices' => fn (Options $options): array => $this->getChoices($options['class'], $options['lookup_field'], $options['label_field']),
    Parameter #2 $lookupField of method JG\BatchEntityImportBundle\Form\Type\EntityLookupType::getChoices() expects string, mixed given.
    Time to fix: about 9 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Jarosław Grygierek
  7. ])
  8. ->setAllowedTypes('label_field', ['null', 'string']);
  9. }
  10. /**
  1. $resolver
  2. ->setDefaults([
  3. 'label_field' => null,
  4. 'placeholder' => '---',
  5. 'translation_domain' => false,
  6. 'choices' => fn (Options $options): array => $this->getChoices($options['class'], $options['lookup_field'], $options['label_field']),
    Parameter #3 $labelField of method JG\BatchEntityImportBundle\Form\Type\EntityLookupType::getChoices() expects string|null, mixed given.
    Time to fix: about 9 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Jarosław Grygierek
  7. ])
  8. ->setAllowedTypes('label_field', ['null', 'string']);
  9. }
  10. /**
  1. $resolver
  2. ->setDefaults([
  3. 'label_field' => null,
  4. 'placeholder' => '---',
  5. 'translation_domain' => false,
  6. 'choices' => fn (Options $options): array => $this->getChoices($options['class'], $options['lookup_field'], $options['label_field']),
    Parameter #1 $class of method JG\BatchEntityImportBundle\Form\Type\EntityLookupType::getChoices() expects string, mixed given.
    Time to fix: about 9 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Jarosław Grygierek
  7. ])
  8. ->setAllowedTypes('label_field', ['null', 'string']);
  9. }
  10. /**
  1. if (isset($this->choicesCache[$cacheKey])) {
  2. return $this->choicesCache[$cacheKey];
  3. }
  4. $manager = $this->getManager($class, $lookupField);
  5. if (null !== $labelField && !$manager->getClassMetadata($class)->hasField($labelField)) {
    Parameter #1 $className of method Doctrine\Persistence\ObjectManager::getClassMetadata() expects class-string<object>, string given.
    Time to fix: about 9 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Jarosław Grygierek
  6. throw new InvalidOptionsException(\sprintf('Field "%s" does not exist in entity "%s".', $labelField, $class));
  7. }
  8. $choices = [];
  9. foreach ($this->loadValuesAndLabels($manager, $class, $lookupField, $labelField) as [$value, $label]) {
  1. if (isset($this->choicesCache[$cacheKey])) {
  2. return $this->choicesCache[$cacheKey];
  3. }
  4. $manager = $this->getManager($class, $lookupField);
  5. if (null !== $labelField && !$manager->getClassMetadata($class)->hasField($labelField)) {
    Unable to resolve the template type T in call to method Doctrine\Persistence\ObjectManager::getClassMetadata()
    Time to fix: about 9 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Jarosław Grygierek
  6. throw new InvalidOptionsException(\sprintf('Field "%s" does not exist in entity "%s".', $labelField, $class));
  7. }
  8. $choices = [];
  9. foreach ($this->loadValuesAndLabels($manager, $class, $lookupField, $labelField) as [$value, $label]) {
  1. // bundle supports only Doctrine ORM, see AbstractImportConfiguration
  2. \assert($manager instanceof EntityManagerInterface);
  3. $queryBuilder = $manager->createQueryBuilder()
  4. ->select('e.' . $lookupField . ' AS value')
  5. ->from($class, 'e');
    Parameter #1 $from of method Doctrine\ORM\QueryBuilder::from() expects class-string, string given.
    Time to fix: about 9 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Jarosław Grygierek
  6. if (null !== $labelField) {
  7. $queryBuilder->addSelect('e.' . $labelField . ' AS label');
  8. }
  9. /** @var array{value: string|int|null, label?: scalar|null} $row */
  1. $manager = $this->getManagerForClass($class);
  2. if (!$manager) {
  3. throw new InvalidArgumentException(\sprintf('Class "%s" is not a managed Doctrine entity.', $class));
  4. }
  5. if (!$manager->getClassMetadata($class)->hasField($lookupField)) {
    Unable to resolve the template type T in call to method Doctrine\Persistence\ObjectManager::getClassMetadata()
    Time to fix: about 9 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Jarosław Grygierek
  6. throw new InvalidArgumentException(\sprintf('Field "%s" does not exist in entity "%s".', $lookupField, $class));
  7. }
  8. return $manager;
  9. }
  1. $manager = $this->getManagerForClass($class);
  2. if (!$manager) {
  3. throw new InvalidArgumentException(\sprintf('Class "%s" is not a managed Doctrine entity.', $class));
  4. }
  5. if (!$manager->getClassMetadata($class)->hasField($lookupField)) {
    Parameter #1 $className of method Doctrine\Persistence\ObjectManager::getClassMetadata() expects class-string<object>, string given.
    Time to fix: about 9 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Jarosław Grygierek
  6. throw new InvalidArgumentException(\sprintf('Field "%s" does not exist in entity "%s".', $lookupField, $class));
  7. }
  8. return $manager;
  9. }
  1. }
  2. private function getManagerForClass(string $class): ?ObjectManager
  3. {
  4. if ($this->managers instanceof ManagerRegistry) {
  5. return $this->managers->getManagerForClass($class);
    Parameter #1 $class of method Doctrine\Persistence\ManagerRegistry::getManagerForClass() expects class-string, string given.
    Time to fix: about 9 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Jarosław Grygierek
  6. }
  7. return \class_exists($class) && !$this->managers->getMetadataFactory()->isTransient($class)
  8. ? $this->managers
  9. : null;

Your project must not contain invalid instantiations 2

More information: https://insight.symfony.com/what-we-analyse/php.invalid_instantiation

  1. $resolver->setNormalizer(
  2. 'constraints',
  3. static function (Options $options, mixed $constraints): array {
  4. /** @var Constraint[] $constraints */
  5. $constraints = \is_array($constraints) ? $constraints : [$constraints];
  6. $constraints[] = new RelatedEntityExists(class: $options['class'], lookupField: $options['lookup_field']);
    Parameter $class of class JG\BatchEntityImportBundle\Validator\Constraints\RelatedEntityExists constructor expects string, mixed given.
    Last edited by Jarosław Grygierek
  7. return $constraints;
  8. },
  9. );
  10. }
  1. $resolver->setNormalizer(
  2. 'constraints',
  3. static function (Options $options, mixed $constraints): array {
  4. /** @var Constraint[] $constraints */
  5. $constraints = \is_array($constraints) ? $constraints : [$constraints];
  6. $constraints[] = new RelatedEntityExists(class: $options['class'], lookupField: $options['lookup_field']);
    Parameter $lookupField of class JG\BatchEntityImportBundle\Validator\Constraints\RelatedEntityExists constructor expects string, mixed given.
    Last edited by Jarosław Grygierek
  7. return $constraints;
  8. },
  9. );
  10. }