Your project should not use invalid return types 4

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

  1. $reader->setDelimiter($detectedDelimiter->value);
  2. } elseif ($reader instanceof Xls || $reader instanceof Xlsx) {
  3. $reader->setIgnoreRowsWithNoCells(true);
  4. }
  5. return $reader;

    Method JG\BatchEntityImportBundle\Model\Matrix\MatrixFactory::getReader() should return PhpOffice\PhpSpreadsheet\Reader\BaseReader but returns object.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarosław Grygierek
  6. }
  7. }
  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. }
  1. }
  2. public function getTemplate(string $name): string
  3. {
  4. if (array_key_exists($name, $this->availableTemplates)) {
  5. return $this->availableTemplates[$name];

    Method JG\BatchEntityImportBundle\Twig\TemplateExtension::getTemplate() should return string but returns mixed.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. }
  7. throw new UnexpectedValueException("Template $name not found.");
  8. }
  9. }
  1. foreach ($delimiters as $delimiter) {
  2. $delimiterCount[$delimiter] = substr_count($csvContent, (string) $delimiter);
  3. }
  4. return array_search(max($delimiterCount), $delimiterCount, true);

    Method JG\BatchEntityImportBundle\Service\CsvDelimiterDetector::detectDelimiter() should return string but returns int|string|false.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarosław Grygierek
  5. }
  6. }

Your project must not contain invalid function or method calls 18

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

  1. return new Matrix($header, $data);
  2. }
  3. public static function createFromPostData(array $data): Matrix
  4. {
  5. return $data ? new Matrix(array_keys($data[0]), $data) : new Matrix();

    Parameter #1 $array of function array_keys expects array, mixed given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. }
  7. private static function addKeysToRows(array $header, array &$data): void
  8. {
  9. array_walk(
  1. private static function addKeysToRows(array $header, array &$data): void
  2. {
  3. array_walk(
  4. $data,
  5. static function (array &$row) use ($header): void {
  6. $row = array_combine($header, $row);

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  7. },
  8. );
  9. }
  10. private static function getReader(UploadedFile $file): BaseReader
  1. private static function addKeysToRows(array $header, array &$data): void
  2. {
  3. array_walk(
  4. $data,
  5. static function (array &$row) use ($header): void {

    Parameter #2 $callback of function array_walk expects callable(mixed, int|string): mixed, Closure(array): void given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarosław Grygierek
  6. $row = array_combine($header, $row);
  7. },
  8. );
  9. }
  1. $reader = self::getReader($file);
  2. $spreadsheet = $reader->load($file->getPathname());
  3. $data = $spreadsheet->getActiveSheet()->toArray();
  4. $header = array_shift($data);
  5. self::addKeysToRows($header, $data);

    Parameter #1 $header of static method JG\BatchEntityImportBundle\Model\Matrix\MatrixFactory::addKeysToRows() expects array, array<mixed>|null given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarosław Grygierek
  6. return new Matrix($header, $data);
  7. }
  8. public static function createFromPostData(array $data): Matrix
  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. #[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. #[Assert\Callback]
  3. public function validateExtensions(ExecutionContextInterface $context): void
  4. {
  5. $extensions = array_map(strtolower(...), $this->allowedExtensions);

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. if (!in_array(strtolower($this->file->getClientOriginalExtension()), $extensions, true)) {
  7. $context->buildViolation('validation.file.extension', ['%extensions' => implode(', ', $extensions)])->addViolation();
  8. }
  9. }
  10. }
  1. */
  2. public function __construct(string $entityClass)
  3. {
  4. $this->reflectionClass = new ReflectionClass($entityClass);
  5. if (\interface_exists(TranslatableInterface::class) && is_subclass_of($entityClass, TranslatableInterface::class)) {
  6. $this->translationReflectionClass = new ReflectionClass($this->reflectionClass->newInstanceWithoutConstructor()->translate());

    Call to an undefined method object::translate().

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Micheal
  7. }
  8. }
  9. public function propertyExists(string $name): bool
  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. }
  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. );
  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
  1. foreach ($delimiters as $delimiter) {
  2. $delimiterCount[$delimiter] = substr_count($csvContent, (string) $delimiter);
  3. }
  4. return array_search(max($delimiterCount), $delimiterCount, true);

    Parameter #1 ...$arg1 of function max expects non-empty-array, array<int<0, max>> given.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarosław Grygierek
  5. }
  6. }

