@psalm-inheritors@phpstan-sealed.
References:
- Psalm supported_annotations.md: @psalm-inheritors
- Psalm InheritorViolation / InvalidExtendClass| 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.12 | Not enforced | No diagnostics reported.
|
| phpstan | 2.3.7PHPStan - PHP Static Analysis Tool 2.3.7 | Enforced reported Lv.0+ | phpdoc_advanced_psalm_inheritors.php:34: Type Conformance\Tests\PhpdocAdvancedPsalmInheritors\Forbidden is not allowed to be a subtype of Conformance\Tests\PhpdocAdvancedPsalmInheritors\Base. [reported-from-level=0] With strict-rulesphpdoc_advanced_psalm_inheritors.php:34: Type Conformance\Tests\PhpdocAdvancedPsalmInheritors\Forbidden is not allowed to be a subtype of Conformance\Tests\PhpdocAdvancedPsalmInheritors\Base.
|
| phpstan-strict | 2.3.7PHPStan - PHP Static Analysis Tool 2.3.7 | Enforced | phpdoc_advanced_psalm_inheritors.php:34: Type Conformance\Tests\PhpdocAdvancedPsalmInheritors\Forbidden is not allowed to be a subtype of Conformance\Tests\PhpdocAdvancedPsalmInheritors\Base.
|
| psalm | 6.21.4Psalm 6.21.4@72023213487628df0bc5b2e02d68cbac614b7ef5 | Enforced | phpdoc_advanced_psalm_inheritors.php:34: Class Conformance\Tests\PhpdocAdvancedPsalmInheritors\Forbidden is not an allowed inheritor of parent class Conformance\Tests\PhpdocAdvancedPsalmInheritors\Base [InheritorViolation]
|
| psalm 7 | 7.21.0Psalm 7.21.0@1a665f0114bd40cf12ad57a1a82066549d92f1b6 | Enforced | phpdoc_advanced_psalm_inheritors.php:34: Class Conformance\Tests\PhpdocAdvancedPsalmInheritors\Forbidden is not an allowed inheritor of parent class Conformance\Tests\PhpdocAdvancedPsalmInheritors\Base [InheritorViolation]
|
| mago | 1.61.0mago 1.61.0 | Not enforced ⚠ 1 false positive | phpdoc_advanced_psalm_inheritors.php:35: Class `Conformance\Tests\PhpdocAdvancedPsalmInheritors\Forbidden` is not permitted to extend `Conformance\Tests\PhpdocAdvancedPsalmInheritors\Base` [invalid-extend]
Expectation diffLine 35: Unexpected errors ["Class `Conformance\\Tests\\PhpdocAdvancedPsalmInheritors\\Forbidden` is not permitted to extend `Conformance\\Tests\\PhpdocAdvancedPsalmInheritors\\Base` [invalid-extend]"] |
| mir | 0.101.0mir 0.101.0 | Enforced | phpdoc_advanced_psalm_inheritors.php:34: InvalidExtendClass: Class Conformance\Tests\PhpdocAdvancedPsalmInheritors\Forbidden cannot extend sealed Conformance\Tests\PhpdocAdvancedPsalmInheritors\Base, which allows only Conformance\Tests\PhpdocAdvancedPsalmInheritors\AllowedOne|Conformance\Tests\PhpdocAdvancedPsalmInheritors\AllowedTwo [MIR0704]
|
| phpantom | 1.1.0phpantom_lsp 1.1.0 | Not enforced | No diagnostics reported.
|
| pun | 0.4.3pun 0.4.3 | Enforced | phpdoc_advanced_psalm_inheritors.php:34: Type Conformance\Tests\PhpdocAdvancedPsalmInheritors\Forbidden is not allowed to be a subtype of Conformance\Tests\PhpdocAdvancedPsalmInheritors\Base. [class.disallowedSubtype]
|
| intelephense | 1.18.5intelephense 1.18.5 | Not enforced | No diagnostics reported.
|
| phpactor | 2026.11.22.0Phpactor 2026.11.22.0 | Not enforced | No diagnostics reported.
|
| phpy | 1.0.19566phpy 1.0.19566 | Not enforced | No diagnostics reported.
|
| qodana | 263.7307.215PhpStorm 263.7307.215 | Not enforced | No diagnostics reported.
|
| noverify | 0.5.5NoVerify, version 0.5.5: built on: 2025.04.22 14:36:46 OS: r-kuchinskas arm64 Commit: 4774b82f8adc53fbef38f95e97af4b953b4d1529 | Not enforced | No diagnostics reported.
|
| steins | 0.1.8steins 0.1.8 (2026-09-21 revision 76306a9) | Not enforced | No diagnostics reported.
|
<?php
declare(strict_types=1);
namespace Conformance\Tests\PhpdocAdvancedPsalmInheritors;
/**
* Cross-tool handling of `@psalm-inheritors`.
*
* Restricts which types may extend the annotated class. Psalm's spelling of
* the same idea as `@phpstan-sealed`.
*
* References:
* - Psalm supported_annotations.md: `@psalm-inheritors`
* - Psalm InheritorViolation / InvalidExtendClass
*/
/**
* @psalm-inheritors AllowedOne|AllowedTwo
*/
abstract class Base // T: @psalm-inheritors
{
}
final class AllowedOne extends Base // V
{
}
final class AllowedTwo extends Base // V
{
}
// Not in the inheritor allow-list.
final class Forbidden extends Base // E?: Forbidden is not allowed as a subtype of Base
{
}