[PHP-BUG] Bug #76246 [NEW]: cannot access private variable in file included in method
[email protected] ("miklcct at gmail dot com") Sat, 21 Apr 2018 03:50:49 GMT
| Newsgroups | php.standards |
|---|---|
| Message-ID | <[email protected]> |
From: miklcct at gmail dot com
Operating system: Debian
PHP version: 7.2.4
Package: PHP Language Specification
Bug Type: Bug
Bug description:cannot access private variable in file included in method
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 bug report at https://bugs.php.net/bug.php?id=76246&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76246&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76246&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76246&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76246&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76246&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76246&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76246&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76246&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76246&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76246&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76246&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76246&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76246&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76246&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76246&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76246&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76246&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76246&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76246&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76246&r=mysqlcfg