Skip to content

Commit 0b45862

Browse files
rubenvdlindeclaude
andcommitted
fix: Fix return type bugs found by tightening Psalm suppressors
Removed InvalidArgument, InvalidReturnType, InvalidReturnStatement, InvalidCast, InvalidMethodCall suppressors from psalm.xml — exposing 5 real bugs that were previously hidden: - ArchiMateExportService::createSectionFolder(): return type was SimpleXMLElement but function can return null; fixed to ?SimpleXMLElement - ArchiMateExportService::extractModelMetadata(): return can be ArrayAccess; cast to (array) to satisfy array return type - ContactPersonHandler::assignUserGroups(): docblock said @return void but function signature and body return string; fixed docblock Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b7a1084 commit 0b45862

3 files changed

Lines changed: 5 additions & 8 deletions

File tree

lib/Service/ArchiMateExportService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ private function generateXmlDirectly(array $objects, array $schemaIdMap): string
893893
/**
894894
* Create section element in XML (matching original ArchiMate structure)
895895
*/
896-
private function createSectionFolder(\SimpleXMLElement $xml, string $sectionName): \SimpleXMLElement
896+
private function createSectionFolder(\SimpleXMLElement $xml, string $sectionName): ?\SimpleXMLElement
897897
{
898898
// Map our section names to proper ArchiMate XML elements
899899
$sectionMapping = [
@@ -1515,7 +1515,7 @@ private function extractModelMetadata(array $objects): array
15151515
}
15161516

15171517
if (isset($object['section']) && $object['section'] === 'model') {
1518-
return $object;
1518+
return (array) $object;
15191519
}
15201520
}
15211521

lib/Service/SoftwareCatalogue/ContactPersonHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ public function createUserAccount(object $contactpersoonObject, bool $isFirstCon
614614
* @param array $objectData The contactpersoon object data.
615615
* @param bool $isFirstContact Whether this is the first contact of the organization.
616616
*
617-
* @return void
617+
* @return string
618618
*/
619619
private function assignUserGroups(\OCP\IUser $user, array $objectData, bool $isFirstContact=false): string
620620
{

psalm.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,14 @@
126126
<TypeDoesNotContainType errorLevel="suppress"/>
127127
<InvalidArrayOffset errorLevel="suppress"/>
128128
<InvalidArrayAccess errorLevel="suppress"/>
129-
<InvalidCast errorLevel="suppress"/>
130-
<InvalidArgument errorLevel="suppress"/>
131-
<InvalidReturnType errorLevel="suppress"/>
132-
<InvalidReturnStatement errorLevel="suppress"/>
129+
133130
<MismatchingDocblockReturnType errorLevel="suppress"/>
134131
<EmptyArrayAccess errorLevel="suppress"/>
135132
<ImplementedReturnTypeMismatch errorLevel="suppress"/>
136-
<InvalidMethodCall errorLevel="suppress"/>
137133
<MissingTemplateParam errorLevel="suppress"/>
138134
<UndefinedInterfaceMethod errorLevel="suppress"/>
139135
<UnusedMethodCall errorLevel="suppress"/>
136+
<UnusedReturnValue errorLevel="suppress"/>
140137
<NullableReturnStatement errorLevel="suppress"/>
141138
</issueHandlers>
142139
</psalm>

0 commit comments

Comments
 (0)