Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 12 additions & 126 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,38 +1,20 @@
parameters:
ignoreErrors:
-
message: '#^Cannot access offset ''entries'' on array\|bool\|float\|int\|string\|null\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/bundle/Command/MigrateLegacyMatrixCommand.php

-
message: '#^Method Ibexa\\Bundle\\FieldTypeMatrix\\Command\\MigrateLegacyMatrixCommand\:\:convertCellsToRows\(\) has parameter \$cells with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/bundle/Command/MigrateLegacyMatrixCommand.php

-
message: '#^Method Ibexa\\Bundle\\FieldTypeMatrix\\Command\\MigrateLegacyMatrixCommand\:\:convertCellsToRows\(\) has parameter \$columns with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/bundle/Command/MigrateLegacyMatrixCommand.php

-
message: '#^Method Ibexa\\Bundle\\FieldTypeMatrix\\Command\\MigrateLegacyMatrixCommand\:\:convertCellsToRows\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
message: '#^Binary operation "%%" between int\|string and int\<0, max\> results in an error\.$#'
identifier: binaryOp.invalid
count: 1
path: src/bundle/Command/MigrateLegacyMatrixCommand.php

-
message: '#^Method Ibexa\\Bundle\\FieldTypeMatrix\\Command\\MigrateLegacyMatrixCommand\:\:getContentClassAttributes\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
message: '#^Cannot access offset ''entries'' on array\|bool\|float\|int\|string\|null\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/bundle/Command/MigrateLegacyMatrixCommand.php

-
message: '#^Method Ibexa\\Bundle\\FieldTypeMatrix\\Command\\MigrateLegacyMatrixCommand\:\:getContentObjectAttributes\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
message: '#^Cannot access property \$identifier on array\<string, mixed\>\.$#'
identifier: property.nonObject
count: 1
path: src/bundle/Command/MigrateLegacyMatrixCommand.php

Expand All @@ -43,115 +25,19 @@ parameters:
path: src/bundle/Command/MigrateLegacyMatrixCommand.php

-
message: '#^Parameter \#1 \$input of static method Symfony\\Component\\Yaml\\Yaml\:\:parse\(\) expects string, string\|false given\.$#'
identifier: argument.type
count: 1
path: src/bundle/DependencyInjection/IbexaFieldTypeMatrixExtension.php

-
message: '#^Property Ibexa\\Core\\Persistence\\Legacy\\Content\\StorageFieldDefinition\:\:\$dataText5 \(string\) on left side of \?\? is not nullable\.$#'
identifier: nullCoalesce.property
count: 1
path: src/lib/FieldType/Converter/MatrixConverter.php

-
message: '#^Method Ibexa\\FieldTypeMatrix\\FieldType\\Value\\Row\:\:__construct\(\) has parameter \$cells with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/FieldType/Value/Row.php

-
message: '#^Method Ibexa\\FieldTypeMatrix\\FieldType\\Value\\Row\:\:__get\(\) has no return type specified\.$#'
identifier: missingType.return
message: '#^Method Ibexa\\FieldTypeMatrix\\FieldType\\Mapper\\MatrixFormMapper\:\:mapFieldDefinitionForm\(\) has parameter \$fieldDefinitionForm with generic interface Symfony\\Component\\Form\\FormInterface but does not specify its types\: TData$#'
identifier: missingType.generics
count: 1
path: src/lib/FieldType/Value/Row.php
path: src/lib/FieldType/Mapper/MatrixFormMapper.php

-
message: '#^Method Ibexa\\FieldTypeMatrix\\FieldType\\Value\\Row\:\:__get\(\) has parameter \$name with no type specified\.$#'
identifier: missingType.parameter
message: '#^Method Ibexa\\FieldTypeMatrix\\FieldType\\Mapper\\MatrixFormMapper\:\:mapFieldValueForm\(\) has parameter \$fieldForm with generic interface Symfony\\Component\\Form\\FormInterface but does not specify its types\: TData$#'
identifier: missingType.generics
count: 1
path: src/lib/FieldType/Value/Row.php

-
message: '#^Method Ibexa\\FieldTypeMatrix\\FieldType\\Value\\Row\:\:__isset\(\) has parameter \$name with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: src/lib/FieldType/Value/Row.php

-
message: '#^Method Ibexa\\FieldTypeMatrix\\FieldType\\Value\\Row\:\:getCells\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/FieldType/Value/Row.php
path: src/lib/FieldType/Mapper/MatrixFormMapper.php

-
message: '#^Parameter \#2 \$callback of function array_filter expects \(callable\(string\)\: bool\)\|null, ''strlen'' given\.$#'
identifier: argument.type
count: 1
path: src/lib/FieldType/Value/Row.php

