← All results

non-empty-mixed

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

mixed with the falsy values subtracted — not "mixed but set". Since mixed is the type an analyzer falls back to when it understands nothing, this is the spelling where "recognized but not enforced" and "not recognized at all" look most alike from the outside; only the probes tell them apart. References: - PHPStan TypeNodeResolver non-empty-mixed resolves to MixedType(true, StaticTypeFactory::falsey())

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 Enforced
phpdoc_advanced_fallback_non_empty_mixed.php:48: Argument 1 ($value) is '' of type string but \Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\acceptsNonEmptyMixed() takes non-empty-mixed defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_empty_mixed.php:34 [PhanTypeMismatchArgument]
phpdoc_advanced_fallback_non_empty_mixed.php:49: Argument 1 ($value) is 0 of type int (value: 0) but \Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\acceptsNonEmptyMixed() takes non-empty-mixed defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_empty_mixed.php:34 [PhanTypeMismatchArgument]
phpdoc_advanced_fallback_non_empty_mixed.php:50: Argument 1 ($value) is [] of type array{} but \Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\acceptsNonEmptyMixed() takes non-empty-mixed defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_empty_mixed.php:34 [PhanTypeMismatchArgument]
phpdoc_advanced_fallback_non_empty_mixed.php:51: Argument 1 ($value) is null of type null but \Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\acceptsNonEmptyMixed() takes non-empty-mixed (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_empty_mixed.php:34 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]
  • Recognition: spelling resolved
  • Enforcement: 4/4 of the expected violations reported
phpstan 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 Not enforced

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/4 of the expected violations reported
psalm 6.16.1Psalm 6.16.1@f1f5de594dc76faf8784e02d3dc4716c91c6f6ac
next: 7.0.0-beta19
Unrecognized (pzoom≠)
phpdoc_advanced_fallback_non_empty_mixed.php:22: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\non-empty-mixed in docblock for Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\returnsNonEmptyMixed [InvalidDocblock]
phpdoc_advanced_fallback_non_empty_mixed.php:22: Method Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\returnsNonEmptyMixed does not have a return type, expecting 1 [MissingReturnType]
phpdoc_advanced_fallback_non_empty_mixed.php:32: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\non-empty-mixed in docblock for Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\acceptsNonEmptyMixed [InvalidDocblock]
phpdoc_advanced_fallback_non_empty_mixed.php:34: Parameter $value has no provided type [MissingParamType]
pzoom (Psalm port)

No diagnostics from pzoom.

  • Recognition: spelling not resolved — reported on declaration line(s) 22, 32, 34
  • Enforcement: 0/4 of the expected violations reported — incidental, since the spelling was not resolved
mago 1.46.0mago 1.46.0 Partly enforced (1/4)
phpdoc_advanced_fallback_non_empty_mixed.php:51: Argument #1 of function `Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\acceptsNonEmptyMixed` is `null`, but parameter type `truthy-mixed` does not accept it. [null-argument]
  • Recognition: spelling resolved
  • Enforcement: 1/4 of the expected violations reported
mir 0.70.1mir 0.70.1 Incidental (4/4)
phpdoc_advanced_fallback_non_empty_mixed.php:42: InvalidArgument: Argument $value of acceptsNonEmptyMixed() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\non-empty-mixed', got '1' [MIR0201]
phpdoc_advanced_fallback_non_empty_mixed.php:43: InvalidArgument: Argument $value of acceptsNonEmptyMixed() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\non-empty-mixed', got '"x"' [MIR0201]
phpdoc_advanced_fallback_non_empty_mixed.php:44: InvalidArgument: Argument $value of acceptsNonEmptyMixed() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\non-empty-mixed', got 'array{0: 1}' [MIR0201]
phpdoc_advanced_fallback_non_empty_mixed.php:48: InvalidArgument: Argument $value of acceptsNonEmptyMixed() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\non-empty-mixed', got '""' [MIR0201]
phpdoc_advanced_fallback_non_empty_mixed.php:49: InvalidArgument: Argument $value of acceptsNonEmptyMixed() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\non-empty-mixed', got '0' [MIR0201]
phpdoc_advanced_fallback_non_empty_mixed.php:50: InvalidArgument: Argument $value of acceptsNonEmptyMixed() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\non-empty-mixed', got 'array{}' [MIR0201]
phpdoc_advanced_fallback_non_empty_mixed.php:51: NullArgument: Argument $value of acceptsNonEmptyMixed() cannot be null [MIR0100]
  • Recognition: spelling resolved
  • Enforcement: 4/4 of the expected violations reported — incidental, since values the type admits were also rejected on line(s) 42, 43, 44
