Your project must not contain invalid function or method calls 16

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

  1. {
  2. $info = [];
  3. $checker = new PropertyExistenceChecker($className);
  4. foreach ($this->header as $name) {
  5. $info[$name] = $checker->propertyExists($name);

    Parameter #1 $name of method JG\BatchEntityImportBundle\Service\PropertyExistenceChecker::propertyExists() expects string, mixed given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarosław Grygierek
  6. }
  7. return $info;
  8. }
  1. $this->header = $this->clearHeader($header);
  2. foreach ($recordsData as $data) {
  3. $clearedData = $this->clearRecordData($data);
  4. if ($clearedData) {
  5. $this->records[] = new MatrixRecord($clearedData, $this->getEntityIdValue($data));

    Parameter #1 $data of method JG\BatchEntityImportBundle\Model\Matrix\Matrix::getEntityIdValue() expects array, mixed given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. }
  7. }
  8. }
  9. public function getHeader(): array
  1. public function __construct(array $header = [], array $recordsData = [])
  2. {
  3. $this->header = $this->clearHeader($header);
  4. foreach ($recordsData as $data) {
  5. $clearedData = $this->clearRecordData($data);

    Parameter #1 $data of method JG\BatchEntityImportBundle\Model\Matrix\Matrix::clearRecordData() expects array, mixed given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. if ($clearedData) {
  7. $this->records[] = new MatrixRecord($clearedData, $this->getEntityIdValue($data));
  8. }
  9. }
  10. }
  1. }
  2. private function clearHeader(array $header): array
  3. {
  4. $header = array_values(
  5. array_filter($header, $this->isColumnNameValid(...)),

    Parameter #2 $callback of function array_filter expects (callable(mixed): bool)|null, Closure(string|null): bool given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. );
  7. return \array_map(static fn (string $name): string => \str_replace(' ', '_', $name), $header);
  8. }
  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 #1 $callback of function array_map expects (callable(mixed): mixed)|null, Closure(string): string given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. }
  7. private function clearRecordData(array $data): array
  8. {
  9. return array_filter($data, $this->isColumnNameValid(...), ARRAY_FILTER_USE_KEY);
  1. $configuration = new Configuration();
  2. $config = $processor->processConfiguration($configuration, $configs);
  3. $templates = $config['templates'];
  4. $container->setParameter('batch_entity_import.templates', $templates);
  5. $container->setParameter('batch_entity_import.templates.select_file', $templates['select_file']);

    Parameter #2 $value of method Symfony\Component\DependencyInjection\Container::setParameter() expects array|bool|float|int|string|UnitEnum|null, mixed given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. $container->setParameter('batch_entity_import.templates.edit_matrix', $templates['edit_matrix']);
  7. $container->setParameter('batch_entity_import.templates.layout', $templates['layout']);
  8. }
  9. }
  1. $templates = $config['templates'];
  2. $container->setParameter('batch_entity_import.templates', $templates);
  3. $container->setParameter('batch_entity_import.templates.select_file', $templates['select_file']);
  4. $container->setParameter('batch_entity_import.templates.edit_matrix', $templates['edit_matrix']);
  5. $container->setParameter('batch_entity_import.templates.layout', $templates['layout']);

    Parameter #2 $value of method Symfony\Component\DependencyInjection\Container::setParameter() expects array|bool|float|int|string|UnitEnum|null, mixed given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarosław Grygierek
  6. }
  7. }
  1. $config = $processor->processConfiguration($configuration, $configs);
  2. $templates = $config['templates'];
  3. $container->setParameter('batch_entity_import.templates', $templates);
  4. $container->setParameter('batch_entity_import.templates.select_file', $templates['select_file']);
  5. $container->setParameter('batch_entity_import.templates.edit_matrix', $templates['edit_matrix']);

    Parameter #2 $value of method Symfony\Component\DependencyInjection\Container::setParameter() expects array|bool|float|int|string|UnitEnum|null, mixed given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. $container->setParameter('batch_entity_import.templates.layout', $templates['layout']);
  7. }
  8. }
  1. $processor = new Processor();
  2. $configuration = new Configuration();
  3. $config = $processor->processConfiguration($configuration, $configs);
  4. $templates = $config['templates'];
  5. $container->setParameter('batch_entity_import.templates', $templates);

    Parameter #2 $value of method Symfony\Component\DependencyInjection\Container::setParameter() expects array|bool|float|int|string|UnitEnum|null, mixed given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. $container->setParameter('batch_entity_import.templates.select_file', $templates['select_file']);
  7. $container->setParameter('batch_entity_import.templates.edit_matrix', $templates['edit_matrix']);
  8. $container->setParameter('batch_entity_import.templates.layout', $templates['layout']);
  9. }
  10. }
  1. }
  2. private function parseValueForArrayType(FormFieldDefinition $fieldDefinition, ?string $value): array
  3. {
  4. return $value
  5. ? explode($fieldDefinition->getOptions()['separator'] ?? ArrayTextType::DEFAULT_SEPARATOR, $value)

    Parameter #1 $separator of function explode expects non-empty-string, mixed given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Pierre Svgnt
  6. : [];
  7. }
  8. }
  1. $setterName = ColumnNameHelper::getSetterName($name);
  2. if (isset($fieldDefinitions[$name])) {
  3. $fieldDefinition = $fieldDefinitions[$name];
  4. if (ArrayTextType::class === $fieldDefinition->getClass()) {
  5. $value = $this->parseValueForArrayType($fieldDefinition, $value);

    Parameter #2 $value of method JG\BatchEntityImportBundle\Model\Configuration\AbstractImportConfiguration::parseValueForArrayType() expects string|null, mixed given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Pierre Svgnt
  6. }
  7. }
  8. try {
  9. if (\interface_exists(TranslatableInterface::class) && $entity instanceof TranslatableInterface && $locale) {
  1. }
  2. protected function dispatchEvents(): void
  3. {
  4. foreach ($this->updatedEntities as $entity) {
  5. $identifierValues = $this->em->getUnitOfWork()->getEntityIdentifier($entity);

    Parameter #1 $entity of method Doctrine\ORM\UnitOfWork::getEntityIdentifier() expects object, mixed given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. $this->eventDispatcher->dispatch(
  7. new RecordImportedSuccessfullyEvent($this->getEntityClassName(), (string) \reset($identifierValues)),
  8. );
  9. }
  1. }
  2. try {
  3. if (\interface_exists(TranslatableInterface::class) && $entity instanceof TranslatableInterface && $locale) {
  4. $translatedEntity = $entity->translate($locale, false);
  5. if (method_exists($translatedEntity, $setterName)) {

    Parameter #1 $object_or_class of function method_exists expects object|string, mixed given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarosław Grygierek
  6. $translatedEntity->$setterName($value);
  7. } else {
  8. $translatedEntity->$propertyName = $value;
  9. }
  10. } elseif (!$locale) {
  1. #[Assert\Callback]
  2. public function validateExtensions(ExecutionContextInterface $context): void
  3. {
  4. $extensions = array_map(strtolower(...), $this->allowedExtensions);
  5. if (!in_array(strtolower($this->file->getClientOriginalExtension()), $extensions, true)) {

    Cannot call method getClientOriginalExtension() on Symfony\Component\HttpFoundation\File\UploadedFile|null.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. $context->buildViolation('validation.file.extension', ['%extensions' => implode(', ', $extensions)])->addViolation();
  7. }
  8. }
  9. }
  1. );
  2. }
  3. private function getMatrixRecordDataForDuplicationCheck(MatrixRecord $matrixRecord, array $fieldsUsedInDuplicationCheck): array
  4. {
  5. return array_intersect_key($matrixRecord->getData(), array_flip($fieldsUsedInDuplicationCheck));

    Parameter #1 $array of function array_flip expects array<int|string>, array given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. }
  7. }
  1. }
  2. private function getHashedMatrixRecordsDataForDuplicationCheck(array $records, array $fieldsUsedInDuplicationCheck): array
  3. {
  4. return array_map(
  5. fn (MatrixRecord $record): string => $this->getHash($this->getMatrixRecordDataForDuplicationCheck($record, $fieldsUsedInDuplicationCheck)),

    Parameter #1 $callback of function array_map expects (callable(mixed): mixed)|null, Closure(JG\BatchEntityImportBundle\Model\Matrix\MatrixRecord): string given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarosław Grygierek
  6. $records
  7. );
  8. }
  9. private function getMatrixRecordDataForDuplicationCheck(MatrixRecord $matrixRecord, array $fieldsUsedInDuplicationCheck): array

