Bug #16045 Updated: count($array) logical error

2002-05-04 Thread php-bugs

 ID:   16045
 Updated by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
-Status:   Feedback
+Status:   No Feedback
 Bug Type: *General Issues
 Operating System: All
 PHP Version:  4.1.1
 New Comment:

No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to Open.


Previous Comments:


[2002-03-13 15:45:18] [EMAIL PROTECTED]

FWIW, I used the following script and got the correct 
results:

?php
error_reporting(E_ALL);
$x = array(1);
echo Count:  . count($x) . \n;
unset($x[0]);
echo Count:  . count($x) . \n;
?

Results:

Count: 1
Count: 0


This is on version 4.2.0-dev. and 4.1.2. What does this
script produce for you?


Torben



[2002-03-13 15:11:08] [EMAIL PROTECTED]

Hello,

Funny logical error:

if we have a simple variable, say
$x = 1

then
count($x) == 1, which is natural (I don't think so)

And if we have an array
$x[0] = 1;
count($x) == 1,

but after
UnSet($x[0])

we still have
count($x) = 1!

This leads to a very special kind of logical errors which are really
hard to track.

My suggestion:
either: introduce explicit type system (with unions, structs and arrays
;)
or: disable count on variables




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




Bug #16045 Updated: count($array) logical error

2002-03-13 Thread torben

 ID:   16045
 Updated by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
-Status:   Open
+Status:   Feedback
 Bug Type: *General Issues
 Operating System: All
 PHP Version:  4.1.1
 New Comment:

FWIW, I used the following script and got the correct 
results:

?php
error_reporting(E_ALL);
$x = array(1);
echo Count:  . count($x) . \n;
unset($x[0]);
echo Count:  . count($x) . \n;
?

Results:

Count: 1
Count: 0


This is on version 4.2.0-dev. and 4.1.2. What does this
script produce for you?


Torben


Previous Comments:


[2002-03-13 15:11:08] [EMAIL PROTECTED]

Hello,

Funny logical error:

if we have a simple variable, say
$x = 1

then
count($x) == 1, which is natural (I don't think so)

And if we have an array
$x[0] = 1;
count($x) == 1,

but after
UnSet($x[0])

we still have
count($x) = 1!

This leads to a very special kind of logical errors which are really
hard to track.

My suggestion:
either: introduce explicit type system (with unions, structs and arrays
;)
or: disable count on variables




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