Bug #64755 [Com]: Only variables should be passed by reference

2013-10-06 Thread a at b dot c dot de
Edit report at https://bugs.php.net/bug.php?id=64755edit=1

 ID: 64755
 Comment by: a at b dot c dot de
 Reported by:eth at ethaniel dot com
 Summary:Only variables should be passed by reference
 Status: Not a bug
 Type:   Bug
 Package:Scripting Engine problem
 Operating System:   Debian 7.0
 PHP Version:5.4.14
 Block user comment: N
 Private report: N

 New Comment:

For guy's example. Yes, your assumption is wrong; the suggestion 'that the type 
of $value = array() is expression and not a variable' is correct. It's not a 
variable, it's an assignment expression.


Previous Comments:

[2013-09-12 01:41:42] guy at syntheticwebapps dot com

To respond to eth: I'm not disagreeing with you, but just keep in mind that 
before 5.4, func()[$index] was not legal syntax, so it made a lot of sense to 
use phrasing like array_shift(array_splice(...)). So there's a bunch of code 
out 
there that uses the old approach, and in 5.4+ it's no longer considered OK. 

I'm just asking: Why should it not be OK? This example around arrays is not the 
only one, so the syntax you suggested will not apply to all cases. It seems 
unduly inflexible to disallow values to be passed in where reference aliasing 
is 
intended. So what if the caller intends to disregard the response? Why force 
them to care enough to create a variable of their own when that only serves 
to 
delay the freeing of that value from memory by one level of the call stack? 
Fact 
is, functions have side effects and return values and other call-by-reference 
parameters which may be what the caller is really looking for. The caller 
shouldn't need to pretend to care about every value they pass to a function 
which deems it reference aliasable.

I realize here I'm going deeper into PHP history. I just think it's an 
improvement along positive lines to relax this and not move toward strictness 
for non-utilitarian reasons. Today's E_STRICT becomes tomorrow's E_DEPRECATED 
and next week's E_ERROR. So why be picky about this when there's no ambiguity?


[2013-09-11 23:28:13] ni...@php.net

array_shift(array_splice($dbents, $x, 1)) does not throw an ERROR exception 
(whatever that is). It throws an E_STRICT level error, which is the lowest 
error type we have.

The E_STRICT tells you that you have some code that currently works, but is 
discouraged. What you were actually looking for is array_splice($dbents, $x, 
1)[0] (at least I assume so, because I don't really get your code sample.)


[2013-09-11 23:13:24] guy at syntheticwebapps dot com

Even worse, the following no longer works in PHP 5.4+ and this is an ERROR 
exception: 

$dbentry = array_shift(array_splice($dbents, $x, 1)))

This is why some leeway is appropriate on this error. I you can't chain 
together 
such logical progressions without INVENTING a variable in the code which has no 
other purpose than to avoid this ERROR exception, the language is headed the 
wrong direction and causing limitations for no cause.

I really think this needs to be fixed.


[2013-09-11 22:59:26] guy at syntheticwebapps dot com

I have a different example than the one given. Consider:

function myfunc( $refvar ) {
  ...
}

$horse = myfunc( $value = array() );

The code example above also gets the same exception, however, this does not 
seem 
correct. This suggests that the type of $value = array() is expression and 
not 
a variable. But this violates an assumption in the language. Is this assumption 
incorrect? Should it be incorrect?

As in the original reported form of the problem, I believe there should be some 
forgiveness in the call-by-reference receiver. I can understand why NOT to do 
that, but there are safe ways to do it anyway, like create a new zval for local 
use. 

But it's more important to me that $value = array() evaluates to the VARIABLE 
$value and NOT an expression. What expression could it possibly represent? The 
supposed expression in such a case is meaningless, whereas the variable is 
meaningful and useful. Any chance this could be fixed in future?


[2013-05-02 08:25:11] paj...@php.net

See www.php.net/array_pop.

Using: array_pop(array_keys($a)); array_keys($a) is an expression while 
array_pop 
expects a variable. ($k = array_keys($a);...).




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

https://bugs.php.net/bug.php?id=64755


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64755edit

Bug #64693 [Com]: Third argument ($initial) passed to array_reduce should be immutable.

2013-10-06 Thread a at b dot c dot de
Edit report at https://bugs.php.net/bug.php?id=64693edit=1

 ID: 64693
 Comment by: a at b dot c dot de
 Reported by:jdoane at vlacs dot org
 Summary:Third argument ($initial) passed to array_reduce
 should be immutable.
 Status: Not a bug
 Type:   Bug
 Package:Arrays related
 Operating System:   Ubuntu 12.04.02 LTS
 PHP Version:5.3.24
 Block user comment: N
 Private report: N

 New Comment:

Normal passing semantics refers not only to the pass-by-value semantics of 
PHP, but also to many OO-based languages such as Java and C#: changing an 
object's properties inside a function will change the properties of the object 
- the object itself remains the same object and doesn't get cloned or replaced 
in the process.

Of course, if you explicitly pass the object by reference as you do in your 
sample code then the behaviour changes in a way similar to C#'s ref signature 
modifier.


Previous Comments:

[2013-04-23 15:54:49] jdoane at vlacs dot org

So you're telling me that the inconsistent behavior is not due to the poor 
implementation of array_reduce() but rather of PHP? So even though things by 
name imply that a variable is immutable (hence $initial, you do know what 
initial means, right?) that the resulting mutation will make it something other 
than the initial value?

Thank you for clarifying that for me, but you leave me baffled as to your 
reasoning why this seems like a good idea. Maybe it's not a bug, but it's 
definitely not clean and consistent. Consider saying that a variable is an 
initial value, you would think that it would remain an initial value, hence 
implying the value (regardless of type) is immutable.


[2013-04-23 15:27:11] ni...@php.net

array_reduce uses the normal passing semantics. We do not document for every 
function that it uses the normal passing semantics, because, well, they are the 
same everywhere.

PHP never clones your objects unless you tell it to.


[2013-04-23 13:04:13] jdoane at vlacs dot org

The order of the expected output is backwards, I apologize.

It should be:
~$ php test.php
stdClass Object
(
[count] = 2
[maxlen] = 5
)
stdClass Object
(
[count] = 0
[maxlen] = 0
)


[2013-04-22 19:41:14] jdoane at vlacs dot org

Description:

When array_reduce is called with an object as the third argument, the variable 
passed to said third argument will turn into the result of the array_reduce() 
call. It feels like the object getting passed into array_reduce is not being 
cloned and is being modified in place. Since all objects are passed as a 
reference 
it changes the $initial variable in the scope where array_reduce was called.

So either documentation needs to be updated that says that $initial gets set to 
the return value when it is an object or this shouldn't happen to begin with as 
it 
appears that $initial should remain immutable for the duration of the 
array_reduce() call.

Test script:
---
$array = (object)Array('foo', 'baraz');
$initial = (object)Array('count' = 0, 'maxlen' = 0);
$output = array_reduce($array, function($d, $item) {
if($d-maxlen  strlen($d)) { $d-maxlen = strlen($d); }
$d-count++;
return $d;
}
print_r($output);
print_r($initial);

Expected result:

~$ php test.php
stdClass Object
(
[count] = 0
[maxlen] = 0
)
stdClass Object
(
[count] = 2
[maxlen] = 5
)

Actual result:
--
~$ php test.php
stdClass Object
(
[count] = 2
[maxlen] = 5
)
stdClass Object
(
[count] = 2
[maxlen] = 5
)






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


Bug #60697 [Com]: gettype() cann't distinguish object and function?

2012-08-14 Thread a at b dot c dot de
Edit report at https://bugs.php.net/bug.php?id=60697edit=1

 ID: 60697
 Comment by: a at b dot c dot de
 Reported by:hfcorriez at gmail dot com
 Summary:gettype() cann't distinguish object and function?
 Status: Not a bug
 Type:   Bug
 Package:Scripting Engine problem
 Operating System:   all
 PHP Version:5.3.8
 Block user comment: N
 Private report: N

 New Comment:

If you want to tell if something is a function (i.e. callable), use 
is_callable(). If you want to tell if something is an object and callable, use 
is_object and is_callable().


Previous Comments:

[2012-01-10 08:44:19] hfcorriez at gmail dot com

I think it's not good for use
When I want to check function and call witch $a(), I must check it's a object 
and 
the class name is Closure


[2012-01-10 08:20:50] cataphr...@php.net

function is not a type. See http://php.net/manual/en/language.types.php


[2012-01-10 05:25:13] hfcorriez at gmail dot com

Description:

I create a lambda function with a variable, then check it type with gettype , 
it's 
return object, It think it's not good in here.

Test script:
---
$a = function(){}; 
$b = new stdClass();
echo gettype($a) . '|' . gettype($b); // echo 'object|object'







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


[PHP-BUG] Req #62291 [NEW]: Mixed first argument for strtr

2012-06-11 Thread a at b dot c dot de
From: a at b dot c dot de
Operating system: Any
PHP version:  5.4.3
Package:  Strings related
Bug Type: Feature/Change Request
Bug description:Mixed first argument for strtr

Description:

While preg_replace and str_replace can both apply changes to arrays of
strings, strtr can only be passed one string at a time for translation; it
can only be called as strtr(string, string, string) or strtr(string,
array).

This suggestion/request is for strtr to be support being called as, for
example, strtr(array, string1$, string2$) (which would be effectively
equivalent to array_map(function($w)use($string1, $string2) { return
strtr($w, $string1, $string2); }, $array)).

This would bring it into closer line with the other
string-search-and-replace functions.

Test script:
---
$words = ['this', 'is', 'a', 'bunch', 'of', 'words', 'with', 'no',
'rhythm'];

$translated = strtr($words, 'aeiou', 'AEIOU');

print_r($translated);

Expected result:

Array
(
[0] = thIs
[1] = Is
[2] = A
[3] = bUnch
[4] = Of
[5] = wOrds
[6] = wIth
[7] = nO
[8] = rhythm
)

Actual result:
--
A warning about a parameter 1 being an array instead of the expected
string.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=62291edit=1
-- 
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=62291r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=62291r=trysnapshot53
Try a snapshot (trunk):  
https://bugs.php.net/fix.php?id=62291r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=62291r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=62291r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=62291r=alreadyfixed
Need backtrace:  
https://bugs.php.net/fix.php?id=62291r=needtrace
Need Reproduce Script:   
https://bugs.php.net/fix.php?id=62291r=needscript
Try newer version:   
https://bugs.php.net/fix.php?id=62291r=oldversion
Not developer issue: 
https://bugs.php.net/fix.php?id=62291r=support
Expected behavior:   
https://bugs.php.net/fix.php?id=62291r=notwrong
Not enough info: 
https://bugs.php.net/fix.php?id=62291r=notenoughinfo
Submitted twice: 
https://bugs.php.net/fix.php?id=62291r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=62291r=globals
PHP 4 support discontinued:  
https://bugs.php.net/fix.php?id=62291r=php4
Daylight Savings:https://bugs.php.net/fix.php?id=62291r=dst
IIS Stability:   
https://bugs.php.net/fix.php?id=62291r=isapi
Install GNU Sed: 
https://bugs.php.net/fix.php?id=62291r=gnused
Floating point limitations:  
https://bugs.php.net/fix.php?id=62291r=float
No Zend Extensions:  
https://bugs.php.net/fix.php?id=62291r=nozend
MySQL Configuration Error:   
https://bugs.php.net/fix.php?id=62291r=mysqlcfg



[PHP-BUG] Req #61522 [NEW]: E_STRICT for compatibility TZs

2012-03-26 Thread a at b dot c dot de
From: 
Operating system: generic
PHP version:  5.4.0
Package:  Date/time related
Bug Type: Feature/Change Request
Bug description:E_STRICT for compatibility TZs

Description:

A bunch of the Timezones supported by PHP come with a warning in the
manual: Please do not use any of the timezones listed here (besides UTC),
they only exist for backward compatible reasons.

I'd just like to suggest having functions that take timezone strings as
arguments (such as date_default_timezone_set) trigger an E_STRICT notice
when passed one of these compatibility zone names.

Should the list change in future, this could give developers a heads-up.


Test script:
---
?php
date_default_timezone_set('EST');
?

Expected result:

PHP Strict Standards:  Use of compatibility Timezone ID 'EST' should be
replaced with current name in test.php on line 2.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=61522edit=1
-- 
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=61522r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=61522r=trysnapshot53
Try a snapshot (trunk):  
https://bugs.php.net/fix.php?id=61522r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=61522r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=61522r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=61522r=alreadyfixed
Need backtrace:  
https://bugs.php.net/fix.php?id=61522r=needtrace
Need Reproduce Script:   
https://bugs.php.net/fix.php?id=61522r=needscript
Try newer version:   
https://bugs.php.net/fix.php?id=61522r=oldversion
Not developer issue: 
https://bugs.php.net/fix.php?id=61522r=support
Expected behavior:   
https://bugs.php.net/fix.php?id=61522r=notwrong
Not enough info: 
https://bugs.php.net/fix.php?id=61522r=notenoughinfo
Submitted twice: 
https://bugs.php.net/fix.php?id=61522r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=61522r=globals
PHP 4 support discontinued:  
https://bugs.php.net/fix.php?id=61522r=php4
Daylight Savings:https://bugs.php.net/fix.php?id=61522r=dst
IIS Stability:   
https://bugs.php.net/fix.php?id=61522r=isapi
Install GNU Sed: 
https://bugs.php.net/fix.php?id=61522r=gnused
Floating point limitations:  
https://bugs.php.net/fix.php?id=61522r=float
No Zend Extensions:  
https://bugs.php.net/fix.php?id=61522r=nozend
MySQL Configuration Error:   
https://bugs.php.net/fix.php?id=61522r=mysqlcfg



[PHP-BUG] Req #54106 [NEW]: Shortcut ternary companion operator

2011-02-26 Thread a at b dot c dot de
From: 
Operating system: Irrelevant
PHP version:  Irrelevant
Package:  Scripting Engine problem
Bug Type: Feature/Change Request
Bug description:Shortcut ternary companion operator

Description:

The expression $a ? $b : $c can be shortened to $a ?: $c if $b==$c.



In this the ?: operator behaves much like the || operator in, say, Perl
or JavaScript, or the or operator of Python: $a if it looks true, $c
otherwise.



But those three languages also have  (or and) operators which mean
$a if it looks false, $c otherwise.



PHP currently lacks such an operator: where Python can have a and c, PHP
still needs $a ? $c : $a, including the potential double evaluation or
intermediate variable needed if $a is anything more complex.



So the Feature Request is another operator, perhaps :?, which behaves as
described in the third paragraph above: $a :? $c would be an abbreviation
for and equivalent to $a ? $c : $a. It's possible to come up with a
tortured bit of algebra to justify the :? symbol, but aesthetic symmetry
ought to be enough of an excuse both for the symbol and more importantly
the operator it identifies.


-- 
Edit bug report at http://bugs.php.net/bug.php?id=54106edit=1
-- 
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=54106r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=54106r=trysnapshot53
Try a snapshot (trunk):  
http://bugs.php.net/fix.php?id=54106r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=54106r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=54106r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=54106r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=54106r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=54106r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=54106r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=54106r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=54106r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=54106r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=54106r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=54106r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=54106r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=54106r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=54106r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=54106r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=54106r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=54106r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=54106r=mysqlcfg



Bug #54039 [Fbk-Opn]: use() of static variables in lambda functions can break staticness

2011-02-18 Thread a at b dot c dot de
Edit report at http://bugs.php.net/bug.php?id=54039edit=1

 ID: 54039
 User updated by:a at b dot c dot de
 Reported by:a at b dot c dot de
 Summary:use() of static variables in lambda functions can
 break staticness
-Status: Feedback
+Status: Open
 Type:   Bug
 Package:Scripting Engine problem
 Operating System:   Windows XP
 PHP Version:5.3.5
 Block user comment: N
 Private report: N

 New Comment:

The cited snapshot (the VC6 build, FYI) shows the correct behaviour for
the incrementing tests.



$v remains static in the string concatenation test as well, but there is
what is probably an additional issue at play there:



Outer function catenates 'b' onto $v to give b

Outer function catenates 'a' onto $v to give ba

Inner function reckons $v is b

Outer function catenates 'b' onto $v to give bab

Outer function catenates 'a' onto $v to give baba

Inner function reckons $v is X☼←

Outer function catenates 'b' onto $v to give X☼←☺b

Outer function catenates 'a' onto $v to give X☼←☺ba

Inner function reckons $v is  ↕←☺b

Outer function catenates 'b' onto $v to give  ↕←☺bab

Outer function catenates 'a' onto $v to give  ↕←☺baba

Inner function reckons $v is  ↕←☺bab


Previous Comments:

[2011-02-18 13:59:28] cataphr...@php.net

For windows, the address will be
http://rmtools.php.net/snaps/5.3-ts-windows-vc9-x86/builds/php-5.3-ts-windows-vc9-x86-r308443.zip
(or similar for other compiler/thread safety combination)


[2011-02-18 13:54:23] cataphr...@php.net

Please try using this snapshot:

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

  http://windows.php.net/snapshots/

Bug #53958 is similar and is fixed in SVN.


[2011-02-18 04:16:43] a at b dot c dot de

A little further testing gives this:



function test_1()

{

static $v = '';

$v .= 'b';

echo Outer function catenates 'b' onto \$v to give $v\n;

$f = function()use($v)

{

echo Inner function reckons \$v is $v\n;

};

$v .= 'a';

echo Outer function catenates 'a' onto \$v to give $v\n;

return $f;

}

$f = test_1(); $f();

$f = test_1(); $f();

$f = test_1(); $f();

$f = test_1(); $f();



The second concatenation ('a') fails to be retained; if only the
anonymous function didn't use($v), the variable would end up containing
'babababa'.


[2011-02-18 00:49:00] a at b dot c dot de

Description:

Let an ordinary function declare a static local variable, and let it
also define an anonymous function that uses that static variable. It can
happen that the static variable no longer retains its value across calls
to the ordinary function; i.e., it loses that static property.



It seems to be limited to situations where the anonymous function is
defined before the static variable has had its value changed.

Test script:
---
function test_1()

{

static $v = 0;

++$v;

echo Outer function increments \$v to $v\n;

$f = function()use($v)

{

echo Inner function reckons \$v is $v\n;

};

return $f;

}



echo \nIncrement static variable, then use it in anonymous function
definition:\n;

$f = test_1(); $f();

$f = test_1(); $f();



function test_2()

{

static $v = 0;

$f = function()use($v)

{

echo Inner function reckons \$v is $v\n;

};

++$v;

echo Outer function increments \$v to $v\n;

return $f;

}



echo \nUse static variable in anonymous function definition, then
increment it:\n;

$f = test_2(); $f();

$f = test_2(); $f();



Expected result:

Increment static variable, then use it in anonymous function
definition:

Outer function increments $v to 1

Inner function reckons $v is 1

Outer function increments $v to 2

Inner function reckons $v is 2



Use static variable in anonymous function definition, then increment
it:

Outer function increments $v to 1

Inner function reckons $v is 0

Outer function increments $v to 2

Inner function reckons $v is 1

Actual result:
--
Increment static variable, then use it in anonymous function
definition:

Outer function increments $v to 1

Inner function reckons $v is 1

Outer function increments $v to 2

Inner function reckons $v is 2



Use static variable in anonymous function definition, then increment
it:

Outer function increments $v to 1

Inner function reckons $v is 0

Outer function increments $v to 1

Inner function reckons $v is 0

[PHP-BUG] Bug #54039 [NEW]: use() of static variables in lambda functions can break staticness

2011-02-17 Thread a at b dot c dot de
From: 
Operating system: Windows XP
PHP version:  5.3.5
Package:  Scripting Engine problem
Bug Type: Bug
Bug description:use() of static variables in lambda functions can break 
staticness

Description:

Let an ordinary function declare a static local variable, and let it also
define an anonymous function that uses that static variable. It can happen
that the static variable no longer retains its value across calls to the
ordinary function; i.e., it loses that static property.



It seems to be limited to situations where the anonymous function is
defined before the static variable has had its value changed.

Test script:
---
function test_1()

{

static $v = 0;

++$v;

echo Outer function increments \$v to $v\n;

$f = function()use($v)

{

echo Inner function reckons \$v is $v\n;

};

return $f;

}



echo \nIncrement static variable, then use it in anonymous function
definition:\n;

$f = test_1(); $f();

$f = test_1(); $f();



function test_2()

{

static $v = 0;

$f = function()use($v)

{

echo Inner function reckons \$v is $v\n;

};

++$v;

echo Outer function increments \$v to $v\n;

return $f;

}



echo \nUse static variable in anonymous function definition, then
increment it:\n;

$f = test_2(); $f();

$f = test_2(); $f();



Expected result:

Increment static variable, then use it in anonymous function definition:

Outer function increments $v to 1

Inner function reckons $v is 1

Outer function increments $v to 2

Inner function reckons $v is 2



Use static variable in anonymous function definition, then increment it:

Outer function increments $v to 1

Inner function reckons $v is 0

Outer function increments $v to 2

Inner function reckons $v is 1

Actual result:
--
Increment static variable, then use it in anonymous function definition:

Outer function increments $v to 1

Inner function reckons $v is 1

Outer function increments $v to 2

Inner function reckons $v is 2



Use static variable in anonymous function definition, then increment it:

Outer function increments $v to 1

Inner function reckons $v is 0

Outer function increments $v to 1

Inner function reckons $v is 0

-- 
Edit bug report at http://bugs.php.net/bug.php?id=54039edit=1
-- 
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=54039r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=54039r=trysnapshot53
Try a snapshot (trunk):  
http://bugs.php.net/fix.php?id=54039r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=54039r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=54039r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=54039r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=54039r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=54039r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=54039r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=54039r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=54039r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=54039r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=54039r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=54039r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=54039r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=54039r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=54039r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=54039r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=54039r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=54039r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=54039r=mysqlcfg



Bug #54039 [Opn]: use() of static variables in lambda functions can break staticness

2011-02-17 Thread a at b dot c dot de
Edit report at http://bugs.php.net/bug.php?id=54039edit=1

 ID: 54039
 User updated by:a at b dot c dot de
 Reported by:a at b dot c dot de
 Summary:use() of static variables in lambda functions can
 break staticness
 Status: Open
 Type:   Bug
 Package:Scripting Engine problem
 Operating System:   Windows XP
 PHP Version:5.3.5
 Block user comment: N
 Private report: N

 New Comment:

A little further testing gives this:



function test_1()

{

static $v = '';

$v .= 'b';

echo Outer function catenates 'b' onto \$v to give $v\n;

$f = function()use($v)

{

echo Inner function reckons \$v is $v\n;

};

$v .= 'a';

echo Outer function catenates 'a' onto \$v to give $v\n;

return $f;

}

$f = test_1(); $f();

$f = test_1(); $f();

$f = test_1(); $f();

$f = test_1(); $f();



The second concatenation ('a') fails to be retained; if only the
anonymous function didn't use($v), the variable would end up containing
'babababa'.


Previous Comments:

[2011-02-18 00:49:00] a at b dot c dot de

Description:

Let an ordinary function declare a static local variable, and let it
also define an anonymous function that uses that static variable. It can
happen that the static variable no longer retains its value across calls
to the ordinary function; i.e., it loses that static property.



It seems to be limited to situations where the anonymous function is
defined before the static variable has had its value changed.

Test script:
---
function test_1()

{

static $v = 0;

++$v;

echo Outer function increments \$v to $v\n;

$f = function()use($v)

{

echo Inner function reckons \$v is $v\n;

};

return $f;

}



echo \nIncrement static variable, then use it in anonymous function
definition:\n;

$f = test_1(); $f();

$f = test_1(); $f();



function test_2()

{

static $v = 0;

$f = function()use($v)

{

echo Inner function reckons \$v is $v\n;

};

++$v;

echo Outer function increments \$v to $v\n;

return $f;

}



echo \nUse static variable in anonymous function definition, then
increment it:\n;

$f = test_2(); $f();

$f = test_2(); $f();



Expected result:

Increment static variable, then use it in anonymous function
definition:

Outer function increments $v to 1

Inner function reckons $v is 1

Outer function increments $v to 2

Inner function reckons $v is 2



Use static variable in anonymous function definition, then increment
it:

Outer function increments $v to 1

Inner function reckons $v is 0

Outer function increments $v to 2

Inner function reckons $v is 1

Actual result:
--
Increment static variable, then use it in anonymous function
definition:

Outer function increments $v to 1

Inner function reckons $v is 1

Outer function increments $v to 2

Inner function reckons $v is 2



Use static variable in anonymous function definition, then increment
it:

Outer function increments $v to 1

Inner function reckons $v is 0

Outer function increments $v to 1

Inner function reckons $v is 0






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


[PHP-BUG] Req #52734 [NEW]: Extend hypot() to three dimensions

2010-08-29 Thread a at b dot c dot de
From: 
Operating system: Windows XP
PHP version:  5.3.3
Package:  Math related
Bug Type: Feature/Change Request
Bug description:Extend hypot() to three dimensions

Description:

The existing hypot() function is limited to finding the hypotenuse of a
right-angled triangle in two dimensions ($h = hypot($x,$y)), when in fact
it is well-defined for higher dimensions as well as the length of the
diagonal of a (hyper)cuboid with edge lengths $x,$y,$z...; it's the square
root of the sum of the squares of the edge lengths.



For geometric purposes it would be helpful to have at least
hypot($x,$y,$z). The existing alternatives are sqrt($x*$x+$y*$y+$z*$z) or
hypot(hypot($x,$y),$z). The latter is (not surprisingly) markedly slower,
and also less accurate.

Test script:
---
function length($v1, $v2)

{

return hypot($v1[0]-$v2[0], $v1[1]-$v2[1], $v1[2]-$v2[2]);

}



$v1 = array(1, 1, 1);

$v2 = array(5, 6, 1);

echo length($v1, $v2);



Expected result:

6.4031242374328

Actual result:
--
A warning about hypot expecting exactly two parameters, and a NULL return
value.

-- 
Edit bug report at http://bugs.php.net/bug.php?id=52734edit=1
-- 
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52734r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52734r=trysnapshot53
Try a snapshot (trunk):  
http://bugs.php.net/fix.php?id=52734r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52734r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52734r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52734r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=52734r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=52734r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=52734r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=52734r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=52734r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=52734r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=52734r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52734r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=52734r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=52734r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=52734r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=52734r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=52734r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=52734r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=52734r=mysqlcfg



Req #50980 [Com]: lambda/anonymous functions do not have proper scope

2010-05-20 Thread a at b dot c dot de
Edit report at http://bugs.php.net/bug.php?id=50980edit=1

 ID:   50980
 Comment by:   a at b dot c dot de
 Reported by:  nate at frickenate dot com
 Summary:  lambda/anonymous functions do not have proper scope
 Status:   Open
 Type: Feature/Change Request
 Package:  Feature/Change Request
 Operating System: Linux
 PHP Version:  5.3.1

 New Comment:

use() parameters are early binding - they use the variable's value at
the point where the lambda function is declared, rather than the point
where the lambda function is called (late binding).



If you want late binding then there is already syntax for that ('') -
which works as expected to propagate assignments up to the calling
scope. To make it the default would be (a) contrary to the way
ordinary function parameters are passed, (b) require the addition of
new syntax to indicate that early binding is wanted, (c) deal with the
situation where a used variable doesn't exist at call time, (d) make it
hard to understand the difference between an ordinary function parameter
and a closure.



The problem with allowing variables in the outer scope to leak by
default into the lambda function is that a copy of the ENTIRE collection
returned by get_defined_vars() would need to be persisted for the
lifetime of the closure object (less any that are overridden by
call-time arguments) just in case any of them are needed.



'I imagine this has to do with the php5 fake references that are used
to pass objects around.'

The mechanism is the same as that used in Java and C#: the object
reference is passed by value. It's just that in PHP you also have the
option of passing the reference by reference as well (see the chapter in
the manual on Objects and references, where it explains that what is
passed is an object identifier and not a PHP reference).


Previous Comments:

[2010-02-09 22:53:17] nate at frickenate dot com

Description:

The way in which variables are passed to the inside of a lambda function
via the 'use (...)' syntax is broken. The entire concept of scope or
closures does not seem to apply in php whatsoever.



Variables within a lambda are supposed to be resolved/looked up in the
parent scope at runtime when the variable is actually accessed within
the lambda function's code. It seems that php just dumbly creates a copy
of the variable when it sees the definition of the lambda function with
the 'use (...)' clause. Changes to the variable in the parent scope
between the moment where the lambda is defined and the lambda function
is called are not propagated.



The worst part happens with objects. When passing in an object instance
to a lambda, any changes to the original object in the parent scope
after the lambda definition do affect the same object (problem 4 in
reproduce code), but replacing the object altogether does not (problem 3
in reproduce code). I imagine this has to do with the php5 fake
references that are used to pass objects around.



I get the feeling this is just a horrible limitation of the devs having
hacked a best-possible implementation of lambdas into a Zend
codebase that can't handle proper scope lookup. If this is the case, it
would be nice if the documentation could be updated to really nail home
the fact that there is no scoping going on at all, and that quite
literally all you get is a copy of the variable as it exists at the
moment the lambda is defined (except for the strangeness going on with
objects).



It's unfortunate that the solution for the time being is to *always*
pass in *every* variable as a reference, which results in expected
output. But this requires creating a local copy within the lambda for
every variable that one wants to modify without affecting the parent
scope. :'(

Reproduce code:
---
?php



// problem 1: this should echo Canada, not a php notice

$fn = function () use ($country) { echo $country . \n; };

$country = 'Canada';

$fn();





// problem 2: this should echo Canada, not UnitedStates

$country = 'UnitedStates';

$fn = function () use ($country) { echo $country . \n; };

$country = 'Canada';

$fn();





// problem 3: this should echo Canada, not UnitedStates

$country = (object)array('name' = 'UnitedStates');

$fn = function () use ($country) { echo $country-name . \n; };

$country = (object)array('name' = 'Canada');

$fn();





// problem 4: this outputs Canada. if this outputs Canada,

// then so should problem 2 above. otherwise this should be

// just as broken as problem 2 and be outputting UnitedStates

$country = (object)array('name' = 'UnitedStates');

$fn = function () use ($country) { echo $country-name . \n; };

$country-name = 'Canada';

$fn();



?

Expected result:

If scope was actually handled properly, then the lookup of the use
(...)'d variable would occur at the moment the variable is used within
the lambda

[PHP-BUG] Req #51876 [NEW]: Assigning to list(); list() as an lvalue

2010-05-20 Thread a at b dot c dot de
From: 
Operating system: 
PHP version:  Irrelevant
Package:  Scripting Engine problem
Bug Type: Feature/Change Request
Bug description:Assigning to list(); list() as an lvalue

Description:

When an array is assigned to a list($of,$variables), the elements of the
array are extracted and assigned to the listed variables; elements can be
skipped by duplicating commas in the list().



The variables in the list() construct may themselves be list() constructs,
allowing the extraction of values from nested arrays (the nesting of the
list()s reflects the nesting of the arrays).



On the PHP6 TODO list is the job of allowing list() to appear as the
iterated value in a foreach statement (foreach($array as
$key=list($v1,$v2)){...}).



My suggestion is that another place where list() might play a role is in
function declarations; when a function parameter is in a list(), the
argument it gets when it's called has its elements extracted and assigned
to the variables in the list (see the test script for this to be clearer).



If the argument is not an array, the behaviour would be the same in
existing situations where list() is not given an array. References would
behave as usual also.

Test script:
---
?php



function foo($a, list($b, $c), $d)

{

   echo $a $c $b $d;

   $c = 'Zero';

}



$coconuts = array('One', 'Two', 'Three', 'Four');

foo(17, $coconuts, radish);

echo \n, $coconuts[1];

?

Expected result:

17 Two One radish

Zero

Actual result:
--
At present it's a parse error, of course.

-- 
Edit bug report at http://bugs.php.net/bug.php?id=51876edit=1
-- 
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=51876r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=51876r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=51876r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=51876r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=51876r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=51876r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=51876r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=51876r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=51876r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=51876r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=51876r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=51876r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=51876r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=51876r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=51876r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=51876r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=51876r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=51876r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=51876r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=51876r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=51876r=mysqlcfg



[PHP-BUG] Req #51855 [NEW]: Optional tuning parameter for get_defined_functions and get_defined_constants

2010-05-18 Thread a at b dot c dot de
From: 
Operating system: Irrelevant
PHP version:  5.3.2
Package:  Unknown/Other Function
Bug Type: Feature/Change Request
Bug description:Optional tuning parameter for get_defined_functions and 
get_defined_constants

Description:

get_defined_constants() offers an optional parameter which, when passed
true, categorises the constants by extension.



get_defined_functions() returns a list of function names categorised by
whether they are user or internal.



Both could benefit from being able to specify an actual category, instead
of just that the returned list be categorised. For example,
get_defined_functions('internal') would return a one-dimensional
numerically-indexed array of internally-defined functions.



It's mainly for convenience: avoiding the extra variable, and depending on
the internals some work collating the data.



Since the list of extensions is so variable from configuration to
configuration, it would be infeasible to define(DEFINED_CONSTANTS_PCRE,
pcre) and so forth.



If the syntax engine could be convinced then this suggestion would be
redundant, since it could then be achieved as
get_defined_functions()['internal'].

Test script:
---
print_r(get_defined_functions('internal'));



Equivalent to:



$functions = get_defined_functions();

print_r($functions['internal']);



Expected result:

Array(

[0] = zend_version

[1] = func_num_args

[2] = func_get_arg

[3] = func_get_args

[4] = strlen



)

Actual result:
--
A Warning is triggered stating that get_defined_functions() expects exactly
0 parameters, not the 1 that it was given. print_r() outputs null.

-- 
Edit bug report at http://bugs.php.net/bug.php?id=51855edit=1
-- 
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=51855r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=51855r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=51855r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=51855r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=51855r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=51855r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=51855r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=51855r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=51855r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=51855r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=51855r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=51855r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=51855r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=51855r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=51855r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=51855r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=51855r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=51855r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=51855r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=51855r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=51855r=mysqlcfg



Req #51855 [Opn]: Optional tuning parameter for get_defined_functions and get_defined_constants

2010-05-18 Thread a at b dot c dot de
Edit report at http://bugs.php.net/bug.php?id=51855edit=1

 ID:   51855
 User updated by:  a at b dot c dot de
 Reported by:  a at b dot c dot de
 Summary:  Optional tuning parameter for get_defined_functions
   and get_defined_constants
 Status:   Open
 Type: Feature/Change Request
 Package:  Unknown/Other Function
 Operating System: Irrelevant
 PHP Version:  5.3.2

 New Comment:

Oh, one other thing ... the optional parameter to
get_defined_constants() would be of type mixed: give it true and it
behaves as it does currently, give it a string and it will restrict its
results to the extension with the given name.


Previous Comments:

[2010-05-19 02:02:51] a at b dot c dot de

Description:

get_defined_constants() offers an optional parameter which, when passed
true, categorises the constants by extension.



get_defined_functions() returns a list of function names categorised by
whether they are user or internal.



Both could benefit from being able to specify an actual category,
instead of just that the returned list be categorised. For example,
get_defined_functions('internal') would return a one-dimensional
numerically-indexed array of internally-defined functions.



It's mainly for convenience: avoiding the extra variable, and depending
on the internals some work collating the data.



Since the list of extensions is so variable from configuration to
configuration, it would be infeasible to
define(DEFINED_CONSTANTS_PCRE, pcre) and so forth.



If the syntax engine could be convinced then this suggestion would be
redundant, since it could then be achieved as
get_defined_functions()['internal'].

Test script:
---
print_r(get_defined_functions('internal'));



Equivalent to:



$functions = get_defined_functions();

print_r($functions['internal']);



Expected result:

Array(

[0] = zend_version

[1] = func_num_args

[2] = func_get_arg

[3] = func_get_args

[4] = strlen



)

Actual result:
--
A Warning is triggered stating that get_defined_functions() expects
exactly 0 parameters, not the 1 that it was given. print_r() outputs
null.






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


Req #51001 [Com]: Always shows stack trace when a Fatal error occurs

2010-04-09 Thread a at b dot c dot de
Edit report at http://bugs.php.net/bug.php?id=51001edit=1

 ID:   51001
 Comment by:   a at b dot c dot de
 Reported by:  abdallah at gmx dot com
 Summary:  Always shows stack trace when a Fatal error occurs
 Status:   Open
 Type: Feature/Change Request
 Package:  Feature/Change Request
 Operating System: Windows 7
 PHP Version:  5.3.1

 New Comment:

An observation from me:



A stack trace is dumped in the event of a fatal error (depending on the
error reporting level); but it's only when an uncaught exception reaches
the top of the call stack without being handled that such an error
occurs. If it is caught, then it's not an uncaught exception and
therefore not a Fatal error.


Previous Comments:

[2010-02-10 20:05:24] abdallah at gmx dot com

Description:

Always shows stack trace when a Fatal error occurs without having to do
always something like this :



?php

function test() {

throw new Exception;

}



try {

test();

} catch(Exception $e) {

echo $e-getTraceAsString();

}

?



Reproduce code:
---
?php

function test() {

throw new Exception;

}



try {

test();

} catch(Exception $e) {

echo $e-getTraceAsString();

}

?

Expected result:

#0 /home/bjori/tmp/ex.php(7): test()

#1 {main}

Actual result:
--
nothin'






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


[PHP-BUG] Req #51460 [NEW]: yield syntax construct

2010-04-01 Thread a at b dot c dot de
From: 
Operating system: Irrelevant
PHP version:  5.3.2
Package:  *Programming Data Structures
Bug Type: Feature/Change Request
Bug description:yield syntax construct

Description:

I draw your attention to the yield construct as used in Python, (recent)
JavaScript, and C#. This would be I think a nice way of creating Iterators
for traversing complex objects.



A method that uses yield can be replaced by one that declares an instance
of a custom implementation of Iterator that takes $this and the method's
arguments in its constructor, and cranks through a state machine on each
call of next(). (Microsoft's C# compiler handles it in essentially this
way, but has a much harder time of it because of things like multithreading
and explicit resource disposal.)



To some extent this can be done by hand now (I've done some work on a
preprocessing script that automates this) but in the absence of inner
classes (which is what this Iterator ought to be) - hint, hint - it plays
havoc with visibility attributes.

Expected result:

/*

Example method that produces an inorder traversal of a binary tree.

foreach($btree-traverse_inorder() as $node)

{

do_something_with($node);

}

*/

public function traverse_inorder()

{

foreach($this-left-traverse_inorder() as $child)

{

yield $child;

}

yield $this;

foreach($this-right-traverse_inorder() as $child)

{

yield $child;

}

}



Actual result:
--
/*

The state machine that implements the body of the test script's function
(identifies if the end of the traversal has been reached, and obtains the
next value to return if not)

*/

do

{

switch($this-_state)

{

case -1:

return false;

case 0:

// the object being traversed needs left made public

$this-_t1 = $this-_this-left-traverse_inorder();

reset($this-_t1);

$this-_state = 1;

case 1:

if(!($e = each($this-_t1)))

{

$this-_t1 = null;

$this-_state = 2;

continue;

}

$this-_value = $e['value'];

return true;

case 2:

$this-_value = $this-_this;

$this-_state = 3;

return true;

case 3:

// the object being traversed needs right made public

$this-_t2 = $this-_this-right-traverse_inorder();

reset($this-_t2);

$this-_state = 4;

case 4:

if(!($e = each($this-_t2)))

{

$this-_t2 = null;

$this-_state = -1;

return false;

}

$this-_value = $e['value'];

return true;

}

} while(false);



-- 
Edit bug report at http://bugs.php.net/bug.php?id=51460edit=1
-- 
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=51460r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=51460r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=51460r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=51460r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=51460r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=51460r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=51460r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=51460r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=51460r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=51460r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=51460r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=51460r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=51460r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=51460r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=51460r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=51460r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=51460r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=51460r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=51460r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=51460r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=51460r=mysqlcfg



#48810 [Com]: Variable Function Request

2009-11-20 Thread a at b dot c dot de
 ID:   48810
 Comment by:   a at b dot c dot de
 Reported By:  moonlightcheese at gmail dot com
 Status:   Open
 Bug Type: Feature/Change Request
 Operating System: Ubuntu
 PHP Version:  5.2.10
 New Comment:

Uh, you can already do that


Previous Comments:


[2009-07-05 20:38:17] moonlightcheese at gmail dot com

Description:

the use of constructs would be nice.  i don't see a reason why i
shouldn't be able to do something like this:

$db_prefix=mysql_;
$conn_func=$db_prefix.connect;

$conn_func('localhost','example','password');

having to build wrapper functions for every construct i want to use
within a class bloats the code and makes things less manageable.

Reproduce code:
---
---
From manual page: functions.variable-functions
---







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



#49598 [Com]: Save the POSIX RegExp functions - they're useful!

2009-09-30 Thread a at b dot c dot de
 ID:   49598
 Comment by:   a at b dot c dot de
 Reported By:  sergey at lisergey dot net
 Status:   Open
 Bug Type: Feature/Change Request
 Operating System: FreeBSD
 PHP Version:  5.2.11
 New Comment:

Use the PCRE functions (such as preg_grep) instead.


Previous Comments:


[2009-09-19 06:55:25] sergey at lisergey dot net

Description:

I use posix regexp for log parsing and its extremely useful.
If it would be deprecated, I'd have to rewrite alot of code.

Yes, of course, I could call system() and use egrep, but it's weightier
and unsafer way to get some sophisticated stings out of a huge log.

Reproduce code:
---
---
From manual page: function.ereg
---


Expected result:

POSIX RegExp functions to be not deprecated






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



#49594 [Com]: POSIX regex are important

2009-09-30 Thread a at b dot c dot de
 ID:   49594
 Comment by:   a at b dot c dot de
 Reported By:  jay at phpcourses dot ca
 Status:   Open
 Bug Type: Feature/Change Request
 Operating System: all
 PHP Version:  5.3.0
 New Comment:

For the past eight years PHP has recommended using the PCRE regex
functions. This has been noted on, for example, the manual page for
ereg().


Previous Comments:


[2009-09-18 19:53:09] jay at phpcourses dot ca

Description:

why is PHP deprecating the pervasive, very important POSIX regex
support? nearly every script i have ever written and/or taught in the
past 8 years uses posix regex, and now it will ALL be useless? my
customers will be disappointed and their code won't work. just LEAVE THE
POSIX REGEX ALONE.

Reproduce code:
---
ereg('posix')

Expected result:

success

Actual result:
--
the single worst mistake php has ever made





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



#47708 [Com]: explode() with empty delimiter

2009-06-07 Thread a at b dot c dot de
 ID:  47708
 Comment by:  a at b dot c dot de
 Reported By: david at grudl dot com
 Status:  Open
 Bug Type:Feature/Change Request
 PHP Version: 5.3.0beta1
 New Comment:

It must be done using preg_split...
Or str_split().


Previous Comments:


[2009-03-18 18:30:00] david at grudl dot com

Description:

Splitting a string into array of characters is not easy in PHP. It must
be done using preg_split (slow) and with a lot of parameters:

$chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);

Feature request: allow function explode() to split string into
characters. Usage:

$chars = explode('', $str);

Rationale: there is counterpart function implode() which allows to use
empty separator:

$str = explode('', $chars); // works






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



#48305 [Com]: SORT_VERSION for sort functions

2009-05-18 Thread a at b dot c dot de
 ID:   48305
 Comment by:   a at b dot c dot de
 Reported By:  sean at wdsolutions dot com
 Status:   Open
 Bug Type: Feature/Change Request
 Operating System: Linux
 PHP Version:  5.2.9
 New Comment:

You could use the existing version_compare function instead of
writing your own. That would cover the PHP version-numbering convention.
Other conventions could be addressed by hand-written functions, but
given the existence of those other conventions a single SORT_VERSION
flag wouldn't be sufficient.


Previous Comments:


[2009-05-16 18:49:07] sean at wdsolutions dot com

Description:

It would be awesome to have a SORT_VERSION flag for the sort family of
functions, whose behavior would be to sort most common multi-number
version strings (with possible support for detecting -cvs, -rc, -svn,
and other suffixes).

For example, SORT_NUMERIC and SORT_STRING both fail to properly sort
the following version numbers:

1.2.1
1.2.2
1.2.10
1.20.5
1.22.50

They get sorted as:

1.20.5
1.2.1
1.2.10
1.2.2
1.22.50

