PHP static private function in constructor
Hi,
I don't know, if this is a Problem from PHPStorm only, or I I made a mistake.
Is it allowed to use a static private function in an __constructor?
PHPStorm sometimes shows an error. And if I want to refactor the methodename, PHPStorm didnt find the other name.
This is what I got:
Mmm - Bug? Or my fault (its not allowed to use self:: for private static functions in __constructor)
PHP shows no error - and it works ....
cu
请先登录再写评论。
Jörg, what is your PhpStorm version? I can't reproduce the issue nor in PhpStorm 5.0.4 neither in the latest EAP.
Is it a consistent problem?
Hi Maxim,
it is still in 126.97 (I have regonized it in the EAP before).
Some remarks:
I made a testfile:
It is not always shown.
When I change something in the function "otherName()" - then the Errormsg can disapear. But when I change something somewhere else in the Class (insert new Lines after the constructor for example), then the Error is there again (sometimes I need to insert 5 or 10 lines...)
I tryed to refactor the class. I clicked on self::otherName(); and I got an Error in the IDE (see below).
Important: after I creating the testfile with the testclass, you have to save the file (STRG-S) and then make some changes in the file. For example I insert a few blank lines after the constructor.
Error during dispatching of java.awt.event.KeyEvent[KEY_PRESSED,keyCode=10,keyText=Eingabe,keyChar=Eingabe,keyLocation=KEY_LOCATION_NUMPAD,rawCode=13,primaryLevelUnicode=13,scancode=28,extendedKeyCode=0xa] on EditorComponent file=null
java.lang.NullPointerException
at com.jetbrains.php.lang.psi.elements.impl.PhpClassImpl.selectBestClass(PhpClassImpl.java:360)
at com.jetbrains.php.lang.psi.elements.impl.PhpClassImpl.getSuperClass(PhpClassImpl.java:354)
at com.jetbrains.php.PhpClassHierarchyUtils.getImmediateParents(PhpClassHierarchyUtils.java:283)
at com.jetbrains.php.PhpClassHierarchyUtils.processSuperMembers(PhpClassHierarchyUtils.java:264)
at com.jetbrains.php.refactoring.rename.PhpClassMemberRenameProcessor.prepareRenaming(PhpClassMemberRenameProcessor.java:32)
at com.intellij.refactoring.rename.RenameProcessor.prepareRenaming(RenameProcessor.java:129)
at com.intellij.refactoring.rename.RenameProcessor.doRun(RenameProcessor.java:119)
at com.intellij.refactoring.BaseRefactoringProcessor.run(BaseRefactoringProcessor.java:539)
at com.intellij.refactoring.ui.RefactoringDialog.invokeRefactoring(RefactoringDialog.java:174)
at com.intellij.refactoring.rename.RenameDialog.performRename(RenameDialog.java:288)
at com.intellij.refactoring.rename.RenameDialog.doAction(RenameDialog.java:265)
at com.intellij.refactoring.ui.RefactoringDialog.doRefactorAction(RefactoringDialog.java:85)
at com.intellij.refactoring.ui.RefactoringDialog$RefactorAction.actionPerformed(RefactoringDialog.java:148)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at javax.swing.plaf.basic.BasicRootPaneUI$Actions.actionPerformed(BasicRootPaneUI.java:208)
at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1664)
at javax.swing.JComponent.processKeyBinding(JComponent.java:2879)
at javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:306)
at javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:250)
at javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:2971)
at javax.swing.JComponent.processKeyBindings(JComponent.java:2963)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2842)
at java.awt.Component.processEvent(Component.java:6282)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1895)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:762)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1027)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:899)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:727)
at java.awt.Component.dispatchEventImpl(Component.java:4731)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:696)
at java.awt.EventQueue$4.run(EventQueue.java:694)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
at com.intellij.ide.IdeEventQueue.d(IdeEventQueue.java:685)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:480)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:333)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:154)
at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182)
at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219)
at java.awt.Dialog.show(Dialog.java:1077)
at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:692)
at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:397)
at com.intellij.openapi.ui.DialogWrapper.showAndGetOk(DialogWrapper.java:1442)
at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1418)
at com.intellij.refactoring.rename.PsiElementRenameHandler.a(PsiElementRenameHandler.java:172)
at com.intellij.refactoring.rename.PsiElementRenameHandler.rename(PsiElementRenameHandler.java:143)
at com.intellij.refactoring.rename.PsiElementRenameHandler.invoke(PsiElementRenameHandler.java:95)
at com.intellij.refactoring.rename.PsiElementRenameHandler.invoke(PsiElementRenameHandler.java:61)
at com.intellij.refactoring.actions.BaseRefactoringAction.actionPerformed(BaseRefactoringAction.java:122)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$3.performAction(IdeKeyEventDispatcher.java:564)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:611)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.d(IdeKeyEventDispatcher.java:463)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:206)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:479)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:333)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Jörg, thank you!
Please, see issue WI-16435.
This bug is fixed and will be available in the next EAP.