note 126362 added to language.oop5.visibility
| From: | kostya at eltexsoft dot com | Date: | Mon, 23 Aug 2021 22:05:14 +0000 |
| Subject: | note 126362 added to language.oop5.visibility | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-216822@lists.php.net to get a copy of this message | ||
I see we can redeclare private properties into child class
<?php
class A{
private int $private_prop = 4;
protected int $protected_prop = 8;
}
class B extends A{
private int $private_prop = 7; // we can redeclare private property!!!
public function printAll() {
echo $this->private_prop;
echo $this->protected_prop;
}
}
$b = new B;
$b->printAll(); // show 78
}
?>
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 188.163.99.153)
----
Manual Page -- https://php.net/manual/en/language.oop5.visibility.php
Edit -- https://main.php.net/note/edit/126362
Del: integrated -- https://main.php.net/note/delete/126362/integrated
Del: useless -- https://main.php.net/note/delete/126362/useless
Del: bad code -- https://main.php.net/note/delete/126362/bad+code
Del: spam -- https://main.php.net/note/delete/126362/spam
Del: non-english -- https://main.php.net/note/delete/126362/non-english
Del: in docs -- https://main.php.net/note/delete/126362/in+docs
Del: other reasons-- https://main.php.net/note/delete/126362
Reject -- https://main.php.net/note/reject/126362
Search -- https://main.php.net/manage/user-notes.php