Your project must not contain invalid function or method calls 2

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

  1. {
  2. $header = array_values(
  3. array_filter($header, $this->isColumnNameValid(...)),
  4. );
  5. return \array_map(static fn (?string $name): string => \str_replace(' ', '_', $name), $header);

    Parameter #3 $subject of function str_replace expects array<string>|string, string|null given.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarosław Grygierek
  6. }
  7. /**
  8. * @param array<string, string> $data
  9. *
  1. * @param string[] $header
  2. */
  3. private static function addKeysToRows(array $header, array &$data): void
  4. {
  5. $data = array_map(
  6. static fn (array $row): array => array_combine($header, $row),

    Parameter #1 $callback of function array_map expects (callable(mixed): mixed)|null, Closure(array): array<string, mixed> given.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarosław Grygierek
  7. $data
  8. );
  9. }
  10. private static function getReader(UploadedFile $file): BaseReader

Your project must not contain invalid instantiations 4

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

  1. $data = $spreadsheet->getActiveSheet()->toArray();
  2. /** @var string[] $header */
  3. $header = array_shift($data);
  4. self::addKeysToRows($header, $data);
  5. return new Matrix($header, $data);

    Parameter #2 $recordsData of class JG\BatchEntityImportBundle\Model\Matrix\Matrix constructor expects array<array<string, string>>, array given.

    Time to fix: about 1 hour
    Read doc Open Issue Permalink
    Last edited by Jarek
  6. }
  7. /**
  8. * @param array<array<string, mixed>> $data
  9. */
  1. /**
  2. * @param array<array<string, mixed>> $data
  3. */
  4. public static function createFromPostData(array $data): Matrix
  5. {
  6. return $data ? new Matrix(array_keys($data[0]), $data) : new Matrix();

    Parameter #2 $recordsData of class JG\BatchEntityImportBundle\Model\Matrix\Matrix constructor expects array<array<string, string>>, array<array<string, mixed>> given.

    Time to fix: about 1 hour
    Read doc Open Issue Permalink
    Last edited by Jarek
  7. }
  8. /**
  9. * @param string[] $header
  10. */
  1. /**
  2. * @throws ReflectionException
  3. */
  4. public function __construct(string $entityClass)
  5. {
  6. $this->reflectionClass = new ReflectionClass($entityClass);

    Parameter #1 $objectOrClass of class ReflectionClass constructor expects class-string<T of object>|T of object, string given.

    Time to fix: about 1 hour
    Read doc Open Issue Permalink
    Last edited by Micheal
  7. if (\interface_exists(TranslatableInterface::class) && is_subclass_of($entityClass, TranslatableInterface::class)) {
  8. /** @var TranslatableInterface $instance */
  9. $instance = $this->reflectionClass->newInstanceWithoutConstructor();
  10. $this->translationReflectionClass = new ReflectionClass($instance->translate());
  11. }
  1. {
  2. $this->reflectionClass = new ReflectionClass($entityClass);
  3. if (\interface_exists(TranslatableInterface::class) && is_subclass_of($entityClass, TranslatableInterface::class)) {
  4. /** @var TranslatableInterface $instance */
  5. $instance = $this->reflectionClass->newInstanceWithoutConstructor();
  6. $this->translationReflectionClass = new ReflectionClass($instance->translate());

    Parameter #1 $objectOrClass of class ReflectionClass constructor expects class-string<T of object>|T of object, mixed given.

    Time to fix: about 1 hour
    Read doc Open Issue Permalink
    Last edited by Jarosław Grygierek
  7. }
  8. }
  9. public function propertyExists(string $name): bool
  10. {

Your project should not use invalid parameter and return typehints 17

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

  1. }
  2. /**
  3. * @param string[] $header
  4. */
  5. private static function addKeysToRows(array $header, array &$data): void

    Method JG\BatchEntityImportBundle\Model\Matrix\MatrixFactory::addKeysToRows() has parameter $data with no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  6. {
  7. $data = array_map(
  8. static fn (array $row): array => array_combine($header, $row),
  9. $data
  10. );
  1. private function translationPropertyExists(string $name): bool
  2. {
  3. return $this->translationReflectionClass instanceof ReflectionClass && $this->isPropertyWritable($this->translationReflectionClass, $name);
  4. }
  5. private function isPropertyWritable(ReflectionClass $entity, string $name): bool

    Method JG\BatchEntityImportBundle\Service\PropertyExistenceChecker::isPropertyWritable() has parameter $entity with generic class ReflectionClass but does not specify its types: T

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarosław Grygierek
  6. {
  7. $setterName = ColumnNameHelper::getSetterName($name);
  8. return ($entity->hasProperty($name) && $entity->getProperty($name)->isPublic())
  9. || ($entity->hasMethod($setterName) && $entity->getMethod($setterName)->isPublic());
  1. }
  2. $this->save();
  3. }
  4. protected function prepareRecord(MatrixRecord $record, array $headerInfo): void

    Method JG\BatchEntityImportBundle\Model\Configuration\AbstractImportConfiguration::prepareRecord() has parameter $headerInfo with no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarosław Grygierek
  5. {
  6. $entity = $this->getEntity($record);
  7. $data = $record->getData();
  8. $fieldDefinitions = $this->getFieldsDefinitions();
  1. }
  2. parent::validateArguments($value, $constraint);
  3. }
  4. private function getMatrixRecordDataToCompare(MatrixRecord $matrixRecord, array $fields): array

    Method JG\BatchEntityImportBundle\Validator\Constraints\DatabaseEntityUniqueValidator::getMatrixRecordDataToCompare() has parameter $fields with no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  5. {
  6. $data = [];
  7. foreach ($fields as $field) {
  8. $data[$field] = $matrixRecord->$field;
  9. }
  1. }
  2. return $data;
  3. }
  4. private function isDuplicate(array $matrixDataToCompare): bool

    Method JG\BatchEntityImportBundle\Validator\Constraints\DatabaseEntityUniqueValidator::isDuplicate() has parameter $matrixDataToCompare with no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  5. {
  6. return array_key_exists($this->getHash($matrixDataToCompare), $this->duplicatedRecords);
  7. }
  8. private function isCorrectRecord(array $matrixDataToCompare): bool
  1. private function isDuplicate(array $matrixDataToCompare): bool
  2. {
  3. return array_key_exists($this->getHash($matrixDataToCompare), $this->duplicatedRecords);
  4. }
  5. private function isCorrectRecord(array $matrixDataToCompare): bool

    Method JG\BatchEntityImportBundle\Validator\Constraints\DatabaseEntityUniqueValidator::isCorrectRecord() has parameter $matrixDataToCompare with no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  6. {
  7. return array_key_exists($this->getHash($matrixDataToCompare), $this->correctRecords);
  8. }
  9. private function addDuplicate(array $matrixDataToCompare): void
  1. private function isCorrectRecord(array $matrixDataToCompare): bool
  2. {
  3. return array_key_exists($this->getHash($matrixDataToCompare), $this->correctRecords);
  4. }
  5. private function addDuplicate(array $matrixDataToCompare): void

    Method JG\BatchEntityImportBundle\Validator\Constraints\DatabaseEntityUniqueValidator::addDuplicate() has parameter $matrixDataToCompare with no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  6. {
  7. $this->duplicatedRecords[$this->getHash($matrixDataToCompare)] = true;
  8. }
  9. private function markAsCorrectRecord(array $matrixDataToCompare): void
  1. private function addDuplicate(array $matrixDataToCompare): void
  2. {
  3. $this->duplicatedRecords[$this->getHash($matrixDataToCompare)] = true;
  4. }
  5. private function markAsCorrectRecord(array $matrixDataToCompare): void

    Method JG\BatchEntityImportBundle\Validator\Constraints\DatabaseEntityUniqueValidator::markAsCorrectRecord() has parameter $matrixDataToCompare with no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  6. {
  7. $this->correctRecords[$this->getHash($matrixDataToCompare)] = true;
  8. }
  9. /**
  1. }
  2. /**
  3. * @return array<string, array<int, array{0: string, 1: scalar}>>
  4. */
  5. private function buildCriteria(MatrixRecord $matrixRecord, array $matrixDataToCompare): array

    Method JG\BatchEntityImportBundle\Validator\Constraints\DatabaseEntityUniqueValidator::buildCriteria() has parameter $matrixDataToCompare with no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  6. {
  7. /** @var array<string, array<int, array{0: string, 1: scalar}>> $criteria */
  8. $criteria = [];
  9. foreach ($matrixDataToCompare as $fieldName => $value) {
  10. $criteria[ColumnNameHelper::toCamelCase($fieldName)][] = ['=', $value];
  1. }
  2. return $criteria;
  3. }
  4. private function addCriteriaToOmitEntity(array &$criteria, object $entityToOverride): void

    Method JG\BatchEntityImportBundle\Validator\Constraints\DatabaseEntityUniqueValidator::addCriteriaToOmitEntity() has parameter $criteria with no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  5. {
  6. $primaryKeyData = $this->entityManager->getUnitOfWork()->getEntityIdentifier($entityToOverride);
  7. foreach ($primaryKeyData as $primaryKeyName => $primaryValue) {
  8. $criteria[$primaryKeyName][] = ['!=', $primaryValue];
  1. $container
  2. ->registerForAutoconfiguration(ImportConfigurationAutoInjectInterface::class)
  3. ->addTag('batch_entity_import.controller');
  4. }
  5. private function setParameters(array $configs, ContainerBuilder $container): void

    Method JG\BatchEntityImportBundle\DependencyInjection\BatchEntityImportExtension::setParameters() has parameter $configs with no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  6. {
  7. $processor = new Processor();
  8. $configuration = new Configuration();
  9. $config = $processor->processConfiguration($configuration, $configs);
  1. $this->addTemplatesConfig($rootNode->children());
  2. return $treeBuilder;
  3. }
  4. private function addTemplatesConfig(NodeBuilder $parentBuilder): void

    Method JG\BatchEntityImportBundle\DependencyInjection\Configuration::addTemplatesConfig() has parameter $parentBuilder with generic class Symfony\Component\Config\Definition\Builder\NodeBuilder but does not specify its types: TParent

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  5. {
  6. $builder = $parentBuilder->arrayNode('templates')->addDefaultsIfNotSet()->children();
  7. $this->addNodeConfig($builder, 'select_file', '@BatchEntityImport/select_file.html.twig');
  8. $this->addNodeConfig($builder, 'edit_matrix', '@BatchEntityImport/edit_matrix.html.twig');
  1. $this->addNodeConfig($builder, 'select_file', '@BatchEntityImport/select_file.html.twig');
  2. $this->addNodeConfig($builder, 'edit_matrix', '@BatchEntityImport/edit_matrix.html.twig');
  3. $this->addNodeConfig($builder, 'layout', '@BatchEntityImport/layout.html.twig');
  4. }
  5. private function addNodeConfig(NodeBuilder $builder, string $name, string $value): void

    Method JG\BatchEntityImportBundle\DependencyInjection\Configuration::addNodeConfig() has parameter $builder with generic class Symfony\Component\Config\Definition\Builder\NodeBuilder but does not specify its types: TParent

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  6. {
  7. $builder
  8. ->scalarNode($name)
  9. ->defaultValue($value)
  10. ->cannotBeEmpty()
  1. namespace JG\BatchEntityImportBundle\Model\Form;
  2. readonly class FormFieldDefinition
  3. {
  4. public function __construct(private string $class, private array $options = [])

    Method JG\BatchEntityImportBundle\Model\Form\FormFieldDefinition::__construct() has parameter $options with no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarosław Grygierek
  5. {
  6. }
  7. public function getClass(): string
  8. {
  1. class MatrixRecord
  2. {
  3. private ?object $entity = null;
  4. private array $data = [];
  5. public function __construct(array $data = [], public readonly int|string|null $entityId = null)

    Method JG\BatchEntityImportBundle\Model\Matrix\MatrixRecord::__construct() has parameter $data with no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  6. {
  7. foreach ($data as $name => $value) {
  8. if (!empty(\trim((string) $name))) {
  9. $this->data[\str_replace(' ', '_', (string) $name)] = $value;
  10. }
  1. protected function prepareContext(): void
  2. {
  3. $this->context->setNode($this->context->getValue(), $this->context->getObject(), $this->context->getMetadata(), '');
  4. }
  5. protected function addErrorToMatrixRecord(MatrixRecord $record, MatrixRecordUnique|DatabaseEntityUnique $constraint, int $index, array $fields): void

    Method JG\BatchEntityImportBundle\Validator\Constraints\AbstractValidator::addErrorToMatrixRecord() has parameter $fields with no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarosław Grygierek
  6. {
  7. $this->context
  8. ->buildViolation($constraint->message, ['%fields%' => implode(', ', $fields)])
  9. ->atPath(sprintf('children[records][%d][%s]', $index, $constraint->fields[0]))
  10. ->setInvalidValue($record)
  1. ->atPath(sprintf('children[records][%d][%s]', $index, $constraint->fields[0]))
  2. ->setInvalidValue($record)
  3. ->addViolation();
  4. }
  5. protected function getHash(array $data): string

    Method JG\BatchEntityImportBundle\Validator\Constraints\AbstractValidator::getHash() has parameter $data with no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  6. {
  7. return md5(implode('--', $data));
  8. }
  9. }

Your project should not use invalid return types 2

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

  1. /**
  2. * @phpstan-return non-empty-string
  3. */
  4. private function getSeparator(FormFieldDefinition $fieldDefinition): string
  5. {
  6. return $fieldDefinition->getOptions()['separator'] ?? ArrayTextType::DEFAULT_SEPARATOR;

    Method JG\BatchEntityImportBundle\Model\Configuration\AbstractImportConfiguration::getSeparator() should return non-empty-string but returns mixed.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarosław Grygierek
  7. }
  8. }
  1. $entityToOverride = $matrixRecord->getEntity();
  2. if (null !== $entityToOverride) {
  3. $this->addCriteriaToOmitEntity($criteria, $entityToOverride);
  4. }
  5. return $criteria;

    Method JG\BatchEntityImportBundle\Validator\Constraints\DatabaseEntityUniqueValidator::buildCriteria() should return array<string, array<int, array{string, bool|float|int|string}>> but returns array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  6. }
  7. private function addCriteriaToOmitEntity(array &$criteria, object $entityToOverride): void
  8. {
  9. $primaryKeyData = $this->entityManager->getUnitOfWork()->getEntityIdentifier($entityToOverride);

Your project should use return types 7

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

  1. }
  2. parent::validateArguments($value, $constraint);
  3. }
  4. private function getMatrixRecordDataToCompare(MatrixRecord $matrixRecord, array $fields): array

    Method JG\BatchEntityImportBundle\Validator\Constraints\DatabaseEntityUniqueValidator::getMatrixRecordDataToCompare() return type has no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  5. {
  6. $data = [];
  7. foreach ($fields as $field) {
  8. $data[$field] = $matrixRecord->$field;
  9. }
  1. public function getClass(): string
  2. {
  3. return $this->class;
  4. }
  5. public function getOptions(): array

    Method JG\BatchEntityImportBundle\Model\Form\FormFieldDefinition::getOptions() return type has no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  6. {
  7. return $this->options;
  8. }
  9. }
  1. public function setEntity(?object $entity): void
  2. {
  3. $this->entity = $entity;
  4. }
  5. public function getData(): array

    Method JG\BatchEntityImportBundle\Model\Matrix\MatrixRecord::getData() return type has no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  6. {
  7. return $this->data;
  8. }
  9. public function __isset(string $name): bool
  1. }
  2. return implode($this->separator, $value);
  3. }
  4. public function reverseTransform(mixed $value): array

    Method JG\BatchEntityImportBundle\Form\Type\ArrayTextType::reverseTransform() return type has no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Pierre Svgnt
  5. {
  6. if (!is_string($value)) {
  7. throw new UnexpectedValueException('Only strings are allowed');
  8. }
  1. public function getEntityTranslationRelationName(): ?string;
  2. /**
  3. * Use this method to pass constraints to the main Matrix form.
  4. */
  5. public function getMatrixConstraints(): array;

    Method JG\BatchEntityImportBundle\Model\Configuration\ImportConfigurationInterface::getMatrixConstraints() return type has no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  6. /**
  7. * Use this method to set allowed file extensions.
  8. */
  9. public function getAllowedFileExtensions(): array;
  1. public function getMatrixConstraints(): array;
  2. /**
  3. * Use this method to set allowed file extensions.
  4. */
  5. public function getAllowedFileExtensions(): array;

    Method JG\BatchEntityImportBundle\Model\Configuration\ImportConfigurationInterface::getAllowedFileExtensions() return type has no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  6. /**
  7. * Import data from matrix to database.
  8. */
  9. public function import(Matrix $matrix): void;
  1. }
  2. /**
  3. * @param string[] $fieldsUsedInDuplicationCheck
  4. */
  5. private function getMatrixRecordDataForDuplicationCheck(MatrixRecord $matrixRecord, array $fieldsUsedInDuplicationCheck): array

    Method JG\BatchEntityImportBundle\Validator\Constraints\MatrixRecordUniqueValidator::getMatrixRecordDataForDuplicationCheck() return type has no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarek
  6. {
  7. return array_intersect_key($matrixRecord->getData(), array_flip($fieldsUsedInDuplicationCheck));
  8. }
  9. }