WordPress / WordPress/phpdoc-parser

DocBlocks for filters inside a conditional expression are not imported

Open
#185 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
239
Forks
81
Avg merge
16h 29m
Merged PRs (30d)
8

Description

DocBlocks outside a conditional are not imported if there are other filters (with DocBlocks) within the conditional.

Example 1

In this example DocBlock 2 is not imported for the filter in_conditional_expression

/**
 * DocBlock 1
 */
function test_docblocks() {
	/**
	 * DocBlock 2
	 */
	if ( apply_filters( 'in_conditional_expression', true ) ) {
		/**
		 * DocBlock 3
		 */
		$value = apply_filters( 'in_conditional', true );
	}
}
Example 2

In this example the (wrong) DocBlock 2 is imported for the filter 'in_conditional`.

/**
 * DocBlock 1
 */
function test_docblocks() {
	/**
	 * DocBlock 2
	 */
	if ( apply_filters( 'in_conditional_expression', true ) ) {

		$value = apply_filters( 'in_conditional', true );
	}
}

The wp_save_post_revision_check_for_changes filter doesn't get its DocBlock imported because of this bug.

See this filter in trac

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two PHP examples and tracing how apply_filters calls inside conditional expressions are associated with DocBlocks. Compare the parser's result for both examples with the expected filter documentation, including wp_save_post_revision_check_for_changes. Done means DocBlock 2 is assigned to in_conditional_expression and the correct DocBlock is assigned to in_conditional.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.