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

Closed
opened 2018-07-13 09:13:11 +02:00 by belliash · 1 comment
Owner

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 added the
bug
label 2018-07-13 09:13:11 +02:00
belliash self-assigned this 2018-07-13 17:51:13 +02:00
Author
Owner

This is fixed by 408ccc73c2.

This is fixed by 408ccc73c2.
belliash self-assigned this 2018-07-28 19:23:07 +02:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: aerscript/Aer#4
No description provided.