| Analyzer | Version | Result | Diagnostics |
|---|---|---|---|
| phan | 6.0.11Phan 6.0.11 php-ast version 1.1.3 PHP version used to run Phan: 8.5.11 | Enforced | callables_array_element_signature.php:32: Argument 1 ($value) is $closures[0]('hello') of type string but \Conformance\Tests\CallablesArrayElementSignature\takesInt() takes int defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/callables_array_element_signature.php:22 [PhanTypeMismatchArgument]
callables_array_element_signature.php:33: Argument 1 ($p0) is 1 of type int (value: 1) but callable(string):string takes string (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/callables_array_element_signature.php:29 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]
callables_array_element_signature.php:42: Argument 1 ($value) is $closures['key'](42) of type int but \Conformance\Tests\CallablesArrayElementSignature\takesString() takes string defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/callables_array_element_signature.php:18 [PhanTypeMismatchArgument]
|
| phpstan | 2.3.5PHPStan - PHP Static Analysis Tool 2.3.5 | Enforced reported Lv.5+ | callables_array_element_signature.php:32: Parameter #1 $value of function Conformance\Tests\CallablesArrayElementSignature\takesInt expects int, string given. [reported-from-level=5] callables_array_element_signature.php:33: Parameter #1 of callable callable(string): string expects string, int given. [reported-from-level=5] callables_array_element_signature.php:42: Parameter #1 $value of function Conformance\Tests\CallablesArrayElementSignature\takesString expects string, int given. [reported-from-level=5] With strict-rulescallables_array_element_signature.php:32: Parameter #1 $value of function Conformance\Tests\CallablesArrayElementSignature\takesInt expects int, string given. callables_array_element_signature.php:33: Parameter #1 of callable callable(string): string expects string, int given. callables_array_element_signature.php:42: Parameter #1 $value of function Conformance\Tests\CallablesArrayElementSignature\takesString expects string, int given.
|
| psalm | 6.20.9Psalm 6.20.9@f67170ac3c3b931f5088681e21d6c8babc601c08 next: 7.0.4 |
Enforced | callables_array_element_signature.php:32: Argument 1 of Conformance\Tests\CallablesArrayElementSignature\takesInt expects int, but string provided [InvalidScalarArgument] callables_array_element_signature.php:33: Argument 1 expects string, but 1 provided [InvalidArgument] callables_array_element_signature.php:42: Argument 1 of Conformance\Tests\CallablesArrayElementSignature\takesString expects string, but int provided [InvalidScalarArgument]
|
| mago | 1.59.0mago 1.59.0 | Enforced | callables_array_element_signature.php:32: Invalid argument type for argument #1 of `Conformance\Tests\CallablesArrayElementSignature\takesInt`: expected `int`, but found `string`. [invalid-argument] callables_array_element_signature.php:33: Invalid argument type for argument #1 of `callable`: expected `string`, but found `int(1)`. [invalid-argument] callables_array_element_signature.php:42: Invalid argument type for argument #1 of `Conformance\Tests\CallablesArrayElementSignature\takesString`: expected `string`, but found `int`. [invalid-argument]
|
| mir | 0.91.0mir 0.91.0 | Enforced | callables_array_element_signature.php:32: InvalidArgument: Argument $value of takesInt() expects 'int', got 'string' [MIR0201] callables_array_element_signature.php:33: InvalidArgument: Argument $arg0 of callable() expects 'string', got '1' [MIR0201] callables_array_element_signature.php:42: InvalidArgument: Argument $value of takesString() expects 'string', got 'int' [MIR0201]
|
| phpantom | 0.11.1phpantom_lsp 0.11.1 | Partly enforced (2/3) | callables_array_element_signature.php:32: Argument 1 ($value) expects int, got string [type_mismatch_argument] callables_array_element_signature.php:42: Argument 1 ($value) expects string, got int [type_mismatch_argument]
|
| intelephense | 1.18.5intelephense 1.18.5 | Partly enforced (2/3) | callables_array_element_signature.php:32: Expected type 'int'. Found 'string'. [P1006] callables_array_element_signature.php:42: Expected type 'string'. Found 'int'. [P1006]
|
| phpactor | 2026.10.07.0Phpactor 2026.10.07.0 | Not enforced | No diagnostics reported.
Expectation diffLine 32: Expected 1 error(s) Line 42: Expected 1 error(s) |
| phpy | 1.0.19490phpy 1.0.19490 | Enforced | callables_array_element_signature.php:32: Argument '1' passed to Conformance\Tests\CallablesArrayElementSignature\takesInt() is expected to be of type int, string given callables_array_element_signature.php:33: Argument '1' passed to callable() is expected to be of type string, int given callables_array_element_signature.php:42: Argument '1' passed to Conformance\Tests\CallablesArrayElementSignature\takesString() is expected to be of type string, int given
|
| qodana | 262.11879.104PhpStorm 262.11879.104 | Partly enforced (2/3) | callables_array_element_signature.php:32: Parameter '$closures[0]('hello')' type is not compatible with declaration when using strict type matching [PhpParamsInspection]
callables_array_element_signature.php:32: Parameter '$closures[0]('hello')' type is not compatible with declaration [PhpStrictTypeCheckingInspection]
callables_array_element_signature.php:42: Parameter '$closures['key'](42)' type is not compatible with declaration when using strict type matching [PhpParamsInspection]
callables_array_element_signature.php:42: Parameter '$closures['key'](42)' 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 | Unrecognized | callables_array_element_signature.php:29: param $closures miss matched with phpdoc type <<array<int, callable(string): string>>> [funcParamTypeMissMatch] callables_array_element_signature.php:39: param $closures miss matched with phpdoc type <<array<string, callable(int): int>>> [funcParamTypeMissMatch]
Expectation diffLine 32: Expected 1 error(s) Line 42: Expected 1 error(s) |
| steins | 0.1.8steins 0.1.8 (2026-09-21 revision 76306a9) | Not enforced | No diagnostics reported.
Expectation diffLine 32: Expected 1 error(s) Line 42: Expected 1 error(s) |
| phpstan-strict | 2.3.5PHPStan - PHP Static Analysis Tool 2.3.5 | Enforced | callables_array_element_signature.php:32: Parameter #1 $value of function Conformance\Tests\CallablesArrayElementSignature\takesInt expects int, string given. callables_array_element_signature.php:33: Parameter #1 of callable callable(string): string expects string, int given. callables_array_element_signature.php:42: Parameter #1 $value of function Conformance\Tests\CallablesArrayElementSignature\takesString expects string, int given.
|
| psalm-next | 7.0.4Psalm 7.0.4@fa5b1f6e665cb743838ffd865b8fc96207f9409f | Enforced | callables_array_element_signature.php:32: Argument 1 of Conformance\Tests\CallablesArrayElementSignature\takesInt expects int, but string provided [InvalidScalarArgument] callables_array_element_signature.php:33: Argument 1 expects string, but 1 provided [InvalidArgument] callables_array_element_signature.php:42: Argument 1 of Conformance\Tests\CallablesArrayElementSignature\takesString expects string, but int provided [InvalidScalarArgument]
|
<?php
declare(strict_types=1);
namespace Conformance\Tests\CallablesArrayElementSignature;
/**
* Callable signatures stored as array values keep their parameter and return
* types when invoked through the array.
*
* Source: vimeo/psalm#11239 (6.3.0).
*
* References:
* - https://github.com/vimeo/psalm/pull/11239
* - callables_docblock_signature for the non-array form
*/
function takesString(string $value): void
{
}
function takesInt(int $value): void
{
}
/**
* @param array<int, callable(string): string> $closures
*/
function invokeStringCallback(array $closures): void // T: callable(string): string
{
takesString($closures[0]('hello')); // V
takesInt($closures[0]('hello')); // E: the callable returns string
$closures[0](1); // E?: the callable parameter is string, not int
}
/**
* @param array<string, callable(int): int> $closures
*/
function invokeIntCallback(array $closures): void // T: callable(int): int
{
takesInt($closures['key'](42)); // V
takesString($closures['key'](42)); // E: the callable returns int
}