Phpinspectionsea: Trait method collission inspection ignores 'insteadof' conflict resolution

Created on 17 Oct 2019  路  9Comments  路  Source: kalessil/phpinspectionsea


| Subject | Details |
| :------------- | :---------------------------------------------------------------------------- |
| Plugin | Php Inspections (EA Extended), 4.0.1 |
| Language level | PHP 7.1 |

Current behaviour

<?php
trait A {
    public function smallTalk() {
        echo 'a';
    }
    public function talkA() {
        echo 'A';
    }
}

trait B {
    public function smallTalk() {
        echo 'b';
    }
    public function talkB() {
        echo 'B';
    }
}

class Talker {
    // Inspections reports an error:
    //       "Trait method 'smallTalk' will not be applied, because it collides with A"
    use A, B {
        B::smallTalk insteadof A;
    }
}

Expected behaviour

It should take the conflict resolution (insteadof) into account, so this would be a false positive?

Environment details

PhpStorm 2019.3 EAP
Build #PS-193.4386.20, built on October 10, 2019
PhpStorm EAP User
Expiration date: November 9, 2019
Runtime version: 11.0.4+10-b517.1 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.0.0-31-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 1342M
Cores: 4
Registry: run.processes.with.pty=TRUE
Non-Bundled Plugins: com.kalessil.phpStorm.phpInspectionsEA, de.espend.idea.laravel, org.sonarlint.idea, ru.adelf.idea.dotenv

bug / false-positive fixed

Most helpful comment

As mentioned by @kalessil the issue you seeing is most likely not an problem from this plugin but a bug in PhpStorm which will be fixed in the next release, see: https://youtrack.jetbrains.com/issue/WI-50492.

All 9 comments

Thank you for reporting @pipegris, I'll take care of fixing this.

Fixed!

@kalessil: I have no clue why but this is still a problem in my code, however when trying to reduce it to a simple reproduction case like above I get stuck :)

Somehow something in my traits causes this, but no clue how to reproduce (the test case provided in this issue has no errors).

image

Also I am unable to find the inspection and disable it with a @noinspection comment.

Any tips on how to give you some debugging data to get to the bottom of this?

Php Inspections 4.0.3, PhpStorm 2019.3.

@stayallive: the message has no '[EA] ' prefix, so it's raised by IDE itself. Apart from it looks like a bug in the bundled inspection.

Oh! That would make sense! Thanks for the quick feedback and sorry for the bother :)

did we ever get a fix for this?

As mentioned by @kalessil the issue you seeing is most likely not an problem from this plugin but a bug in PhpStorm which will be fixed in the next release, see: https://youtrack.jetbrains.com/issue/WI-50492.

I am still experiencing this with v2020.1.2

I also get the same warning in a similar scenario where one trait overrides another trait's method.

trait a
{
   public function myMethod()
   {
      //
   }
}

trait b
{

   use a;

   public function myMethod()
   {
      // override original method
   }
}

class c
{
   use b; // Trait method 'myMethod' will not be applied, because it collides with 'b'
}

@willsmanley, our inspections reporting messages starting with '[EA] ', so this case is reported by PhpStorm itself.

Was this page helpful?
0 / 5 - 0 ratings