__toString() satisfies \Stringablephpdoc_advanced_psalm_stringable_object measures the PHPDoc spelling
stringable-object. This file asks the native question: a parameter typed
\Stringable accepts an interface that declares __toString() without
extending \Stringable.
Source: carthage-software/mago#2450 (1.56.0).
References:
- mago#2450| 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.11 | Pass | objects_implicit_stringable.php:42: Argument 1 ($value) is $value of type \Conformance\Tests\ObjectsImplicitStringable\NotStringable but \Conformance\Tests\ObjectsImplicitStringable\takesStringable() takes \Stringable defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/objects_implicit_stringable.php:31 [PhanTypeMismatchArgument] |
| phpstan | 2.3.5PHPStan - PHP Static Analysis Tool 2.3.5 | Pass reported Lv.5+ | objects_implicit_stringable.php:42: Parameter #1 $value of function Conformance\Tests\ObjectsImplicitStringable\takesStringable expects Stringable, Conformance\Tests\ObjectsImplicitStringable\NotStringable given. [reported-from-level=5] With strict-rulesobjects_implicit_stringable.php:42: Parameter #1 $value of function Conformance\Tests\ObjectsImplicitStringable\takesStringable expects Stringable, Conformance\Tests\ObjectsImplicitStringable\NotStringable given. |
| psalm | 6.20.9Psalm 6.20.9@f67170ac3c3b931f5088681e21d6c8babc601c08 next: 7.0.4 |
Pass | objects_implicit_stringable.php:42: Argument 1 of Conformance\Tests\ObjectsImplicitStringable\takesStringable expects Stringable, but Conformance\Tests\ObjectsImplicitStringable\NotStringable provided [InvalidArgument] |
| mago | 1.59.0mago 1.59.0 | Pass | objects_implicit_stringable.php:42: Possible argument type mismatch for argument #1 of `Conformance\Tests\ObjectsImplicitStringable\takesStringable`: expected `Stringable`, but possibly received `Conformance\Tests\ObjectsImplicitStringable\NotStringable`. [possibly-invalid-argument] |
| mir | 0.91.0mir 0.91.0 | Fail | objects_implicit_stringable.php:37: InvalidArgument: Argument $value of takesStringable() expects 'Stringable', got 'Conformance\Tests\ObjectsImplicitStringable\CustomStringable' [MIR0201] objects_implicit_stringable.php:42: InvalidArgument: Argument $value of takesStringable() expects 'Stringable', got 'Conformance\Tests\ObjectsImplicitStringable\NotStringable' [MIR0201] Expectation diffLine 37: Expected valid value to be accepted, got ["InvalidArgument: Argument $value of takesStringable() expects 'Stringable', got 'Conformance\\Tests\\ObjectsImplicitStringable\\CustomStringable' [MIR0201]"] |
| phpantom | 0.11.1phpantom_lsp 0.11.1 | Fail | objects_implicit_stringable.php:37: Argument 1 ($value) expects Stringable, got Conformance\Tests\ObjectsImplicitStringable\CustomStringable [type_mismatch_argument] objects_implicit_stringable.php:42: Argument 1 ($value) expects Stringable, got Conformance\Tests\ObjectsImplicitStringable\NotStringable [type_mismatch_argument] Expectation diffLine 37: Expected valid value to be accepted, got ["Argument 1 ($value) expects Stringable, got Conformance\\Tests\\ObjectsImplicitStringable\\CustomStringable [type_mismatch_argument]"] |
| intelephense | 1.18.5intelephense 1.18.5 | Pass | objects_implicit_stringable.php:42: Expected type 'Stringable'. Found 'Conformance\Tests\ObjectsImplicitStringable\NotStringable'. [P1006] |
| phpactor | 2026.10.07.0Phpactor 2026.10.07.0 | Fail | No diagnostics reported. Expectation diffLine 42: Expected 1 error(s) |
| phpy | 1.0.19490phpy 1.0.19490 | Fail | objects_implicit_stringable.php:37: Argument '1' passed to Conformance\Tests\ObjectsImplicitStringable\takesStringable() is expected to be of type Stringable, Conformance\Tests\ObjectsImplicitStringable\CustomStringable given objects_implicit_stringable.php:42: Argument '1' passed to Conformance\Tests\ObjectsImplicitStringable\takesStringable() is expected to be of type Stringable, Conformance\Tests\ObjectsImplicitStringable\NotStringable given Expectation diffLine 37: Expected valid value to be accepted, got ["Argument '1' passed to Conformance\\Tests\\ObjectsImplicitStringable\\takesStringable() is expected to be of type Stringable, Conformance\\Tests\\ObjectsImplicitStringable\\CustomStringable given"] |
| qodana | 262.11879.104PhpStorm 262.11879.104 | Pass | objects_implicit_stringable.php:42: Parameter '$value' 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 | Fail | objects_implicit_stringable.php:37: potentially not safe call in function Conformance\Tests\ObjectsImplicitStringable\takesStringable signature of param value [notSafeCall] objects_implicit_stringable.php:42: potentially not safe call in function Conformance\Tests\ObjectsImplicitStringable\takesStringable signature of param value [notSafeCall] Expectation diffLine 37: Expected valid value to be accepted, got ["potentially not safe call in function Conformance\\Tests\\ObjectsImplicitStringable\\takesStringable signature of param value [notSafeCall]"] |
| steins | 0.1.8steins 0.1.8 (2026-09-21 revision 76306a9) | Fail | No diagnostics reported. Expectation diffLine 42: Expected 1 error(s) |
| phpstan-strict | 2.3.5PHPStan - PHP Static Analysis Tool 2.3.5 | Pass | objects_implicit_stringable.php:42: Parameter #1 $value of function Conformance\Tests\ObjectsImplicitStringable\takesStringable expects Stringable, Conformance\Tests\ObjectsImplicitStringable\NotStringable given. |
| psalm-next | 7.0.4Psalm 7.0.4@fa5b1f6e665cb743838ffd865b8fc96207f9409f | Pass | objects_implicit_stringable.php:42: Argument 1 of Conformance\Tests\ObjectsImplicitStringable\takesStringable expects Stringable, but Conformance\Tests\ObjectsImplicitStringable\NotStringable provided [InvalidArgument] |
<?php
declare(strict_types=1);
namespace Conformance\Tests\ObjectsImplicitStringable;
/**
* An interface that declares `__toString()` satisfies `\Stringable`.
*
* `phpdoc_advanced_psalm_stringable_object` measures the PHPDoc spelling
* `stringable-object`. This file asks the native question: a parameter typed
* `\Stringable` accepts an interface that declares `__toString()` without
* extending `\Stringable`.
*
* Source: carthage-software/mago#2450 (1.56.0).
*
* References:
* - https://github.com/carthage-software/mago/pull/2450
*/
interface CustomStringable
{
public function __toString(): string;
}
interface NotStringable
{
public function name(): string;
}
function takesStringable(\Stringable $value): void
{
}
function fromCustom(CustomStringable $value): void
{
takesStringable($value); // V: __toString() makes the interface Stringable
}
function fromUnrelated(NotStringable $value): void
{
takesStringable($value); // E: NotStringable has no __toString()
}