@phan-output-reference@phan-output-reference
- Parallel idea: @param-out (covered separately)| Analyzer | Version | Result | Diagnostics |
|---|---|---|---|
| phan | 6.0.7Phan 6.0.7 php-ast version 1.1.3 PHP version used to run Phan: 8.5.9 | Recognized (no probes) | No diagnostics reported.
|
| phpstan | 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 | Recognized (no probes) reported Lv.8+ | phpdoc_advanced_vendor_prefixed_output_reference_phan.php:43: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedVendorPrefixedOutputReferencePhan\takesString expects string, string|null given. [identifier=argument.type] [reported-from-level=8] With strict-rulesphpdoc_advanced_vendor_prefixed_output_reference_phan.php:43: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedVendorPrefixedOutputReferencePhan\takesString expects string, string|null given. [identifier=argument.type]
|
| psalm | 6.16.1Psalm 6.16.1@f1f5de594dc76faf8784e02d3dc4716c91c6f6ac next: 7.0.0-beta19 |
Recognized (no probes) | phpdoc_advanced_vendor_prefixed_output_reference_phan.php:43: Argument 1 of Conformance\Tests\PhpdocAdvancedVendorPrefixedOutputReferencePhan\takesString cannot be null, possibly null value provided [PossiblyNullArgument]
|
| mago | 1.46.0mago 1.46.0 | Recognized (no probes) | phpdoc_advanced_vendor_prefixed_output_reference_phan.php:43: Argument #1 of function `Conformance\Tests\PhpdocAdvancedVendorPrefixedOutputReferencePhan\takesString` is possibly `null`, but parameter type `string` does not accept it. [possibly-null-argument]
|
| mir | 0.70.1mir 0.70.1 | Recognized (no probes) | No diagnostics reported.
|
| phpantom | 0.9.0phpantom_lsp 0.9.0 | Recognized (no probes) | phpdoc_advanced_vendor_prefixed_output_reference_phan.php:43: Argument 1 ($value) expects string, got null [type_mismatch_argument]
|
| intelephense | 1.18.5intelephense 1.18.5 | Recognized (no probes) | phpdoc_advanced_vendor_prefixed_output_reference_phan.php:43: Expected type 'string'. Found 'null'. [P1006]
|
| phpy | 0.2.0phpy 0.2.0 | Recognized (no probes) | No diagnostics reported.
|
| qodana | 262.8665.325Qodana 262.8665.325 | Recognized (no probes) | phpdoc_advanced_vendor_prefixed_output_reference_phan.php:43: Parameter '$value' type is not compatible with declaration [PhpStrictTypeCheckingInspection]
|
| noverify | 0.5.5NoVerify, version 0.5.5: built on: 2025.04.22 14:36:46 OS: r-kuchinskas arm64 Commit: 4774b82f8adc53fbef38f95e97af4b953b4d1529 | Recognized (no probes) | phpdoc_advanced_vendor_prefixed_output_reference_phan.php:43: not null safety call in function Conformance\Tests\PhpdocAdvancedVendorPrefixedOutputReferencePhan\takesString signature of param value [notNullSafetyFunctionArgumentVariable]
|
| steins | 0.1.5steins 0.1.5 (2026-08-12 revision 39b4cc1) | Recognized (no probes) | No diagnostics reported.
|
| phpstan-strict | 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 | Recognized (no probes) | phpdoc_advanced_vendor_prefixed_output_reference_phan.php:43: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedVendorPrefixedOutputReferencePhan\takesString expects string, string|null given. [identifier=argument.type]
|
| psalm-next | 7.0.0-beta19Psalm 7.0.0-beta19@7e751c06a756fa64dc4c759c09fe4a173afcb433 | Recognized (no probes) | phpdoc_advanced_vendor_prefixed_output_reference_phan.php:43: Argument 1 of Conformance\Tests\PhpdocAdvancedVendorPrefixedOutputReferencePhan\takesString cannot be null, possibly null value provided [PossiblyNullArgument]
|
<?php
declare(strict_types=1);
namespace Conformance\Tests\PhpdocAdvancedVendorPrefixedOutputReferencePhan;
/**
* Cross-tool handling of `@phan-output-reference`.
*
* Marks a by-ref parameter as an output: after the call, supporting tools treat
* the argument as definitely assigned (and often non-null) even when the
* pre-call type included null.
*
* References:
* - Phan Annotating-Your-Source-Code: `@phan-output-reference`
* - Parallel idea: `@param-out` (covered separately)
*/
/**
* @param string|null $value @phan-output-reference
*/
function assignString(?string &$value): void // T: @phan-output-reference
{
// Keep a null path so tools do not complain the by-ref type is over-wide.
$value = \rand(0, 10) > 0 ? 'assigned' : null;
}
function takesString(string $value): void
{
}
function example(): void
{
$value = null;
assignString($value);
// NOTE: no analyzer in this suite discriminates on @phan-output-reference
// here. Tools that ignore it fall back to the declared `?string` by-ref type
// and report the null argument; Phan (the origin) does not surface this
// by-ref flow at all, so it stays silent whether or not the tag is honoured.
// The diagnostic therefore tracks the declared by-ref type, not the tag, and
// must not be scored as enforcement.
takesString($value); // E?[noise]: declared ?string by-ref type, independent of the tag
}