← All results

properties-of<T> is a Psalm-only utility type

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

properties-of<T> expands to an array shape of the class's properties (array{name: string, age: int} here). Psalm models it; other analyzers do not recognize the keyword and either ignore it or report an unknown type. References: - Psalm TPropertiesOf (properties-of / public-properties-of ...)

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 Unrecognized
phpdoc_advanced_psalm_properties_of.php:26: Saw possibly unextractable annotation for a fragment of comment '* @param properties-of<User> $data': after properties, did not see an element name (will guess based on comment order) [PhanUnextractableAnnotationElementName]
phpdoc_advanced_psalm_properties_of.php:26: Saw a token Phan may have failed to parse after '* @param properties-of<User> $data': after properties, saw '-' [PhanUnextractableAnnotationSuffix]
  • Recognition: spelling not resolved — reported on declaration line(s) 26
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved
phpstan 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 Unrecognized
phpdoc_advanced_psalm_properties_of.php:28: Function Conformance\Tests\PhpdocAdvancedPsalmPropertiesOf\acceptsUserProps() has parameter $data with no value type specified in iterable type array. [identifier=missingType.iterableValue] [reported-from-level=6]
phpdoc_advanced_psalm_properties_of.php:28: PHPDoc tag @param for parameter $data contains unresolvable type. [identifier=parameter.unresolvableType] [reported-from-level=2]
With strict-rules
phpdoc_advanced_psalm_properties_of.php:28: Function Conformance\Tests\PhpdocAdvancedPsalmPropertiesOf\acceptsUserProps() has parameter $data with no value type specified in iterable type array. [identifier=missingType.iterableValue]
phpdoc_advanced_psalm_properties_of.php:28: PHPDoc tag @param for parameter $data contains unresolvable type. [identifier=parameter.unresolvableType]
  • Recognition: spelling not resolved — reported on declaration line(s) 28
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved
psalm 6.16.1Psalm 6.16.1@f1f5de594dc76faf8784e02d3dc4716c91c6f6ac
next: 7.0.0-beta19
Enforced
phpdoc_advanced_psalm_properties_of.php:36: Argument 1 of Conformance\Tests\PhpdocAdvancedPsalmPropertiesOf\acceptsUserProps expects array{age: int, name: string}, but array{age: 'old', name: 'Ada'} provided [InvalidScalarArgument]
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported
mago 1.46.0mago 1.46.0 Enforced
phpdoc_advanced_psalm_properties_of.php:36: Possible argument type mismatch for argument #1 of `Conformance\Tests\PhpdocAdvancedPsalmPropertiesOf\acceptsUserProps`: expected `array{'age': int, 'name': string}`, but possibly received `array{'age': string('old'), 'name': string('Ada')}`. [possibly-invalid-argument]
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported
mir 0.70.1mir 0.70.1 Incidental (1/1)
phpdoc_advanced_psalm_properties_of.php:33: InvalidArgument: Argument $data of acceptsUserProps() expects 'Conformance\Tests\PhpdocAdvancedPsalmPropertiesOf\properties-of<Conformance\Tests\PhpdocAdvancedPsalmPropertiesOf\User>', got 'array{'name': "Ada", 'age': 36}' [MIR0201]
phpdoc_advanced_psalm_properties_of.php:36: InvalidArgument: Argument $data of acceptsUserProps() expects 'Conformance\Tests\PhpdocAdvancedPsalmPropertiesOf\properties-of<Conformance\Tests\PhpdocAdvancedPsalmPropertiesOf\User>', got 'array{'name': "Ada", 'age': "old"}' [MIR0201]
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported — incidental, since values the type admits were also rejected on line(s) 33
Expectation diff
Line 33: Expected valid value to be accepted, got ["InvalidArgument: Argument $data of acceptsUserProps() expects 'Conformance\\Tests\\PhpdocAdvancedPsalmPropertiesOf\\properties-of<Conformance\\Tests\\PhpdocAdvancedPsalmPropertiesOf\\User>', got 'array{'name': \"Ada\", 'age': 36}' [MIR0201]"]
phpantom 0.9.0phpantom_lsp 0.9.0 Not enforced

