Skip to content

false-positive: method identical to parent's one / method only calls its parent method with php attributes #1998

@homersimpsons

Description

@homersimpsons
Subject Details
Plugin Php Inspections (EA Extended), 5.6.0
Language level 8.2

Current behaviour

The following code reports "[EA] 'getInt' method can be dropped, as it identical to parent's one.":

class Parent {
  public function getInt(): int { return 1; }
}

class Child extends Parent {
  #[\Deprecated] // Or any other attribute
  public function getInt(): int { return 1; }
}

Similarly the following code reports "[EA] The 'getInt' method only calls its parent method, so it can be removed to simplify the code.":

class Parent {
  public function getInt(): int { return 1; }
}

class Child extends Parent {
  #[\Deprecated] // Or any other attribute
  public function getInt(): int { return parent::getInt(); }
}

Expected behaviour

This should not report anything as there is an attribute. In fact, to declare the attribute, you have to re-declare the method.

Note that I'm not sure if anything should be reported if we also have the attribute on the parent:

class Parent {
  #[\Deprecated]
  public function getInt(): int { return 1; }
}

I believe this is raised in:

String.format(MessagesPresentationUtil.prefixWithEa(messagePatternIdentical), method.getName()),

Environment details

PhpStorm 2025.3.1.1
Build #PS-253.29346.257, built on January 8, 2026
Source revision: e2e1ea212b1e0
Licensed to XXX / XXX
Subscription is active until February 2, 2026.
Runtime version: 21.0.9+10-b1163.86 amd64 (JCEF 137.0.17)
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.awt.X11.XToolkit
Linux 6.14.0-37-generic
Ubuntu 24.04.3 LTS; glibc: 2.39
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 4096M
Cores: 20
Registry:
  debugger.new.tool.window.layout=true
  vcs.log.index.enable=true
  run.processes.with.pty=TRUE
  ide.experimental.ui=true
  llm.jcp.analytics.endpoint.url=https://api.jetbrains.cloud/analytics/events/push
  terminal.new.ui.reworked=true
  eslint.additional.file.extensions=svelte
Non-Bundled Plugins:
  com.jetbrains.space (253.29346.45)
  Subversion (253.29346.379)
  ru.adelf.idea.dotenv (253.29346.379)
  com.intellij.lang.jsgraphql (253.28294.218)
  com.intellij.mermaid (0.0.26+IJ.252)
  com.github.deeepamin.gitlabciaid (1.14.0)
  com.jetbrains.restClient (253.29346.270)
  com.intellij.ml.llm (253.29346.331)
  dev.blachut.svelte.lang (253.29346.45)
  deno (253.29346.45)
  com.kalessil.phpStorm.phpInspectionsEA (5.6.0)
  de.espend.idea.php.annotation (12.0.2)
  com.laravel_idea.plugin (12.0.0.253)
  com.github.copilot (1.5.62-243)
Current Desktop: ubuntu:GNOME

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions