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

 ID:                 77224
 User updated by:    fkruidhof at mailbox dot org
 Reported by:        fkruidhof at mailbox dot org
 Summary:            Stack Trace shows wrong parameter value
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            Testing related
 Operating System:   MacOs Mojave
 PHP Version:        7.2.12
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for your reply.


Previous Comments:
------------------------------------------------------------------------
[2018-11-30 09:52:33] ni...@php.net

This is one of the unfortunate changes resulting from optimizations in PHP 7. 
It's noted in the PHP 7 migration guide here: 
https://secure.php.net/manual/en/migration70.incompatible.php#migration70.incompatible.other.func-parameter-modified

It's a known issue, but as far as I'm aware there is no work towards improving 
this (if it can be improved).

------------------------------------------------------------------------
[2018-11-30 09:45:51] fkruidhof at mailbox dot org

Description:
------------
The stack trace from an exception shows the wrong value of the parameter that 
was passed to a function if it's value is changed inside that function (before 
the exception is thrown).

First bug report, novice PHP developer. Apologies if I miscategorized this 
report.

Test script:
---------------
<?php
$variable = 'foo';
one($variable);

function one($variable)
{
    try {
        two($variable);
    } catch (Exception $e) {
        echo $e->getTraceAsString();
    }
}

function two($variable)
{
    $variable = 'bar';
    throw new Exception('problem');
}

Expected result:
----------------
Stack trace output:
#0 /file.php(8): two('foo')
#1 /file.php(3): one('foo')
#2 {main}

Actual result:
--------------
Stack trace output:
#0 /file.php(8): two('bar')
#1 /file.php(3): one('foo')
#2 {main}


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



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

Reply via email to