Your project should not use invalid parameter and return typehints 32

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

  1. public static function createFromPostData(array $data): Matrix
  2. {
  3. return $data ? new Matrix(array_keys($data[0]), $data) : new Matrix();
  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 Permalink
    Last edited by Jarek
  6. {
  7. array_walk(
  8. $data,
  9. static function (array &$row) use ($header): void {
  10. $row = array_combine($header, $row);
  1. public static function createFromPostData(array $data): Matrix
  2. {
  3. return $data ? new Matrix(array_keys($data[0]), $data) : new Matrix();
  4. }
  5. private static function addKeysToRows(array $header, array &$data): void

    Method JG\BatchEntityImportBundle\Model\Matrix\MatrixFactory::addKeysToRows() 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. array_walk(
  8. $data,
  9. static function (array &$row) use ($header): void {
  10. $row = array_combine($header, $row);
  1. self::addKeysToRows($header, $data);
  2. return new Matrix($header, $data);
  3. }
  4. public static function createFromPostData(array $data): Matrix

    Method JG\BatchEntityImportBundle\Model\Matrix\MatrixFactory::createFromPostData() 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. return $data ? new Matrix(array_keys($data[0]), $data) : new Matrix();
  7. }
  8. private static function addKeysToRows(array $header, array &$data): void
  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 \array_map(static fn (string $name): string => \str_replace(' ', '_', $name), $header);
  3. }
  4. private function clearRecordData(array $data): array

    Method JG\BatchEntityImportBundle\Model\Matrix\Matrix::clearRecordData() 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. return array_filter($data, $this->isColumnNameValid(...), ARRAY_FILTER_USE_KEY);
  7. }
  8. private function isColumnNameValid(?string $name): bool
  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. use Twig\TwigFunction;
  2. use UnexpectedValueException;
  3. class TemplateExtension extends AbstractExtension
  4. {
  5. public function __construct(private readonly array $availableTemplates = [])

    Method JG\BatchEntityImportBundle\Twig\TemplateExtension::__construct() has parameter $availableTemplates with no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarosław Grygierek
  6. {
  7. }
  8. public function getFunctions(): array
  9. {
  1. {
  2. #[Assert\File]
  3. #[Assert\NotNull]
  4. private ?UploadedFile $file = null;
  5. public function __construct(private readonly array $allowedExtensions = [])

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. {
  7. }
  8. public function getFile(): ?UploadedFile
  9. {
  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 Permalink
    Last edited by Jarek
  5. {
  6. $data = [];
  7. foreach ($fields as $field) {
  8. $data[$field] = $matrixRecord->$field;
  9. }
  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 Permalink
    Last edited by Jarek
  5. {
  6. $primaryKeyData = $this->entityManager->getUnitOfWork()->getEntityIdentifier($entityToOverride);
  7. foreach ($primaryKeyData as $primaryKeyName => $primaryValue) {
  8. $criteria[$primaryKeyName][] = ['!=', $primaryValue];
  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 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. foreach ($primaryKeyData as $primaryKeyName => $primaryValue) {
  2. $criteria[$primaryKeyName][] = ['!=', $primaryValue];
  3. }
  4. }
  5. private function isRecordDuplicatedInDatabase(EntityManagerInterface $em, string $class, array $criteria): bool

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. {
  7. $query = $em->createQuery($this->buildDQL($class, $criteria));
  8. $this->passParametersToQuery($query, $criteria);
  9. return !empty($query->getArrayResult());
  1. private function markAsCorrectRecord(array $matrixDataToCompare): void
  2. {
  3. $this->correctRecords[$this->getHash($matrixDataToCompare)] = true;
  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 Permalink
    Last edited by Jarek
  6. {
  7. $criteria = [];
  8. foreach ($matrixDataToCompare as $fieldName => $value) {
  9. $criteria[ColumnNameHelper::toCamelCase($fieldName)][] = ['=', $value];
  10. }
  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 Permalink
    Last edited by Jarek
  6. {
  7. $this->correctRecords[$this->getHash($matrixDataToCompare)] = true;
  8. }
  9. private function buildCriteria(MatrixRecord $matrixRecord, array $matrixDataToCompare): array
  1. $this->passParametersToQuery($query, $criteria);
  2. return !empty($query->getArrayResult());
  3. }
  4. private function buildDQL(string $class, array $criteria): string

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  5. {
  6. $sql = /* @lang DQL */
  7. "SELECT c FROM $class c";
  8. $nmb = 0;
  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 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 Permalink
    Last edited by Jarek
  6. {
  7. $this->duplicatedRecords[$this->getHash($matrixDataToCompare)] = true;
  8. }
  9. private function markAsCorrectRecord(array $matrixDataToCompare): void
  1. }
  2. return $sql;
  3. }
  4. private function passParametersToQuery(AbstractQuery $query, array $criteria): void

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  5. {
  6. $nmb = 0;
  7. foreach ($criteria as $data) {
  8. foreach ($data as [$operator, $value]) {
  9. $query->setParameter('param_' . $nmb++, $value);
  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 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 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 getHashedMatrixRecordsDataForDuplicationCheck(array $records, array $fieldsUsedInDuplicationCheck): array

    Method JG\BatchEntityImportBundle\Validator\Constraints\MatrixRecordUniqueValidator::getHashedMatrixRecordsDataForDuplicationCheck() 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
  5. {
  6. return array_map(
  7. fn (MatrixRecord $record): string => $this->getHash($this->getMatrixRecordDataForDuplicationCheck($record, $fieldsUsedInDuplicationCheck)),
  8. $records
  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. );
  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 Permalink
    Last edited by Jarosław Grygierek
  6. {
  7. $this->context
  8. ->buildViolation($constraint->message, ['%fields%' => implode(', ', $fields)])
  9. ->atPath("children[records][$index][{$constraint->fields[0]}]")
  10. ->setInvalidValue($record)
  1. ->atPath("children[records][$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 Permalink
    Last edited by Jarek
  6. {
  7. return md5(implode('--', $data));
  8. }
  9. }
  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 Permalink
    Last edited by Jarek
  6. {
  7. $processor = new Processor();
  8. $configuration = new Configuration();
  9. $config = $processor->processConfiguration($configuration, $configs);
  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 Permalink
    Last edited by Jarek
  6. {
  7. $builder
  8. ->scalarNode($name)
  9. ->defaultValue($value)
  10. ->cannotBeEmpty()
  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 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. 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 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. namespace JG\BatchEntityImportBundle\Model\Form;
  2. class FormFieldDefinition
  3. {
  4. public function __construct(private readonly string $class, private readonly 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 Permalink
    Last edited by Jarosław Grygierek
  5. {
  6. }
  7. public function getClass(): string
  8. {

Your project must not contain invalid instantiations 3

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();
  1. */
  2. public function __construct(string $entityClass)
  3. {
  4. $this->reflectionClass = new ReflectionClass($entityClass);
  5. if (\interface_exists(TranslatableInterface::class) && is_subclass_of($entityClass, TranslatableInterface::class)) {
  6. $this->translationReflectionClass = new ReflectionClass($this->reflectionClass->newInstanceWithoutConstructor()->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 Permalink
    Last edited by Micheal
  7. }
  8. }
  9. public function propertyExists(string $name): bool
  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 Permalink
    Last edited by Micheal
  7. if (\interface_exists(TranslatableInterface::class) && is_subclass_of($entityClass, TranslatableInterface::class)) {
  8. $this->translationReflectionClass = new ReflectionClass($this->reflectionClass->newInstanceWithoutConstructor()->translate());
  9. }
  10. }

Your project should use return types 14

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. $this->records[] = new MatrixRecord($clearedData, $this->getEntityIdValue($data));
  2. }
  3. }
  4. }
  5. public function getHeader(): array

    Method JG\BatchEntityImportBundle\Model\Matrix\Matrix::getHeader() 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 $this->header;
  8. }
  9. /**
  1. public function getRecords(): array
  2. {
  3. return $this->records;
  4. }
  5. public function getHeaderInfo(string $className): array

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarosław Grygierek
  6. {
  7. $info = [];
  8. $checker = new PropertyExistenceChecker($className);
  9. foreach ($this->header as $name) {
  1. );
  2. return \array_map(static fn (string $name): string => \str_replace(' ', '_', $name), $header);
  3. }
  4. private function clearRecordData(array $data): array

    Method JG\BatchEntityImportBundle\Model\Matrix\Matrix::clearRecordData() 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_filter($data, $this->isColumnNameValid(...), ARRAY_FILTER_USE_KEY);
  7. }
  8. private function isColumnNameValid(?string $name): bool
  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 Permalink
    Last edited by Jarek
  5. {
  6. $data = [];
  7. foreach ($fields as $field) {
  8. $data[$field] = $matrixRecord->$field;
  9. }
  1. private function markAsCorrectRecord(array $matrixDataToCompare): void
  2. {
  3. $this->correctRecords[$this->getHash($matrixDataToCompare)] = true;
  4. }
  5. private function buildCriteria(MatrixRecord $matrixRecord, array $matrixDataToCompare): array

    Method JG\BatchEntityImportBundle\Validator\Constraints\DatabaseEntityUniqueValidator::buildCriteria() 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. $criteria = [];
  8. foreach ($matrixDataToCompare as $fieldName => $value) {
  9. $criteria[ColumnNameHelper::toCamelCase($fieldName)][] = ['=', $value];
  10. }
  1. public function getAllowedFileExtensions(): array
  2. {
  3. return ['csv', 'xls', 'xlsx', 'ods'];
  4. }
  5. private function parseValueForArrayType(FormFieldDefinition $fieldDefinition, ?string $value): array

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

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Pierre Svgnt
  6. {
  7. return $value
  8. ? explode($fieldDefinition->getOptions()['separator'] ?? ArrayTextType::DEFAULT_SEPARATOR, $value)
  9. : [];
  10. }
  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. );
  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() 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 array_intersect_key($matrixRecord->getData(), array_flip($fieldsUsedInDuplicationCheck));
  8. }
  9. }
  1. public function getDefaultOption(): string
  2. {
  3. return 'entityClassName';
  4. }
  5. public function getRequiredOptions(): array

    Method JG\BatchEntityImportBundle\Validator\Constraints\DatabaseEntityUnique::getRequiredOptions() 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 ['entityClassName', 'fields'];
  8. }
  9. }
  1. enum CsvDelimiterEnum: string
  2. {
  3. case SEMICOLON = ';';
  4. case COMMA = ',';
  5. public static function asValues(): array

    Method JG\BatchEntityImportBundle\Enums\CsvDelimiterEnum::asValues() return type has no value type specified in iterable type array.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarosław Grygierek
  6. {
  7. return [
  8. self::SEMICOLON->value,
  9. self::COMMA->value,
  10. ];
  1. public function getDefaultOption(): string
  2. {
  3. return 'fields';
  4. }
  5. public function getRequiredOptions(): array

    Method JG\BatchEntityImportBundle\Validator\Constraints\MatrixRecordUnique::getRequiredOptions() 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 ['fields'];
  8. }
  9. }

Your project should only use iterable types in foreach loops 3

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

  1. private function passParametersToQuery(AbstractQuery $query, array $criteria): void
  2. {
  3. $nmb = 0;
  4. foreach ($criteria as $data) {
  5. foreach ($data as [$operator, $value]) {

    Argument of an invalid type mixed supplied for foreach, only iterables are supported.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. $query->setParameter('param_' . $nmb++, $value);
  7. }
  8. }
  9. }
  10. }
  1. $sql = /* @lang DQL */
  2. "SELECT c FROM $class c";
  3. $nmb = 0;
  4. foreach ($criteria as $fieldName => $data) {
  5. foreach ($data as [$operator, $value]) {

    Argument of an invalid type mixed supplied for foreach, only iterables are supported.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. $sql .= $nmb > 0 ? ' AND' : ' WHERE';
  7. $sql .= " c.$fieldName $operator :param_" . $nmb++;
  8. }
  9. }
  1. {
  2. /** @var MatrixRecord $entity */
  3. $entity = $form->getData();
  4. $selectedValue = $entity->entityId;
  5. foreach ($view['entity']->vars['choices'] ?? [] as $index => $choice) {

    Argument of an invalid type mixed supplied for foreach, only iterables are supported.

    Time to fix: about 9 minutes
    Read doc Permalink
    Last edited by Jarek
  6. if ($choice->value === $selectedValue) {
  7. $view['entity']->vars['choices'][$index]->attr['selected'] = 'selected';
  8. }
  9. }
  10. }