kalessil / phpinspectionsea

A Static Code Analyzer for PHP (a PhpStorm/Idea Plugin)
https://plugins.jetbrains.com/plugin/7622?pr=phpStorm
Other
1.44k stars 118 forks source link

"Define the same property" warning when setting trait property value in class constructor #1832

Open ghost opened 2 years ago

ghost commented 2 years ago
Subject Details
Plugin Php Inspections (EA Extended) 4.0.7.1
Language level e.g. PHP 7.4

Current behaviour

image

Example code:

<?php

declare(strict_types=1);

trait PropertiesTrait
{
    private string $property;
}

class Properties
{
    use PropertiesTrait;

    public function __construct(string $property)
    {
        $this->property = $property;
    }
}

Expected behaviour

No warning as the class doesn't define the property, only sets its value.

Environment details

PhpStorm 2022.1.2
Build #PS-221.5787.33, built on June 1, 2022
Licensed to Petri Haikonen
You have a perpetual fallback license for this version.
Subscription is active until April 19, 2023.
Runtime version: 11.0.15+10-b2043.56 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.4.0-113-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 8
Registry:
    run.processes.with.pty=TRUE

Non-Bundled Plugins:
    some.awesome (1.14)
    net.sjrx.intellij.plugins.systemdunitfiles (0.3.7)
    Key Promoter X (2022.2)
    zielu.gittoolbox (212.9.0)
    mobi.hsz.idea.gitignore (4.4.0)
    com.kalessil.phpStorm.phpInspectionsEA (4.0.7.1)
    de.espend.idea.php.toolbox (6.1.0)
    de.espend.idea.php.annotation (8.2.1)
    ru.adelf.idea.dotenv (2022.1)

Current Desktop: ubuntu:GNOME
InvisibleSmiley commented 1 year ago

FTR this also happens if the property is protected.