← All results

non-empty-string&lowercase-string

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

The intersection of two string refinements, written with & rather than as the fused spelling non-empty-lowercase-string. Psalm 6.19 collapses the intersection to that atomic; PHPStan already models it as the same pair of accessories. Analyzers that still require intersection members to be objects reject the spelling at the declaration. '' fails only the non-empty half and 'ABC' only the lowercase half, so an analyzer can model one and miss the other. The fused spelling is already measured in phpdoc_advanced_fallback_non_empty_lowercase_string. Source: vimeo/psalm#11823 (6.19.0), from Laravel Str::lower(). References: - psalm#11823 - PHPStan TypeNodeResolver non-empty-lowercase-string

Analyzer results

AnalyzerVersionResultDiagnostics
phan 6.0.10Phan 6.0.10 php-ast version 1.1.3 PHP version used to run Phan: 8.5.11 Partly enforced (1/2)
phpdoc_advanced_string_pseudo_intersection.php:44: Argument 1 ($value) is '' of type string but \Conformance\Tests\PhpdocAdvancedStringPseudoIntersection\acceptsIntersection() takes non-empty-string (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_string_pseudo_intersection.php:30 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]
  • Recognition: spelling resolved
  • Enforcement: 1/2 of the expected violations reported
phpstan 2.3.1PHPStan - PHP Static Analysis Tool 2.3.1 Enforced reported Lv.5+
phpdoc_advanced_string_pseudo_intersection.php:44: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedStringPseudoIntersection\acceptsIntersection expects lowercase-string&non-empty-string, '' given. [reported-from-level=5]
phpdoc_advanced_string_pseudo_intersection.php:45: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedStringPseudoIntersection\acceptsIntersection expects lowercase-string&non-empty-string, 'ABC' given. [reported-from-level=5]
With strict-rules
phpdoc_advanced_string_pseudo_intersection.php:44: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedStringPseudoIntersection\acceptsIntersection expects lowercase-string&non-empty-string, '' given.
phpdoc_advanced_string_pseudo_intersection.php:45: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedStringPseudoIntersection\acceptsIntersection expects lowercase-string&non-empty-string, 'ABC' given.
  • Recognition: spelling resolved
  • Enforcement: 2/2 of the expected violations reported
psalm 6.20.0Psalm 6.20.0@804f03c0c183d149fcd4b8c7c0c9b3fbf836d34c
next: 7.0.0-rc2
Enforced
phpdoc_advanced_string_pseudo_intersection.php:44: Argument 1 of Conformance\Tests\PhpdocAdvancedStringPseudoIntersection\acceptsIntersection expects non-empty-lowercase-string, but '' provided [InvalidArgument]
phpdoc_advanced_string_pseudo_intersection.php:45: Argument 1 of Conformance\Tests\PhpdocAdvancedStringPseudoIntersection\acceptsIntersection expects non-empty-lowercase-string, but 'ABC' provided [InvalidArgument]
  • Recognition: spelling resolved
  • Enforcement: 2/2 of the expected violations reported
mago 1.57.0mago 1.57.0 Enforced
phpdoc_advanced_string_pseudo_intersection.php:44: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedStringPseudoIntersection\acceptsIntersection`: expected `lowercase-non-empty-string`, but found `string('')`. [invalid-argument]
phpdoc_advanced_string_pseudo_intersection.php:45: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedStringPseudoIntersection\acceptsIntersection`: expected `lowercase-non-empty-string`, but found `string('ABC')`. [invalid-argument]
  • Recognition: spelling resolved
  • Enforcement: 2/2 of the expected violations reported
mir 0.87.0mir 0.87.0 Incidental (2/2)
phpdoc_advanced_string_pseudo_intersection.php:41: InvalidArgument: Argument $value of acceptsIntersection() expects 'non-empty-string&string', got '"abc"' [MIR0201]
phpdoc_advanced_string_pseudo_intersection.php:44: InvalidArgument: Argument $value of acceptsIntersection() expects 'non-empty-string&string', got '""' [MIR0201]
phpdoc_advanced_string_pseudo_intersection.php:45: InvalidArgument: Argument $value of acceptsIntersection() expects 'non-empty-string&string', got '"ABC"' [MIR0201]
  • Recognition: spelling resolved
  • Enforcement: 2/2 of the expected violations reported — incidental, since values the type admits were also rejected on line(s) 41
