Try to add some type comments#2842
Conversation
📝 WalkthroughWalkthroughThis PR adds PHPDoc type annotations ( Changes
Sequence DiagramsequenceDiagram
participant PHP_CodeSniffer as PHP_CodeSniffer
participant Sniff as AddMissingTypeCommentsSniff
participant Fixer as Fixer
participant File as PHP File
PHP_CodeSniffer->>Sniff: register()
Sniff-->>PHP_CodeSniffer: return [T_FUNCTION]
PHP_CodeSniffer->>Sniff: process(File, stackPtr)
Sniff->>Sniff: findDocblock()
Sniff->>Sniff: getFunctionParams()
Sniff->>Sniff: detectReturnType()
Sniff->>Sniff: getMissingParamDocs()
Sniff->>Sniff: getMissingReturn()
alt Missing Type Comments Detected
Sniff->>Sniff: addMissingDocblock()
alt No Docblock Exists
Sniff->>Sniff: createNewDocblock()
Sniff->>Fixer: addFixableError + auto-fix
Fixer->>File: insert new docblock
else Docblock Exists
Sniff->>Sniff: updateExistingDocblock()
Sniff->>Fixer: addFixableError + auto-fix
Fixer->>File: append missing `@param/`@return
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Fix all issues with AI agents
In `@classes/models/fields/FrmFieldCheckbox.php`:
- Around line 119-125: The docblock for prepare_import_value in
FrmFieldCheckbox.php lists `@param` array $atts before `@param` mixed $value which
is opposite the method signature prepare_import_value($value, $atts); update the
docblock so parameters are documented in the same order as the signature (first
`@param` mixed $value, then `@param` array $atts) and ensure the types and
descriptions match the actual parameters used by get_multi_opts_for_import.
In `@phpcs-sniffs/Formidable/Sniffs/Commenting/AddMissingTypeCommentsSniff.php`:
- Around line 236-290: The hasParamDoc check in hasParamDoc() uses strpos which
can falsely match substrings (e.g., "$args2" matching "$args"); replace the
substring check with a boundary-aware regular expression match: when inspecting
$tokens[$contentToken]['content'] for $paramName, use preg_match with
preg_quote($paramName) and word boundaries (or an appropriate regex like '/\b' .
preg_quote($paramName, '/') . '\b/') to ensure only the exact parameter name is
matched; update hasParamDoc() accordingly so getMissingParamDocs() reliably
detects undocumented params.
In `@tests/phpunit/base/FrmUnitTest.php`:
- Around line 645-648: Update the docblock for run_private_method() to match the
actual signature and types: list the parameters in the correct order (first
$method, then $args) and set their types to reflect usage (e.g. `@param` array
$method and `@param` array $args). Ensure the docblock order and types mirror the
function signature run_private_method($method, $args = array()).
In `@tests/phpunit/emails/test_FrmEmail.php`:
- Around line 496-524: Update the PHPDoc blocks to match each method signature
and include missing return tags: for add_to_emails( $to_emails, $values,
$form_id, $args ) reorder the `@param` lines to `@param` array $to_emails, `@param`
mixed $values, `@param` mixed $form_id, `@param` array $args and add an `@return`
array tag; for change_email_subject( $subject, $args ) ensure `@param` order is
`@param` mixed $subject, `@param` array $args and keep the existing `@return` string
tag; for send_separate_emails( $is_single, $args ) reorder to `@param` mixed
$is_single, `@param` array $args and add an `@return` bool tag so docblocks match
the function signatures and returned types.
In `@tests/phpunit/entries/test_FrmShowEntryShortcode.php`:
- Around line 823-826: Docblock `@param` order is inconsistent with the actual
method signatures; update the `@param` tags to match the argument order for each
affected method (e.g., for two_cell_table_row($field_key, $atts) list `@param`
mixed $field_key before `@param` array $atts, for get_field_html_value($entry,
$field, $atts) list `@param` mixed $entry then `@param` mixed $field then `@param`
array $atts, for expected_array($entry, $atts) list `@param` mixed $entry before
`@param` array $atts, and similarly fix other occurrences noted). Locate the
docblocks for two_cell_table_row, get_field_html_value, expected_array and the
other mentioned blocks and reorder the `@param` tags so they exactly match each
function signature order.
🧹 Nitpick comments (7)
classes/models/fields/FrmFieldUrl.php (2)
68-70: Add a return type forvalidate().The method returns the
$errorsarray; documenting it improves clarity and aligns with the PR goal.Suggested docblock tweak
/** * `@param` array $args + * `@return` array */ public function validate( $args ) {
95-98: Document the return type forprepare_display_value().This method returns the original value or a rendered string; documenting
string|array(ormixed) would be clearer.Suggested docblock tweak
/** * `@param` array $atts * `@param` mixed $value + * `@return` string|array */ protected function prepare_display_value( $value, $atts ) {classes/models/fields/FrmFieldSelect.php (1)
94-97: Add a return type forprepare_import_value().This method returns the processed value; documenting
mixedkeeps the docblock complete.Suggested docblock tweak
/** * `@param` array $atts * `@param` mixed $value + * `@return` mixed */ protected function prepare_import_value( $value, $atts ) {classes/models/fields/FrmFieldNumber.php (1)
62-65: LGTM!The
@param array $argsannotation is correct. Consider adding@return arrayto document the returned errors array for completeness.classes/models/fields/FrmFieldText.php (1)
42-54: LGTM!The
@param array $argsannotation correctly documents the parameter type.Consider adding
@return arrayto complete the method documentation, matching the pattern used inFrmFieldUserID::validate().📝 Optional enhancement
/** * `@param` array $args + * + * `@return` array */ public function validate( $args ) {phpcs-sniffs/Formidable/Sniffs/Commenting/AddMissingTypeCommentsSniff.php (2)
335-398: Drop unused locals to keep PHPMD clean.
addMissingDocblock()andcreateNewDocblock()initialize locals that aren’t used.🧹 Suggested cleanup
private function addMissingDocblock( File $phpcsFile, $stackPtr, $docblock, $missingParamDocs, $missingReturn ) { - $tokens = $phpcsFile->getTokens(); - $fixer = $phpcsFile->fixer; - if ( false === $docblock ) { // No existing docblock - create a new one. $this->createNewDocblock( $phpcsFile, $stackPtr, $missingParamDocs, $missingReturn ); @@ private function createNewDocblock( File $phpcsFile, $stackPtr, $missingParamDocs, $missingReturn ) { - $tokens = $phpcsFile->getTokens(); $fixer = $phpcsFile->fixer;
399-461: Remove unused$lastTagPos.It’s assigned but never read.
🧹 Suggested cleanup
- $lastParamPos = false; - $lastTagPos = false; + $lastParamPos = false; @@ - if ( $tokens[ $i ]['code'] === T_DOC_COMMENT_TAG ) { - $lastTagPos = $i; - - if ( $tokens[ $i ]['content'] === '@param' ) { - $lastParamPos = $i; - } - } + if ( $tokens[ $i ]['code'] === T_DOC_COMMENT_TAG && $tokens[ $i ]['content'] === '@param' ) { + $lastParamPos = $i; + }
| /** | ||
| * @param array $atts | ||
| * @param mixed $value | ||
| */ | ||
| protected function prepare_import_value( $value, $atts ) { | ||
| return $this->get_multi_opts_for_import( $value ); | ||
| } |
There was a problem hiding this comment.
Parameter order in docblock doesn't match method signature.
The method signature is prepare_import_value( $value, $atts ), but the docblock lists @param array $atts before @param mixed $value. The parameters should be documented in the same order as they appear in the method signature.
Suggested fix
/**
- * `@param` array $atts
* `@param` mixed $value
+ * `@param` array $atts
*/
protected function prepare_import_value( $value, $atts ) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /** | |
| * @param array $atts | |
| * @param mixed $value | |
| */ | |
| protected function prepare_import_value( $value, $atts ) { | |
| return $this->get_multi_opts_for_import( $value ); | |
| } | |
| /** | |
| * `@param` mixed $value | |
| * `@param` array $atts | |
| */ | |
| protected function prepare_import_value( $value, $atts ) { | |
| return $this->get_multi_opts_for_import( $value ); | |
| } |
🧰 Tools
🪛 PHPMD (2.15.0)
123-123: Avoid unused parameters such as '$atts'. (undefined)
(UnusedFormalParameter)
🤖 Prompt for AI Agents
In `@classes/models/fields/FrmFieldCheckbox.php` around lines 119 - 125, The
docblock for prepare_import_value in FrmFieldCheckbox.php lists `@param` array
$atts before `@param` mixed $value which is opposite the method signature
prepare_import_value($value, $atts); update the docblock so parameters are
documented in the same order as the signature (first `@param` mixed $value, then
`@param` array $atts) and ensure the types and descriptions match the actual
parameters used by get_multi_opts_for_import.
| /** | ||
| * Get parameters that need @param array documentation. | ||
| * | ||
| * @param File $phpcsFile The file being scanned. | ||
| * @param false|int $docblock The docblock opener position, or false. | ||
| * @param array $params Array of parameter names. | ||
| * | ||
| * @return array Array of parameter names that need documentation. | ||
| */ | ||
| private function getMissingParamDocs( File $phpcsFile, $docblock, $params ) { | ||
| $needsDocs = array(); | ||
| $targetNames = array( '$args', '$atts' ); | ||
|
|
||
| foreach ( $params as $param ) { | ||
| if ( ! in_array( $param, $targetNames, true ) ) { | ||
| continue; | ||
| } | ||
|
|
||
| // Check if already documented. | ||
| if ( false !== $docblock && $this->hasParamDoc( $phpcsFile, $docblock, $param ) ) { | ||
| continue; | ||
| } | ||
|
|
||
| $needsDocs[ $param ] = 'array'; | ||
| } | ||
|
|
||
| return $needsDocs; | ||
| } | ||
|
|
||
| /** | ||
| * Check if a parameter is documented in the docblock. | ||
| * | ||
| * @param File $phpcsFile The file being scanned. | ||
| * @param int $docblockStart The docblock opener position. | ||
| * @param string $paramName The parameter name to check. | ||
| * | ||
| * @return bool | ||
| */ | ||
| private function hasParamDoc( File $phpcsFile, $docblockStart, $paramName ) { | ||
| $tokens = $phpcsFile->getTokens(); | ||
| $docblockEnd = $tokens[ $docblockStart ]['comment_closer']; | ||
|
|
||
| for ( $i = $docblockStart; $i < $docblockEnd; $i++ ) { | ||
| if ( $tokens[ $i ]['code'] === T_DOC_COMMENT_TAG && $tokens[ $i ]['content'] === '@param' ) { | ||
| // Check the content after @param for the variable name. | ||
| $contentToken = $phpcsFile->findNext( T_DOC_COMMENT_STRING, $i + 1, $docblockEnd ); | ||
|
|
||
| if ( false !== $contentToken && strpos( $tokens[ $contentToken ]['content'], $paramName ) !== false ) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
fd -t f "AddMissingTypeCommentsSniff.php" --exec wc -l {}Repository: Strategy11/formidable-forms
Length of output: 150
🏁 Script executed:
head -n 290 phpcs-sniffs/Formidable/Sniffs/Commenting/AddMissingTypeCommentsSniff.php | tail -n 60Repository: Strategy11/formidable-forms
Length of output: 1804
🏁 Script executed:
sed -n '260,280p' phpcs-sniffs/Formidable/Sniffs/Commenting/AddMissingTypeCommentsSniff.phpRepository: Strategy11/formidable-forms
Length of output: 766
🏁 Script executed:
sed -n '230,250p' phpcs-sniffs/Formidable/Sniffs/Commenting/AddMissingTypeCommentsSniff.phpRepository: Strategy11/formidable-forms
Length of output: 666
🏁 Script executed:
rg -n "getMissingParamDocs|hasParamDoc" phpcs-sniffs/Formidable/Sniffs/Commenting/AddMissingTypeCommentsSniff.php -A 2 -B 2Repository: Strategy11/formidable-forms
Length of output: 902
Avoid substring matches when detecting documented params.
strpos() can treat @param ... $args2 as matching $args, so missing docs may be skipped. A boundary-aware match avoids that.
🛠️ Proposed fix
- if ( false !== $contentToken && strpos( $tokens[ $contentToken ]['content'], $paramName ) !== false ) {
+ if ( false !== $contentToken && preg_match( '/\Q' . $paramName . '\E(\s|$)/', $tokens[ $contentToken ]['content'] ) ) {
return true;
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /** | |
| * Get parameters that need @param array documentation. | |
| * | |
| * @param File $phpcsFile The file being scanned. | |
| * @param false|int $docblock The docblock opener position, or false. | |
| * @param array $params Array of parameter names. | |
| * | |
| * @return array Array of parameter names that need documentation. | |
| */ | |
| private function getMissingParamDocs( File $phpcsFile, $docblock, $params ) { | |
| $needsDocs = array(); | |
| $targetNames = array( '$args', '$atts' ); | |
| foreach ( $params as $param ) { | |
| if ( ! in_array( $param, $targetNames, true ) ) { | |
| continue; | |
| } | |
| // Check if already documented. | |
| if ( false !== $docblock && $this->hasParamDoc( $phpcsFile, $docblock, $param ) ) { | |
| continue; | |
| } | |
| $needsDocs[ $param ] = 'array'; | |
| } | |
| return $needsDocs; | |
| } | |
| /** | |
| * Check if a parameter is documented in the docblock. | |
| * | |
| * @param File $phpcsFile The file being scanned. | |
| * @param int $docblockStart The docblock opener position. | |
| * @param string $paramName The parameter name to check. | |
| * | |
| * @return bool | |
| */ | |
| private function hasParamDoc( File $phpcsFile, $docblockStart, $paramName ) { | |
| $tokens = $phpcsFile->getTokens(); | |
| $docblockEnd = $tokens[ $docblockStart ]['comment_closer']; | |
| for ( $i = $docblockStart; $i < $docblockEnd; $i++ ) { | |
| if ( $tokens[ $i ]['code'] === T_DOC_COMMENT_TAG && $tokens[ $i ]['content'] === '@param' ) { | |
| // Check the content after @param for the variable name. | |
| $contentToken = $phpcsFile->findNext( T_DOC_COMMENT_STRING, $i + 1, $docblockEnd ); | |
| if ( false !== $contentToken && strpos( $tokens[ $contentToken ]['content'], $paramName ) !== false ) { | |
| return true; | |
| } | |
| } | |
| } | |
| return false; | |
| } | |
| /** | |
| * Get parameters that need `@param` array documentation. | |
| * | |
| * `@param` File $phpcsFile The file being scanned. | |
| * `@param` false|int $docblock The docblock opener position, or false. | |
| * `@param` array $params Array of parameter names. | |
| * | |
| * `@return` array Array of parameter names that need documentation. | |
| */ | |
| private function getMissingParamDocs( File $phpcsFile, $docblock, $params ) { | |
| $needsDocs = array(); | |
| $targetNames = array( '$args', '$atts' ); | |
| foreach ( $params as $param ) { | |
| if ( ! in_array( $param, $targetNames, true ) ) { | |
| continue; | |
| } | |
| // Check if already documented. | |
| if ( false !== $docblock && $this->hasParamDoc( $phpcsFile, $docblock, $param ) ) { | |
| continue; | |
| } | |
| $needsDocs[ $param ] = 'array'; | |
| } | |
| return $needsDocs; | |
| } | |
| /** | |
| * Check if a parameter is documented in the docblock. | |
| * | |
| * `@param` File $phpcsFile The file being scanned. | |
| * `@param` int $docblockStart The docblock opener position. | |
| * `@param` string $paramName The parameter name to check. | |
| * | |
| * `@return` bool | |
| */ | |
| private function hasParamDoc( File $phpcsFile, $docblockStart, $paramName ) { | |
| $tokens = $phpcsFile->getTokens(); | |
| $docblockEnd = $tokens[ $docblockStart ]['comment_closer']; | |
| for ( $i = $docblockStart; $i < $docblockEnd; $i++ ) { | |
| if ( $tokens[ $i ]['code'] === T_DOC_COMMENT_TAG && $tokens[ $i ]['content'] === '@param' ) { | |
| // Check the content after `@param` for the variable name. | |
| $contentToken = $phpcsFile->findNext( T_DOC_COMMENT_STRING, $i + 1, $docblockEnd ); | |
| if ( false !== $contentToken && preg_match( '/\Q' . $paramName . '\E(\s|$)/', $tokens[ $contentToken ]['content'] ) ) { | |
| return true; | |
| } | |
| } | |
| } | |
| return false; | |
| } |
🤖 Prompt for AI Agents
In `@phpcs-sniffs/Formidable/Sniffs/Commenting/AddMissingTypeCommentsSniff.php`
around lines 236 - 290, The hasParamDoc check in hasParamDoc() uses strpos which
can falsely match substrings (e.g., "$args2" matching "$args"); replace the
substring check with a boundary-aware regular expression match: when inspecting
$tokens[$contentToken]['content'] for $paramName, use preg_match with
preg_quote($paramName) and word boundaries (or an appropriate regex like '/\b' .
preg_quote($paramName, '/') . '\b/') to ensure only the exact parameter name is
matched; update hasParamDoc() accordingly so getMissingParamDocs() reliably
detects undocumented params.
| /** | ||
| * @param array $args | ||
| * @param mixed $method | ||
| */ |
There was a problem hiding this comment.
Fix docblock parameter order/types for run_private_method().
The docblock lists $args before $method, but the signature is ($method, $args = array()), and $method is expected to be an array.
Suggested docblock fix
/**
- * `@param` array $args
- * `@param` mixed $method
+ * `@param` array $method
+ * `@param` array $args
+ * `@return` mixed
*/
protected function run_private_method( $method, $args = array() ) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /** | |
| * @param array $args | |
| * @param mixed $method | |
| */ | |
| /** | |
| * `@param` array $method | |
| * `@param` array $args | |
| * `@return` mixed | |
| */ | |
| protected function run_private_method( $method, $args = array() ) { |
🤖 Prompt for AI Agents
In `@tests/phpunit/base/FrmUnitTest.php` around lines 645 - 648, Update the
docblock for run_private_method() to match the actual signature and types: list
the parameters in the correct order (first $method, then $args) and set their
types to reflect usage (e.g. `@param` array $method and `@param` array $args).
Ensure the docblock order and types mirror the function signature
run_private_method($method, $args = array()).
| /** | ||
| * @param array $args | ||
| * @param mixed $to_emails | ||
| * @param mixed $values | ||
| * @param mixed $form_id | ||
| */ | ||
| public function add_to_emails( $to_emails, $values, $form_id, $args ) { | ||
| $to_emails[] = 'test3@mail.com'; | ||
| $to_emails[] = '1231231234'; | ||
| return $to_emails; | ||
| } | ||
|
|
||
| /** | ||
| * @param array $args | ||
| * @param mixed $subject | ||
| * | ||
| * @return string | ||
| */ | ||
| public function change_email_subject( $subject, $args ) { | ||
| return 'New subject'; | ||
| } | ||
|
|
||
| /** | ||
| * @param array $args | ||
| * @param mixed $is_single | ||
| */ | ||
| public function send_separate_emails( $is_single, $args ) { | ||
| return true; | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n tests/phpunit/emails/test_FrmEmail.php | sed -n '496,524p'Repository: Strategy11/formidable-forms
Length of output: 858
Align PHPDoc @param order with method signatures and add missing @return tags.
The @param order in all three methods doesn't match their signatures, which can confuse PHPDoc tooling. Additionally, add_to_emails() and send_separate_emails() are missing @return tags despite returning values.
🛠️ Proposed docblock fix
/**
- * `@param` array $args
- * `@param` mixed $to_emails
- * `@param` mixed $values
- * `@param` mixed $form_id
+ * `@param` mixed $to_emails
+ * `@param` mixed $values
+ * `@param` mixed $form_id
+ * `@param` array $args
+ *
+ * `@return` array
*/
public function add_to_emails( $to_emails, $values, $form_id, $args ) {
@@
/**
- * `@param` array $args
- * `@param` mixed $subject
+ * `@param` mixed $subject
+ * `@param` array $args
*
* `@return` string
*/
public function change_email_subject( $subject, $args ) {
@@
/**
- * `@param` array $args
- * `@param` mixed $is_single
+ * `@param` mixed $is_single
+ * `@param` array $args
+ *
+ * `@return` bool
*/
public function send_separate_emails( $is_single, $args ) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /** | |
| * @param array $args | |
| * @param mixed $to_emails | |
| * @param mixed $values | |
| * @param mixed $form_id | |
| */ | |
| public function add_to_emails( $to_emails, $values, $form_id, $args ) { | |
| $to_emails[] = 'test3@mail.com'; | |
| $to_emails[] = '1231231234'; | |
| return $to_emails; | |
| } | |
| /** | |
| * @param array $args | |
| * @param mixed $subject | |
| * | |
| * @return string | |
| */ | |
| public function change_email_subject( $subject, $args ) { | |
| return 'New subject'; | |
| } | |
| /** | |
| * @param array $args | |
| * @param mixed $is_single | |
| */ | |
| public function send_separate_emails( $is_single, $args ) { | |
| return true; | |
| } | |
| /** | |
| * `@param` mixed $to_emails | |
| * `@param` mixed $values | |
| * `@param` mixed $form_id | |
| * `@param` array $args | |
| * | |
| * `@return` array | |
| */ | |
| public function add_to_emails( $to_emails, $values, $form_id, $args ) { | |
| $to_emails[] = 'test3@mail.com'; | |
| $to_emails[] = '1231231234'; | |
| return $to_emails; | |
| } | |
| /** | |
| * `@param` mixed $subject | |
| * `@param` array $args | |
| * | |
| * `@return` string | |
| */ | |
| public function change_email_subject( $subject, $args ) { | |
| return 'New subject'; | |
| } | |
| /** | |
| * `@param` mixed $is_single | |
| * `@param` array $args | |
| * | |
| * `@return` bool | |
| */ | |
| public function send_separate_emails( $is_single, $args ) { | |
| return true; | |
| } |
🧰 Tools
🪛 PHPMD (2.15.0)
502-502: Avoid unused parameters such as '$values'. (undefined)
(UnusedFormalParameter)
502-502: Avoid unused parameters such as '$form_id'. (undefined)
(UnusedFormalParameter)
502-502: Avoid unused parameters such as '$args'. (undefined)
(UnusedFormalParameter)
514-514: Avoid unused parameters such as '$subject'. (undefined)
(UnusedFormalParameter)
514-514: Avoid unused parameters such as '$args'. (undefined)
(UnusedFormalParameter)
522-522: Avoid unused parameters such as '$is_single'. (undefined)
(UnusedFormalParameter)
522-522: Avoid unused parameters such as '$args'. (undefined)
(UnusedFormalParameter)
🤖 Prompt for AI Agents
In `@tests/phpunit/emails/test_FrmEmail.php` around lines 496 - 524, Update the
PHPDoc blocks to match each method signature and include missing return tags:
for add_to_emails( $to_emails, $values, $form_id, $args ) reorder the `@param`
lines to `@param` array $to_emails, `@param` mixed $values, `@param` mixed $form_id,
`@param` array $args and add an `@return` array tag; for change_email_subject(
$subject, $args ) ensure `@param` order is `@param` mixed $subject, `@param` array
$args and keep the existing `@return` string tag; for send_separate_emails(
$is_single, $args ) reorder to `@param` mixed $is_single, `@param` array $args and
add an `@return` bool tag so docblocks match the function signatures and returned
types.
| /** | ||
| * @param array $atts | ||
| * @param mixed $field_key | ||
| */ |
There was a problem hiding this comment.
Parameter order in docblocks doesn't match method signatures throughout the file.
Multiple methods have docblock parameters listed in a different order than the method signature. For example:
two_cell_table_row( $field_key, $atts )but docblock lists@param array $attsbefore@param mixed $field_keyget_field_html_value( $entry, $field, $atts )but docblock lists@param array $attsfirstexpected_array( $entry, $atts )but docblock lists@param array $attsbefore@param mixed $entry
The @param tags should be documented in the same order as they appear in the method signature to avoid confusion.
Also applies to: 838-842, 865-868, 883-886, 904-907, 984-988, 994-998, 1170-1173, 1202-1205
🤖 Prompt for AI Agents
In `@tests/phpunit/entries/test_FrmShowEntryShortcode.php` around lines 823 - 826,
Docblock `@param` order is inconsistent with the actual method signatures; update
the `@param` tags to match the argument order for each affected method (e.g., for
two_cell_table_row($field_key, $atts) list `@param` mixed $field_key before `@param`
array $atts, for get_field_html_value($entry, $field, $atts) list `@param` mixed
$entry then `@param` mixed $field then `@param` array $atts, for
expected_array($entry, $atts) list `@param` mixed $entry before `@param` array
$atts, and similarly fix other occurrences noted). Locate the docblocks for
two_cell_table_row, get_field_html_value, expected_array and the other mentioned
blocks and reorder the `@param` tags so they exactly match each function signature
order.
Summary by CodeRabbit
Documentation
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.