Your project must not contain invalid function or method calls 2

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

  1. return [];
  2. }
  3. public function import(Matrix $matrix): void
  4. {
  5. $headerInfo = $matrix->getHeaderInfo($this->getEntityClassName());

    Parameter #1 $className of method JG\BatchEntityImportBundle\Model\Matrix\Matrix::getHeaderInfo() expects class-string, string given.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarosław Grygierek
  6. foreach ($matrix->getRecords() as $record) {
  7. $this->prepareRecord($record, $headerInfo);
  8. }
  9. $this->save();
  1. /** @var string[] $header */
  2. $header = array_shift($data);
  3. return new Matrix(
  4. $header,
  5. self::addKeysToRows($header, $data),

    Parameter #2 $data of static method JG\BatchEntityImportBundle\Model\Matrix\MatrixFactory::addKeysToRows() expects array<array<string>>, array<int, array<string|null>> given.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarosław Grygierek
  6. );
  7. }
  8. /**
  9. * @param array<array<string, string|int>> $data

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 not use invalid parameter and return typehints 16

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

  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. 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. 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 must not contain invalid instantiations

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

  1. /**
  2. * @param array<array<string, string|int>> $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, int|string>> given.

    Time to fix: about 1 hour
    Read doc Open Issue Permalink
    Last edited by Jarek
  7. }
  8. /**
  9. * @param string[] $header
  10. * @param array<array<string>> $data

Your project should not rely on undefined constants

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

  1. $this->reflectionClass = new ReflectionClass($entityClass);
  2. if (\interface_exists(TranslatableInterface::class) && is_subclass_of($entityClass, TranslatableInterface::class)) {
  3. /** @var TranslatableInterface $instance */
  4. $instance = $this->reflectionClass->newInstanceWithoutConstructor();
  5. /** @var class-string $translationInstance */
  6. $translationInstance = $instance->translate()::class;

    Cannot access constant class on mixed.

    Time to fix: about 9 minutes
    Read doc Open Issue Permalink
    Last edited by Jarosław Grygierek
  7. $this->translationReflectionClass = new ReflectionClass($translationInstance);
  8. }
  9. }
  10. public function propertyExists(string $name): bool

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. }