OOP: Constructors and destructors does not obey to access modifiers #4

已關閉
建立於 2018-07-13 09:13:11 +02:00belliash · 1 comment
擁有者

Aer Information

  • Aer Version (or commit ref): e53cfb8ba0
  • Operating System: Linux
  • System Architecture (eg. arm, x86_64, ...): x86_64

Your problem description

__construct() and __destruct() are always considered to be public by PH7 Engine and this is wrong behaviour. There should be no exception in the matter of how access modifiers are working.

    <?php
            class Test {
                    private function __construct() {
                            echo "I live, again!\n";
                            self::__toString();
                    }
                    private function __destruct() {
                            echo "DONE\n";
                    }
                    private function __toString() {
                            echo "STRING\n";
                    }
            }
            Test::__destruct();

    ?>

Above example shows that when calling private __toString method from constructor it is working, but call from outside class is omitted, as expected. Anyway constructor is still called, despite it is private.

Expected results

// No output at all

Current results

I live, again!

STRING

<!-- 1. Please speak English, this is the language all of us can speak and write. 2. Please take a moment to check that your issue doesn't already exist. 3. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> # Aer Information - Aer Version (or commit ref): e53cfb8ba0 - Operating System: Linux - System Architecture (eg. arm, x86_64, ...): x86_64 # Your problem description __construct() and __destruct() are always considered to be public by PH7 Engine and this is wrong behaviour. There should be no exception in the matter of how access modifiers are working. <?php class Test { private function __construct() { echo "I live, again!\n"; self::__toString(); } private function __destruct() { echo "DONE\n"; } private function __toString() { echo "STRING\n"; } } Test::__destruct(); ?> Above example shows that when calling private __toString method from constructor it is working, but call from outside class is omitted, as expected. Anyway constructor is still called, despite it is private. # Expected results // No output at all # Current results I live, again! STRING
belliash 加入了
bug
標籤 2018-07-13 09:13:11 +02:00
belliash 指派給自己 2018-07-13 17:51:13 +02:00
作者
擁有者

This is fixed by 408ccc73c2.

This is fixed by 408ccc73c2.
belliash 關閉了這個問題 2018-07-13 18:18:34 +02:00
belliash 指派給自己 2018-07-28 19:23:07 +02:00
登入 才能加入這對話。
1 參與者
通知
截止日期
未設定截止日期。
先決條件

未設定先決條件。

參考: aerscript/Aer#4
No description provided.