Skip to content

Commit

Permalink
[FEATURE] Allow exclusion of member descriptions (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
linawolf authored May 15, 2024
1 parent 18958ba commit 8be3cad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
10 changes: 0 additions & 10 deletions Build/phpstan/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ parameters:
count: 1
path: ../../Classes/Util/ClassDocsHelper.php

-
message: "#^Static method T3docs\\\\Codesnippet\\\\Util\\\\ClassDocsHelper\\:\\:getConstantCode\\(\\) invoked with 6 parameters, 5 required\\.$#"
count: 2
path: ../../Classes/Util/ClassDocsHelper.php

-
message: "#^Static method T3docs\\\\Codesnippet\\\\Util\\\\ClassDocsHelper\\:\\:getPropertyCode\\(\\) invoked with 6 parameters, 5 required\\.$#"
count: 2
path: ../../Classes/Util/ClassDocsHelper.php

-
message: "#^Variable \\$description might not be defined\\.$#"
count: 1
Expand Down
22 changes: 16 additions & 6 deletions Classes/Util/ClassDocsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public static function extractPhpDomain(
$allowDeprecated = $config['allowDeprecated'] ?? false;
$includeClassComment = $config['includeClassComment'] ?? true;
$includeMemberComment = $config['includeMemberComment'] ?? true;
$includeMethodParameters = $config['includeMemberComment'] ?? true;
$includeMethodParameters = $config['includeMethodParameters'] ?? true;
$includeConstructor = $config['includeConstructor'] ?? false;
$noindexInClass = $config['noindexInClass'] ?? false;
$noindexInClassMembers = $config['noindexInClassMembers'] ?? false;
Expand Down Expand Up @@ -785,7 +785,7 @@ public static function getMethodCode(
);
}
}
if ($comment) {
if ($comment && $includeMemberComment) {
$result[] = $comment;
$result[] = "\n\n";
}
Expand All @@ -795,7 +795,7 @@ public static function getMethodCode(
$result[] = StringHelper::indentMultilineText($code, ' ');
$result[] = "\n\n";
}
if ($parameterInRst) {
if ($includeMethodParameters && $parameterInRst) {
$result[] = implode("\n", $parameterInRst) . "\n";
}
if ($returnType instanceof \ReflectionUnionType or $returnType instanceof \ReflectionNamedType && $returnType->getName() != 'void') {
Expand All @@ -821,7 +821,9 @@ public static function getMethodCode(
if ($noindexInClassMembers) {
$methodHead .= ' :noindex:' . "\n";
}
$methodHead .= $returnPart . "\n";
if ($includeMethodParameters) {
$methodHead .= $returnPart . "\n";
}
$methodHead .= "\n";

$methodBody = StringHelper::indentMultilineText(implode('', $result), ' ');
Expand Down Expand Up @@ -881,6 +883,7 @@ public static function getPropertyCode(
bool $withCode,
int $modifierSum,
bool $noindexInClassMembers,
bool $includeMemberComment,
): string {
$classReflection = self::getClassReflection($class);
$propertyReflection = $classReflection->getProperty($property);
Expand Down Expand Up @@ -934,7 +937,10 @@ public static function getPropertyCode(

// SplFileObject locks the file, so null it when no longer needed
$splFileObject = null;
return $header . StringHelper::indentMultilineText(implode('', $body), ' ');
if ($includeMemberComment) {
return $header . StringHelper::indentMultilineText(implode('', $body), ' ');
}
return $header;
}

/**
Expand All @@ -961,6 +967,7 @@ public static function getConstantCode(
bool $withCode,
int $modifierSum,
bool $noindexInClassMembers,
bool $includeMemberComment,
): string {
$classReflection = self::getClassReflection($class);
$constantReflection = $classReflection->getConstant($constant);
Expand Down Expand Up @@ -1005,6 +1012,9 @@ public static function getConstantCode(

// SplFileObject locks the file, so null it when no longer needed
$splFileObject = null;
return $header . StringHelper::indentMultilineText(implode('', $body), ' ');
if ($includeMemberComment) {
return $header . StringHelper::indentMultilineText(implode('', $body), ' ');
}
return $header;
}
}

0 comments on commit 8be3cad

Please sign in to comment.