#41641 [Com]: Indirect Modification Notice due to modification using __set

2007-09-27 Thread brjann at gmail dot com
 ID:   41641
 Comment by:   brjann at gmail dot com
 Reported By:  asnyder at mddev dot com
 Status:   Assigned
 Bug Type: Scripting Engine problem
 Operating System: Linux Fedora Core 4
 PHP Version:  5.2.3
 Assigned To:  helly
 New Comment:

It seems that declaring the getter as public function __get(){...}
does the trick. However, it took some googling to find.


Previous Comments:


[2007-09-25 16:22:55] brjann at gmail dot com

When 5.2.0 was released, several complaints about this issue were
submitted (see http://bugs.php.net/bug.php?id=39449), and it was
resolved. But now we're there again. 

Fact is that this seriously breaks wrapping functions that my project
relies on, and I still don't understand the logic of modification of
overloaded array properties not working is expected behaviour, while
modification of non-array properties works.

Will this be fixed? If not, why, and why was it then fixed after bug
report 39449? Was it just so that me and others would keep on writing
code that is now useless?



[2007-08-22 14:49:30] [EMAIL PROTECTED]

Marcus, can you give an educated answer to this..? 



[2007-08-22 05:53:14] asnyder at mddev dot com

First of all, I don't appreciate your snotty attitude.  Second, if you
actuallyread the post, you would realize this is not the same issue. In
that post they were actually modifying a value, in my post, I'm simply
using the __get, __set as magic methods in order to call a different
function. This is VERY different. It's ok for the call to Set and not
raise the notice. If you look at the functions there's nothing in danger
of being modifed incorrectly. Please read before you post an incorrect
response. 

I know its hard from that pedestool your on, but sometimes it's best to
come down, and discuss things with other people. I would like to think
myself as educated in the ways of PHP, and might consider fixing this
myself, and submitting it to the repository. I was hoping to save myself
the trouble, and let someone more experienced with the php internals
work on it, but if you won't fix it, I will.



[2007-08-17 20:12:26] [EMAIL PROTECTED]

Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Same as bug #38102.



[2007-07-18 14:26:49] [EMAIL PROTECTED]

Oops, wrong id, see bug #42030



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/41641

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


#41641 [Com]: Indirect Modification Notice due to modification using __set

2007-09-25 Thread brjann at gmail dot com
 ID:   41641
 Comment by:   brjann at gmail dot com
 Reported By:  asnyder at mddev dot com
 Status:   Assigned
 Bug Type: Scripting Engine problem
 Operating System: Linux Fedora Core 4
 PHP Version:  5.2.3
 Assigned To:  helly
 New Comment:

When 5.2.0 was released, several complaints about this issue were
submitted (see http://bugs.php.net/bug.php?id=39449), and it was
resolved. But now we're there again. 

Fact is that this seriously breaks wrapping functions that my project
relies on, and I still don't understand the logic of modification of
overloaded array properties not working is expected behaviour, while
modification of non-array properties works.

Will this be fixed? If not, why, and why was it then fixed after bug
report 39449? Was it just so that me and others would keep on writing
code that is now useless?


Previous Comments:


[2007-08-22 14:49:30] [EMAIL PROTECTED]

Marcus, can you give an educated answer to this..? 



[2007-08-22 05:53:14] asnyder at mddev dot com

First of all, I don't appreciate your snotty attitude.  Second, if you
actuallyread the post, you would realize this is not the same issue. In
that post they were actually modifying a value, in my post, I'm simply
using the __get, __set as magic methods in order to call a different
function. This is VERY different. It's ok for the call to Set and not
raise the notice. If you look at the functions there's nothing in danger
of being modifed incorrectly. Please read before you post an incorrect
response. 

I know its hard from that pedestool your on, but sometimes it's best to
come down, and discuss things with other people. I would like to think
myself as educated in the ways of PHP, and might consider fixing this
myself, and submitting it to the repository. I was hoping to save myself
the trouble, and let someone more experienced with the php internals
work on it, but if you won't fix it, I will.



[2007-08-17 20:12:26] [EMAIL PROTECTED]

Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Same as bug #38102.



[2007-07-18 14:26:49] [EMAIL PROTECTED]

Oops, wrong id, see bug #42030



[2007-06-25 19:49:07] asnyder at mddev dot com

Ok, HOW is this code, or code like it WRONG? The code has the desired
effect. The purpose of the code is to allow the user to call a function
via the __set, __get without having to actually call the actual
function. For instance, if one would want to have properties. Regardless
of what you think the code should be, the code has the effect that the
developer wanted, thus the code is not wrong, it's just confusing to
you.

What EXACTLY is wrong with this code? What effect is it having that is
not the desired effect?



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/41641

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


#39449 [Com]: Overloaded array properties do not work correctly

2006-12-06 Thread brjann at gmail dot com
 ID:   39449
 Comment by:   brjann at gmail dot com
 Reported By:  pstradomski at gmail dot com
 Status:   Assigned
 Bug Type: Scripting Engine problem
 Operating System: Linux
 PHP Version:  5.2.0
 Assigned To:  dmitry
 New Comment:

// This should not raise notice
foreach( $a-overloaded_property as $val )
echo $val.br /\n;

// This should raise notice
$a-overloaded_property[] = 6;

I do not agree with that. Neither of the examples should raise a
notice. There is no reason for

$a-overloadedprop = $bar

to work, but not

$a-overloadedprop[$foo] = $bar 

or

foreach($a-overloadedprop){}

Either properties can be overloaded and therefore read, assigned and
iterated over, or not. Overloaded properties should behave the same way
as ordinary properties, or else the object's behaviour is
unpredictable.

Perhaps the solution of using __get() to return a reference is
unsatisfactory in some way, but the behaviour should still be there.

/Brjánn


Previous Comments:


[2006-12-04 08:55:15] denis at edistar dot com

I think the warning should be raised only when someone is 
trying to write the overloaded property.

Foreach and other loop constructs are readonly constructs 
except when they are using references of the overloaded 
properties.

For example:
?php

class A{

private $test = array(1,2,3,4,5);

public function __get($v){
return $this-test;
}

}

$a = new A;

// This should not raise notice
foreach( $a-overloaded_property as $val )
echo $val.br /\n;

// This should raise notice
$a-overloaded_property[] = 6;

?

Thank you,
Denis



[2006-11-19 11:53:11] v dot anagnostos at mail dot bg

Reproduce code:
---

?php

class A{

private $test = array(1,2,3,4,5);

public function __get($v){
return $this-test;
}

}

$a = new A;

foreach( $a-overloaded_property as $val )
echo $val.br /\n;

?

Expected result:


1
2
3
4
5

Actual result:
--

Notice: Indirect modification of overloaded property
A::$overloaded_property has no effect in
C:\Apache\htdocs\dancho\index.php on line 15
1
2
3
4
5



[2006-11-14 20:31:16] cboden at gmail dot com

In the above example:
  $a-arr[]='d';
produced the expected results in PHP-5.1 but now gives the following
error in PHP-5.2
Notice: Indirect modification of overloaded property



[2006-11-09 14:05:23] pstradomski at gmail dot com

Reopening.

This should never be expected behaviour. This way encapsulation got
severly broken - __get was introduced to allow dynamic creation of
properties - and therefore implementation of record-like classes. Such
properties were meant to be indistinguishable from standard properties
- but aren't. Neither passing by reference works, nor array elements
do.

Developer can expect to be able to modify object properties for example
in such a way:

$x-arr = array('a');
array_push($x-arr, 'b');

Now it is impossible - although it should be. I understand previous
behaviour could be considered improper, bu now developers don't even
get a chance to choose between passing by value and passing by
reference.



[2006-11-09 13:50:54] [EMAIL PROTECTED]

This is expected behaviour.



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/39449

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