ID:               43698
 Updated by:       [EMAIL PROTECTED]
 Reported By:      robin_fernandes at uk dot ibm dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Windows
 PHP Version:      5.3CVS-2007-12-28 (snap)
 New Comment:

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

.


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

[2007-12-28 16:20:49] robin_fernandes at uk dot ibm dot com

Description:
------------
The assignment in the __set() method below is caught by the setter
recursion guard. Subsequently, I would expect it to be treated like a
direct assignment, and therefore to fail due to an attempt to write to
another class's private property.
Instead, nothing happens at all.

I believe this is related to bug 38461, whereby a crash caused by a
similar testcase was fixed, but the expected result of the assignment
was not discussed.

Reproduce code:
---------------
<?php
class C {
  function __set($name, $value) {
    echo "In " . __METHOD__ . "('$name', '$value')\n";
    $this->$name = $value;
  }
}

class D extends C {
  private $hidden = "Original Value";
}

$d = new D;
$d->hidden = "New Value";
var_dump($d);
?>

Expected result:
----------------
In C::__set('hidden', 'New Value')

Fatal error: Cannot access private property D::$hidden in %s on line 5

Actual result:
--------------
In C::__set('hidden', 'New Value')
object(D)#1 (1) {
  ["hidden":"D":private]=>
  string(14) "Original Value"
}


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


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

Reply via email to