Skip to content

Commit 9c686af

Browse files
committed
fix: Resolve PHPCS and Psalm errors after merge with development
- Fix named argument mismatches in ArchiMate services (propDefMap) - Fix undefined $propRef variable in ArchiMateExportService - Fix $this->_appName → $this->appName in SettingsService - Fix empty() on boolean in SettingsService - Add @psalm-suppress for Doctrine PostgreSQLPlatform in OrganizationSyncService - Fix PHPCS formatting in OrganizationHandler
1 parent defea1b commit 9c686af

5 files changed

Lines changed: 41 additions & 31 deletions

File tree

lib/Service/ArchiMateExportService.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ private function generateXmlDirectly(array $objects, array $schemaIdMap): string
10961096
folder: $sectionFolder,
10971097
object: $object,
10981098
sectionName: $sectionName,
1099-
propertyDefinitionMap: $propertyDefinitionMap
1099+
propertyDefinitionMap: $propDefMap
11001100
);
11011101
}
11021102

@@ -1186,7 +1186,7 @@ private function addObjectDirectlyToXmlWithProperties(
11861186
$xmlData = $object['xml'];
11871187
unset($xmlData['_essential_data']);
11881188
} else {
1189-
$xmlData = $this->cleanObjectDataForXml(object: $object, propDefMap: $propDefMap);
1189+
$xmlData = $this->cleanObjectDataForXml(object: $object, propDefMap: $propertyDefinitionMap);
11901190
}
11911191

11921192
if (is_array($xmlData) === true && empty($xmlData) === false) {
@@ -1498,8 +1498,8 @@ private function formatXmlOutput(string $xmlString): string
14981498
/**
14991499
* Clean object data for XML export.
15001500
*
1501-
* @param array $object The object data to clean.
1502-
* @param array $propertyDefinitionMap Property definition map.
1501+
* @param array $object The object data to clean.
1502+
* @param array $propDefMap Property definition map.
15031503
*
15041504
* @return array The cleaned object data.
15051505
*/
@@ -1652,17 +1652,17 @@ private function addCleanDataToXmlNode(
16521652
}
16531653

16541654
// Add properties from root fields using propertyDefinitionMap ONLY if no properties were already processed.
1655-
if (empty($propDefMap) === false && isset($data['properties']) === false) {
1656-
$this->addPropertiesFromRootFields(node: $node, object: $data, propDefMap: $propDefMap);
1655+
if (empty($propertyDefinitionMap) === false && isset($data['properties']) === false) {
1656+
$this->addPropertiesFromRootFields(node: $node, object: $data, propDefMap: $propertyDefinitionMap);
16571657
}
16581658
}//end addCleanDataToXmlNode()
16591659

16601660
/**
16611661
* Add properties to XML node using propertyDefinitionMap from model.
16621662
*
1663-
* @param \SimpleXMLElement $node XML node to add properties to.
1664-
* @param array $object The object with root-level properties.
1665-
* @param array $propertyDefinitionMap Map of property name to ref.
1663+
* @param \SimpleXMLElement $node XML node to add properties to.
1664+
* @param array $object The object with root-level properties.
1665+
* @param array $propDefMap Map of property name to ref.
16661666
*
16671667
* @return void
16681668
*/
@@ -2281,7 +2281,8 @@ private function validatePropertiesAreNotEmpty(\SimpleXMLElement $xml): void
22812281
throw new \InvalidArgumentException("Property missing value element: $propRef");
22822282
}
22832283

2284-
$value = trim((string) $valueElements[0]);
2284+
$value = trim((string) $valueElements[0]);
2285+
$propRef = (string) $attributes['propertyDefinitionRef'];
22852286
if (empty($value) === true) {
22862287
throw new \InvalidArgumentException("Property has empty value: $propRef");
22872288
}
@@ -3195,7 +3196,7 @@ private function assembleOrganizationXml(
31953196
folder: $elementsFolder,
31963197
object: $obj,
31973198
sectionName: 'elements',
3198-
propertyDefinitionMap: $propertyDefinitionMap
3199+
propertyDefinitionMap: $propDefMap
31993200
);
32003201
}
32013202
}
@@ -3228,7 +3229,7 @@ private function assembleOrganizationXml(
32283229
folder: $relsFolder,
32293230
object: $obj,
32303231
sectionName: 'relationships',
3231-
propertyDefinitionMap: $propertyDefinitionMap
3232+
propertyDefinitionMap: $propDefMap
32323233
);
32333234
}
32343235
}
@@ -3260,7 +3261,7 @@ private function assembleOrganizationXml(
32603261
folder: $propDefsFolder,
32613262
object: $obj,
32623263
sectionName: 'property_definitions',
3263-
propertyDefinitionMap: $propertyDefinitionMap
3264+
propertyDefinitionMap: $propDefMap
32643265
);
32653266
}
32663267
}
@@ -3334,7 +3335,7 @@ private function assembleOrganizationXml(
33343335
folder: $diagramsFolder,
33353336
object: $obj,
33363337
sectionName: 'views',
3337-
propertyDefinitionMap: $propertyDefinitionMap
3338+
propertyDefinitionMap: $propDefMap
33383339
);
33393340
}
33403341
}

