← All results

Conflicting property types composed from two traits

Group: Cross-analyzer regressions · Category: regression · File: regressions_trait_property_type_conflict.php

LeftTrait::$prop is string and RightTrait::$prop is int. Composing both into one class is a compile-time fatal error in PHP ("traits define the same property … the definition differs and is considered incompatible"). Analyzers diverge on whether they report this statically. PHPStan is silent even though the program cannot run. Tools that only complain about a missing constructor (Psalm, pzoom, mir) are still a hit for this row: they saw the composition, just not the incompatibility. Source lead: Mago analyzer test trait_property_type_conflicts.

Analyzer results

AnalyzerVersionResultDiagnostics
phan 6.0.11Phan 6.0.11 php-ast version 1.1.3 PHP version used to run Phan: 8.5.11 Pass
regressions_trait_property_type_conflict.php:22: Declaration of \Conformance\Tests\RegressionsTraitPropertyTypeConflict\Composed::prop of real type string is incompatible with inherited property \Conformance\Tests\RegressionsTraitPropertyTypeConflict\RightTrait::prop of real type int defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/regressions_trait_property_type_conflict.php:27 [PhanIncompatibleRealPropertyType]
phpstan 2.3.5PHPStan - PHP Static Analysis Tool 2.3.5 Fail

No diagnostics reported.

Expectation diff
Lines 22, 27, 30, 32, 33: Expected error (tag conflict)
psalm 6.20.9Psalm 6.20.9@f67170ac3c3b931f5088681e21d6c8babc601c08
next: 7.0.4
Pass (pzoom≠)
regressions_trait_property_type_conflict.php:22: Conformance\Tests\RegressionsTraitPropertyTypeConflict\Composed has an uninitialized property Conformance\Tests\RegressionsTraitPropertyTypeConflict\LeftTrait::$prop, but no constructor [MissingConstructor]
pzoom (Psalm port)
regressions_trait_property_type_conflict.php:30: Conformance\Tests\RegressionsTraitPropertyTypeConflict\Composed has an uninitialized property Conformance\Tests\RegressionsTraitPropertyTypeConflict\Composed::$prop, but no constructor [MissingConstructor]
mago 1.59.0mago 1.59.0 Pass
regressions_trait_property_type_conflict.php:33: Property `$prop` is defined differently in `Conformance\Tests\RegressionsTraitPropertyTypeConflict\LeftTrait` and `Conformance\Tests\RegressionsTraitPropertyTypeConflict\RightTrait` used by `conformance\tests\regressionstraitpropertytypeconflict\composed`: type declaration differs (string vs int) [incompatible-property-type]
mir 0.91.0mir 0.91.0 Fail
regressions_trait_property_type_conflict.php:30: MissingConstructor: Class Conformance\Tests\RegressionsTraitPropertyTypeConflict\Composed has uninitialized properties but no constructor [MIR1507]
regressions_trait_property_type_conflict.php:33: CompileError: Conformance\Tests\RegressionsTraitPropertyTypeConflict\LeftTrait and Conformance\Tests\RegressionsTraitPropertyTypeConflict\RightTrait define the same property ($prop) in the composition of Conformance\Tests\RegressionsTraitPropertyTypeConflict\Composed. However, the definition differs and is considered incompatible. Class was composed [trait-property-conflict] [MIR1401]
Expectation diff
Lines 22, 27, 30, 32, 33: Expected exactly one error (tag conflict)

Notes: 0.89.0 reports CompileError (MIR1401, trait-property-conflict) at the class `use` line, in addition to MissingConstructor. The test wants exactly one conflict-tagged error per marked line.

phpantom 0.11.1phpantom_lsp 0.11.1 Fail

No diagnostics reported.

Expectation diff
Lines 22, 27, 30, 32, 33: Expected error (tag conflict)
intelephense 1.18.5intelephense 1.18.5 Fail

No diagnostics reported.

Expectation diff
Lines 22, 27, 30, 32, 33: Expected error (tag conflict)
phpactor 2026.10.07.0Phpactor 2026.10.07.0 Fail

No diagnostics reported.

Expectation diff
Lines 22, 27, 30, 32, 33: Expected error (tag conflict)
phpy 1.0.19490phpy 1.0.19490 Fail

No diagnostics reported.

Expectation diff
Lines 22, 27, 30, 32, 33: Expected error (tag conflict)
qodana 262.11879.104PhpStorm 262.11879.104 Fail

No diagnostics reported.

Expectation diff
Lines 22, 27, 30, 32, 33: Expected error (tag conflict)
noverify 0.5.5NoVerify, version 0.5.5: built on: 2025.04.22 14:36:46 OS: r-kuchinskas arm64 Commit: 4774b82f8adc53fbef38f95e97af4b953b4d1529 Fail

No diagnostics reported.

Expectation diff
Lines 22, 27, 30, 32, 33: Expected error (tag conflict)
steins 0.1.8steins 0.1.8 (2026-09-21 revision 76306a9) Fail

No diagnostics reported.

Expectation diff
Lines 22, 27, 30, 32, 33: Expected error (tag conflict)
phpstan-strict 2.3.5PHPStan - PHP Static Analysis Tool 2.3.5 Fail

No diagnostics reported.

Expectation diff
Lines 22, 27, 30, 32, 33: Expected error (tag conflict)
psalm-next 7.0.4Psalm 7.0.4@fa5b1f6e665cb743838ffd865b8fc96207f9409f Pass
regressions_trait_property_type_conflict.php:22: Conformance\Tests\RegressionsTraitPropertyTypeConflict\Composed has an uninitialized property Conformance\Tests\RegressionsTraitPropertyTypeConflict\LeftTrait::$prop, but no constructor [MissingConstructor]

Source

<?php

declare(strict_types=1);

namespace Conformance\Tests\RegressionsTraitPropertyTypeConflict;

/**
 * Conflicting property types composed from two traits.
 *
 * `LeftTrait::$prop` is `string` and `RightTrait::$prop` is `int`. Composing both into one
 * class is a compile-time fatal error in PHP ("traits define the same property … the
 * definition differs and is considered incompatible"). Analyzers diverge on whether they
 * report this statically. PHPStan is silent even though the program cannot run.
 * Tools that only complain about a missing constructor (Psalm, pzoom, mir) are
 * still a hit for this row: they saw the composition, just not the incompatibility.
 *
 * Source lead: Mago analyzer test `trait_property_type_conflicts`.
 */

trait LeftTrait
{
    public string $prop; // E[conflict]: string-vs-int property clash, or a related finding on the composed class // E<psalm>: reports only MissingConstructor for the uninitialized $prop, not the type conflict // E<phan>: PhanIncompatibleRealPropertyType — detects the string-vs-int conflict
}

trait RightTrait
{
    public int $prop; // E[conflict]
}

final class Composed // E[conflict] // E<pzoom>: MissingConstructor on the composed class, same finding as Psalm // E<mir>: same MissingConstructor
{
    use LeftTrait; // E[conflict]
    use RightTrait; // E[conflict] // E<mago>: incompatible-property-type — detects the conflict
}