-
message: '#^Property Ibexa\\FieldTypeMatrix\\FieldType\\Value\\Row\:\:\$cells type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/FieldType/Value/Row.php

-
message: '#^Method Ibexa\\FieldTypeMatrix\\GraphQL\\InputHandler\:\:toFieldValue\(\) has parameter \$input with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: src/lib/GraphQL/InputHandler.php

-
message: '#^Method Ibexa\\FieldTypeMatrix\\GraphQL\\InputHandler\:\:toFieldValue\(\) has parameter \$inputFormat with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: src/lib/GraphQL/InputHandler.php

-
message: '#^Method Ibexa\\FieldTypeMatrix\\GraphQL\\Schema\\MatrixFieldDefinitionInputSchemaWorker\:\:canWork\(\) has parameter \$args with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/GraphQL/Schema/MatrixFieldDefinitionInputSchemaWorker.php

-
message: '#^Method Ibexa\\FieldTypeMatrix\\GraphQL\\Schema\\MatrixFieldDefinitionInputSchemaWorker\:\:typeName\(\) has parameter \$args with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/GraphQL/Schema/MatrixFieldDefinitionInputSchemaWorker.php

-
message: '#^Method Ibexa\\FieldTypeMatrix\\GraphQL\\Schema\\MatrixFieldDefinitionInputSchemaWorker\:\:work\(\) has parameter \$args with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/GraphQL/Schema/MatrixFieldDefinitionInputSchemaWorker.php

-
message: '#^Method Ibexa\\FieldTypeMatrix\\GraphQL\\Schema\\MatrixFieldDefinitionSchemaWorker\:\:canWork\(\) has parameter \$args with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/GraphQL/Schema/MatrixFieldDefinitionSchemaWorker.php

-
message: '#^Method Ibexa\\FieldTypeMatrix\\GraphQL\\Schema\\MatrixFieldDefinitionSchemaWorker\:\:typeName\(\) has parameter \$args with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/GraphQL/Schema/MatrixFieldDefinitionSchemaWorker.php

-
message: '#^Method Ibexa\\FieldTypeMatrix\\GraphQL\\Schema\\MatrixFieldDefinitionSchemaWorker\:\:work\(\) has parameter \$args with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/GraphQL/Schema/MatrixFieldDefinitionSchemaWorker.php

-
message: '#^Method Ibexa\\FieldTypeMatrix\\GraphQL\\SilentRow\:\:__get\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/GraphQL/SilentRow.php

-
message: '#^Method Ibexa\\FieldTypeMatrix\\GraphQL\\SilentRow\:\:__get\(\) has parameter \$name with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: src/lib/GraphQL/SilentRow.php
68 changes: 34 additions & 34 deletions src/bundle/Command/MigrateLegacyMatrixCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,18 @@
use Symfony\Component\Console\Style\SymfonyStyle;

#[AsCommand(name: 'ibexa:migrate:legacy_matrix')]
class MigrateLegacyMatrixCommand extends Command
final class MigrateLegacyMatrixCommand extends Command
{
private const DEFAULT_ITERATION_COUNT = 1000;
private const EZMATRIX_IDENTIFIER = 'ezmatrix';
private const CONFIRMATION_ANSWER = 'yes';
private const int DEFAULT_ITERATION_COUNT = 1000;
private const string IBEXA_MATRIX_IDENTIFIER = 'ibexa_matrix';
private const string CONFIRMATION_ANSWER = 'yes';

private Connection $connection;

/**
* @param \Doctrine\DBAL\Connection $connection
*/
public function __construct(
Connection $connection
private readonly Connection $connection
) {
$this->connection = $connection;

parent::__construct();
}

/**
* {@inheritdoc}
*/
protected function configure(): void
{
$this
Expand All @@ -66,9 +56,6 @@ protected function configure(): void
);
}

/**
* {@inheritdoc}
*/
public function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
Expand All @@ -84,7 +71,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
}
}

$io->comment('Migrating legacy ezmatrix fieldtype');
$io->comment('Migrating legacy ibexa_matrix fieldtype');

$iterationCount = (int)$input->getOption('iteration-count');
$converter = new MatrixConverter();
Expand All @@ -94,13 +81,19 @@ public function execute(InputInterface $input, OutputInterface $output): int
libxml_use_internal_errors(true);

