← All results

@param-immediately-invoked-callable

Group: Advanced PHPDoc types · Category: ecosystem · File: phpdoc_advanced_phpstan_param_immediately_invoked_callable.php

Free functions default to immediately-invoked; object methods default to later. This tag overrides a method parameter to the immediate schedule. References: - PHPStan phpdocs-basics: Callables - PHPStan 1.11 release notes

Analyzer results

AnalyzerVersionResultDiagnostics
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)
phpdoc_advanced_phpstan_param_immediately_invoked_callable.php:46: Argument 1 ($value) is $name of type null but \Conformance\Tests\PhpdocAdvancedPhpstanParamImmediatelyInvokedCallable\takesString() takes string defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_phpstan_param_immediately_invoked_callable.php:29 [PhanTypeMismatchArgument]
  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
phpstan 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 Recognized (no probes) reported Lv.8+
phpdoc_advanced_phpstan_param_immediately_invoked_callable.php:46: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedPhpstanParamImmediatelyInvokedCallable\takesString expects string, string|null given. [identifier=argument.type] [reported-from-level=8]
With strict-rules
phpdoc_advanced_phpstan_param_immediately_invoked_callable.php:46: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedPhpstanParamImmediatelyInvokedCallable\takesString expects string, string|null given. [identifier=argument.type]
  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
psalm 6.16.1Psalm 6.16.1@f1f5de594dc76faf8784e02d3dc4716c91c6f6ac
next: 7.0.0-beta19
Recognized (no probes)
phpdoc_advanced_phpstan_param_immediately_invoked_callable.php:46: Argument 1 of Conformance\Tests\PhpdocAdvancedPhpstanParamImmediatelyInvokedCallable\takesString cannot be null, possibly null value provided [PossiblyNullArgument]
  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
mago 1.46.0mago 1.46.0 Recognized (no probes)
phpdoc_advanced_phpstan_param_immediately_invoked_callable.php:46: Argument #1 of function `Conformance\Tests\PhpdocAdvancedPhpstanParamImmediatelyInvokedCallable\takesString` is possibly `null`, but parameter type `string` does not accept it. [possibly-null-argument]
  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
mir 0.70.1mir 0.70.1 Recognized (no probes)
phpdoc_advanced_phpstan_param_immediately_invoked_callable.php:46: NullArgument: Argument $value of takesString() cannot be null [MIR0100]
  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
phpantom 0.9.0phpantom_lsp 0.9.0 Recognized (no probes)
phpdoc_advanced_phpstan_param_immediately_invoked_callable.php:46: Argument 1 ($value) expects string, got null [type_mismatch_argument]
  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
intelephense 1.18.5intelephense 1.18.5 Recognized (no probes)
phpdoc_advanced_phpstan_param_immediately_invoked_callable.php:46: Expected type 'string'. Found 'null'. [P1006]
  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
phpy 0.2.0phpy 0.2.0 Recognized (no probes)

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
qodana 262.8665.325Qodana 262.8665.325 Recognized (no probes)

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
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_phpstan_param_immediately_invoked_callable.php:46: not null safety call in function Conformance\Tests\PhpdocAdvancedPhpstanParamImmediatelyInvokedCallable\takesString signature of param value [notNullSafetyFunctionArgumentVariable]
  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
steins 0.1.5steins 0.1.5 (2026-08-12 revision 39b4cc1) Recognized (no probes)

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
phpstan-strict 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 Recognized (no probes)
phpdoc_advanced_phpstan_param_immediately_invoked_callable.php:46: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedPhpstanParamImmediatelyInvokedCallable\takesString expects string, string|null given. [identifier=argument.type]
  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
psalm-next 7.0.0-beta19Psalm 7.0.0-beta19@7e751c06a756fa64dc4c759c09fe4a173afcb433 Recognized (no probes)
phpdoc_advanced_phpstan_param_immediately_invoked_callable.php:46: Argument 1 of Conformance\Tests\PhpdocAdvancedPhpstanParamImmediatelyInvokedCallable\takesString cannot be null, possibly null value provided [PossiblyNullArgument]
  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes

Source

<?php

declare(strict_types=1);

namespace Conformance\Tests\PhpdocAdvancedPhpstanParamImmediatelyInvokedCallable;

/**
 * Cross-tool handling of `@param-immediately-invoked-callable`.
 *
 * Free functions default to immediately-invoked; object methods default to
 * later. This tag overrides a method parameter to the immediate schedule.
 *
 * References:
 * - PHPStan phpdocs-basics: Callables
 * - PHPStan 1.11 release notes
 */

final class Runner
{
    /**
     * @param-immediately-invoked-callable $callback
     */
    public function runNow(callable $callback): void // T: @param-immediately-invoked-callable
    {
        $callback();
    }
}

function takesString(string $value): void
{
}

function example(Runner $runner): void
{
    $name = null;
    $runner->runNow(static function () use (&$name): void {
        $name = 'Ada';
    });

    // NOTE: the invocation-timing tags govern checked-exception propagation
    // (@throws / try-catch), not by-ref narrowing. PHPStan infers `'Ada'|null`
    // for $name whether or not the callable is immediately invoked, so this
    // diagnostic fires independently of the tag and must not be scored as tag
    // enforcement. The checked-exceptions rule that the tag actually feeds is
    // not enabled in this harness, so there is no enforcement probe to make.
    takesString($name); // E?[noise]: string|null argument, independent of the tag
}