← 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.10Phan 6.0.10 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.1PHPStan - PHP Static Analysis Tool 2.3.1 Fail

No diagnostics reported.

Expectation diff
Lines 22, 27, 30, 32, 33: Expected error (tag conflict)
psalm 6.20.0Psalm 6.20.0@804f03c0c183d149fcd4b8c7c0c9b3fbf836d34c
next: 7.0.0-rc2
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.57.0mago 1.57.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.87.0mir 0.87.0 Pass
regressions_trait_property_type_conflict.php:30: MissingConstructor: Class Conformance\Tests\RegressionsTraitPropertyTypeConflict\Composed has uninitialized properties but no constructor [MIR1507]
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.19409phpy 1.0.19409 Fail

No diagnostics reported.

Expectation diff
Lines 22, 27, 30, 32, 33: Expected error (tag conflict)
qodana 262.10968.76PhpStorm 262.10968.76 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.1PHPStan - PHP Static Analysis Tool 2.3.1 Fail

No diagnostics reported.

Expectation diff
Lines 22, 27, 30, 32, 33: Expected error (tag conflict)
psalm-next 7.0.0-rc2Psalm 7.0.0-rc2@20339e3fe5b8d03bcd8061030eb2a83ad50e5783 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
}