uppercase-stringstrtoupper(), the mirror of lowercase-string. A
string with no cased characters at all, '123' or '', satisfies both at
once; a single lowercase character disqualifies the whole string. Analyzers
that model the refinement reject such a literal; others fall back to plain
string and accept it.
References:
- PHPStan TypeNodeResolver uppercase-string resolves to string&AccessoryUppercaseStringType| 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 | Unrecognized | phpdoc_advanced_fallback_uppercase_string.php:21: Saw a token Phan may have failed to parse after '* @return uppercase-string': after uppercase, saw '-' [PhanUnextractableAnnotationSuffix] phpdoc_advanced_fallback_uppercase_string.php:23: Return type of returnsUppercaseString() is undeclared type \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\uppercase [PhanUndeclaredTypeReturnType] phpdoc_advanced_fallback_uppercase_string.php:25: Returning 'ABC' of type string but returnsUppercaseString() is declared to return \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\uppercase (no real type) (the inferred real return type has nothing in common with the declared phpdoc return type) [PhanTypeMismatchReturnProbablyReal] phpdoc_advanced_fallback_uppercase_string.php:33: Saw possibly unextractable annotation for a fragment of comment '* @param uppercase-string $value': after uppercase, did not see an element name (will guess based on comment order) [PhanUnextractableAnnotationElementName] phpdoc_advanced_fallback_uppercase_string.php:33: Saw a token Phan may have failed to parse after '* @param uppercase-string $value': after uppercase, saw '-' [PhanUnextractableAnnotationSuffix] phpdoc_advanced_fallback_uppercase_string.php:35: Parameter $value has undeclared type \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\uppercase [PhanUndeclaredTypeParameter] phpdoc_advanced_fallback_uppercase_string.php:40: Argument 1 ($value) is returnsUppercaseString() of type \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\uppercase but \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsString() takes string defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_uppercase_string.php:28 [PhanTypeMismatchArgument] phpdoc_advanced_fallback_uppercase_string.php:44: Argument 1 ($value) is 'ABC' of type string but \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsUppercaseString() takes \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\uppercase (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_uppercase_string.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal] phpdoc_advanced_fallback_uppercase_string.php:45: Argument 1 ($value) is '123' of type string but \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsUppercaseString() takes \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\uppercase (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_uppercase_string.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal] phpdoc_advanced_fallback_uppercase_string.php:46: Argument 1 ($value) is '' of type string but \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsUppercaseString() takes \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\uppercase (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_uppercase_string.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal] phpdoc_advanced_fallback_uppercase_string.php:49: Argument 1 ($value) is 'abc' of type string but \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsUppercaseString() takes \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\uppercase (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_uppercase_string.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal] phpdoc_advanced_fallback_uppercase_string.php:52: Argument 1 ($value) is 'ABc' of type string but \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsUppercaseString() takes \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\uppercase (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_uppercase_string.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]
Expectation diffLine 25: Expected valid value to be accepted, got ["Returning 'ABC' of type string but returnsUppercaseString() is declared to return \\Conformance\\Tests\\PhpdocAdvancedFallbackUppercaseString\\uppercase (no real type) (the inferred real return type has nothing in common with the declared phpdoc return type) [PhanTypeMismatchReturnProbablyReal]"] Line 40: Expected valid value to be accepted, got ["Argument 1 ($value) is returnsUppercaseString() of type \\Conformance\\Tests\\PhpdocAdvancedFallbackUppercaseString\\uppercase but \\Conformance\\Tests\\PhpdocAdvancedFallbackUppercaseString\\acceptsString() takes string defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_uppercase_string.php:28 [PhanTypeMismatchArgument]"] Line 44: Expected valid value to be accepted, got ["Argument 1 ($value) is 'ABC' of type string but \\Conformance\\Tests\\PhpdocAdvancedFallbackUppercaseString\\acceptsUppercaseString() takes \\Conformance\\Tests\\PhpdocAdvancedFallbackUppercaseString\\uppercase (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_uppercase_string.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]"] Line 45: Expected valid value to be accepted, got ["Argument 1 ($value) is '123' of type string but \\Conformance\\Tests\\PhpdocAdvancedFallbackUppercaseString\\acceptsUppercaseString() takes \\Conformance\\Tests\\PhpdocAdvancedFallbackUppercaseString\\uppercase (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_uppercase_string.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]"] Line 46: Expected valid value to be accepted, got ["Argument 1 ($value) is '' of type string but \\Conformance\\Tests\\PhpdocAdvancedFallbackUppercaseString\\acceptsUppercaseString() takes \\Conformance\\Tests\\PhpdocAdvancedFallbackUppercaseString\\uppercase (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_uppercase_string.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]"] |
| phpstan | 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 | Enforced reported Lv.5+ | phpdoc_advanced_fallback_uppercase_string.php:49: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsUppercaseString expects uppercase-string, 'abc' given. [identifier=argument.type] [reported-from-level=5] phpdoc_advanced_fallback_uppercase_string.php:52: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsUppercaseString expects uppercase-string, 'ABc' given. [identifier=argument.type] [reported-from-level=5] With strict-rulesphpdoc_advanced_fallback_uppercase_string.php:49: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsUppercaseString expects uppercase-string, 'abc' given. [identifier=argument.type] phpdoc_advanced_fallback_uppercase_string.php:52: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsUppercaseString expects uppercase-string, 'ABc' given. [identifier=argument.type]
|
| psalm | 6.16.1Psalm 6.16.1@f1f5de594dc76faf8784e02d3dc4716c91c6f6ac next: 7.0.0-beta19 |
Unrecognized (pzoom≠) | phpdoc_advanced_fallback_uppercase_string.php:23: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\uppercase-string in docblock for Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\returnsUppercaseString [InvalidDocblock] phpdoc_advanced_fallback_uppercase_string.php:23: Method Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\returnsUppercaseString does not have a return type, expecting 'ABC' [MissingReturnType] phpdoc_advanced_fallback_uppercase_string.php:33: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\uppercase-string in docblock for Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsUppercaseString [InvalidDocblock] phpdoc_advanced_fallback_uppercase_string.php:35: Parameter $value has no provided type [MissingParamType] phpdoc_advanced_fallback_uppercase_string.php:40: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsString cannot be mixed, expecting string [MixedArgument] pzoom (Psalm port)phpdoc_advanced_fallback_uppercase_string.php:23: Invalid return docblock type [InvalidDocblock] phpdoc_advanced_fallback_uppercase_string.php:23: Function Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\returnsUppercaseString does not have a return type [MissingReturnType] phpdoc_advanced_fallback_uppercase_string.php:35: Invalid docblock type [InvalidDocblock] phpdoc_advanced_fallback_uppercase_string.php:35: Argument $value of Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsUppercaseString does not have a type [MissingParamType] phpdoc_advanced_fallback_uppercase_string.php:40: Argument 1 of acceptsString cannot be mixed, expecting string [MixedArgument]
Expectation diffLine 40: Expected valid value to be accepted, got ["Argument 1 of Conformance\\Tests\\PhpdocAdvancedFallbackUppercaseString\\acceptsString cannot be mixed, expecting string [MixedArgument]"] |
| mago | 1.46.0mago 1.46.0 | Enforced | phpdoc_advanced_fallback_uppercase_string.php:49: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsUppercaseString`: expected `uppercase-string`, but found `string('abc')`. [invalid-argument]
phpdoc_advanced_fallback_uppercase_string.php:52: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsUppercaseString`: expected `uppercase-string`, but found `string('ABc')`. [invalid-argument]
|
| mir | 0.70.1mir 0.70.1 | Widened to string | No diagnostics reported.
|
| phpantom | 0.9.0phpantom_lsp 0.9.0 | Not enforced | No diagnostics reported.
|
| intelephense | 1.18.5intelephense 1.18.5 | Incidental (0/2) | phpdoc_advanced_fallback_uppercase_string.php:40: Expected type 'string'. Found 'Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\uppercase-string'. [P1006]
Expectation diffLine 40: Expected valid value to be accepted, got ["Expected type 'string'. Found 'Conformance\\Tests\\PhpdocAdvancedFallbackUppercaseString\\uppercase-string'. [P1006]"] |
| phpy | 0.2.0phpy 0.2.0 | Not enforced | No diagnostics reported.
|
| qodana | 262.8665.325Qodana 262.8665.325 | Unrecognized | phpdoc_advanced_fallback_uppercase_string.php:21: Return type in PHPDoc does not match the actual return type [PhpReturnDocTypeMismatchInspection] phpdoc_advanced_fallback_uppercase_string.php:21: Undefined class 'uppercase-string' [PhpUndefinedClassInspection] phpdoc_advanced_fallback_uppercase_string.php:25: Return value type is not compatible with declared [PhpIncompatibleReturnTypeInspection] phpdoc_advanced_fallback_uppercase_string.php:33: Undefined class 'uppercase-string' [PhpUndefinedClassInspection] phpdoc_advanced_fallback_uppercase_string.php:44: Parameter ''ABC'' type is not compatible with declaration [PhpParamsInspection] phpdoc_advanced_fallback_uppercase_string.php:45: Parameter ''123'' type is not compatible with declaration [PhpParamsInspection] phpdoc_advanced_fallback_uppercase_string.php:46: Parameter '''' type is not compatible with declaration [PhpParamsInspection] phpdoc_advanced_fallback_uppercase_string.php:49: Parameter ''abc'' type is not compatible with declaration [PhpParamsInspection] phpdoc_advanced_fallback_uppercase_string.php:52: Parameter ''ABc'' type is not compatible with declaration [PhpParamsInspection]
Expectation diffLine 25: Expected valid value to be accepted, got ["Return value type is not compatible with declared [PhpIncompatibleReturnTypeInspection]"] Line 44: Expected valid value to be accepted, got ["Parameter ''ABC'' type is not compatible with declaration [PhpParamsInspection]"] Line 45: Expected valid value to be accepted, got ["Parameter ''123'' type is not compatible with declaration [PhpParamsInspection]"] Line 46: Expected valid value to be accepted, got ["Parameter '''' 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_uppercase_string.php:12: Class or interface named \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\uppercase-string does not exist [undefinedClass] phpdoc_advanced_fallback_uppercase_string.php:33: Class or interface named \Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\uppercase-string does not exist [undefinedClass]
Expectation diffLine 12: Unexpected errors ["Class or interface named \\Conformance\\Tests\\PhpdocAdvancedFallbackUppercaseString\\uppercase-string does not exist [undefinedClass]"] |
| steins | 0.1.5steins 0.1.5 (2026-08-12 revision 39b4cc1) | Enforced | phpdoc_advanced_fallback_uppercase_string.php:49: argument "abc" to acceptsUppercaseString() violates declared @param uppercase-string $value — declared contract violation [phpdoc.param-mismatch] phpdoc_advanced_fallback_uppercase_string.php:52: argument "ABc" to acceptsUppercaseString() violates declared @param uppercase-string $value — declared contract violation [phpdoc.param-mismatch]
|
| phpstan-strict | 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 | Enforced | phpdoc_advanced_fallback_uppercase_string.php:49: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsUppercaseString expects uppercase-string, 'abc' given. [identifier=argument.type] phpdoc_advanced_fallback_uppercase_string.php:52: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsUppercaseString expects uppercase-string, 'ABc' given. [identifier=argument.type]
|
| psalm-next | 7.0.0-beta19Psalm 7.0.0-beta19@7e751c06a756fa64dc4c759c09fe4a173afcb433 | Unrecognized | phpdoc_advanced_fallback_uppercase_string.php:23: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\uppercase-string in docblock for Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\returnsUppercaseString [InvalidDocblock] phpdoc_advanced_fallback_uppercase_string.php:23: Method Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\returnsUppercaseString does not have a return type, expecting 'ABC' [MissingReturnType] phpdoc_advanced_fallback_uppercase_string.php:33: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\uppercase-string in docblock for Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsUppercaseString [InvalidDocblock] phpdoc_advanced_fallback_uppercase_string.php:35: Parameter $value has no provided type [MissingParamType] phpdoc_advanced_fallback_uppercase_string.php:40: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackUppercaseString\acceptsString cannot be mixed, expecting string [MixedArgument]
Expectation diffLine 40: Expected valid value to be accepted, got ["Argument 1 of Conformance\\Tests\\PhpdocAdvancedFallbackUppercaseString\\acceptsString cannot be mixed, expecting string [MixedArgument]"] |
<?php
declare(strict_types=1);
namespace Conformance\Tests\PhpdocAdvancedFallbackUppercaseString;
/**
* `uppercase-string`
*
* A string unchanged by `strtoupper()`, the mirror of `lowercase-string`. A
* string with no cased characters at all, `'123'` or `''`, satisfies both at
* once; a single lowercase character disqualifies the whole string. Analyzers
* that model the refinement reject such a literal; others fall back to plain
* `string` and accept it.
*
* References:
* - PHPStan TypeNodeResolver `uppercase-string` resolves to string&AccessoryUppercaseStringType
*/
/**
* @return uppercase-string
*/
function returnsUppercaseString() // T: uppercase-string
{
return 'ABC'; // V
}
function acceptsString(string $value): void
{
}
/**
* @param uppercase-string $value
*/
function acceptsUppercaseString($value): void // T: uppercase-string
{
}
// An `uppercase-string` value always satisfies a native `string` parameter.
acceptsString(returnsUppercaseString()); // V
// Uppercase letters satisfy the parameter, and so does a string with nothing
// to uppercase.
acceptsUppercaseString('ABC'); // V
acceptsUppercaseString('123'); // V
acceptsUppercaseString(''); // V
// A fully lowercase literal is outside the refinement.
acceptsUppercaseString('abc'); // E?: 'abc' is not an uppercase-string
// So is a mixed one, on the strength of a single character.
acceptsUppercaseString('ABc'); // E?: 'ABc' is not an uppercase-string