Bug #76246 [Csd->Nab]: cannot access private variable in file included in method

From: Date: Sat, 21 Apr 2018 04:14:23 +0000
Subject: Bug #76246 [Csd->Nab]: cannot access private variable in file included in method
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214822@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76246&edit=1 ID: 76246 Updated by: requinix@php.net Reported by: miklcct at gmail dot com Summary: cannot access private variable in file included in method -Status: Closed +Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Debian PHP Version: 7.2.4 Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2018-04-21 04:13:36] miklcct at gmail dot com Sorry, my mistake ------------------------------------------------------------------------ [2018-04-21 04:13:34] miklcct at gmail dot com Sorry, my mistake ------------------------------------------------------------------------ [2018-04-21 04:06:20] requinix@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. Works for me. Hacked out a single-file version too: https://3v4l.org/Qv730 ------------------------------------------------------------------------ [2018-04-21 03:50:48] miklcct at gmail dot com Description: ------------ An included file inside a class method cannot access class private member, but can access protected member Test script: --------------- // View.php class View { private $data = 'test'; public function render() { require 'view.phtml' } } (new View)->render(); // view.phtml <html><head><title>$this->data</title></head><body></body></html> Expected result: ---------------- An HTML with title test is returned Actual result: -------------- A fatal error saying cannot access private property ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76246&edit=1

« previous php.bugs (#214822) next »