ID:               25815
 User updated by:  dan at wep dot net
 Reported By:      dan at wep dot net
 Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: Linux (Redhat 9, 2.4.22)
 PHP Version:      5CVS-2003-10-09 (dev)
 New Comment:

Hrm. After some more thought I see why this should not throw a
notice/warning. It just seems odd that the setter is disabled when
myVar is never declared or used in the unusedFunction().


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

[2003-10-10 12:44:33] dan at wep dot net

OK, so it is a scoping issue. That's fine, but when a variable name is
reserved from all scopes (even though it's only declared in one ..
strange ..), shouldn't the code at the very least throw back an
E_NOTICE when something tries to create or access a variable by the
same name from a different scope?

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

[2003-10-10 12:21:56] [EMAIL PROTECTED]

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

That\'s correct. We have three types of object bound properties:
1) declared with or without default value
2) implicit declared by usage in source (for BC reasons)
3) virtual through __get() and __set()

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

[2003-10-09 21:33:33] dan at wep dot net

Description:
------------
When a class definition contains any reference to a variable name that
will be later used in a __set() (or __get()) operation, the setter (or
getter) will not fire.

This variable does not have to be defined or used at all. The code must
simply exist.

In the following example code, simply comment out the
print($this->myVar); line and you will see the 'setter fired' message.

This is NOT similar to bug #24608 as the element never gets created in
this case.

Reproduce code:
---------------
class test {
  function unusedFunction() {
    print($this->myVar);  
  }
  function __set($nm, $vl) {
    print('setter fired');
  }
}

$obj = new test();
$obj->myVar = 'some data';

Expected result:
----------------
'setter fired'


Actual result:
--------------
Nothing.


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


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

Reply via email to