php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: thc at forestfactory dot de
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 15:01:32 2024 UTC