Your project should use return types 4

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

  1. }
  2. return null;
  3. }
  4. private function clearHeader(array $header): array

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  5. {
  6. $header = array_values(
  7. array_filter($header, $this->isColumnNameValid(...)),
  8. );
  1. public function allowOverrideEntity(): bool
  2. {
  3. return true;
  4. }
  5. public function getAllowedFileExtensions(): array

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. {
  7. return ['csv', 'xls', 'xlsx', 'ods'];
  8. }
  9. private function parseValueForArrayType(FormFieldDefinition $fieldDefinition, ?string $value): array
  1. public function getEntityTranslationRelationName(): ?string
  2. {
  3. return null;
  4. }
  5. public function getMatrixConstraints(): array

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. {
  7. return [];
  8. }
  9. public function import(Matrix $matrix): void
  1. }
  2. parent::validateArguments($value, $constraint);
  3. }
  4. private function getHashedMatrixRecordsDataForDuplicationCheck(array $records, array $fieldsUsedInDuplicationCheck): array

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  5. {
  6. return array_map(
  7. fn (MatrixRecord $record): string => $this->getHash($this->getMatrixRecordDataForDuplicationCheck($record, $fieldsUsedInDuplicationCheck)),
  8. $records
  9. );

Your project should not use invalid parameter and return typehints 6

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

  1. new Assert\Type(MatrixRecord::class),
  2. ])]
  3. #[Assert\NotBlank]
  4. private array $records = [];
  5. public function __construct(array $header = [], array $recordsData = [])

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. {
  7. $this->header = $this->clearHeader($header);
  8. foreach ($recordsData as $data) {
  9. $clearedData = $this->clearRecordData($data);
  1. }
  2. return null;
  3. }
  4. private function clearHeader(array $header): array

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  5. {
  6. $header = array_values(
  7. array_filter($header, $this->isColumnNameValid(...)),
  8. );
  1. new Assert\Type(MatrixRecord::class),
  2. ])]
  3. #[Assert\NotBlank]
  4. private array $records = [];
  5. public function __construct(array $header = [], array $recordsData = [])

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. {
  7. $this->header = $this->clearHeader($header);
  8. foreach ($recordsData as $data) {
  9. $clearedData = $this->clearRecordData($data);
  1. }
  2. return $info;
  3. }
  4. private function getEntityIdValue(array $data): int|string|null

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  5. {
  6. foreach ($data as $name => $value) {
  7. if (self::RESERVED_ENTITY_ID_COLUMN_NAME === $name) {
  8. return $value;
  9. }
  1. fn (MatrixRecord $record): string => $this->getHash($this->getMatrixRecordDataForDuplicationCheck($record, $fieldsUsedInDuplicationCheck)),
  2. $records
  3. );
  4. }
  5. private function getMatrixRecordDataForDuplicationCheck(MatrixRecord $matrixRecord, array $fieldsUsedInDuplicationCheck): array

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. {
  7. return array_intersect_key($matrixRecord->getData(), array_flip($fieldsUsedInDuplicationCheck));
  8. }
  9. }
  1. }
  2. parent::validateArguments($value, $constraint);
  3. }
  4. private function getHashedMatrixRecordsDataForDuplicationCheck(array $records, array $fieldsUsedInDuplicationCheck): array

    Method JG\BatchEntityImportBundle\Validator\Constraints\MatrixRecordUniqueValidator::getHashedMatrixRecordsDataForDuplicationCheck() has parameter $records with no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  5. {
  6. return array_map(
  7. fn (MatrixRecord $record): string => $this->getHash($this->getMatrixRecordDataForDuplicationCheck($record, $fieldsUsedInDuplicationCheck)),
  8. $records
  9. );

Your project should not use invalid return types

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

  1. private function getEntityIdValue(array $data): int|string|null
  2. {
  3. foreach ($data as $name => $value) {
  4. if (self::RESERVED_ENTITY_ID_COLUMN_NAME === $name) {
  5. return $value;

    Method JG\BatchEntityImportBundle\Model\Matrix\Matrix::getEntityIdValue() should return int|string|null but returns mixed.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. }
  7. }
  8. return null;
  9. }

Your project must not contain invalid instantiations

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

  1. $data = $spreadsheet->getActiveSheet()->toArray();
  2. $header = array_shift($data);
  3. self::addKeysToRows($header, $data);
  4. return new Matrix($header, $data);

    Parameter #1 $header of class JG\BatchEntityImportBundle\Model\Matrix\Matrix constructor expects array, array<mixed>|null given.

    Time to fix: about 1 hour
    Read doc Permalink
    Last edited by Jarek
  5. }
  6. public static function createFromPostData(array $data): Matrix
  7. {
  8. return $data ? new Matrix(array_keys($data[0]), $data) : new Matrix();