8

Is there any way to get rid of this annoying PhpStorm warning:

Member has private access, but class has magic method __get

Thank you!

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Ksamp
  • 139
  • 2
  • 9
  • Unfortunately no. See my comment to the similar question: http://stackoverflow.com/q/38004272/783119 . The author of that question decided to just hide all warnings altogether... which is wrong. – LazyOne Jul 01 '16 at 20:35
  • Possible duplicate of [How to stop this inspection: "Member has protected access, but class has magic method \_\_get"?](https://stackoverflow.com/questions/38004272/how-to-stop-this-inspection-member-has-protected-access-but-class-has-magic-m) –  Jun 03 '19 at 09:34

1 Answers1

11

You can turn off warnings for magically accessing properties in the following way:

  1. Go to File -> Settings -> Editor -> Inspections
  2. Go to PHP -> Undefined -> Undefined field
  3. Uncheck the box for "Notify about access to a field via magic method"

I am not entirely sure if this will also hide the warning in your case, for accessing private members. If not, you could also use the @property PHPDoc tag to describe which fields are accessible through your magic __get method.

Check this page for more information

chocochaos
  • 1,466
  • 10
  • 15