non-empty-arraynon-empty-string, and the only member of this group whose base type can be
written natively, so the parameter can carry array in the signature and the
refinement in the docblock at once.
References:
- PHPStan TypeNodeResolver non-empty-array resolves to array&NonEmptyArrayType| Analyzer | Version | Result | Diagnostics |
|---|---|---|---|
| phan | 6.0.7Phan 6.0.7 php-ast version 1.1.3 PHP version used to run Phan: 8.5.9 | Enforced | phpdoc_advanced_fallback_non_empty_array.php:49: Argument 1 ($value) is [] of type array{} but \Conformance\Tests\PhpdocAdvancedFallbackNonEmptyArray\acceptsNonEmptyArray() takes non-empty-array<mixed,mixed> defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_empty_array.php:37 [PhanTypeMismatchArgument]
|
| phpstan | 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 | Enforced reported Lv.5+ | phpdoc_advanced_fallback_non_empty_array.php:49: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonEmptyArray\acceptsNonEmptyArray expects non-empty-array<mixed>, array{} given. [identifier=argument.type] [reported-from-level=5]With strict-rulesphpdoc_advanced_fallback_non_empty_array.php:49: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonEmptyArray\acceptsNonEmptyArray expects non-empty-array<mixed>, array{} given. [identifier=argument.type]
|
| psalm | 6.16.1Psalm 6.16.1@f1f5de594dc76faf8784e02d3dc4716c91c6f6ac next: 7.0.0-beta19 |
Enforced | phpdoc_advanced_fallback_non_empty_array.php:49: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackNonEmptyArray\acceptsNonEmptyArray expects non-empty-array<array-key, mixed>, but array<never, never> provided [InvalidArgument]
|
| mago | 1.46.0mago 1.46.0 | Enforced | phpdoc_advanced_fallback_non_empty_array.php:49: Possible argument type mismatch for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNonEmptyArray\acceptsNonEmptyArray`: expected `non-empty-array<array-key, mixed>`, but possibly received `array{}`. [possibly-invalid-argument]
|
| mir | 0.70.1mir 0.70.1 | Enforced | phpdoc_advanced_fallback_non_empty_array.php:49: InvalidArgument: Argument $value of acceptsNonEmptyArray() expects 'non-empty-array', got 'array{}' [MIR0201]
|
| phpantom | 0.9.0phpantom_lsp 0.9.0 | Not enforced | No diagnostics reported.
|
| intelephense | 1.18.5intelephense 1.18.5 | Not enforced | No diagnostics reported.
|
| phpy | 0.2.0phpy 0.2.0 | Not enforced | No diagnostics reported.
|
| qodana | 262.8665.325Qodana 262.8665.325 | 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 | Unrecognized ⚠ 1 false positive | phpdoc_advanced_fallback_non_empty_array.php:30: param $value miss matched with phpdoc type <<array<mixed>>> [funcParamTypeMissMatch] phpdoc_advanced_fallback_non_empty_array.php:37: param $value miss matched with phpdoc type <<non-empty-array<mixed>>> [funcParamTypeMissMatch]
Expectation diffLine 30: Unexpected errors ["param $value miss matched with phpdoc type <<array<mixed>>> [funcParamTypeMissMatch]"] |
| steins | 0.1.5steins 0.1.5 (2026-08-12 revision 39b4cc1) | Enforced | phpdoc_advanced_fallback_non_empty_array.php:49: argument [] to acceptsNonEmptyArray() violates declared @param non-empty-array<mixed> $value — declared contract violation [phpdoc.param-mismatch]
|
| phpstan-strict | 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 | Enforced | phpdoc_advanced_fallback_non_empty_array.php:49: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonEmptyArray\acceptsNonEmptyArray expects non-empty-array<mixed>, array{} given. [identifier=argument.type]
|
| psalm-next | 7.0.0-beta19Psalm 7.0.0-beta19@7e751c06a756fa64dc4c759c09fe4a173afcb433 | Enforced | phpdoc_advanced_fallback_non_empty_array.php:49: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackNonEmptyArray\acceptsNonEmptyArray expects non-empty-array<array-key, mixed>, but array<never, never> provided [InvalidArgument]
|
<?php
declare(strict_types=1);
namespace Conformance\Tests\PhpdocAdvancedFallbackNonEmptyArray;
/**
* `non-empty-array`
*
* An array with at least one element. It is the array counterpart of
* `non-empty-string`, and the only member of this group whose base type can be
* written natively, so the parameter can carry `array` in the signature and the
* refinement in the docblock at once.
*
* References:
* - PHPStan TypeNodeResolver `non-empty-array` resolves to array&NonEmptyArrayType
*/
/**
* @return non-empty-array<mixed>
*/
function returnsNonEmptyArray(): array // T: non-empty-array<mixed>
{
return [1]; // V
}
/**
* @param array<mixed> $value
*/
function acceptsArray(array $value): void
{
}
/**
* @param non-empty-array<mixed> $value
*/
function acceptsNonEmptyArray(array $value): void // T: non-empty-array<mixed>
{
}
// A `non-empty-array` value always satisfies a native `array` parameter.
acceptsArray(returnsNonEmptyArray()); // V
// One element is enough, whatever it is.
acceptsNonEmptyArray([1]); // V
acceptsNonEmptyArray([null]); // V
// The empty array is not.
acceptsNonEmptyArray([]); // E?: [] is not a non-empty-array