andrey613 / php-form-builder-class

Automatically exported from code.google.com/p/php-form-builder-class
GNU General Public License v3.0
0 stars 0 forks source link

get_class_vars ignores protected class variables in php 5.2.6-3ubuntu4.6? #148

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I simply loaded up the elements.php example that comes with the zip file.

I expect to see Form labels, no php notices, and the form width respected (400).
I do see the form. However, I see no labels. I see php notices. All of the 
elements span the entire screen.
HTML shows that the form has no id at all (should be called 'elements').

Using:
pfbc2.2-php5.zip
php 5.2.6-3ubuntu4.6

I discovered that get_class_vars($class) in Base.php returns no protected class 
variables. To test this, I added a dummy public class variable in Element.php 
and could get that. So, the following fixed everything that I can tell so far. 
But my question is, shouldn't this already work with the version of PHP I'm 
using? Is this just the beginning of my troubles?

//replace this line:
//$available = array_keys(get_class_vars($class));
//with these
$strObjDump = print_r($this, true);
preg_match_all('/\[(.{1,}):pr[^\]].+\]/',$strObjDump,$matches);         
$available = $matches[1];

Thanks.

Original issue reported on code.google.com by mirthca...@gmail.com on 20 Jul 2011 at 6:49

GoogleCodeExporter commented 8 years ago
See 
http://groups.google.com/group/php-form-builder-class/browse_thread/thread/3ec95
8eec90b69fc?hl=en

Original comment by ajporterfield@gmail.com on 20 Jul 2011 at 1:05

GoogleCodeExporter commented 8 years ago
had the same problem is resolved to the following way, using the 
ReflectionClass class:

public function configure(array $properties = null) {
     if(!empty($properties)) {
    $class = get_class($this);
    /*The property_reference lookup array is created so that properties can be set case-insensitively.*/

    $reflection = new ReflectionClass($class);
        $available = array_keys($reflection->getdefaultProperties());
        //$available = array_keys(get_class_vars($class));

my configuration is:
- Windows 7
- Apache server 2.0
- Php 5.1.6

Thanks

Antonio Huaman

Original comment by listas....@gmail.com on 6 May 2012 at 3:02