Expectation diff
Line 42: Expected valid value to be accepted, got ["InvalidArgument: Argument $value of acceptsNonEmptyMixed() expects 'Conformance\\Tests\\PhpdocAdvancedFallbackNonEmptyMixed\\non-empty-mixed', got '1' [MIR0201]"]
Line 43: Expected valid value to be accepted, got ["InvalidArgument: Argument $value of acceptsNonEmptyMixed() expects 'Conformance\\Tests\\PhpdocAdvancedFallbackNonEmptyMixed\\non-empty-mixed', got '\"x\"' [MIR0201]"]
Line 44: Expected valid value to be accepted, got ["InvalidArgument: Argument $value of acceptsNonEmptyMixed() expects 'Conformance\\Tests\\PhpdocAdvancedFallbackNonEmptyMixed\\non-empty-mixed', got 'array{0: 1}' [MIR0201]"]
phpantom 0.9.0phpantom_lsp 0.9.0 Not enforced

No diagnostics reported.

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

No diagnostics reported.

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

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/4 of the expected violations reported
qodana 262.8665.325Qodana 262.8665.325 Unrecognized
phpdoc_advanced_fallback_non_empty_mixed.php:20: Return type in PHPDoc does not match the actual return type [PhpReturnDocTypeMismatchInspection]
phpdoc_advanced_fallback_non_empty_mixed.php:20: Undefined class 'non-empty-mixed' [PhpUndefinedClassInspection]
phpdoc_advanced_fallback_non_empty_mixed.php:24: Return value type is not compatible with declared [PhpIncompatibleReturnTypeInspection]
phpdoc_advanced_fallback_non_empty_mixed.php:32: Undefined class 'non-empty-mixed' [PhpUndefinedClassInspection]
phpdoc_advanced_fallback_non_empty_mixed.php:42: Parameter '1' type is not compatible with declaration [PhpParamsInspection]
phpdoc_advanced_fallback_non_empty_mixed.php:43: Parameter ''x'' type is not compatible with declaration [PhpParamsInspection]
phpdoc_advanced_fallback_non_empty_mixed.php:44: Parameter '[1]' type is not compatible with declaration [PhpParamsInspection]
phpdoc_advanced_fallback_non_empty_mixed.php:45: Parameter 'new \stdClass()' type is not compatible with declaration [PhpParamsInspection]
phpdoc_advanced_fallback_non_empty_mixed.php:48: Parameter '''' type is not compatible with declaration [PhpParamsInspection]
phpdoc_advanced_fallback_non_empty_mixed.php:49: Parameter '0' type is not compatible with declaration [PhpParamsInspection]
phpdoc_advanced_fallback_non_empty_mixed.php:50: Parameter '[]' type is not compatible with declaration [PhpParamsInspection]
phpdoc_advanced_fallback_non_empty_mixed.php:51: Parameter 'null' type is not compatible with declaration [PhpParamsInspection]
  • Recognition: spelling not resolved — reported on declaration line(s) 20, 32
  • Enforcement: 4/4 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 24: Expected valid value to be accepted, got ["Return value type is not compatible with declared [PhpIncompatibleReturnTypeInspection]"]
Line 42: Expected valid value to be accepted, got ["Parameter '1' type is not compatible with declaration [PhpParamsInspection]"]
Line 43: Expected valid value to be accepted, got ["Parameter ''x'' type is not compatible with declaration [PhpParamsInspection]"]
Line 44: Expected valid value to be accepted, got ["Parameter '[1]' type is not compatible with declaration [PhpParamsInspection]"]
Line 45: Expected valid value to be accepted, got ["Parameter 'new \\stdClass()' type is not compatible with declaration [PhpParamsInspection]"]
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_mixed.php:12: Class or interface named \Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\non-empty-mixed does not exist [undefinedClass]
phpdoc_advanced_fallback_non_empty_mixed.php:32: Class or interface named \Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\non-empty-mixed does not exist [undefinedClass]
  • Recognition: spelling not resolved — reported on declaration line(s) 32
  • Enforcement: 0/4 of the expected violations reported — incidental, since the spelling was not resolved
  • False positives: line(s) 12
Expectation diff
Line 12: Unexpected errors ["Class or interface named \\Conformance\\Tests\\PhpdocAdvancedFallbackNonEmptyMixed\\non-empty-mixed does not exist [undefinedClass]"]
steins 0.1.5steins 0.1.5 (2026-08-12 revision 39b4cc1) Enforced
phpdoc_advanced_fallback_non_empty_mixed.php:48: argument "" to acceptsNonEmptyMixed() violates declared @param non-empty-mixed $value — declared contract violation [phpdoc.param-mismatch]
phpdoc_advanced_fallback_non_empty_mixed.php:49: argument 0 to acceptsNonEmptyMixed() violates declared @param non-empty-mixed $value — declared contract violation [phpdoc.param-mismatch]
phpdoc_advanced_fallback_non_empty_mixed.php:50: argument [] to acceptsNonEmptyMixed() violates declared @param non-empty-mixed $value — declared contract violation [phpdoc.param-mismatch]
phpdoc_advanced_fallback_non_empty_mixed.php:51: argument null to acceptsNonEmptyMixed() violates declared @param non-empty-mixed $value — declared contract violation [phpdoc.param-mismatch]
  • Recognition: spelling resolved
  • Enforcement: 4/4 of the expected violations reported
phpstan-strict 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 Not enforced

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/4 of the expected violations reported
psalm-next 7.0.0-beta19Psalm 7.0.0-beta19@7e751c06a756fa64dc4c759c09fe4a173afcb433 Unrecognized
phpdoc_advanced_fallback_non_empty_mixed.php:22: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\non-empty-mixed in docblock for Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\returnsNonEmptyMixed [InvalidDocblock]
phpdoc_advanced_fallback_non_empty_mixed.php:22: Method Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\returnsNonEmptyMixed does not have a return type, expecting 1 [MissingReturnType]
phpdoc_advanced_fallback_non_empty_mixed.php:32: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\non-empty-mixed in docblock for Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed\acceptsNonEmptyMixed [InvalidDocblock]
phpdoc_advanced_fallback_non_empty_mixed.php:34: Parameter $value has no provided type [MissingParamType]
  • Recognition: spelling not resolved — reported on declaration line(s) 22, 32, 34
  • Enforcement: 0/4 of the expected violations reported — incidental, since the spelling was not resolved

Source

<?php

declare(strict_types=1);

namespace Conformance\Tests\PhpdocAdvancedFallbackNonEmptyMixed;

/**
 * `non-empty-mixed`
 *
 * `mixed` with the falsy values subtracted — not "mixed but set". Since `mixed`
 * is the type an analyzer falls back to when it understands nothing, this is
 * the spelling where "recognized but not enforced" and "not recognized at all"
 * look most alike from the outside; only the probes tell them apart.
 *
 * References:
 * - PHPStan TypeNodeResolver `non-empty-mixed` resolves to MixedType(true, StaticTypeFactory::falsey())
 */

/**
 * @return non-empty-mixed
 */
function returnsNonEmptyMixed() // T: non-empty-mixed
{
    return 1; // V
}

function acceptsMixed(mixed $value): void
{
}

/**
 * @param non-empty-mixed $value
 */
function acceptsNonEmptyMixed($value): void // T: non-empty-mixed
{
}

// A `non-empty-mixed` value always satisfies a native `mixed` parameter.
acceptsMixed(returnsNonEmptyMixed()); // V

// Any truthy value satisfies the parameter, of any type.
acceptsNonEmptyMixed(1); // V
acceptsNonEmptyMixed('x'); // V
acceptsNonEmptyMixed([1]); // V
acceptsNonEmptyMixed(new \stdClass()); // V

// The falsy values are subtracted, whatever their type.
acceptsNonEmptyMixed(''); // E?: '' is falsy, so it is not a non-empty-mixed
acceptsNonEmptyMixed(0); // E?: 0 is falsy, so it is not a non-empty-mixed
acceptsNonEmptyMixed([]); // E?: [] is falsy, so it is not a non-empty-mixed
acceptsNonEmptyMixed(null); // E?: null is falsy, so it is not a non-empty-mixed