Code I used to work around it is below:

Reproduce code:
---
function vercmp($a, $b) {
  $as = explode('.', $a);
  $bs = explode('.', $b);
  for ($i = 0, $e = max(count($as), count($bs)); $i != $e; ++$i) {
if ($as[$i]  $bs[$i])
  return -1;
elseif ($as[$i]  $bs[$i])
  return 1;
  }
  return 0;
}







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



#48311 [Com]: Controlable object diposing

2009-05-18 Thread a at b dot c dot de
 ID:   48311
 Comment by:   a at b dot c dot de
 Reported By:  av3ng3r at gmail dot com
 Status:   Open
 Bug Type: Feature/Change Request
 Operating System: -
 PHP Version:  6CVS-2009-05-17 (CVS)
 New Comment:

Your example would be handled by

$reader = new StreamReader($stream);
$reader-write('blahblahblah');
$reader = null; // $reader-__destruct() called

Objects and values are destroyed as soon as the last reference to them
goes away. Remove those references, destroy the object.


$start = microtime(true);

class foo{
private $name;
function __construct($name) {
$this-name = $name;
}
function __destruct() {
echo $this-name. Destroyed at
.(microtime(true)-$GLOBALS['start']). seconds\n;
}

}

$t1 = new foo('t1');
$t2 = new foo('t2');
$t3 = new foo('t3');

echo Set \$t1 to null at .(microtime(true)-$start). seconds\n;
$t1 = null;
echo Sleep 5 seconds\n;
sleep(5);
echo Replace \$t2 with \$t3 at .(microtime(true)-$start).
seconds\n;
$t2 = $t3;
echo Sleep 5 seconds\n;
sleep(5);


Previous Comments:


[2009-05-17 16:50:23] av3ng3r at gmail dot com

Description:

An implementation like C# (
http://www.coderjournal.com/2007/02/proper-use-idisposable/ ) would be
appreciated:

using(StreamReader reader = new StreamReader(stream))
{
   reader.write('blalblabab');
}

The class StreamReader implements an interface IDisposable, by
implementing this interface (creating a function in the class called;
Dispose) the user can use the statement `using` to control the disposal
of the object manually instead of waiting of the garbage collection of
PHP.

This would be usefull for controling database connections, socket
connections, simplexml?, etc.






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



#47160 [NEW]: $foo() syntax is too limited

2009-01-20 Thread a at b dot c dot de
From: a at b dot c dot de
Operating system: Windows (irrelevant)
PHP version:  5.3.0alpha3
PHP Bug Type: Feature/Change Request
Bug description:  $foo() syntax is too limited

Description:

It's already possible to have arrays that represent callable methods
(either static or instance), and 5.3's closures offer a third type of
callable function.

But the $foo() syntax that facilitates calling that callable function
still requires $foo to contain a string.

Since in general one cannot know in advance just what type of callable the
value of $foo actually is, and when one does know it's often NOT a string,
it's necessary to forego the syntax and rely on call_user_func($foo).

What would be nice is if $foo() also worked in the cases where $foo was a
callable array or Closure object. call_user_func() itself would largely be
relegated to the status of function equivalent should you need it and
complement to call_user_func_array().

Reproduce code:
---
?php
// For 5.2.x as well.
class Thing {
static function DoesStuff() {
echo 'Hello, World';
}
}

$f = array('Thing', 'DoesStuff');

$f();
?

Expected result:

Hello, World

Actual result:
--
Fatal error: Function name must be a string in C:\test.php on line 11


-- 
Edit bug report at http://bugs.php.net/?id=47160edit=1
-- 
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47160r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47160r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47160r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47160r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47160r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47160r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=47160r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=47160r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=47160r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=47160r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=47160r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=47160r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=47160r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47160r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=47160r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=47160r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=47160r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=47160r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=47160r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=47160r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=47160r=mysqlcfg



#47161 [NEW]: Dereferencing for array/function access

2009-01-20 Thread a at b dot c dot de
From: a at b dot c dot de
Operating system: Windows (irrelevant)
PHP version:  5.3.0alpha3
PHP Bug Type: Feature/Change Request
Bug description:  Dereferencing for array/function access

Description:

See Bug #23022.

Since we can have arrays that contain arrays, arrays that contain
functions, functions that return arrays and functions return functions;

and since both arrays and functions effectively define mappings between
their arguments/indices and their values;

and since we can already dereference array accesses into higher dimensions
(i.e., we can write $foo[1][2]);

I would like to be able to do the same thing with the other three cases.
The bug cited above asks for $foo(1)[2]; I'd like to add a request for
$foo[1](2) and $foo(1)(2).

Please, sir: can we have these?

Reproduce code:
---
?php
$func = function($a) {
return function($b)use($a) {
return $a+$b;
};
};

echo $func(5)(3);
?

Expected result:

8

Actual result:
--
Parse error: syntax error, unexpected '(', expecting ',' or ';' in
C:\test.php on line 9

-- 
Edit bug report at http://bugs.php.net/?id=47161edit=1
-- 
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47161r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47161r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47161r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47161r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47161r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47161r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=47161r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=47161r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=47161r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=47161r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=47161r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=47161r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=47161r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47161r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=47161r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=47161r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=47161r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=47161r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=47161r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=47161r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=47161r=mysqlcfg



#47161 [Opn]: Dereferencing for array/function access

2009-01-20 Thread a at b dot c dot de
 ID:   47161
 User updated by:  a at b dot c dot de
 Reported By:  a at b dot c dot de
 Status:   Open
 Bug Type: Feature/Change Request
 Operating System: Windows (irrelevant)
 PHP Version:  5.3.0alpha3
 New Comment:

Perhaps I should just add
although I reference Bug #23022, I'm not asking for this to be over
_arbitrary_ expressions, only arrays and callables. I don't want this
language turning into Perl :)


Previous Comments:


[2009-01-20 09:08:50] a at b dot c dot de

Description:

See Bug #23022.

Since we can have arrays that contain arrays, arrays that contain
functions, functions that return arrays and functions return functions;

and since both arrays and functions effectively define mappings between
their arguments/indices and their values;

and since we can already dereference array accesses into higher
dimensions (i.e., we can write $foo[1][2]);

I would like to be able to do the same thing with the other three
cases. The bug cited above asks for $foo(1)[2]; I'd like to add a
request for $foo[1](2) and $foo(1)(2).

Please, sir: can we have these?

Reproduce code:
---
?php
$func = function($a) {
return function($b)use($a) {
return $a+$b;
};
};

echo $func(5)(3);
?

Expected result:

8

Actual result:
--
Parse error: syntax error, unexpected '(', expecting ',' or ';' in
C:\test.php on line 9





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



#40339 [Com]: new superglobal...

2009-01-20 Thread a at b dot c dot de
 ID:   40339
 Comment by:   a at b dot c dot de
 Reported By:  randallgirard at hotmail dot com
 Status:   Open
 Bug Type: Feature/Change Request
 Operating System: Windows / Linux
 PHP Version:  5.2.0
 New Comment:

I can't even make out what misc features like variable variables which
appear to utilize the local, then global scope if the var is not defined
locally is even referring to - I've never seen global variables leaking
into the local scope without my asking for them.

If your coding is so borked that you don't even know what variables you
have or not you can get a list of local variables by taking
get_defined_vars() and subtracting $GLOBALS.


Previous Comments:


[2007-06-25 13:11:37] michael at chunkycow dot com dot au

This sounds totally bogus, I do not know of any other language that
comes close to providing such a thing.
If you have trouble keeping track of the scoping of a given variable
it's an implementation/programmer problem not a language one.



[2007-02-03 03:50:15] randallgirard at hotmail dot com

Description:

Just as there is a $GLOBALS var pointing to the global scope, there
should also be a $SCOPE or $LOCALS var pointing to the current local,
usually function/method scope. This would add alot of coding potential,
and should be included in the language because of misc features like
variable variables which appear to utilize the local, then global scope
if the var is not defined locally. It would also greatly aid in
debugging, as you could quickly and easily dump all var's in the
scope... And, I'm sure others could find many more uses for such a
feature.

