PHP does not show a significant error. A function with the same name but a different signature in the derived class

I already read the related topic here Function with the same name, but with a different signature in the derived class .

I think the problem is the same, but in my case it happens in PHP 5.4 (it works fine in PHP 5.3). The specific configuration is wamp 2.2, PHP 5.4.3. I see no errors in the logs, and the Chrome browser shows the following: "Error 101 (net :: ERR_CONNECTION_RESET): the connection was reset."

If I change the name of the function "init" in my example below, everything will be fine. Therefore, I know what to do, but I would like to make sure that it is bad practice in general for the same reasons explained in the relevant question. It would be helpful if PHP showed an error, I don't know what is going on inside.

Any thoughts?

thanks

class MyClass1 { private function init(){ } } class MyClass2 extends MyClass1 { private function init($params) { } } $myinstance = new MyClass2(); 
+4
source share
2 answers

I just looked through the PHP changelog and found something that might be relevant.

The item in the release notes for 5.4.4 reads as follows:

Bug # 61761 fixed (Overriding a private static method with a different signature causes a crash)

This is very similar to what you see, especially since you indicated that you are using PHP 5.4.3.

According to my comment earlier, I would suggest upgrading to a newer version 5.4 (preferably the latest - currently 5.4.8).

Hope this helps.

+2
source

From the error you get in Chrome, I would suggest that PHP is crashing (hence there is no meaningful error). I would start by disabling some extensions, perhaps by checking the event viewer for any crash information.

0
source

Source: https://habr.com/ru/post/1446366/


All Articles