← All results

Inline comments inside a typedef array shape

Group: Type aliases · Category: ecosystem · File: aliases_shape_inline_comments.php

If a comment in the shape is treated as a parse error, the alias is not a shape and the missing-key probe stays silent. aliases_local_type is the same expansion without comments. Source: vimeo/psalm#10623 (5.22.0). References: - psalm#10623

Analyzer results

AnalyzerVersionResultDiagnostics
phan 6.0.11Phan 6.0.11 php-ast version 1.1.3 PHP version used to run Phan: 8.5.11 Unrecognized
aliases_shape_inline_comments.php:33: Doc-block of $user in take contains phpdoc param type \Conformance\Tests\AliasesShapeInlineComments\UserShape which is incompatible with the param type array declared in the signature [PhanTypeMismatchDeclaredParam]
  • Recognition: spelling not resolved — reported on declaration line(s) 33
  • Enforcement: 0/2 of the expected violations reported — incidental, since the spelling was not resolved
phpstan 2.3.5PHPStan - PHP Static Analysis Tool 2.3.5 Enforced reported Lv.5+
aliases_shape_inline_comments.php:42: Parameter #1 $user of method Conformance\Tests\AliasesShapeInlineComments\User::take() expects array{id: int, name: string}, array{id: 1} given. [reported-from-level=5]
aliases_shape_inline_comments.php:43: Parameter #1 $user of method Conformance\Tests\AliasesShapeInlineComments\User::take() expects array{id: int, name: string}, array{id: 1, name: 2} given. [reported-from-level=5]
With strict-rules
aliases_shape_inline_comments.php:42: Parameter #1 $user of method Conformance\Tests\AliasesShapeInlineComments\User::take() expects array{id: int, name: string}, array{id: 1} given.
aliases_shape_inline_comments.php:43: Parameter #1 $user of method Conformance\Tests\AliasesShapeInlineComments\User::take() expects array{id: int, name: string}, array{id: 1, name: 2} given.
  • Recognition: spelling resolved
  • Enforcement: 2/2 of the expected violations reported