If such a feature allready exists, I'm sorry for my ignorance and I
would greatly appreciate feedback informing me of how a local scope
array could be accessed. THANKS!!






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



#42566 [Com]: array_reduce coverts '' to 0 for initial value

2007-10-23 Thread a at b dot c dot de
 ID:   42566
 Comment by:   a at b dot c dot de
 Reported By:  lindsay at marshall dot name
 Status:   No Feedback
 Bug Type: Arrays related
 Operating System: Fedora
 PHP Version:  5.2.4
 New Comment:

A short but complete example (copied from the cited user notes on the
array_reduce page):

?php
function arc ($reduced, $item)
{
  $reduced = $item.$reduced;
  return $reduced;
}

array_reduce( array(a,b,c), arc,  );
?

Expected result: cba
Actual result: cba0


Previous Comments:


[2007-09-14 01:00:01] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, 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.



[2007-09-06 10:41:03] [EMAIL PROTECTED]

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with ?php and ends with ?,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.





[2007-09-05 14:59:16] lindsay at marshall dot name

Description:

If you want to use array_reduce to produce a string rather than a
number you cannot set the initial string to be '' as it is converted to
0. You can work round this but it is not elegant. There seems to be no
reason why array_reduce should not work with strings (it did in 4.x)

Reproduce code:
---
see comment on array_reduce page

Expected result:

see comment on array_reduce page






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


#37016 [Asn]: lambda functions unusable in create_function()

2007-09-08 Thread a at b dot c dot de
 ID:   37016
 User updated by:  a at b dot c dot de
 Reported By:  a at b dot c dot de
 Status:   Assigned
 Bug Type: Scripting Engine problem
 Operating System: Windows XP
 PHP Version:  5.1.2
 Assigned To:  derick
 New Comment:

_Would it be sufficient if:_ instead of prefixing the lambda function
with a NUL it were to be prefixed by '__'? Since PHP has (always?)
claimed symbols starting with those characters for magical purposes
anyone who is already declaring functions with names like __lambda_1
is already effectively on notice that their code might break (moreso
than someone who, in PHP 4, say, declared a function named clone).

As it stands, higher-order functions are pretty much unworkable:
attempts to construct new functions from existing ones are hamstrung by
the fact that the existing functions may themselves be lambda functions
and therefore unmentionable in the new function's body.


Currently the only valid workaround would appear to be something like
(to use the notation of the original examples)

$dfun = create_function('','$d1=chr(0).'.substr($d1,1).'; return
!$d1();');

Which of course needs to be further modified to deal with the cases
where $d1 is not the name of a lambda function.


Previous Comments:


[2007-01-18 13:57:08] a dot steenveld at id dot umcn dot nl

hmmm I've not done enough reseachr in the bugreports. Well, I did,
but too late. :(

While looking for a similar problem I found a likely cause for this
problem, found a workaround for my problem, and suggested a change and
filed a bug report.

See report #40160, hope you can use it.



[2006-04-08 11:51:18] [EMAIL PROTECTED]

I can reproduce this... let's see if I can come up with a fix.



[2006-04-08 05:35:12] a at b dot c dot de

Description:

When inserting (the name of) a lambda function provided by
create_function into a string that will be used to create a second
lambda function, the second function fails to parse. The parse error
message makes what appears to be a spurious complaint about the code;
only Test 5's error message makes sense (plus, it seems there is no
callable version of a lambda function's name).

(Cf. bug #10721 - parser chokes on lambda function names in eval'd
code)


Reproduce code:
---
I made five distinct tests to bracket the issue:
TEST 1:
// Creating a function that calls an ordinary function (explict name)
function always_true(){return true;}
$afun = create_function('', 'return !always_true();');
echo Calling $afun()  . ($afun() ? returns true\n : returns
false\n);

TEST 2:
// Creating a function that calls an ordinary function (variable name)
function always_true(){return true;}
$b1 = 'always_true';
$bfun = create_function('','return !'.$b1.'();');
echo Calling $bfun()  . ($bfun() ? returns true\n : returns
false\n);

TEST 3:
// Creating a function that calls an anonymous function (explicit
name);
$c1 = create_function('','return true;');
$cfun = create_function('','return !'.chr(0).'lambda_3();');
echo Calling $cfun()  . ($cfun() ? returns true\n : returns
false\n);

TEST 4:
// Creating a function that calls an anonymous function (variable
name)
$d1 = create_function('','return true;');
$dfun = create_function('','return !'.$d1.'();');
echo Calling $dfun()  . ($dfun() ? returns true\n : returns
false\n);

TEST 5:
// Using is_callable to get a callable version of anonymous function
name
$e1 = create_function('', 'return true;');
if(!is_callable($e1,false,$callable_e1)) die(Couldn't call anonymous
function.);
echo Using $callable_e1 as name of anonymous function\n;
$efun = create_function('','return !'.$callable_e1.'();');
echo Calling $efun()  . ($efun() ? returns true\n : returns
false\n);



Expected result:

TEST 1:
Calling  lambda_1() returns false

TEST 2:
Calling  lambda_1() returns false

TEST 3:
Calling  lambda_2() returns false

TEST 4:
Calling  lambda_2() returns false

TEST 5:
Using  lambda_1 as name of anonymous function  [?]
Calling  lambda_2() returns false


Actual result:
--
Actual Results:
TEST 1:
Calling  lambda_1() returns false

TEST 2:
Calling  lambda_1() returns false

TEST 3:
Parse error: parse error, unexpected '}' in test.php : runtime-created
function on line 1
Fatal error: Function name must be a string in test.php on line 4

TEST 4:
Parse error: parse error, unexpected '}' in test.php : runtime-created
function on line 1
Fatal error: Function name must be a string in test.php on line 4

TEST 5:
Using  as name of anonymous function
Parse error: parse error, unexpected ')' in test.php : runtime-created
function on line 1
Fatal error: Function name must be a string in test.php on line 6

#40446 [Bgs]: php.exe fails to start

2007-02-12 Thread a at b dot c dot de
 ID:   40446
 User updated by:  a at b dot c dot de
 Reported By:  a at b dot c dot de
 Status:   Bogus
 Bug Type: Reproducible crash
 Operating System: Windows XP SP2
 PHP Version:  5.2.1
 New Comment:

Close; the line in php.ini actually read

memory_limit = 128MB  ; Maximum amount of memory a script may
consume (8MB)


Previous Comments:


[2007-02-12 11:56:38] [EMAIL PROTECTED]

Open your php.ini, find the line looking like this:
memory_limit = 128
and change it to this:
memory_limit = 128M -- notice the M here.
128 is 128 bytes
128M is 128 megabytes.



[2007-02-12 11:46:40] a at b dot c dot de

(I said edit). Earlier upgrades included 5.1.6-5.2.0.



[2007-02-12 11:45:39] a at b dot c dot de

Description:

PHP 5.2.1 (manually downloaded, extracted and copied to working
directory) fails to start either as a CLI or as an Apache module;
Apache fails to start also (though this may be a side-effect of
something else).

Installation was through exactly the same installation process as
earlier upgrades (e.g., 5.0.x = 5.1). php.ini is being parsed (one
early attempt at the below reminded me to turn off a third-party
extension with its Failed Loading message).

Downgrading to 5.2.0 (through the same installation process) works
successfully. Installing 5.2.1 side-by-side with 5.2.0 in another
directory has the same result as below.

Reproduce code:
---
From the command line:
c:\ php -v


Expected result:

PHP 5.2.1 (cli) (built: Feb  7 2007 23:19:16)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies

Actual result:
--
Fatal error: Allowed memory size of 128 bytes exhausted (tried to
allocate 8192 bytes) in Unknown on line 0





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


#40446 [Bgs]: php.exe fails to start

2007-02-12 Thread a at b dot c dot de
 ID:   40446
 User updated by:  a at b dot c dot de
 Reported By:  a at b dot c dot de
 Status:   Bogus
 Bug Type: Reproducible crash
 Operating System: Windows XP SP2
 PHP Version:  5.2.1
 New Comment:

So 5.2.0 doesn't mind the 'B', but 5.2.1 does.


Previous Comments:


[2007-02-13 00:15:18] a at b dot c dot de

Close; the line in php.ini actually read

memory_limit = 128MB  ; Maximum amount of memory a script may
consume (8MB)



[2007-02-12 11:56:38] [EMAIL PROTECTED]

Open your php.ini, find the line looking like this:
memory_limit = 128
and change it to this:
memory_limit = 128M -- notice the M here.
128 is 128 bytes
128M is 128 megabytes.



[2007-02-12 11:46:40] a at b dot c dot de

(I said edit). Earlier upgrades included 5.1.6-5.2.0.



[2007-02-12 11:45:39] a at b dot c dot de

Description:

PHP 5.2.1 (manually downloaded, extracted and copied to working
directory) fails to start either as a CLI or as an Apache module;
Apache fails to start also (though this may be a side-effect of
something else).

Installation was through exactly the same installation process as
earlier upgrades (e.g., 5.0.x = 5.1). php.ini is being parsed (one
early attempt at the below reminded me to turn off a third-party
extension with its Failed Loading message).

Downgrading to 5.2.0 (through the same installation process) works
successfully. Installing 5.2.1 side-by-side with 5.2.0 in another
directory has the same result as below.

Reproduce code:
---
From the command line:
c:\ php -v


Expected result:

PHP 5.2.1 (cli) (built: Feb  7 2007 23:19:16)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies

Actual result:
--
Fatal error: Allowed memory size of 128 bytes exhausted (tried to
allocate 8192 bytes) in Unknown on line 0





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


#40446 [NEW]: php.exe fails to start

2007-02-12 Thread a at b dot c dot de
From: a at b dot c dot de
Operating system: Windows XP SP2
PHP version:  5.2.1
PHP Bug Type: Reproducible crash
Bug description:  php.exe fails to start

Description:

PHP 5.2.1 (manually downloaded, extracted and copied to working directory)
fails to start either as a CLI or as an Apache module; Apache fails to
start also (though this may be a side-effect of something else).

Installation was through exactly the same installation process as earlier
upgrades (e.g., 5.0.x = 5.1). php.ini is being parsed (one early attempt
at the below reminded me to turn off a third-party extension with its
Failed Loading message).

Downgrading to 5.2.0 (through the same installation process) works
successfully. Installing 5.2.1 side-by-side with 5.2.0 in another
directory has the same result as below.

Reproduce code:
---
From the command line:
c:\ php -v


Expected result:

PHP 5.2.1 (cli) (built: Feb  7 2007 23:19:16)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies

Actual result:
--
Fatal error: Allowed memory size of 128 bytes exhausted (tried to allocate
8192 bytes) in Unknown on line 0

-- 
Edit bug report at http://bugs.php.net/?id=40446edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40446r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40446r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40446r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40446r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=40446r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=40446r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=40446r=needscript
Try newer version:http://bugs.php.net/fix.php?id=40446r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=40446r=support
Expected behavior:http://bugs.php.net/fix.php?id=40446r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=40446r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=40446r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40446r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40446r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40446r=dst
IIS Stability:http://bugs.php.net/fix.php?id=40446r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=40446r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40446r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=40446r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=40446r=mysqlcfg


#40446 [Opn]: php.exe fails to start

2007-02-12 Thread a at b dot c dot de
 ID:   40446
 User updated by:  a at b dot c dot de
 Reported By:  a at b dot c dot de
 Status:   Open
 Bug Type: Reproducible crash
 Operating System: Windows XP SP2
 PHP Version:  5.2.1
 New Comment:

(I said edit). Earlier upgrades included 5.1.6-5.2.0.


Previous Comments:


[2007-02-12 11:45:39] a at b dot c dot de

Description:

PHP 5.2.1 (manually downloaded, extracted and copied to working
directory) fails to start either as a CLI or as an Apache module;
Apache fails to start also (though this may be a side-effect of
something else).

Installation was through exactly the same installation process as
earlier upgrades (e.g., 5.0.x = 5.1). php.ini is being parsed (one
early attempt at the below reminded me to turn off a third-party
extension with its Failed Loading message).

Downgrading to 5.2.0 (through the same installation process) works
successfully. Installing 5.2.1 side-by-side with 5.2.0 in another
directory has the same result as below.

Reproduce code:
---
From the command line:
c:\ php -v


Expected result:

PHP 5.2.1 (cli) (built: Feb  7 2007 23:19:16)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies

Actual result:
--
Fatal error: Allowed memory size of 128 bytes exhausted (tried to
allocate 8192 bytes) in Unknown on line 0





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


#40061 [NEW]: Repeated dereferencing in object callbacks

2007-01-08 Thread a at b dot c dot de
From: a at b dot c dot de
Operating system: Windows XP SP2
PHP version:  5.2.0
PHP Bug Type: Feature/Change Request
Bug description:  Repeated dereferencing in object callbacks

Description:

Object callbacks $foo-bar() are represented as arrays array($foo, 'bar').
Since PHP now supports the syntax $foo-bar-baz(), it seems at first sight
that callback arrays could be nested similarly.

Currently to use the baz() method above in a callback, one must use a
temporary variable $temp=$foo-bar, and use array($temp, 'baz') as the
callback in the same way that in PHP4 it was necessary to write
$temp=$foo-bar; $temp-baz().

