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:
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
Current behaviour
The “Declaration access can be weaker” inspection reports that the
setUp()
method in a test extending PHPUnit'sPHPUnit\Framework\TestCase
can be made private instead of protected, because the class is final: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