ID:               27798
 User updated by:  ricardo at ish dot com dot br
 Reported By:      ricardo at ish dot com dot br
 Status:           Open
 Bug Type:         Zend Engine 2 problem
 Operating System: Windows XP
-PHP Version:      5.0.1-dev
+PHP Version:      5.0.1
 New Comment:

I'll try to show a new example, to make my point:

Source:
=======
<?php
class Foo {

  public $var1;
  private $var2;

  function __construct() {
    $this->var1 = 'A';
    $this->var2 = 'B';
  }

  public function dumpVars() {
    print_r(get_object_vars($this));
  }

}
?>
<pre>
<?php
$myFoo = new Foo();
echo "My VARS:<br>\n";
$myFoo->dumpVars();
?>
</pre>
==========

<pre>
<?php
print_r(get_object_vars($myFoo));
?>
</pre>

Behavior:
=========

My VARS:
Array
(
    [var1] => A
)

==========

Array
(
    [var1] => A
)

Expected Behavior (IMHO):
=========================

My VARS:
Array
(
    [var1] => A
    [var2] => B
)

==========

Array
(
    [var1] => A
)

Explanation:
============

Note the difference between calling get_object_vars($this) inside a
public method, inside the class (where all variables should be seen),
and calling in the outside - get_object_vars($myFoo).


Previous Comments:
------------------------------------------------------------------------

[2004-07-20 13:54:12] ricardo at ish dot com dot br

I've tried and isn't working yet (and I also get this error message -
phpinfo() is ok and show PHP 5.0.1-dev):

PHP has encountered an Access Violation at 00B4737A
My VARS:
Array
(
    [var1] => A
)

HTTP/1.1 500 Server Error Server: Microsoft-IIS/5.1 Date: Tue, 20 Jul
2004 11:51:51 GMT Content-Type: text/html Content-Length: 44
-2147417842 (0x8001010e)

------------------------------------------------------------------------

[2004-07-19 16:53:53] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



------------------------------------------------------------------------

[2004-04-17 21:30:58] ricardo at ish dot com dot br

Here is the sample code:

<?php
class Foo {

  public $var1;
  private $var2;

  function __construct() {
    $this->var1 = 'A';
    $this->var2 = 'B';
  }

  public function dumpVars() {
    print_r(get_object_vars($this));
  }

}
?>
<pre>
<?php
$myFoo = new Foo();
echo "My VARS:<br>\n";
$myFoo->dumpVars();
?>
</pre>

Here is the behavior:
=====================

My VARS:
Array
(
    [var1] => A
)

Here is the expected Behavior:
==============================

My VARS:
Array
(
    [var1] => A
    [var2] => B
)

My opinion about it:
====================

Since the function get_object_vars is being called inside the class, it
should have access to all PPP types, shouldn't it? (this example above
is a dummy one, but it illustrates the problem quite well).

Sorry about the delay of my reply.

------------------------------------------------------------------------

[2004-04-07 08:57:10] ricardo at ish dot com dot br

Well, as pointed by your observation, it should work if i call
get_object_vars in a method inside the own class, right?

well, it will also fail. :)

------------------------------------------------------------------------

[2004-04-07 04:39:06] [EMAIL PROTECTED]

That's expected behaviour..(what would the use of protected/private be
if you can get access to them anywhere?) 

(if you disagree, give an example..and not a reference to unrelated bug
report)


------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/27798

-- 
Edit this bug report at http://bugs.php.net/?id=27798&edit=1

Reply via email to