It would seem syntactically unambiguous to write the callback as
array(array($foo, 'bar'), 'baz'). There is the matter that its first
element refers to an object, not a method, but that's what the first
element of an array callback is supposed to refer to (static class methods
notwithstanding).

Reproduce code:
---
?php
class aclass
{
public $b;
}
class bclass
{
public function foo($v)
{
return $v*2;
}
}

$t = array('1','2','3','4','5','6','7','8','9');

$a = new aclass;
$a-b = new bclass;
print_r(array_map(array(array($a, 'b') ,'foo'), $t));

Expected result:

Array
(
[0] = 2
[1] = 4
[2] = 6
[3] = 8
[4] = 10
[5] = 12
[6] = 14
[7] = 16
[8] = 18
)

Actual result:
--
Warning: array_map(): The first argument, 'Array', should be either NULL
or a valid callback in ...


-- 
Edit bug report at http://bugs.php.net/?id=40061edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40061r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40061r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40061r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40061r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=40061r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=40061r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=40061r=needscript
Try newer version:http://bugs.php.net/fix.php?id=40061r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=40061r=support
Expected behavior:http://bugs.php.net/fix.php?id=40061r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=40061r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=40061r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40061r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40061r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40061r=dst
IIS Stability:http://bugs.php.net/fix.php?id=40061r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=40061r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40061r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=40061r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=40061r=mysqlcfg


#40061 [Bgs]: Repeated dereferencing in object callbacks

2007-01-08 Thread a at b dot c dot de
 ID:   40061
 User updated by:  a at b dot c dot de
 Reported By:  a at b dot c dot de
 Status:   Bogus
 Bug Type: Feature/Change Request
 Operating System: Windows XP SP2
 PHP Version:  5.2.0
 New Comment:

If my head had been together I would have checked what I was saying
about PHP 4 and I would CERTAINLY have tried array($a-b, 'foo') as
being obvious: I could have sworn I had and this just proves that my
head was not as together as I thought it was at the time. Sorry for
wasting YOUR time because of it.


Previous Comments:


[2007-01-08 11:53:39] [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

$foo-bar-baz() was possible in PHP 4, too. New in PHP 5 was
$foo-bar()-baz() (with bar being a function)

To your Problem: Just use array($a-b,'foo') as callback.



[2007-01-08 11:48:19] a at b dot c dot de

Description:

Object callbacks $foo-bar() are represented as arrays array($foo,
'bar'). Since PHP now supports the syntax $foo-bar-baz(), it seems at
first sight that callback arrays could be nested similarly.

Currently to use the baz() method above in a callback, one must use a
temporary variable $temp=$foo-bar, and use array($temp, 'baz') as the
callback in the same way that in PHP4 it was necessary to write
$temp=$foo-bar; $temp-baz().

It would seem syntactically unambiguous to write the callback as
array(array($foo, 'bar'), 'baz'). There is the matter that its first
element refers to an object, not a method, but that's what the first
element of an array callback is supposed to refer to (static class
methods notwithstanding).

Reproduce code:
---
?php
class aclass
{
public $b;
}
class bclass
{
public function foo($v)
{
return $v*2;
}
}

$t = array('1','2','3','4','5','6','7','8','9');

$a = new aclass;
$a-b = new bclass;
print_r(array_map(array(array($a, 'b') ,'foo'), $t));

Expected result:

Array
(
[0] = 2
[1] = 4
[2] = 6
[3] = 8
[4] = 10
[5] = 12
[6] = 14
[7] = 16
[8] = 18
)

Actual result:
--
Warning: array_map(): The first argument, 'Array', should be either
NULL or a valid callback in ...






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


#38766 [WFx]: Nonbreaking whitespace breaks parsing

2007-01-08 Thread a at b dot c dot de
 ID:   38766
 User updated by:  a at b dot c dot de
 Reported By:  a at b dot c dot de
 Status:   Wont fix
 Bug Type: Feature/Change Request
 Operating System: Windows XP SP2
 PHP Version:  5.1.6
 New Comment:

I guessed as much. Personally I blame stupid text editors for inserting
the character on the ends of lines (which is where I've found them).


Previous Comments:


[2006-09-10 09:38:04] [EMAIL PROTECTED]

Can't do that as people using UTF8 in their scrips might use this
character as part of an identifier.



[2006-09-10 02:19:45] a at b dot c dot de

Description:

In most (Windows) fonts, character 0xa0 renders as a blank
(nonbreaking) space. Some people use text editors that for whatever
reason like to use 0xa0 at random locations instead of ordinary spaces.
The result is code that _looks_ correct, but when run can trigger a
parse error for no apparent reason.

In zend_language_scanner.l, 0xa0 is recognised as a LABEL character
(which means, among other things, that you could have a variable called
$ );. Assuming no-one is perverted enough to do something like that,
it should be safe to reassign it to WHITESPACE (will this cause grief
in other character sets?).


Reproduce code:
---
?php
//There is an 0xa0 character immediately following the
// brace on the next line
for($i=0; $i5; $i++){ 
echo  Hello, World\n;
}
?


Expected result:

Hello, World
Hello, World
Hello, World
Hello, World
Hello, World


Actual result:
--
Parse error: parse error, unexpected T_ECHO in C:\test.php on line 5





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


#39112 [NEW]: Typographical error in error message

2006-10-10 Thread a at b dot c dot de
From: a at b dot c dot de
Operating system: Windows XP
PHP version:  5.1.6
PHP Bug Type: PCRE related
Bug description:  Typographical error in error message

Description:

The Warning: level message that is triggered by preg_replace() when the
pattern is a string, but the replacement is an array has one or two typos:
in instead of is, and a full stop that looks out of place.

Reproduce code:
---
?php

$pattern = /foo/;
$replacement = array('bar','baz');
$string = Womble;

preg_replace($pattern, $replacement, $string);
?



Expected result:

Warning: preg_replace(): Parameter mismatch, pattern is a string while
replacement is an array in C:\test.php on line 8

Actual result:
--
Warning: preg_replace(): Parameter mismatch, pattern is a string while
replacement in an array. in C:\test.php on line 8

-- 
Edit bug report at http://bugs.php.net/?id=39112edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=39112r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=39112r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=39112r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39112r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=39112r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=39112r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=39112r=needscript
Try newer version:http://bugs.php.net/fix.php?id=39112r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=39112r=support
Expected behavior:http://bugs.php.net/fix.php?id=39112r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=39112r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=39112r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39112r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=39112r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39112r=dst
IIS Stability:http://bugs.php.net/fix.php?id=39112r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=39112r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=39112r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=39112r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=39112r=mysqlcfg


#38766 [NEW]: Nonbreaking whitespace breaks parsing

2006-09-09 Thread a at b dot c dot de
From: a at b dot c dot de
Operating system: Windows XP SP2
PHP version:  5.1.6
PHP Bug Type: Feature/Change Request
Bug description:  Nonbreaking whitespace breaks parsing

Description:

In most (Windows) fonts, character 0xa0 renders as a blank (nonbreaking)
space. Some people use text editors that for whatever reason like to use
0xa0 at random locations instead of ordinary spaces. The result is code
that _looks_ correct, but when run can trigger a parse error for no
apparent reason.

In zend_language_scanner.l, 0xa0 is recognised as a LABEL character (which
means, among other things, that you could have a variable called $ );.
Assuming no-one is perverted enough to do something like that, it should
be safe to reassign it to WHITESPACE (will this cause grief in other
character sets?).


Reproduce code:
---
?php
//There is an 0xa0 character immediately following the
// brace on the next line
for($i=0; $i5; $i++){ 
echo  Hello, World\n;
}
?


Expected result:

Hello, World
Hello, World
Hello, World
Hello, World
Hello, World


Actual result:
--
Parse error: parse error, unexpected T_ECHO in C:\test.php on line 5

-- 
Edit bug report at http://bugs.php.net/?id=38766edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=38766r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=38766r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=38766r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38766r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=38766r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=38766r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=38766r=needscript
Try newer version:http://bugs.php.net/fix.php?id=38766r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=38766r=support
Expected behavior:http://bugs.php.net/fix.php?id=38766r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=38766r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=38766r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38766r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=38766r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38766r=dst
IIS Stability:http://bugs.php.net/fix.php?id=38766r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=38766r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=38766r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=38766r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=38766r=mysqlcfg


#37016 [NEW]: lambda functions unusable in create_function()

2006-04-07 Thread a at b dot c dot de
From: a at b dot c dot de
Operating system: Windows XP
PHP version:  5.1.2
PHP Bug Type: Scripting Engine problem
Bug description:  lambda functions unusable in create_function()

Description:

When inserting (the name of) a lambda function provided by create_function
into a string that will be used to create a second lambda function, the
second function fails to parse. The parse error message makes what appears
to be a spurious complaint about the code; only Test 5's error message
makes sense (plus, it seems there is no callable version of a lambda
function's name).

(Cf. bug #10721 - parser chokes on lambda function names in eval'd code)


Reproduce code:
---
I made five distinct tests to bracket the issue:
TEST 1:
// Creating a function that calls an ordinary function (explict name)
function always_true(){return true;}
$afun = create_function('', 'return !always_true();');
echo Calling $afun()  . ($afun() ? returns true\n : returns
false\n);

TEST 2:
// Creating a function that calls an ordinary function (variable name)
function always_true(){return true;}
$b1 = 'always_true';
$bfun = create_function('','return !'.$b1.'();');
echo Calling $bfun()  . ($bfun() ? returns true\n : returns
false\n);

TEST 3:
// Creating a function that calls an anonymous function (explicit name);
$c1 = create_function('','return true;');
$cfun = create_function('','return !'.chr(0).'lambda_3();');
echo Calling $cfun()  . ($cfun() ? returns true\n : returns
false\n);

TEST 4:
// Creating a function that calls an anonymous function (variable name)
$d1 = create_function('','return true;');
$dfun = create_function('','return !'.$d1.'();');
echo Calling $dfun()  . ($dfun() ? returns true\n : returns
false\n);

TEST 5:
// Using is_callable to get a callable version of anonymous function name
$e1 = create_function('', 'return true;');
if(!is_callable($e1,false,$callable_e1)) die(Couldn't call anonymous
function.);
echo Using $callable_e1 as name of anonymous function\n;
$efun = create_function('','return !'.$callable_e1.'();');
echo Calling $efun()  . ($efun() ? returns true\n : returns
false\n);



Expected result:

TEST 1:
Calling  lambda_1() returns false

TEST 2:
Calling  lambda_1() returns false

TEST 3:
Calling  lambda_2() returns false

TEST 4:
Calling  lambda_2() returns false

TEST 5:
Using  lambda_1 as name of anonymous function  [?]
Calling  lambda_2() returns false


Actual result:
--
Actual Results:
TEST 1:
Calling  lambda_1() returns false

TEST 2:
Calling  lambda_1() returns false

TEST 3:
Parse error: parse error, unexpected '}' in test.php : runtime-created
function on line 1
Fatal error: Function name must be a string in test.php on line 4

TEST 4:
Parse error: parse error, unexpected '}' in test.php : runtime-created
function on line 1
Fatal error: Function name must be a string in test.php on line 4

TEST 5:
Using  as name of anonymous function
Parse error: parse error, unexpected ')' in test.php : runtime-created
function on line 1
Fatal error: Function name must be a string in test.php on line 6


-- 
Edit bug report at http://bugs.php.net/?id=37016edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=37016r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=37016r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=37016r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37016r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=37016r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=37016r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=37016r=needscript
Try newer version:http://bugs.php.net/fix.php?id=37016r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=37016r=support
Expected behavior:http://bugs.php.net/fix.php?id=37016r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=37016r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=37016r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37016r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=37016r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37016r=dst
IIS Stability:http://bugs.php.net/fix.php?id=37016r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=37016r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=37016r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=37016r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=37016r=mysqlcfg


#25122 [Opn]: Control over typecasting objects to strings

2005-09-25 Thread a at b dot c dot de
 ID:   25122
 User updated by:  a at b dot c dot de
 Reported By:  a at b dot c dot de
 Status:   Open
 Bug Type: Feature/Change Request
 Operating System: Any
 PHP Version:  5.0.0b1 (beta1)
 New Comment:

Is this still open?

One method that (from this angle) appears quite elegant would be to
give stdClass a __toString() method that simply returns Object (or
even Object and an ID#, a la resources). Then any other __toString()
methods in any other classes would simply be overriding this one.

The clear advantage this gives is that __toString() can be then called
with impunity on any object, safe in the knowledge that it exists. The
type casting engine already knows how to cast objects to arrays; if it
needs to cast the object to anything else it can hapily call
__toString() and proceed from there.

The obvious issue hinted at in the previous paragraph is that the
entity that the object is cast to may require further casting in order
to fit in with whatever expression is being evaluated at the time. This
is something that may happen anyway: without rigorously type-checking
(at runtime) the value returned by __toString() to ensure that it
really is a string, it has to be assumed that the method could return
anything, ranging from Void to Null to Object. And it's all too
reasonable to expect that method writers will want to return, say,
integers in the expectation that they will be cast to strings as per
normal. So after an object has been cast into the result of its
__toString() method, that result would need to be checked again, and,
if necessary, recast again. And it's the method writer's own silly
fault if PHP hangs when they write something that boils down to
function __toString(){return $this;}.


Previous Comments:


[2004-04-07 03:10:41] [EMAIL PROTECTED]

It's still an open feature request Adam.



[2004-04-06 21:42:16] [EMAIL PROTECTED]

This was changed to prevent crashes. This will hopefully 
be fixed in 5.1, but cannot be fixed in time for 5.0. 
Sorry.



[2004-04-06 19:36:37] bendik at infofab dot no

From the latest change log - 18-Mar-2004

Changed __toString() to be called automatically only 
with print and echo  statements. (Andi)

I can not for the life of me figure out why this has 
been done. Why should an object behave differently when 
it is echoed alone and when it is concatinated?
Example:
(the class Foo has a __toString() method 
defined.(returns World))

$obj = new Foo();

echo $obj; // Produces: World!

echo Hello,  . $obj; // Produces: Hello, Object id #1

Why, oh why?



[2003-08-17 22:17:03] a at b dot c dot de

Description:

String casting for objects. When used in a string context (a simple
example being echo $object;) objects are currently cast to the
string
object, which is generally less than helpful.

The enhancement is to allow objects to have a method called, say,
__string or something similar that is called on an object whenever
it
is used in a situation where a string is expected and returns a string
(or something, like a number, that can be readily cast to a string).

One could, for example, have a complex number class, with properties
$r
and $i, with a method like 

function __string()
{
  $s = $this-r;
  if($this-i=0) $s.='+';
  $s.=$this-i;
  $s.='i';
  return $s;
}


so that one can echo or concatenate complex numbers with impunity.

Many classes already possess toString() methods, no doubt in part to
Java's influence. These generally perform the role that I am
advocating
for __string(), with the difference being that the latter is
implicitly
called whenever necessary. Calling the new method toString() could
be
hazardous for existing scripts that already use classes with methods
with this name. Backward compatibility can of course be achieved by
writing one of


function __string()
{ return $this-toString();
}

function toString()
{ return $this-__string();
}


which will give the two methods identical behaviour, except of course
for the fact that toString() is an ordinary  method that needs to be
called explicitly.

Not to be confused with the operation of serialize(); __string() is
intended for e.g., human-readable string representations of an object
and isn't necessarily reversible to produce the original object. A
complex hierarchical object might, for example, generate XML as a
result of calling its __string() method; in the example above, a
complex
number might have a string string representation of -12+2.5i;
something containing binary data (e.g., an image) might return a
textual
description of the data's contents rather than the data itself.

Needless to say, if the __string() method is absent, casting reverts
to
the existing

#32535 [NEW]: Are stream names URLs?

2005-04-12 Thread a at b dot c dot de
From: a at b dot c dot de
Operating system: Irrelevant
PHP version:  5.0.3
PHP Bug Type: Unknown/Other Function
Bug description:  Are stream names URLs?

Description:

As indicated several times in the manual, the filenames that result from
using stream wrappers are to be regarded as URLs, just as http, ftp and
file schemes already are.

However, ALL such wrappers separate the scheme (what the manual refers to
as the protocol from the rest of the URL with :// - an example being
the var://myvar in the example of the stream_wrapper_register() page.

This conflicts with RFC3986, the official specification for URIs (of which
URLs are a subclass). The separator is just :; the double slash should
only appear if what follows is a hierarchical structure in the sense given
in section 3 of that document.

This is explicitly stated as improper in RFC2718, section 2.1.2 (which
refers to the previous URI standard, RFC2396).

If these streams are supposed to be URLs, then the above example from the
manual should read var:myvar.


-- 
Edit bug report at http://bugs.php.net/?id=32535edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32535r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=32535r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=32535r=trysnapshot51
Fixed in CVS:http://bugs.php.net/fix.php?id=32535r=fixedcvs
Fixed in release:http://bugs.php.net/fix.php?id=32535r=alreadyfixed
Need backtrace:  http://bugs.php.net/fix.php?id=32535r=needtrace
Need Reproduce Script:   http://bugs.php.net/fix.php?id=32535r=needscript
Try newer version:   http://bugs.php.net/fix.php?id=32535r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32535r=support
Expected behavior:   http://bugs.php.net/fix.php?id=32535r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=32535r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=32535r=submittedtwice
register_globals:http://bugs.php.net/fix.php?id=32535r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32535r=php3
Daylight Savings:http://bugs.php.net/fix.php?id=32535r=dst
IIS Stability:   http://bugs.php.net/fix.php?id=32535r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32535r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32535r=float
No Zend Extensions:  http://bugs.php.net/fix.php?id=32535r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32535r=mysqlcfg


#32563 [Csd]: stream_wrapper_register() allows registering of invalid schemes.

2005-04-05 Thread a at b dot c dot de
 ID:   32563
 User updated by:  a at b dot c dot de
 Reported By:  a at b dot c dot de
 Status:   Closed
 Bug Type: Filesystem function related
 Operating System: *
 PHP Version:  5.*
 Assigned To:  pollita
 New Comment:

The full '://' is required to delimit a scheme identifier, so in your
example you would have needed to use fopen('tick:tock://thingy', ...
to
even come close to triggering that wrapper.

Incorrect; see bug #32535 and RFC2718.


Previous Comments:


[2005-04-04 22:32:53] [EMAIL PROTECTED]

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Your basic assessment is correct.  ':' is not a valid scheme character
([a-zA-Z0-9+.-]+), however, it is NOT the scheme delimiter by itself.

The full '://' is required to delimit a scheme identifier, so in your
example you would have needed to use fopen('tick:tock://thingy', ... to
even come close to triggering that wrapper.

The only wrapper which supports a single colon as a delimiter is zlib:
which is a hardcoded exception in the streams layer to maintain
backward compatability with old scripts.

The fact that you got Invalid argument as an error message suggests
you're using Win32 (please, when submitting a bug provide the actual
versions you've seen the specific error messages provided on -- Leave
the assumptions to us).  What the filesystem is attempting to do here
is locate an alternate data stream named 'tock:thingy' on the 'tick'
file which is of course an invalid name for an ADS.



[2005-04-04 09:34:02] [EMAIL PROTECTED]

It also crashes in HEAD:

#0  0x0019 in ?? ()
#1  0x0830dee5 in _php_stream_free (stream=0x8ba544c, close_options=11)
at /usr/src/php/php5/main/streams/streams.c:362
#2  0x0830fce7 in stream_resource_regular_dtor (rsrc=0x8ba4dc4) at
/usr/src/php/php5/main/streams/streams.c:1366
#3  0x08347879 in list_entry_destructor (ptr=0x8ba4dc4) at
/usr/src/php/php5/Zend/zend_list.c:178
#4  0x08345af2 in zend_hash_del_key_or_index (ht=0x85eab40, arKey=0x0,
nKeyLength=0, h=6, flag=1)
at /usr/src/php/php5/Zend/zend_hash.c:490
#5  0x083475dd in _zend_list_delete (id=6) at
/usr/src/php/php5/Zend/zend_list.c:58
#6  0x0833c9be in _zval_dtor_func (zvalue=0x8ba5044,
__zend_filename=0x8562434 /usr/src/php/php5/Zend/zend_variables.h, 
__zend_lineno=35) at /usr/src/php/php5/Zend/zend_variables.c:60
#7  0x083318c5 in _zval_dtor (zvalue=0x8ba5044,
__zend_filename=0x85623d8 /usr/src/php/php5/Zend/zend_execute_API.c,

__zend_lineno=391) at zend_variables.h:35
#8  0x08331a78 in _zval_ptr_dtor (zval_ptr=0x8ba4ff8,
__zend_filename=0x8563290 /usr/src/php/php5/Zend/zend_variables.c, 
__zend_lineno=175) at
/usr/src/php/php5/Zend/zend_execute_API.c:391
#9  0x0833cc63 in _zval_ptr_dtor_wrapper (zval_ptr=0x8ba4ff8) at
/usr/src/php/php5/Zend/zend_variables.c:175
#10 0x08345e5a in zend_hash_apply_deleter (ht=0x85eaa10, p=0x8ba4fec)
at /usr/src/php/php5/Zend/zend_hash.c:574
#11 0x0834607b in zend_hash_graceful_reverse_destroy (ht=0x85eaa10) at
/usr/src/php/php5/Zend/zend_hash.c:640
#12 0x08331411 in shutdown_executor () at
/usr/src/php/php5/Zend/zend_execute_API.c:216
#13 0x0833df9e in zend_deactivate () at
/usr/src/php/php5/Zend/zend.c:823
#14 0x082fd3e1 in php_request_shutdown (dummy=0x0) at
/usr/src/php/php5/main/main.c:1217
#15 0x083b9ca0 in main (argc=2, argv=0xbfe6ea74) at
/usr/src/php/php5/sapi/cli/php_cli.c:1057




[2005-04-04 09:33:10] [EMAIL PROTECTED]

Sara, can you please look into this?




[2005-04-04 08:03:08] a at b dot c dot de

Description:

URL schemes may not contain : characters (as this character is used
as the scheme delimiter). stream_wrapper_register() will allow
schemes containing : to be registered, even though the URLs that
result from using them are invalid.


Reproduce code:
---
?php
class foo_class{
function stream_open(){return true;}
}
stream_wrapper_register('tick:tock', 'foo_class');
print_r(stream_get_wrappers());
$fp=fopen('tick:tock:thingy','w');
?

Expected result:

Warning: stream_wrapper_register(tick:tock): Invalid argument ... on
line 5

Array
(
[0] = php
[1] = file
[2] = http
[3] = ftp
[4] = compress.zlib
)


Actual result:
--
Array
(
[0] = php
[1] = file
[2] = http
[3] = ftp
[4] = compress.zlib
[5] = tick:tock
)

Warning: fopen(tick:tock:thingy): failed to open stream: Invalid
argument ... on line 7





-- 
Edit

#32563 [NEW]: stream_wrapper_register() allows registering of invalid schemes.

2005-04-04 Thread a at b dot c dot de
From: a at b dot c dot de
Operating system: 
PHP version:  5.0.3
PHP Bug Type: Unknown/Other Function
Bug description:  stream_wrapper_register() allows registering of invalid 
schemes.

Description:

URL schemes may not contain : characters (as this character is used as
the scheme delimiter). stream_wrapper_register() will allow schemes
containing : to be registered, even though the URLs that result from
using them are invalid.


Reproduce code:
---
?php
class foo_class{
function stream_open(){return true;}
}
stream_wrapper_register('tick:tock', 'foo_class');
print_r(stream_get_wrappers());
$fp=fopen('tick:tock:thingy','w');
?

Expected result:

Warning: stream_wrapper_register(tick:tock): Invalid argument ... on line
5

Array
(
[0] = php
[1] = file
[2] = http
[3] = ftp
[4] = compress.zlib
)


Actual result:
--
Array
(
[0] = php
[1] = file
[2] = http
[3] = ftp
[4] = compress.zlib
[5] = tick:tock
)

Warning: fopen(tick:tock:thingy): failed to open stream: Invalid argument
... on line 7

-- 
Edit bug report at http://bugs.php.net/?id=32563edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32563r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=32563r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=32563r=trysnapshot51
Fixed in CVS:http://bugs.php.net/fix.php?id=32563r=fixedcvs
Fixed in release:http://bugs.php.net/fix.php?id=32563r=alreadyfixed
Need backtrace:  http://bugs.php.net/fix.php?id=32563r=needtrace
Need Reproduce Script:   http://bugs.php.net/fix.php?id=32563r=needscript
Try newer version:   http://bugs.php.net/fix.php?id=32563r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32563r=support
Expected behavior:   http://bugs.php.net/fix.php?id=32563r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=32563r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=32563r=submittedtwice
register_globals:http://bugs.php.net/fix.php?id=32563r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32563r=php3
Daylight Savings:http://bugs.php.net/fix.php?id=32563r=dst
IIS Stability:   http://bugs.php.net/fix.php?id=32563r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32563r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32563r=float
No Zend Extensions:  http://bugs.php.net/fix.php?id=32563r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32563r=mysqlcfg


#31720 [NEW]: Invalid object callbacks not caught in array_walk()

2005-01-27 Thread a at b dot c dot de
From: a at b dot c dot de
Operating system: Windows XP
PHP version:  5.0.3
PHP Bug Type: Reproducible crash
Bug description:  Invalid object callbacks not caught in array_walk()

Description:

Using array_walk will crash PHP if a method of an uninstantiated object
variable is used in the callback method. Other functions that take
variables (at least, usort(), array_map(), array_reduce()) error out
instead. There has to be at least one element in the array being walked.

Reproduce code:
---
$array = array('at least one element');

array_walk($array, array($nonesuchvar,'show'));


Expected result:

PHP 4.3.10's error message for this situation reads:

Warning:  array_walk(): Unable to call Array() - function does not exist
in ...

while PHP 5.0.3 also reports a Notice-level message that $nonesuchvar is
undefined.

Actual result:
--
A Notice-level message that $nonesuchvar is undefined, then a Windows core
dump.


-- 
Edit bug report at http://bugs.php.net/?id=31720edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31720r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=31720r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=31720r=trysnapshot51
Fixed in CVS:http://bugs.php.net/fix.php?id=31720r=fixedcvs
Fixed in release:http://bugs.php.net/fix.php?id=31720r=alreadyfixed
Need backtrace:  http://bugs.php.net/fix.php?id=31720r=needtrace
Need Reproduce Script:   http://bugs.php.net/fix.php?id=31720r=needscript
Try newer version:   http://bugs.php.net/fix.php?id=31720r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31720r=support
Expected behavior:   http://bugs.php.net/fix.php?id=31720r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=31720r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=31720r=submittedtwice
register_globals:http://bugs.php.net/fix.php?id=31720r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31720r=php3
Daylight Savings:http://bugs.php.net/fix.php?id=31720r=dst
IIS Stability:   http://bugs.php.net/fix.php?id=31720r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31720r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31720r=float
No Zend Extensions:  http://bugs.php.net/fix.php?id=31720r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31720r=mysqlcfg


#31720 [Opn]: Invalid object callbacks not caught in array_walk()

2005-01-27 Thread a at b dot c dot de
 ID:   31720
 User updated by:  a at b dot c dot de
 Reported By:  a at b dot c dot de
 Status:   Open
 Bug Type: Reproducible crash
 Operating System: Windows XP
 PHP Version:  5.0.3
 New Comment:

I guess I could point out that when I found this I was trying to find
some way to call a certain method of each of the array's elements, i.e.
call $child-show() for each $child in $children. If there's a way to do
this with array_walk() that doesn't involve additional wrapper functions
then it eludes me.


Previous Comments:


[2005-01-27 13:06:45] a at b dot c dot de

Description:

Using array_walk will crash PHP if a method of an uninstantiated object
variable is used in the callback method. Other functions that take
variables (at least, usort(), array_map(), array_reduce()) error out
instead. There has to be at least one element in the array being
walked.

Reproduce code:
---
$array = array('at least one element');

array_walk($array, array($nonesuchvar,'show'));


Expected result:

PHP 4.3.10's error message for this situation reads:

Warning:  array_walk(): Unable to call Array() - function does not
exist in ...

while PHP 5.0.3 also reports a Notice-level message that $nonesuchvar
is undefined.

Actual result:
--
A Notice-level message that $nonesuchvar is undefined, then a Windows
core dump.






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


#26764 [Com]: Spaces in Font Pathnames

2004-01-03 Thread a at b dot c dot de
 ID:   26764
 Comment by:   a at b dot c dot de
 Reported By:  choinet at rocketmail dot com
 Status:   Bogus
 Bug Type: GD related
 Operating System: Windows/Linux
 PHP Version:  4.3.4
 New Comment:

I mentioned this to Thomas Boutell when I learned about it; GD_Lib
2.0.18 is expected to use a semicolon ';' as path separator instead of
a space.

If you want to recompile it yourself, the change is to
#define LISTSEPARATOR
in gdft.c


Previous Comments:


[2004-01-03 13:27:44] choinet at rocketmail dot com

In other words, the external code must be changed by Boutell?



[2004-01-03 13:15:35] [EMAIL PROTECTED]

It's still bogus, as it's not a bug in PHP



[2004-01-03 13:06:53] choinet at rocketmail dot com

Au contraire, Rasmus says:

---
Since libgd supports multiple alternate font paths separated by spaces,
it is not possible to use individual font paths with spaces in them.

Example: 

$path = 'c:\test folder\arial.ttf';
imagettftext($image, 12, 0, 50, 50, $color, $path, Hello);

...
It is obvious from looking at the code that it is just doing a simple
strtok on the separator without any further logic.  The relevant code
is:

[code segment in ext/gd/libgd/gdft.c]
---

He also said to either get Boutell to fix it or go create a patch on my
own. I understand that there was some deep confusion surrounding the
problem, but nevertheless I'm currently in the process of resolving
this issue.



[2004-01-02 10:59:23] [EMAIL PROTECTED]

There is no bug here, can't you accept that? 
(and no, you can NOT pass multiple font files to these functions)




[2004-01-01 23:43:31] choinet at rocketmail dot com

Description:

This report stems from bug report #26635, where spaces are not allowed
in the pathname. There are more details towards the end of that report
(http://bugs.php.net/26635) as to how I am sure that pathnames with
spaces do not work.

In fact, I have found out that spaces in the fontfile argument gd
functions, such as imagettftext() are used to denote multiple fonts,
which explains why trying to open pathnames with spaces in them did not
work. I have found this by inserting two working paths into the
fontfile argument of the above function and alternating their order to
verify that they are both being opened correctly.

What I am wondering is if there can be a different font list separator
character than a space, such as , that is not used in the directory
naming convention to delimit the fonts specified in the fontfile
argument, so that users may link to a font file with a space-containing
pathname.

Reproduce code:
---
?php
$image = imagecreate(100, 100);

// Example 1: no spaces in pathname
$path = 'c:\arial.ttf';
imagettftext($image, 12, 0, 50, 50, $color, $path, Hello);

// Example 2: space in pathname
$path = 'c:\test folder\arial.ttf';
imagettftext($image, 12, 0, 50, 50, $color, $path, Hello);

// Example 3: no spaces in multiple font pathnames
$path = 'c:\arial.ttf';
$path2 = 'c:\cour.ttf';
imagettftext($image, 12, 0, 50, 50, $color, $path $path2, Hello);
//note the space between the two pathnames

// Example 4: spaces in multiple font pathnames
$path = 'c:\test folder\arial.ttf';
$path2 = 'c:\test folder\cour.ttf';
imagettftext($image, 12, 0, 50, 50, $color, $path $path2, Hello);
//note the space between the two pathnames
?

Expected result:

I expect no errors in each case.

Actual result:
--
(Taking each example one at a time by commenting out the others)
Example 1:
(no error)

Example 2:
Warning: imagettftext(): Could not find/open font in C:\Program
Files\Apache Group\Apache2\htdocs\index.php on line 10

Example 3:
(no error)

Example 4:
Warning: imagettftext(): Could not find/open font in C:\Program
Files\Apache Group\Apache2\htdocs\index.php on line 20





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


#25816 [Com]: Class constants of type array hold directly inaccessible keys/values

2003-12-01 Thread a at b dot c dot de
 ID:   25816
 Comment by:   a at b dot c dot de
 Reported By:  dan at wep dot net
 Status:   Verified
 Bug Type: Zend Engine 2 problem
 Operating System: *
 PHP Version:  5CVS-2003-11-29
 New Comment:

This isn't restricted to associative arrays in which keys are
explicitly specified:

class f { const t = array(7,6,5); }
echo f::t[1];


Previous Comments:


[2003-10-10 12:24:39] [EMAIL PROTECTED]

This is an easier verification:
php -r 'class t{const c=array(1=Hello\n);} echo t::c[1];'



[2003-10-10 00:29:45] dan at wep dot net

The parse error thrown complains about the print(someData['foo']) line.
Sorry if this wasn't clear. Also expected output would probably be more
like bar ..var_dump output.. bar.



[2003-10-10 00:24:51] dan at wep dot net

Description:

Constants defined inside classes can be defined as an array
prepopulated with key, value pairs; however this data is not directly
accessible.

It is possible to create a local variable copy of the constant at
runtime and use it to access the data.

If class constants are not meant to be able to hold array data, then a
parse error should of been thrown on the 'const' declaration.

Reproduce code:
---
class test {
  const someData = array('foo' = 'bar');

  function __construct() {
$dataCopy = someData;
print($dataCopy['foo']);  // This works
print(var_dump(someData));  // This works (shows all array
information)
print(someData['foo']);  // This throws a parse error
  }

}

$obj = new test();

Expected result:

bar
bar
bar

.. Jackpot! :)

Actual result:
--
Parse error: parse error, unexpected '[' 





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


#25122 [NEW]: Control over typecasting objects to strings

2003-08-17 Thread a at b dot c dot de
From: a at b dot c dot de
Operating system: Any
PHP version:  5.0.0b1 (beta1)
PHP Bug Type: Feature/Change Request
Bug description:  Control over typecasting objects to strings

Description:

String casting for objects. When used in a string context (a simple
example being echo $object;) objects are currently cast to the string
object, which is generally less than helpful.

The enhancement is to allow objects to have a method called, say,
__string or something similar that is called on an object whenever it
is used in a situation where a string is expected and returns a string
(or something, like a number, that can be readily cast to a string).

One could, for example, have a complex number class, with properties $r
and $i, with a method like 

function __string()
{
  $s = $this-r;
  if($this-i=0) $s.='+';
  $s.=$this-i;
  $s.='i';
  return $s;
}


so that one can echo or concatenate complex numbers with impunity.

Many classes already possess toString() methods, no doubt in part to
Java's influence. These generally perform the role that I am advocating
for __string(), with the difference being that the latter is implicitly
called whenever necessary. Calling the new method toString() could be
hazardous for existing scripts that already use classes with methods
with this name. Backward compatibility can of course be achieved by
writing one of


function __string()
{ return $this-toString();
}

function toString()
{ return $this-__string();
}


which will give the two methods identical behaviour, except of course
for the fact that toString() is an ordinary  method that needs to be
called explicitly.

Not to be confused with the operation of serialize(); __string() is
intended for e.g., human-readable string representations of an object
and isn't necessarily reversible to produce the original object. A
complex hierarchical object might, for example, generate XML as a
result of calling its __string() method; in the example above, a complex
number might have a string string representation of -12+2.5i;
something containing binary data (e.g., an image) might return a textual
description of the data's contents rather than the data itself.

Needless to say, if the __string() method is absent, casting reverts to
the existing cast to 'object' behaviour.



-- 
Edit bug report at http://bugs.php.net/?id=25122edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25122r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25122r=trysnapshot5
Fixed in CVS:   http://bugs.php.net/fix.php?id=25122r=fixedcvs
Fixed in release:   http://bugs.php.net/fix.php?id=25122r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=25122r=needtrace
Try newer version:  http://bugs.php.net/fix.php?id=25122r=oldversion
Not developer issue:http://bugs.php.net/fix.php?id=25122r=support
Expected behavior:  http://bugs.php.net/fix.php?id=25122r=notwrong
Not enough info:http://bugs.php.net/fix.php?id=25122r=notenoughinfo
Submitted twice:http://bugs.php.net/fix.php?id=25122r=submittedtwice
register_globals:   http://bugs.php.net/fix.php?id=25122r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25122r=php3
Daylight Savings:   http://bugs.php.net/fix.php?id=25122r=dst
IIS Stability:  http://bugs.php.net/fix.php?id=25122r=isapi
Install GNU Sed:http://bugs.php.net/fix.php?id=25122r=gnused



#5435 [Com]: Request to update eval() or create new function.

2003-08-17 Thread a at b dot c dot de
 ID:  5435
 Comment by:  a at b dot c dot de
 Reported By: dahamsta at iewebs dot com
 Status:  Open
 Bug Type:Feature/Change Request
 PHP Version: 4.0.0
 New Comment:

eval(?.$my_eval_str);

works for me.


Previous Comments:


[2002-06-08 09:59:23] bigredlinux at yahoo dot com

Oh, this would be a great feature.  One thing this would add is the
ability to run an xml string with processing instructions right through
php, by just passing it to eval and assuming that eval knows it is
going to have php somewhere in it.  Very nice feature request!



[2000-07-07 15:46:10] dahamsta at iewebs dot com

Currently, to eval() regular data retrieved from a database or include
file, I need to escape from PHP and re-enter it. For example:

Presume that I have retrieved data from a source, which is equivalent
to a regular PHP file (including plain HTML). To operate eval() on
that, and avoid parsing the HTML and thus causing PHP errors, I need to
use a function like this:

function my_eval($my_eval_str) {
$eval_str  = ?;
$eval_str .= $my_eval_str;
$eval_str .= ?;
return eval($eval_str);
}

This would also make it impossible to access variables in the GLOBAL
symbol table, unless I extract($GLOBALS) into the current sumbol
table.

My suggestion is to either add a second eval() function that will
operate in this way; or add a second argument to eval(), such as:

void eval (string code_str, string eval_type);

Where 'code_str' is the same as the current eval() function, and
'eval_type' is one of two options - one for just PHP code, and one for
a string that will contain data escaped from PHP. The default could be
set to the current operation, and the second argument could be
optional.

Ta,
adam




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



#3866 [Com]: stripheaders

2003-08-17 Thread a at b dot c dot de
 ID:   3866
 Comment by:   a at b dot c dot de
 Reported By:  [EMAIL PROTECTED]
 Status:   Closed
 Bug Type: Feature/Change Request
 Operating System: RH 6
 PHP Version:  4.0 Latest CVS (18/03/2000)
 New Comment:

Besides, the division between headers and content is fundamentally
dependent on what protocol is being used over the socket (and that
includes whether or not there are headers or content). I really
don't see an entire function being created to parse every single
possible transport protocol


Previous Comments:


[2000-08-17 10:46:17] [EMAIL PROTECTED]

as you only have to read up to the first empty line
to find the bonudary between headers and content
a special function should not be needed



[2000-08-06 17:38:11] [EMAIL PROTECTED]

Reopened request



[2000-08-06 17:37:25] [EMAIL PROTECTED]

Headers != HTML Tags



[2000-08-06 16:38:01] [EMAIL PROTECTED]

See:

http://www.php.net/manual/function.fgetss.php

--Jani



[2000-03-18 20:14:58] [EMAIL PROTECTED]

A stripheaders() function would be handy for taking the headers out of
a string when you open a socket using fsockopen() and then read in the
data with fgets().




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