[PHP-BUG] Bug #73166 [NEW]: Function ruturns instruction in finally

[email protected] ("shoaib dot bazmi at hotmail dot co dot uk") Sun, 25 Sep 2016 01:15:12 GMT
Newsgroups php.standards
Message-ID <[email protected]>
From:             shoaib dot bazmi at hotmail dot co dot uk
Operating system: Windows 10
PHP version:      5.6.26
Package:          PHP Language Specification
Bug Type:         Bug
Bug description:Function ruturns instruction in finally

Description:
------------
While using try catch and finally, the function returns the instruction
which is mentioned in finally block. It is prohibitted in .Net, gives
syntax error and logically return statement should be a syntax error if
used in finally block. I wrote a function which returns and increment by
1 in argument variable and increment by 2 in finally block. Whenever i
the function it returs variable incremented by 2 i.e finally block
instruction.

Test script:
---------------
function incrementVar($x)
{
try{
 return ++$x;
}catch($e){}
finally{
 return $x+2;
}
}

 echo incrementVar(1);

Expected result:
----------------
2

Actual result:
--------------
3

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