No diagnostics reported.

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

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/1 of the expected violations reported
phpy 0.2.0phpy 0.2.0 Unrecognized
phpdoc_advanced_psalm_properties_of.php:26: Use of unknown class: 'Conformance\Tests\PhpdocAdvancedPsalmPropertiesOf\properties-of'
  • Recognition: spelling not resolved — reported on declaration line(s) 26
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved
qodana 262.8665.325Qodana 262.8665.325 Unrecognized
phpdoc_advanced_psalm_properties_of.php:26: Argument type does not match the declared [PhpDocSignatureInspection]
phpdoc_advanced_psalm_properties_of.php:26: Undefined class 'properties-of' [PhpUndefinedClassInspection]
  • Recognition: spelling not resolved — reported on declaration line(s) 26
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved
noverify 0.5.5NoVerify, version 0.5.5: built on: 2025.04.22 14:36:46 OS: r-kuchinskas arm64 Commit: 4774b82f8adc53fbef38f95e97af4b953b4d1529 Unrecognized
phpdoc_advanced_psalm_properties_of.php:28: param $data miss matched with phpdoc type <<properties-of<User>>> [funcParamTypeMissMatch]
  • Recognition: spelling not resolved — reported on declaration line(s) 28
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved
steins 0.1.5steins 0.1.5 (2026-08-12 revision 39b4cc1) Widened to a nonexistent-class reference

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/1 of the expected violations reported

Notes: `properties-of<User>` has no `lower_generic` entry, so it lowers through the catch-all to `ContractTy::Class("properties-of")` — Steins has no fact form for a class's declared property types, so per-key checking against them is unmodeled.

phpstan-strict 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 Unrecognized
phpdoc_advanced_psalm_properties_of.php:28: Function Conformance\Tests\PhpdocAdvancedPsalmPropertiesOf\acceptsUserProps() has parameter $data with no value type specified in iterable type array. [identifier=missingType.iterableValue]
phpdoc_advanced_psalm_properties_of.php:28: PHPDoc tag @param for parameter $data contains unresolvable type. [identifier=parameter.unresolvableType]
  • Recognition: spelling not resolved — reported on declaration line(s) 28
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved
psalm-next 7.0.0-beta19Psalm 7.0.0-beta19@7e751c06a756fa64dc4c759c09fe4a173afcb433 Enforced
phpdoc_advanced_psalm_properties_of.php:36: Argument 1 of Conformance\Tests\PhpdocAdvancedPsalmPropertiesOf\acceptsUserProps expects array{age: int, name: string}, but array{age: 'old', name: 'Ada'} provided [InvalidScalarArgument]
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported

Source

<?php

declare(strict_types=1);

namespace Conformance\Tests\PhpdocAdvancedPsalmPropertiesOf;

/**
 * `properties-of<T>` is a Psalm-only utility type.
 *
 * `properties-of<T>` expands to an array shape of the class's properties
 * (`array{name: string, age: int}` here). Psalm models it; other analyzers do
 * not recognize the keyword and either ignore it or report an unknown type.
 *
 * References:
 * - Psalm TPropertiesOf (properties-of / public-properties-of ...)
 */

final class User
{
    public string $name = '';

    public int $age = 0;
}

/**
 * @param properties-of<User> $data
 */
function acceptsUserProps(array $data): void // T: properties-of<User>
{
}

// A shape matching the class properties satisfies the parameter.
acceptsUserProps(['name' => 'Ada', 'age' => 36]); // V

// A shape with a wrong property type is rejected by analyzers that model it.
acceptsUserProps(['name' => 'Ada', 'age' => 'old']); // E?: age must be int in properties-of<User>