Expectation diff
Line 41: Expected valid value to be accepted, got ["InvalidArgument: Argument $value of acceptsIntersection() expects 'non-empty-string&string', got '\"abc\"' [MIR0201]"]
phpantom 0.11.1phpantom_lsp 0.11.1 Enforced
phpdoc_advanced_string_pseudo_intersection.php:44: Argument 1 ($value) expects non-empty-string&lowercase-string, got '' [type_mismatch_argument]
phpdoc_advanced_string_pseudo_intersection.php:45: Argument 1 ($value) expects non-empty-string&lowercase-string, got 'ABC' [type_mismatch_argument]
  • Recognition: spelling resolved
  • Enforcement: 2/2 of the expected violations reported
intelephense 1.18.5intelephense 1.18.5 Not enforced

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/2 of the expected violations reported
phpactor 2026.10.07.0Phpactor 2026.10.07.0 Not enforced

No diagnostics reported.

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

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/2 of the expected violations reported
qodana 262.10968.76PhpStorm 262.10968.76 Widened to mixed

No diagnostics reported.

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

Notes: PhpStorm drops `non-empty-string&lowercase-string` altogether: Quick Documentation shows the parameter untyped, and an int or an array passes it. The fused `non-empty-lowercase-string` is checked as plain `string`. The probes are on the intersection.

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.

  • Recognition: spelling resolved
  • Enforcement: 0/2 of the expected violations reported
steins 0.1.8steins 0.1.8 (2026-09-21 revision 76306a9) Not enforced

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/2 of the expected violations reported
phpstan-strict 2.3.1PHPStan - PHP Static Analysis Tool 2.3.1 Enforced
phpdoc_advanced_string_pseudo_intersection.php:44: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedStringPseudoIntersection\acceptsIntersection expects lowercase-string&non-empty-string, '' given.
phpdoc_advanced_string_pseudo_intersection.php:45: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedStringPseudoIntersection\acceptsIntersection expects lowercase-string&non-empty-string, 'ABC' given.
  • Recognition: spelling resolved
  • Enforcement: 2/2 of the expected violations reported
psalm-next 7.0.0-rc2Psalm 7.0.0-rc2@20339e3fe5b8d03bcd8061030eb2a83ad50e5783 Enforced
phpdoc_advanced_string_pseudo_intersection.php:44: Argument 1 of Conformance\Tests\PhpdocAdvancedStringPseudoIntersection\acceptsIntersection expects non-empty-lowercase-string, but '' provided [InvalidArgument]
phpdoc_advanced_string_pseudo_intersection.php:45: Argument 1 of Conformance\Tests\PhpdocAdvancedStringPseudoIntersection\acceptsIntersection expects non-empty-lowercase-string, but 'ABC' provided [InvalidArgument]
  • Recognition: spelling resolved
  • Enforcement: 2/2 of the expected violations reported

Source

<?php

declare(strict_types=1);

namespace Conformance\Tests\PhpdocAdvancedStringPseudoIntersection;

/**
 * `non-empty-string&lowercase-string`
 *
 * The intersection of two string refinements, written with `&` rather than as
 * the fused spelling `non-empty-lowercase-string`. Psalm 6.19 collapses the
 * intersection to that atomic; PHPStan already models it as the same pair of
 * accessories. Analyzers that still require intersection members to be objects
 * reject the spelling at the declaration.
 *
 * `''` fails only the non-empty half and `'ABC'` only the lowercase half, so
 * an analyzer can model one and miss the other. The fused spelling is already
 * measured in `phpdoc_advanced_fallback_non_empty_lowercase_string`.
 *
 * Source: vimeo/psalm#11823 (6.19.0), from Laravel `Str::lower()`.
 *
 * References:
 * - https://github.com/vimeo/psalm/pull/11823
 * - PHPStan TypeNodeResolver `non-empty-lowercase-string`
 */

/**
 * @param non-empty-string&lowercase-string $value
 */
function acceptsIntersection($value): void // T: non-empty-string&lowercase-string
{
}

/**
 * @param non-empty-lowercase-string $value
 */
function acceptsFused($value): void // T: non-empty-lowercase-string
{
}

acceptsIntersection('abc'); // V
acceptsFused('abc'); // V: the fused spelling admits the same value

acceptsIntersection(''); // E?: '' is empty
acceptsIntersection('ABC'); // E?: 'ABC' is not lowercase