lib/Service/ArchiMateImportService.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3284,7 +3284,10 @@ private function extractElementProperties(array $element): array
32843284
foreach ($element as $key => $value) {
32853285
if (in_array($key, $excludedKeys) === false && in_array($key, $basicProperties) === false) {
32863286
// Only include non-object values or simple arrays.
3287-
if (is_scalar($value) === true || (is_array($value) === true && $this->isComplexArray(array: $value) === false)) {
3287+
$isSimple = is_scalar($value) === true
3288+
|| (is_array($value) === true
3289+
&& $this->isComplexArray(array: $value) === false);
3290+
if ($isSimple === true) {
32883291
$properties[$key] = $value;
32893292
}
32903293
}

lib/Service/OrganizationSyncService.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ public function __construct(
147147
* @param string $path The JSON path to extract (e.g., '$.status' or 'status')
148148
*
149149
* @return string The SQL expression for JSON extraction
150+
*
151+
* @psalm-suppress UndefinedClass
150152
*/
151153
private function jsonExtract(string $column, string $path): string
152154
{
@@ -182,6 +184,8 @@ private function jsonExtract(string $column, string $path): string
182184
* @param string $value The value to check for
183185
*
184186
* @return string The SQL expression for JSON contains check
187+
*
188+
* @psalm-suppress UndefinedClass
185189
*/
186190
private function jsonContains(string $column, string $value): string
187191
{
@@ -468,6 +472,8 @@ public function performContactSync(int $batchSize=100, int $maxExecutionSeconds=
468472
* Perform synchronization of users.
469473
*
470474
* @return array The sync statistics.
475+
*
476+
* @psalm-suppress UndefinedClass
471477
*/
472478
public function performUserSync(): array
473479
{

lib/Service/SettingsService.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -508,11 +508,11 @@ public function autoConfigureAfterImport(): array
508508
try {
509509
// Check if auto-configuration has already been completed.
510510
$autoConfigCompleted = $this->config->getValueString(
511-
$this->_appName,
511+
$this->appName,
512512
'auto_config_completed',
513513
'false'
514514
) === 'true';
515-
if (empty($autoConfigCompleted) === false) {
515+
if ($autoConfigCompleted === true) {
516516
$this->logger->info('Auto-configuration already completed, skipping');
517517
return [];
518518
}
@@ -1848,7 +1848,7 @@ public function getEmailSettings(): array
18481848
{
18491849
$this->logger->debug('SoftwareCatalog: Loading email settings from configuration');
18501850

1851-
$app = $this->_appName;
1851+
$app = $this->appName;
18521852
$settings = [
18531853
'enabled' => $this->config->getValueString(
18541854
$app,
@@ -2980,7 +2980,7 @@ public function getVersionInfo(): array
29802980
'versionComparison' => $versionComparisonValue,
29812981
'isFullyConfigured' => $this->isFullyConfigured(),
29822982
'autoConfigCompleted' => $this->config->getValueString(
2983-
$this->_appName,
2983+
$this->appName,
29842984
'auto_config_completed',
29852985
'false'
29862986
) === 'true',
@@ -3930,17 +3930,17 @@ public function getVoorzieningenConfig(): array
39303930
if (is_array($decoded) === false) {
39313931
$decoded = [
39323932
'register' => $this->config->getValueString(
3933-
$this->_appName,
3933+
$this->appName,
39343934
'voorzieningen_register',
39353935
''
39363936
),
39373937
'organisatie_schema' => $this->config->getValueString(
3938-
$this->_appName,
3938+
$this->appName,
39393939
'voorzieningen_organisatie_schema',
39403940
''
39413941
),
39423942
'contactpersoon_schema' => $this->config->getValueString(
3943-
$this->_appName,
3943+
$this->appName,
39443944
'voorzieningen_contactpersoon_schema',
39453945
''
39463946
),
@@ -4062,32 +4062,32 @@ public function getAmefConfig(): array
40624062
// Fallback to individual config values for backward compatibility.
40634063
$decoded = [
40644064
'register_id' => $this->config->getValueString(
4065-
$this->_appName,
4065+
$this->appName,
40664066
'amef_register_id',
40674067
''
40684068
),
40694069
'organizations_schema' => $this->config->getValueString(
4070-
$this->_appName,
4070+
$this->appName,
40714071
'amef_organizations_schema',
40724072
''
40734073
),
40744074
'elements_schema' => $this->config->getValueString(
4075-
$this->_appName,
4075+
$this->appName,
40764076
'amef_elements_schema',
40774077
''
40784078
),
40794079
'relationships_schema' => $this->config->getValueString(
4080-
$this->_appName,
4080+
$this->appName,
40814081
'amef_relationships_schema',
40824082
''
40834083
),
40844084
'views_schema' => $this->config->getValueString(
4085-
$this->_appName,
4085+
$this->appName,
40864086
'amef_views_schema',
40874087
''
40884088
),
40894089
'models_schema' => $this->config->getValueString(
4090-
$this->_appName,
4090+
$this->appName,
40914091
'amef_models_schema',
40924092
''
40934093
),
@@ -4631,7 +4631,7 @@ public function compactToJsonConfiguration(): array
46314631

46324632
try {
46334633
// 1. Migrate Voorzieningen configuration.
4634-
$an = $this->_appName;
4634+
$an = $this->appName;
46354635
$voorzieningenConfig = [
46364636
'register' => $this->config->getValueString(
46374637
$an,

lib/Service/SoftwareCatalogue/OrganizationHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,9 @@ private function findExistingContactgegevens(
518518

519519
$existingObjects = $objectService->findAll(
520520
config: [
521-
'filters' => $searchFilters,
521+
'filters' => $searchFilters,
522522
'_register' => $registerId,
523-
'_schema' => $contactgegevensSchemaId,
523+
'_schema' => $contactgegevensSchemaId,
524524
]
525525
);
526526

0 commit comments

Comments
 (0)