public-properties-of<T> is a Psalm visibility-filtered utility typeproperties-of<T> that only expands *public* non-static
properties. Psalm also documents protected-properties-of and
private-properties-of; this file probes the public variant.
References:
- Psalm utility_types.md: properties-of variants| 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 | Unrecognized | phpdoc_advanced_psalm_public_properties_of.php:34: Saw possibly unextractable annotation for a fragment of comment '* @param public-properties-of<User> $data': after public, did not see an element name (will guess based on comment order) [PhanUnextractableAnnotationElementName] phpdoc_advanced_psalm_public_properties_of.php:34: Saw a token Phan may have failed to parse after '* @param public-properties-of<User> $data': after public, saw '-' [PhanUnextractableAnnotationSuffix]
|
| phpstan | 2.3.5PHPStan - PHP Static Analysis Tool 2.3.5 | Unrecognized | phpdoc_advanced_psalm_public_properties_of.php:36: Function Conformance\Tests\PhpdocAdvancedPsalmPublicPropertiesOf\acceptsPublicUserProps() has parameter $data with no value type specified in iterable type array. [reported-from-level=6] phpdoc_advanced_psalm_public_properties_of.php:36: PHPDoc tag @param for parameter $data contains unresolvable type. [reported-from-level=2] With strict-rulesphpdoc_advanced_psalm_public_properties_of.php:36: Function Conformance\Tests\PhpdocAdvancedPsalmPublicPropertiesOf\acceptsPublicUserProps() has parameter $data with no value type specified in iterable type array. phpdoc_advanced_psalm_public_properties_of.php:36: PHPDoc tag @param for parameter $data contains unresolvable type.
|
| psalm | 6.20.9Psalm 6.20.9@f67170ac3c3b931f5088681e21d6c8babc601c08 next: 7.0.4 |
Enforced | phpdoc_advanced_psalm_public_properties_of.php:44: Argument 1 of Conformance\Tests\PhpdocAdvancedPsalmPublicPropertiesOf\acceptsPublicUserProps expects array{name: string}, but array{age: 42, name: 'Ada'} with additional array shape fields (age) was provided [InvalidArgument]
phpdoc_advanced_psalm_public_properties_of.php:47: Argument 1 of Conformance\Tests\PhpdocAdvancedPsalmPublicPropertiesOf\acceptsPublicUserProps expects array{name: string}, but array{name: 1} provided [InvalidScalarArgument]
|
| mago | 1.59.0mago 1.59.0 | Enforced | phpdoc_advanced_psalm_public_properties_of.php:44: Possible argument type mismatch for argument #1 of `Conformance\Tests\PhpdocAdvancedPsalmPublicPropertiesOf\acceptsPublicUserProps`: expected `array{'name': string}`, but possibly received `array{'age': int(42), 'name': string('Ada')}`. [possibly-invalid-argument]
phpdoc_advanced_psalm_public_properties_of.php:47: Possible argument type mismatch for argument #1 of `Conformance\Tests\PhpdocAdvancedPsalmPublicPropertiesOf\acceptsPublicUserProps`: expected `array{'name': string}`, but possibly received `array{'name': int(1)}`. [possibly-invalid-argument]
|
| mir | 0.91.0mir 0.91.0 | Not enforced | No diagnostics reported.
|
| phpantom | 0.11.1phpantom_lsp 0.11.1 | Not enforced | No diagnostics reported.
|
| intelephense | 1.18.5intelephense 1.18.5 | Not enforced | phpdoc_advanced_psalm_public_properties_of.php:34: Documented type is not compatible with the declared type. [P1131]
|
| phpactor | 2026.10.07.0Phpactor 2026.10.07.0 | Not enforced | No diagnostics reported.
|
| phpy | 1.0.19490phpy 1.0.19490 | Unrecognized | phpdoc_advanced_psalm_public_properties_of.php:34: Use of unknown class: 'Conformance\Tests\PhpdocAdvancedPsalmPublicPropertiesOf\public-properties-of'
|
| qodana | 262.11879.104PhpStorm 262.11879.104 | Unrecognized | phpdoc_advanced_psalm_public_properties_of.php:34: Argument type does not match the declared [PhpDocSignatureInspection] phpdoc_advanced_psalm_public_properties_of.php:34: Undefined class 'public-properties-of' [PhpUndefinedClassInspection]
|
| 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_public_properties_of.php:36: param $data miss matched with phpdoc type <<public-properties-of<User>>> [funcParamTypeMissMatch]
|
| steins | 0.1.8steins 0.1.8 (2026-09-21 revision 76306a9) | Unrecognized | phpdoc_advanced_psalm_public_properties_of.php:34: `public-properties-of` is not type vocabulary — a class name cannot contain `-`, so the name denotes nothing [phpdoc.unknown-vocabulary]
|
| phpstan-strict | 2.3.5PHPStan - PHP Static Analysis Tool 2.3.5 | Unrecognized | phpdoc_advanced_psalm_public_properties_of.php:36: Function Conformance\Tests\PhpdocAdvancedPsalmPublicPropertiesOf\acceptsPublicUserProps() has parameter $data with no value type specified in iterable type array. phpdoc_advanced_psalm_public_properties_of.php:36: PHPDoc tag @param for parameter $data contains unresolvable type.
|
| psalm-next | 7.0.4Psalm 7.0.4@fa5b1f6e665cb743838ffd865b8fc96207f9409f | Enforced | phpdoc_advanced_psalm_public_properties_of.php:44: Argument 1 of Conformance\Tests\PhpdocAdvancedPsalmPublicPropertiesOf\acceptsPublicUserProps expects array{name: string}, but array{age: 42, name: 'Ada'} with additional array shape fields (age) was provided [InvalidArgument]
phpdoc_advanced_psalm_public_properties_of.php:47: Argument 1 of Conformance\Tests\PhpdocAdvancedPsalmPublicPropertiesOf\acceptsPublicUserProps expects array{name: string}, but array{name: 1} provided [InvalidScalarArgument]
|
<?php
declare(strict_types=1);
namespace Conformance\Tests\PhpdocAdvancedPsalmPublicPropertiesOf;
/**
* `public-properties-of<T>` is a Psalm visibility-filtered utility type.
*
* Sibling of `properties-of<T>` that only expands *public* non-static
* properties. Psalm also documents `protected-properties-of` and
* `private-properties-of`; this file probes the public variant.
*
* References:
* - Psalm utility_types.md: properties-of variants
*/
final class User
{
public string $name = '';
protected int $age = 0;
private string $secret = '';
public function describe(): string
{
// Touch non-public fields so unused-property rules stay quiet.
return $this->name . (string) $this->age . $this->secret;
}
}
/**
* @param public-properties-of<User> $data
*/
function acceptsPublicUserProps(array $data): void // T: public-properties-of<User>
{
}
// Only the public property is required / accepted by the shape.
acceptsPublicUserProps(['name' => 'Ada']); // V
// A non-public property key is not part of public-properties-of<User>.
acceptsPublicUserProps(['name' => 'Ada', 'age' => 42]); // E?: age is protected, not in public-properties-of
// Wrong type on the public property.
acceptsPublicUserProps(['name' => 1]); // E?: name must be string in public-properties-of<User>