php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Thank you for your help! If the status of the bug report you submitted changes, you will be notified. You may return here and check the status or update your report at any time.
The URL for your bug report is: https://bugs.php.net/bug.php?id=40348.
Bug #40348 Reading of private/protected properties should be allowed for Reflection API
Submitted: 2007-02-04 06:54 UTC Modified: 2007-02-04 10:09 UTC
From: thc at forestfactory dot de Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: * OS: *
Private report: No CVE-ID: None
 [2007-02-04 06:54 UTC] thc at forestfactory dot de
Description:
------------
"Fixing" "bug" #37816 in PHP 5.2.0 made Reflection more or less useless for the one purpose I used it for: reverse-engineering  and debugging. While I can understand that there might be a reason for disallowing "setValue" on private/protected properties, why shouldn't I be allowed to read the value of a property? 

I wrote a nice debugger/reflection class for 5.1.x which stopped working now. And what will I do? I will use print_r() or var_export() and parse the output using regular expressions or something to get the value. So what is the point of this? I still get the value. You just made my code less readable and more performance consuming

IMHO this was never a bug! And as #24852 mentions it isn't a bug that print_r() gives access to values of non-public properties

Regards Thomas


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-04 10:09 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Use var_dump
 [2011-06-10 16:46 UTC] rasmus at mindplay dot dk
The following method enables access to protected and private properties:

http://de3.php.net/manual/en/reflectionproperty.setaccessible.php
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Jan 28 23:03:34 2022 UTC