🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

Update PHPDoc Tags Docs - #14933

Merged
ondrejmirtes merged 1 commit into
phpstan:2.2.xfrom
phpstan-bot:create-pull-request/patch-avekucx
Jul 7, 2026
Merged

Update PHPDoc Tags Docs#14933
ondrejmirtes merged 1 commit into
phpstan:2.2.xfrom
phpstan-bot:create-pull-request/patch-avekucx

Conversation

@phpstan-bot

Copy link
Copy Markdown
Contributor

Documents the @pure-unless-callable-is-impure PHPDoc tag, which was not covered anywhere on the website.

What was done

I compared the full set of PHPDoc tags PHPStan recognizes (extracted from PhpDocNodeResolver.php and the POSSIBLE_PHPSTAN_TAGS list in InvalidPHPStanDocTagRule.php) against the existing website documentation. Every base tag was already documented except one:

  • @pure-unless-callable-is-impure (with its @phpstan- prefixed variant) — resolved in PhpDocNodeResolver::resolveParamPureUnlessCallableIsImpure() and consumed in SimpleImpurePoint::resolvePureUnlessCallableIsImpureVerdict().

Research

The tag marks a function or method as pure unless the callable passed to the named parameter is impure — the same conditional purity that built-in higher-order functions like array_map() have. Behavior confirmed from the test data in tests/PHPStan/Rules/Pure/data/pure-unless-callable-is-impure.php, which shows:

  • A pure callback keeps the call pure; an impure callback makes it impure.
  • The tag is inherited by overriding methods, including when a child renames the flagged parameter.

Documentation change

Added a new "Conditionally pure functions" section to website/src/writing-php-code/phpdocs-basics.md, placed right after the "Impure functions" section. It includes a concise description, a myMap() code example, and a version badge (Available in PHPStan 2.2).

All other supported tags were verified to already be documented, so no other changes were made.

🤖 Generated with Claude Code

- Added a "Conditionally pure functions" section to phpdocs-basics.md
- Explains marking a function/method as pure unless the callable passed
  to the named parameter is impure (mirrors `array_map()` behavior)
- Notes the tag is inherited by overriding methods and follows renamed
  parameters
@ondrejmirtes
ondrejmirtes merged commit 1acda96 into phpstan:2.2.x Jul 7, 2026
15 checks passed
@ondrejmirtes
ondrejmirtes deleted the create-pull-request/patch-avekucx branch July 7, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants