|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77613 method visibility change
Submitted: 2019-02-13 12:31 UTC Modified: 2019-02-13 13:32 UTC
From: gstachniuk at gmail dot com Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: Next Minor Version OS: Ubuntu 18.04.1 LTS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: gstachniuk at gmail dot com
New email:
PHP Version: OS:


 [2019-02-13 12:31 UTC] gstachniuk at gmail dot com
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-02-13 12:50 UTC]
-Package: PHP Language Specification +Package: Scripting Engine problem -Assigned To: +Assigned To: nikic
 [2019-02-13 13:23 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.
 [2019-02-13 13:32 UTC]
-Assigned To: nikic +Assigned To: dmitry
 [2019-02-13 13:32 UTC]
@dmitry: Can you please take a look at this?

This is easy enough to fix by checking constructor on the actual parent CE rather than common.scope, but I'm wondering if we shouldn't bring back ZEND_ACC_CTOR. The premise was that it can be replaced by a fe->common.scope->constructor == fe check, but this is not the case.
 [2019-02-14 10:18 UTC]
Automatic comment on behalf of
Log: Fixed bug #77613 (method visibility change) (reverted ZEND_ACC_CTOR and ZEND_ACC_DTOR flags removal)
 [2019-02-14 10:18 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 11:01:36 2019 UTC