#26431 [NEW]: Expressions in class constants using don't seem to work?

2003-11-27 Thread jonny at sanriowasteland dot net
From: jonny at sanriowasteland dot net
Operating system: Windows NT
PHP version:  5.0.0b2 (beta2)
PHP Bug Type: Zend Engine 2 problem
Bug description:  Expressions in class constants using  don't seem to work?

Description:

Class Constants cannot use  expressions, apparently they can only be
numbers or strings.

This could be similar to bug #25323, but php does not crash, just returns
a parse error.

Reproduce code:
---
?php

class TestConstBreak
{
const   SOME_EXPRESSION = 5+5;
const   SOME_BIG_EXPRESSOIN = (5 + 2) * 3;
const   LS_EXPRESSION   = 52;
const   SOME_STRING_EXPRESSION = foo.bar;
}

?


Expected result:

The expected result is to be able to use expressions in class constants
without causing parse errors.

Actual result:
--
Parse error: parse error, unexpected '+', expecting ',' or ';' in
php5Breakage.php on line 5

When I comment out line 5:

Parse error: parse error, unexpected '(' in php5Breakage.php on line 6

And when I comment out line 6:

Parse error: parse error, unexpected T_SL, expecting ',' or ';' in
php5Breakage.php on line 7

And when I comment out line 7:

Parse error: parse error, unexpected ., expecting ',' or ';' in
php5Breakage.php on line 7


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


#25038 [Com]: call_user_func issues warning if function throws exception

2003-11-27 Thread jonny at sanriowasteland dot net
 ID:   25038
 Comment by:   jonny at sanriowasteland dot net
 Reported By:  tater at potatoe dot com
 Status:   Open
 Bug Type: Zend Engine 2 problem
 Operating System: *
 PHP Version:  5CVS-2003-08-11 (dev)
 New Comment:

I've done some more testing with this.

From waht I can tell (as a php programmer) the callstack is being
hosed.  Here is an example to show this:

The Code:
--
?php
function bar($x='no argument')
{
throw new Exception(This is an exception from bar({$x}).);
}
try { bar('first try'); }
catch (Exception $e) { print $e-getmessage().\n; }

set_error_handler('handleError');

try { call_user_func('bar','second try'); }
catch (Exception $e) { print $e-getmessage().\n; }

function handleError($errno, $errstr, $errfile, $errline)
{
echo Have an error: $errno, $errstr, $errfile, $errline...\n;

echo Going to a function...;
goInFunction(); 
echo Returned.\n;

$t = debug_backtrace(); 
var_dump($t);
}

function goInFunction()
{
echo In function...;
}
?

Expected Result:

Nothing has changed from the previous bug, it should still be the same.
 However, if call_user_func('bar','second try'); is still supposed to
throw an error, this is what I expect:

This is an exception from bar(first try).
Have an error: 2, call_user_func(bar): Unable to call bar(second try),
php5Breakage2.php, 11...
Going to a function...In function...Returned
[insert a backtrace here]
This is an exception from bar(second try).

Actual Result:
--
This is an exception from bar(first try).
Have an error: 2, call_user_func(bar): Unable to call bar(second try),
php5Breakage2.php, 11...
Going to a function...In function...This is an exception from
bar(second try).

Note that if I comment out lines 18-20 (the call of the user function),
I would get:

This is an exception from bar(first try).
Have an error: 2, call_user_func(bar): Unable to call bar(second try),
php5Breakage2.php, 11...
This is an exception from bar(second try).

So it appears that both user function calls, and internal function
calls within the error handler mess up the stack.


Previous Comments:


[2003-10-08 07:59:46] rep at devdomain dot com

same here with call_user_func_array:

call_user_func_array fails when the method throws an exception issuing
a php warning, and the exception is lost in the process.

try {
  $mValue = call_user_func_array ($func, $params);
  // func throws exception, php warning issued

} catch (devException $oExc) {
  // never gets here
}



[2003-08-11 06:35:02] tater at potatoe dot com

Description:

Throwing an exception from a function called by call_user_func() causes
a warning to be issued,
saying it was unable to call the function.

An odd side note: if I set up my own error handler,
it does not receive this warning. Kind of an 
inadvertant workaround for now...

Reproduce code:
---
function bar($x='no argument')
{
throw new Exception(This is an exception from bar({$x}).);
}
try { bar('first try'); }
catch (Exception $e) { print {$e-message}\n; }
try { call_user_func('bar','second try'); }
catch (Exception $e) { print {$e-message}\n; }

Expected result:

This is an exception from bar(first try).
This is an exception from bar(second try).


Actual result:
--
This is an exception from bar(first try).

Warning: call_user_func(bar): Unable to call bar(second try) in
/my/pathname/test.php on line 8 
This is an exception from bar(second try).





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


#20373 [Com]: T_OBJECT_OPERATOR parse error should not happen

2003-11-20 Thread jonny at sanriowasteland dot net
 ID:   20373
 Comment by:   jonny at sanriowasteland dot net
 Reported By:  rkb at femkant dot dk
 Status:   No Feedback
 Bug Type: Zend Engine 2 problem
 Operating System: Linux
 PHP Version:  4CVS-2002-11-11
 New Comment:

I tested the code givin with PHP5 beta 2, and everything works as
expected.


Previous Comments:


[2003-01-02 18:38:58] [EMAIL PROTECTED]

No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to Open. Thank you.





[2002-12-08 16:28:29] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip





[2002-11-11 17:35:47] rkb at femkant dot dk

The following script produces a Parse error, unexpected 
T_OBJECT_OPERATOR in ... message: 
 
class A {} 
 
class B { 
var $name = A; 
 
function test() { 
new $this-name; 
} 
} 
 
The following change will succeed: 
- new $this-name; 
+ $tmp = $this-name; 
+ new $tmp; 
 




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