psalm 6.20.9Psalm 6.20.9@f67170ac3c3b931f5088681e21d6c8babc601c08
next: 7.0.4
Enforced (pzoom≠)
aliases_shape_inline_comments.php:42: Argument 1 of Conformance\Tests\AliasesShapeInlineComments\User::take expects array{id: int, name: string}, but array{id: 1} provided [InvalidArgument]
aliases_shape_inline_comments.php:43: Argument 1 of Conformance\Tests\AliasesShapeInlineComments\User::take expects array{id: int, name: string}, but array{id: 1, name: 2} provided [InvalidArgument]
pzoom (Psalm port)
aliases_shape_inline_comments.php:41: Argument 1 of Conformance\Tests\AliasesShapeInlineComments\User::take expects array{//userIDname: string, 2: Conformance\Tests\AliasesShapeInlineComments\//username, id: int}, but array{id: 1, name: 'a'} provided [InvalidArgument]
aliases_shape_inline_comments.php:42: Argument 1 of Conformance\Tests\AliasesShapeInlineComments\User::take expects array{//userIDname: string, 2: Conformance\Tests\AliasesShapeInlineComments\//username, id: int}, but array{id: 1} provided [InvalidArgument]
aliases_shape_inline_comments.php:43: Argument 1 of Conformance\Tests\AliasesShapeInlineComments\User::take expects array{//userIDname: string, 2: Conformance\Tests\AliasesShapeInlineComments\//username, id: int}, but array{id: 1, name: 2} provided [InvalidArgument]
  • Recognition: spelling resolved
  • Enforcement: 2/2 of the expected violations reported
mago 1.59.0mago 1.59.0 Enforced
aliases_shape_inline_comments.php:42: Possible argument type mismatch for argument #1 of `Conformance\Tests\AliasesShapeInlineComments\User::take`: expected `array{'id': int, 'name': string}`, but possibly received `array{'id': int(1)}`. [possibly-invalid-argument]
aliases_shape_inline_comments.php:43: Possible argument type mismatch for argument #1 of `Conformance\Tests\AliasesShapeInlineComments\User::take`: expected `array{'id': int, 'name': string}`, but possibly received `array{'id': int(1), 'name': int(2)}`. [possibly-invalid-argument]
  • Recognition: spelling resolved
  • Enforcement: 2/2 of the expected violations reported
mir 0.91.0mir 0.91.0 Incidental (2/2)
aliases_shape_inline_comments.php:41: InvalidArgument: Argument $user of take() expects 'array{'id': int, '// user ID [MIR0201]
aliases_shape_inline_comments.php:42: InvalidArgument: Argument $user of take() expects 'array{'id': int, '// user ID [MIR0201]
aliases_shape_inline_comments.php:43: InvalidArgument: Argument $user of take() expects 'array{'id': int, '// user ID [MIR0201]
  • Recognition: spelling resolved
  • Enforcement: 2/2 of the expected violations reported — incidental, since values the type admits were also rejected on line(s) 41
Expectation diff
Line 41: Expected valid value to be accepted, got ["InvalidArgument: Argument $user of take() expects 'array{'id': int, '// user ID [MIR0201]"]
phpantom 0.11.1phpantom_lsp 0.11.1 Not enforced

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/2 of the expected violations reported
intelephense 1.18.5intelephense 1.18.5 Not enforced

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/2 of the expected violations reported
phpactor 2026.10.07.0Phpactor 2026.10.07.0 Not enforced

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/2 of the expected violations reported
phpy 1.0.19490phpy 1.0.19490 Not enforced

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/2 of the expected violations reported
qodana 262.11879.104PhpStorm 262.11879.104 Enforced
aliases_shape_inline_comments.php:42: Incomplete array according to shape declaration. Missing key(s): name [PhpMissingArrayKeyInspection]
aliases_shape_inline_comments.php:43: Expected parameter of type 'string', 'int' provided [PhpParamsInspection]
  • Recognition: spelling resolved
  • Enforcement: 2/2 of the expected violations reported
noverify 0.5.5NoVerify, version 0.5.5: built on: 2025.04.22 14:36:46 OS: r-kuchinskas arm64 Commit: 4774b82f8adc53fbef38f95e97af4b953b4d1529 Unrecognized
aliases_shape_inline_comments.php:33: Class or interface named \Conformance\Tests\AliasesShapeInlineComments\UserShape does not exist [undefinedClass]
aliases_shape_inline_comments.php:35: param $user miss matched with phpdoc type <<UserShape>> [funcParamTypeMissMatch]
  • Recognition: spelling not resolved — reported on declaration line(s) 33, 35
  • Enforcement: 0/2 of the expected violations reported — incidental, since the spelling was not resolved
steins 0.1.8steins 0.1.8 (2026-09-21 revision 76306a9) Not enforced

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/2 of the expected violations reported
phpstan-strict 2.3.5PHPStan - PHP Static Analysis Tool 2.3.5 Enforced
aliases_shape_inline_comments.php:42: Parameter #1 $user of method Conformance\Tests\AliasesShapeInlineComments\User::take() expects array{id: int, name: string}, array{id: 1} given.
aliases_shape_inline_comments.php:43: Parameter #1 $user of method Conformance\Tests\AliasesShapeInlineComments\User::take() expects array{id: int, name: string}, array{id: 1, name: 2} given.
  • Recognition: spelling resolved
  • Enforcement: 2/2 of the expected violations reported
psalm-next 7.0.4Psalm 7.0.4@fa5b1f6e665cb743838ffd865b8fc96207f9409f Enforced
aliases_shape_inline_comments.php:42: Argument 1 of Conformance\Tests\AliasesShapeInlineComments\User::take expects array{id: int, name: string}, but array{id: 1} provided [InvalidArgument]
aliases_shape_inline_comments.php:43: Argument 1 of Conformance\Tests\AliasesShapeInlineComments\User::take expects array{id: int, name: string}, but array{id: 1, name: 2} provided [InvalidArgument]
  • Recognition: spelling resolved
  • Enforcement: 2/2 of the expected violations reported

Source

<?php

declare(strict_types=1);

namespace Conformance\Tests\AliasesShapeInlineComments;

/**
 * Inline comments inside a typedef array shape.
 *
 * If a comment in the shape is treated as a parse error, the alias is not
 * a shape and the missing-key probe stays silent. `aliases_local_type` is
 * the same expansion without comments.
 *
 * Source: vimeo/psalm#10623 (5.22.0).
 *
 * References:
 * - https://github.com/vimeo/psalm/pull/10623
 */

/**
 * @phpstan-type UserShape array{
 *   id: int, // user ID
 *   name: string, // user name
 * }
 * @psalm-type UserShape = array{
 *   id: int, // user ID
 *   name: string, // user name
 * }
 */
final class User // T: @phpstan-type / @psalm-type
{
    /**
     * @param UserShape $user
     */
    public function take(array $user): void // T: UserShape
    {
    }
}

$user = new User();
$user->take(['id' => 1, 'name' => 'a']); // V
$user->take(['id' => 1]); // E?: name is required
$user->take(['id' => 1, 'name' => 2]); // E?: name is string