← 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.15PHPStan - PHP Static Analysis Tool 2.2.15 Fail

No diagnostics reported.

Expectation diff
Lines 22, 27, 30, 32, 33: Expected error (tag conflict)
psalm 6.18.0Psalm 6.18.0@536dd6236b39a5115385b0307b42d6d1ad431a02
next: 7.0.0-beta22
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.50.0mago 1.50.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.78.0mir 0.78.0 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.06.23.0Phpactor 2026.06.23.0 Fail

No diagnostics reported.

Expectation diff
Lines 22, 27, 30, 32, 33: Expected error (tag conflict)
phpy 1.0.19274phpy 1.0.19274 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.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.2.15PHPStan - PHP Static Analysis Tool 2.2.15 Fail

No diagnostics reported.

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