phan / phan/phan

Add `@phan-real-param` annotation option?

Open
#4,069 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
5.6k
Forks
365
Avg merge
1h 25m
Merged PRs (30d)
6

Description

When that annotation is used, pretend it is the real signature type for analysis purposes. Warn if they are incompatible or about not being fully supported if they overridden by other methods

This can be used to generate stubs with the equivalent of union types, or newer features, or resource.
(e.g. to prepare for upgrading an extension or php version, in combination with internal stubs)

This may be useful for tooling that removes syntax incompatible with older php versions.

Phan already supports @phan-real-return


/** @phan-real-param array|int $x */
function test($x) {
     
}
test('test');  // Should emit stricter real type mismatch warning

Contributor guide

Open the contributing guide

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 locating Phan's existing @phan-real-return support and tracing how annotations affect signature analysis. Define the behavior for @phan-real-param, including incompatible calls and overrides, then add coverage for the union-type example and verify the intended warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.