Bug #67047 [Opn]: weird behaviour of finally()

From: Date: Wed, 09 Apr 2014 11:00:13 +0000
Subject: Bug #67047 [Opn]: weird behaviour of finally()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185153@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67047&edit=1

 ID:                 67047
 Updated by:         laruence@php.net
 Reported by:        tony2001@php.net
 Summary:            weird behaviour of finally()
 Status:             Open
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   *
 PHP Version:        5.5Git-2014-04-09 (Git)
-Assigned To:        
+Assigned To:        laruence
 Block user comment: N
 Private report:     N

 New Comment:

As we talked, this is a knew issue, which should be fixed in 5.6+, but due to ABI break, we can not
bring the fix to 5.5...


Previous Comments:
------------------------------------------------------------------------
[2014-04-09 09:52:07] tony2001@php.net

Description:
------------
The following code behaves unexpectedly with finally, see the reproduce code.

Test script:
---------------
First file: 
<?php
spl_autoload_register(function(){ require_once "test1.php"; });

try {
    try {
        throw new \RuntimeException("ERROR");
    }
    finally {
        echo "AUTOLOAD", PHP_EOL;
        $q = \Test::ONE;
        echo "YOU WON'T SEE THIS LINE", PHP_EOL;
    }
}
catch (\Exception $Error) {
    echo $Error->getMessage(), PHP_EOL;
}
?>

Second file: test1.php
<?php

class Test
{
    const ONE = "ONE";
}

echo \Test::ONE, PHP_EOL;

Expected result:
----------------
The code in finally() is executed only partly: the lines after the autoload are ignored.
I would expect the result look like this:
AUTOLOAD
ONE
YOU WON'T SEE THIS LINE
ERROR

Actual result:
--------------
AUTOLOAD
ONE
ERROR



------------------------------------------------------------------------



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


Thread (3 messages)

« previous php.bugs (#185153) next »