foreach ($contentClassAttributes as $contentClassAttribute) {
$io->comment(sprintf('Migrate %s:%s attribute.', $contentClassAttribute['contenttype_identifier'], $contentClassAttribute['identifier']));
$io->comment(
sprintf(
'Migrate %s:%s attribute.',
$contentClassAttribute['contenttype_identifier'],
$contentClassAttribute['identifier']
)
);

try {
$xml = new SimpleXMLElement((string)$contentClassAttribute['columns']);

$isValidXml = true;
} catch (Exception $e) {
} catch (Exception) {
$isValidXml = false;
}

Expand Down Expand Up @@ -128,8 +121,8 @@ public function execute(InputInterface $input, OutputInterface $output): int

$this->updateContentClassAttribute(
(int)$contentClassAttribute['id'],
(int)$storageFieldDefinition->dataInt1,
(string)$storageFieldDefinition->dataText5
$storageFieldDefinition->dataInt1,
$storageFieldDefinition->dataText5
);

$columnsJson = $storageFieldDefinition->dataText5;
Expand All @@ -141,8 +134,15 @@ public function execute(InputInterface $input, OutputInterface $output): int
(int)$contentClassAttribute['id']
);

if ($contentAttributesCount === 0) {
$io->comment(sprintf('Zero instances of %s:%s attribute to migrate.', $contentClassAttribute['contenttype_identifier'], $contentClassAttribute['identifier']));
if ($contentAttributesCount == 0) {
$io->comment(
sprintf(
'Zero instances of %s:%s attribute to migrate.',
$contentClassAttribute['contenttype_identifier'],
$contentClassAttribute['identifier']
)
);

continue;
}

Expand All @@ -165,7 +165,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
$xml = new SimpleXMLElement(
(string)$contentObjectAttribute['data_text']
);
} catch (Exception $e) {
} catch (Exception) {
$progressBar->advance();

continue;
Expand All @@ -186,7 +186,7 @@ public function execute(InputInterface $input, OutputInterface $output): int

$this->updateContentObjectAttribute(
(int)$contentObjectAttribute['id'],
(string)$storageFieldValue->dataText
$storageFieldValue->dataText
);

$progressBar->advance();
Expand All @@ -206,10 +206,10 @@ public function execute(InputInterface $input, OutputInterface $output): int
}

/**
* @param array $cells
* @param array $columns
* @param array<string|int, mixed> $cells
* @param list<array<string, mixed>> $columns
*
* @return array
* @return list<array<string, string>>
*/
private function convertCellsToRows(array $cells, array $columns): array
{
Expand All @@ -223,7 +223,7 @@ private function convertCellsToRows(array $cells, array $columns): array

$row[$columnIdentifier] = (string)$cell;

if ($columnIndex === $columnsCount - 1) {
if ($columnIndex == $columnsCount - 1) {
$rows[] = $row;
$row = [];
}
Expand All @@ -233,7 +233,7 @@ private function convertCellsToRows(array $cells, array $columns): array
}

/**
* @return array
* @return list<array<string,mixed>>
*/
private function getContentClassAttributes(): array
{
Expand All @@ -249,7 +249,7 @@ private function getContentClassAttributes(): array
->from(ContentTypeGateway::FIELD_DEFINITION_TABLE, 'attr')
->join('attr', ContentTypeGateway::CONTENT_TYPE_TABLE, 'class', 'class.id = attr.content_type_id')
->where('attr.data_type_string = :identifier')
->setParameter('identifier', self::EZMATRIX_IDENTIFIER);
->setParameter('identifier', self::IBEXA_MATRIX_IDENTIFIER);

return $query->executeQuery()->fetchAllAssociative();
}
Expand Down Expand Up @@ -282,7 +282,7 @@ private function getContentObjectAttributesCount(int $id): int
}

/**
* @return array
* @return list<array<string, mixed>>
*/
private function getContentObjectAttributes(int $id, int $offset, int $iterationCount): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Yaml\Yaml;

class IbexaFieldTypeMatrixExtension extends Extension implements PrependExtensionInterface
final class IbexaFieldTypeMatrixExtension extends Extension implements PrependExtensionInterface
{
public function load(array $configs, ContainerBuilder $container): void
{
Expand All @@ -39,7 +39,7 @@ public function prepend(ContainerBuilder $container): void
public function prependKernelSettings(ContainerBuilder $container): void
{
$configFile = __DIR__ . '/../Resources/config/kernel.yaml';
$config = Yaml::parse(file_get_contents($configFile));
$config = Yaml::parseFile($configFile);
$container->prependExtensionConfig('ibexa', $config);
$container->addResource(new FileResource($configFile));
}
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/IbexaFieldTypeMatrixBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

use Symfony\Component\HttpKernel\Bundle\Bundle;

class IbexaFieldTypeMatrixBundle extends Bundle
final class IbexaFieldTypeMatrixBundle extends Bundle
{
}
Loading
Loading