|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-02-13 12:31 UTC] gstachniuk at gmail dot com
Description:
------------
in php version 7.4 I can not change methods visibility anymore.
Test script:
---------------
class CustomException extends \RuntimeException {
private function __construct(string $msg) {
return new self($msg);
}
}
Expected result:
----------------
no error message
```
::__construct() must be public (as in class Exception) in
```
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 04:00:01 2025 UTC |
Here is another reproducer: class A { public function __construct() { static $foo; } } class B extends A { } class C extends B { private function __construct() {} } The important bit is that a) we have an intermediate class that inherits the ctor b) the ctor is duplicated. In the original example this is due to an internal class, in this example due to use of static variables. The reason why this issue occurs is that "parent->common.scope->constructor == parent" is used to detect a constructor. However, if parent comes from class B then parent->common.scope will be A, which has a different instance of the same constructor.