kalessil / phpinspectionsea

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

[FP] `Declaration access can be weaker` for overridden methods in final classes #1957

Open jdreesen opened 1 month ago

jdreesen commented 1 month ago
Subject Details
Plugin Php Inspections EA Ultimate, 2024.1.1
Language level 8.1

Current behaviour

The “Declaration access can be weaker” inspection reports that the setUp() method in a test extending PHPUnit's PHPUnit\Framework\TestCase can be made private instead of protected, because the class is final: image

Expected behaviour

The suggestion isn't shown because decreasing the visibility of an overriden method is not allowed in PHP, see: https://3v4l.org/PF8l6

Environment details

PhpStorm 2024.2.3 Build #PS-242.23339.16, built on September 25, 2024 Runtime version: 21.0.4+13-b509.17 amd64 (JCEF 122.1.9) VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Toolkit: sun.awt.X11.XToolkit Linux 5.4.0-196-generic GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation Memory: 6144M Cores: 8 Current Desktop: ubuntu:GNOME

jdreesen commented 1 month ago

Note: there was already a similar bug a few years ago: #1384