Error "Member has protected access" since 6.02 EAP

Hi together,

Since phpStorm 6.02 EAP Build PS-129.395 on OS X 10.7.5, errors "Member has protected access" are appearing.
I use Contao (contao.org). Many classes extends the abstract "Backend"-Class. The constructor is protected. In the in childclass, the call parent::__construct() trigg the error. (see attachment).
The same errors appears also in dynamic calls like $this->blablaMethod() from other extended Classes.

Maybe I missunderstand something, so before I send a Bugreport, I will ask in the community: Do you have an explenation for this attitude?
The same code opened with phpStorm 6.01 there are no errormessages at all.

Kind regards
Martin



Attachment(s):
MemberHasProtectedAccesSmall.png
10 comments

Hi there,

Hi together,

Who is that "together" guy?


Back to the subject:

  1. Please try "File | Invalidate caches..."
  2. If nothing -- create brand new empty project and try to reproduce the issue there (use as little classes/files as possible)


What can I say: seems to work just fine for me with this example code:

file1.php

<?php
class
BaseOne {     protected function __construct()     {         echo "Created!\n";     }     }


file2.php

<?php
class
ChildOne extends BaseOne {     public function __construct()     {         parent::__construct();              } }


P.S.
I'm using 6.0.2 EAP build #129.394

0

Hi Andriy :O
Sorry, I had stored your name wrong.

I invalidated the cache, no change.
I created a new project with only 2 files. Class Backend and Class tl_article extends Backend. With the same, original code. No change. Same error.
But I tried to find a solution and add the maybe missing "namespace=Contao;" in the head of tl_article Class. After this, the error disappeared.

I'm not a namespace crack. But it could be a solution; but it's a too heavy workaround: There are so many files without namespace tag because Contao is the default namespace.

It is absolutely crazy: The class tl_file has the absolute identical code for the __construct()-Methode also in the method itself. The same extended class Backend, also no namespace line like tl_article, BUT NO ERROR!!!
I can't understand. So for the first I reuse the phpStorm 6.01. Maybe after the EAP-phase it will be changed. I hope ?:|. Or maybe someone else will have a hint.

Kind regards
Martin

0

Please attach these problematic files (so that they can be copied to another computer to reproduce the issue). You can delete not important methods -- just leave the code that reproduces the issue in new empty project.

0

Hi Andriy,
now, it's strange.

I restarted 6.02 EAP and in the testfiles there are no errors. Back to the before no-Error marked File "tl_files.php", now there are errors too. It seems obvious. I think it will the missing namespace=contao; line in all the "tl_*" files.
Maybe it have to change from the contao-Project. Strange, in the 6.01 no errors and the code works. But maybe php isn't such strict like phpStorm. Maybe there is an fallback for missing namespace declaration... Who knows! I will not be the onlyone with this problem in future. Some Contao core developer work with phpStorm. I hope they don't will stay on phpStorm 5.X. But I think no.

Thank you for your help. And excuse this faults.
Martin

0

Hi Andriy,
Maybe phpStorm 6.02 ignore an workaround from Contao. There ist a file ide_compat. It should route the namespaces to the right direction. Maybe in 6.01 it works and in 6.02 it doesn't work. I send an Message to the Contao-Board. Perhaps there know someone an solution.

Maybe you can see an other viewpoint with this print-Screen. I don't know, but maybe there is the problem.



Attachment(s):
ide_compat.png
0

Same problem here:

  • I'm extending a class containing a Method say "protected myMethod()"
  • I'm calling $this->myMethod() from within my extension class
  • I'm getting a red highlighted error saying "Member has protected access" (which is correct but clearly no mistake here)
  • I'm getting this only sometimes
  • When using this Method several times within my extension class I'm getting the error on an arbitrary usages of this method. Say I use it three times then sometimes I get the error not at all, sometimes on one, sometimes on two other usage points.


Unfortunately the project is much too big and proprietory so I can't post the code here and I don't get the problem reproduced reliably

1

Additional info: I might have found the reason for this: I have another (deprecated) folder in my project containing a class with the same name and the same method (ok this IS uncool I know ;-)). And it seems to me like PhpStorm is mixing up both versions when checking for errors thus claiming something would be wrong. When excluding this old folder from my projects all arbitrary errors are gone. Still this behaviour seemed new to me since 6.02. Anyway: at least for me it's solved by this...

0

That is the point !!!!

Thank you Andriy and Maximilian. Contao creates a cached file, from the file that has the problem with the error "Member has protected access". If I delete fhis cache-file, the Error disappears. The existing of this cached file was the reason, why the error appears sometimes and sometimes there was no error.

Since 6.02 - also in the newest brench 129.487, this cached file is the reason for the error-message. If i delete the cache, no errors appears. So my work-around is to exclude the cache-directory in the Project settings under :

phpStorm>Preferences>Project Settings>Directories

Maybe jetBrain will develope a better solution. But now, I can work with the newest phpStorm. Thank you for your help.

Martin
0

Now, there is grow up a new problem.
Is there a way to exclude directories from the error-search-process without to exclude the file from the project?
Because, the errors are gone away, but know in the project-view I can't see the files in the exluded directory. So I can't open or manipulate them.

Maybe there is an other way, not such all-embracing.
It would be nice.

Kind regards
Martin

0

Please sign in to leave a comment.