← 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.7Phan 6.0.7 php-ast version 1.1.3 PHP version used to run Phan: 8.5.9 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.2.11PHPStan - PHP Static Analysis Tool 2.2.11 Fail

No diagnostics reported.

Expectation diff
Lines 22, 27, 30, 32, 33: Expected error (tag conflict)
psalm 6.16.1Psalm 6.16.1@f1f5de594dc76faf8784e02d3dc4716c91c6f6ac
next: 7.0.0-beta19
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.47.4mago 1.47.4 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.72.1mir 0.72.1 Pass
regressions_trait_property_type_conflict.php:30: MissingConstructor: Class Conformance\Tests\RegressionsTraitPropertyTypeConflict\Composed has uninitialized properties but no constructor [MIR1507]
phpantom 0.10.0phpantom_lsp 0.10.0 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.07.22.0Phpactor 2026.07.22.0 Fail

No diagnostics reported.

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

No diagnostics reported.

Expectation diff
Lines 22, 27, 30, 32, 33: Expected error (tag conflict)
qodana 262.9437.196Qodana 262.9437.196 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.6steins 0.1.6 (2026-08-25 revision c13b4c7) Fail

No diagnostics reported.

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

No diagnostics reported.

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